1 package net.sourceforge.phpeclipse.preferences;
 
   3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
   5 import org.eclipse.core.resources.IProject;
 
   6 import org.eclipse.core.runtime.CoreException;
 
   7 import org.eclipse.core.runtime.IAdaptable;
 
   8 import org.eclipse.core.runtime.IStatus;
 
   9 import org.eclipse.core.runtime.Status;
 
  10 import org.eclipse.jface.dialogs.ErrorDialog;
 
  11 import org.eclipse.swt.SWT;
 
  12 import org.eclipse.swt.layout.GridData;
 
  13 import org.eclipse.swt.layout.GridLayout;
 
  14 import org.eclipse.swt.layout.RowLayout;
 
  15 import org.eclipse.swt.widgets.Composite;
 
  16 import org.eclipse.swt.widgets.Control;
 
  17 import org.eclipse.swt.widgets.Group;
 
  18 import org.eclipse.swt.widgets.Label;
 
  19 import org.eclipse.swt.widgets.Text;
 
  20 import org.eclipse.ui.PlatformUI;
 
  21 import org.eclipse.ui.dialogs.PropertyPage;
 
  25  * This page will be added to the project's property page dialog when the "Properties..." popup menu item is selected
 
  27 public class PHPObfuscatorPropertyPage 
 
  29    implements IObfuscatorPreferences
 
  31    private Text publishText;
 
  32 //   private Button hasNature,
 
  35    private ProjectProperties properties;
 
  37    private Control buildUI(Composite parent)
 
  39       Composite composite = new Composite(parent,SWT.NULL);
 
  40       RowLayout rowLayout = new RowLayout();
 
  41       rowLayout.type = SWT.VERTICAL;
 
  42       rowLayout.wrap = false;
 
  43       composite.setLayout(rowLayout);
 
  44 //      hasNature = new Button(composite,SWT.CHECK);
 
  45 //      hasNature.setText(PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.hasnature"));
 
  46 //      hasNature.addSelectionListener(new SelectionListener()
 
  48 //         public void widgetDefaultSelected(SelectionEvent e)
 
  50 //            group.setEnabled(hasNature.getSelection());
 
  53 //         public void widgetSelected(SelectionEvent e)
 
  55 //          group.setEnabled(hasNature.getSelection());
 
  58       group = new Group(composite,SWT.NONE);
 
  59       group.setText(PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.properties"));
 
  60       GridLayout gridLayout = new GridLayout();
 
  61       gridLayout.numColumns = 2;
 
  62       group.setLayout(gridLayout);
 
  64       Label label = new Label(group,SWT.RIGHT);
 
  65       label.setText(PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.publish"));
 
  66       publishText = new Text(group,SWT.LEFT);
 
  67       publishText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
 
  71    public void readProperties()
 
  74        publishText.setText(properties.getPublish());
 
  75 //       hasNature.setSelection(properties.hasNature());
 
  76 //       group.setEnabled(hasNature.getSelection());
 
  77      group.setEnabled(true);
 
  80    public void writeProperties()
 
  83    //   properties.setNature(hasNature.getSelection());
 
  84       properties.setPublish(publishText.getText());
 
  87    public Control createContents(Composite parent)
 
  89       Control control = buildUI(parent);
 
  92          IAdaptable adaptable = getElement();
 
  93          if(adaptable instanceof IProject)
 
  95           properties = new ProjectProperties((IProject)adaptable);
 
  99       catch(CoreException x)
 
 101          ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
 
 102                                PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.dialogtitle"),
 
 103                                PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.propertyerror"),
 
 109    public boolean performOk()
 
 115       catch(CoreException x)
 
 117          ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
 
 118                                PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.dialogtitle"),
 
 119                                PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.propertyerror"),
 
 122       return super.performOk();
 
 125    public void performApply()
 
 131       catch(CoreException x)
 
 133          ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
 
 134                                PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.dialogtitle"),
 
 135                                PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.propertyerror"),
 
 138       super.performApply();
 
 141    * Create an IStatus object from an exception.
 
 142    * @param x exception to process
 
 143    * @return IStatus status object for the above exception
 
 145   public static IStatus makeStatus(Exception x)
 
 147 //     Throwable t = popThrowables(x);
 
 148 //     if(t instanceof CoreException)
 
 149 //        return ((CoreException)t).getStatus();
 
 151         return new Status(IStatus.ERROR,
 
 152                            PHPeclipsePlugin.PLUGIN_ID,
 
 157    public void performDefaults()
 
 159   //    hasNature.setSelection(true);
 
 160       publishText.setText(DEFAULT_PUBLISH_DIR);
 
 161       super.performDefaults();