From e7b39f16e9ca347f922bfddec9a72d8ebfd4008d Mon Sep 17 00:00:00 2001 From: khartlage Date: Mon, 23 Jun 2003 16:28:23 +0000 Subject: [PATCH 1/1] Improved pref page layout --- .../phpeclipse/PHPEclipseBasePreferencePage.java | 60 +++-- .../preferences/PHPObfuscatorPropertyPage.java | 235 +++++++++----------- 2 files changed, 145 insertions(+), 150 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java index 000a10e..f46d66e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java @@ -15,6 +15,7 @@ import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; @@ -98,37 +99,25 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor Composite webSettingsComposite = new Composite(composite, SWT.NONE); webSettingsComposite.setLayout(new GridLayout()); webSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE); - webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup")); - webSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - webSettingsGroup.setLayout(new GridLayout()); - localHostSFE = - new StringFieldEditor( - IPreferenceConstants.LOCALHOST_PREF, - PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"), - webSettingsGroup); - localHostSFE.setPreferencePage(this); - localHostSFE.setPreferenceStore(getPreferenceStore()); - localHostSFE.load(); - documentRootDFE = - new DirectoryFieldEditor( - IPreferenceConstants.DOCUMENTROOT_PREF, - PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"), - webSettingsGroup); - documentRootDFE.setPreferencePage(this); - documentRootDFE.setPreferenceStore(getPreferenceStore()); - documentRootDFE.load(); - - new Label(webSettingsGroup, SWT.NONE); + showExternalPreviewBFE = new BooleanFieldEditor( IPreferenceConstants.SHOW_EXTERNAL_PREVIEW_PREF, PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.showexternalpreview"), - webSettingsGroup); + webSettingsComposite); showExternalPreviewBFE.setPreferencePage(this); showExternalPreviewBFE.setPreferenceStore(getPreferenceStore()); showExternalPreviewBFE.load(); - new Label(webSettingsGroup, SWT.NONE); + + Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE); + webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup")); + GridLayout gridLayout = new GridLayout(); + // gridLayout.numColumns = 3; + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + webSettingsGroup.setLayoutData(gridData); + webSettingsGroup.setLayout(gridLayout); + + // new Label(webSettingsGroup, SWT.NONE); externalBrowserBFE = new BooleanFieldEditor( IPreferenceConstants.USE_EXTERNAL_BROWSER_PREF, @@ -138,6 +127,8 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor externalBrowserBFE.setPreferenceStore(getPreferenceStore()); externalBrowserBFE.load(); new Label(webSettingsGroup, SWT.NONE); + new Label(webSettingsGroup, SWT.NONE); + // new Label(webSettingsGroup, SWT.NONE); externalBrowserSFE = new StringFieldEditor( IPreferenceConstants.EXTERNAL_BROWSER_PREF, @@ -146,7 +137,26 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor externalBrowserSFE.setPreferencePage(this); externalBrowserSFE.setPreferenceStore(getPreferenceStore()); externalBrowserSFE.load(); + new Label(webSettingsGroup, SWT.NONE); + localHostSFE = + new StringFieldEditor( + IPreferenceConstants.LOCALHOST_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"), + webSettingsGroup); + localHostSFE.setPreferencePage(this); + localHostSFE.setPreferenceStore(getPreferenceStore()); + localHostSFE.load(); + new Label(webSettingsGroup, SWT.NONE); + + documentRootDFE = + new DirectoryFieldEditor( + IPreferenceConstants.DOCUMENTROOT_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"), + webSettingsGroup); + documentRootDFE.setPreferencePage(this); + documentRootDFE.setPreferenceStore(getPreferenceStore()); + documentRootDFE.load(); //Create apache Composite apacheSettingsComposite = new Composite(composite, SWT.NULL); apacheSettingsComposite.setLayout(new GridLayout()); @@ -179,7 +189,7 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor apacheRestartSFE.setPreferencePage(this); apacheRestartSFE.setPreferenceStore(getPreferenceStore()); apacheRestartSFE.load(); - + phpRunSFE = new StringFieldEditor( IPreferenceConstants.PHP_RUN_PREF, diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPObfuscatorPropertyPage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPObfuscatorPropertyPage.java index 3397ab3..70e5200 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPObfuscatorPropertyPage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPObfuscatorPropertyPage.java @@ -8,6 +8,7 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -24,140 +25,124 @@ import org.eclipse.ui.dialogs.PropertyPage; * * This page will be added to the project's property page dialog when the "Properties..." popup menu item is selected */ -public class PHPObfuscatorPropertyPage - extends PropertyPage - implements IObfuscatorPreferences -{ - private Text publishText; -// private Button hasNature, -// isBuild; - private Group group; - private ProjectProperties properties; - - private Control buildUI(Composite parent) - { - Composite composite = new Composite(parent,SWT.NULL); - RowLayout rowLayout = new RowLayout(); - rowLayout.type = SWT.VERTICAL; - rowLayout.wrap = false; - composite.setLayout(rowLayout); -// hasNature = new Button(composite,SWT.CHECK); -// hasNature.setText(PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.hasnature")); -// hasNature.addSelectionListener(new SelectionListener() -// { -// public void widgetDefaultSelected(SelectionEvent e) -// { -// group.setEnabled(hasNature.getSelection()); -// } -// -// public void widgetSelected(SelectionEvent e) -// { -// group.setEnabled(hasNature.getSelection()); -// } -// }); - group = new Group(composite,SWT.NONE); - group.setText(PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.properties")); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - group.setLayout(gridLayout); - - Label label = new Label(group,SWT.RIGHT); - label.setText(PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.publish")); - publishText = new Text(group,SWT.LEFT); - publishText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - return composite; - } +public class PHPObfuscatorPropertyPage extends PropertyPage implements IObfuscatorPreferences { + private Text publishText; + // private DirectoryFieldEditor dfe; + private Group group; + private ProjectProperties properties; - public void readProperties() - throws CoreException - { - publishText.setText(properties.getPublish()); -// hasNature.setSelection(properties.hasNature()); -// group.setEnabled(hasNature.getSelection()); - group.setEnabled(true); - } + private Control buildUI(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + RowLayout rowLayout = new RowLayout(); + rowLayout.type = SWT.VERTICAL; + rowLayout.wrap = false; + composite.setLayout(rowLayout); + // hasNature = new Button(composite,SWT.CHECK); + // hasNature.setText(PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.hasnature")); + // hasNature.addSelectionListener(new SelectionListener() + // { + // public void widgetDefaultSelected(SelectionEvent e) + // { + // group.setEnabled(hasNature.getSelection()); + // } + // + // public void widgetSelected(SelectionEvent e) + // { + // group.setEnabled(hasNature.getSelection()); + // } + // }); + group = new Group(composite, SWT.NONE); + group.setText(PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.properties")); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + group.setLayout(gridLayout); - public void writeProperties() - throws CoreException - { - // properties.setNature(hasNature.getSelection()); - properties.setPublish(publishText.getText()); - } + Label label = new Label(group, SWT.RIGHT); + label.setText(PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.publish")); + publishText = new Text(group, SWT.LEFT); + publishText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - public Control createContents(Composite parent) - { - Control control = buildUI(parent); - try - { - IAdaptable adaptable = getElement(); - if(adaptable instanceof IProject) - { - properties = new ProjectProperties((IProject)adaptable); - readProperties(); - } - } - catch(CoreException x) - { - ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), - PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.dialogtitle"), - PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.propertyerror"), - makeStatus(x)); - } - return control; - } - - public boolean performOk() - { - try - { - writeProperties(); - } - catch(CoreException x) - { - ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), - PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.dialogtitle"), - PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.propertyerror"), - makeStatus(x)); - } - return super.performOk(); - } +// dfe = +// new DirectoryFieldEditor( +// "PHPObfuscatorPropertyPage.publish", +// PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.publish"), +// group); - public void performApply() - { - try - { - writeProperties(); - } - catch(CoreException x) - { - ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), - PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.dialogtitle"), - PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.propertyerror"), - makeStatus(x)); + return composite; + } + + public void readProperties() throws CoreException { + publishText.setText(properties.getPublish()); + // dfe.loadDefault(); + // hasNature.setSelection(properties.hasNature()); + // group.setEnabled(hasNature.getSelection()); + group.setEnabled(true); + } + + public void writeProperties() throws CoreException { + // properties.setNature(hasNature.getSelection()); + properties.setPublish(publishText.getText()); + // dfe.store(); + } + + public Control createContents(Composite parent) { + Control control = buildUI(parent); + try { + IAdaptable adaptable = getElement(); + if (adaptable instanceof IProject) { + properties = new ProjectProperties((IProject) adaptable); + readProperties(); } - super.performApply(); - } + } catch (CoreException x) { + ErrorDialog.openError( + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.dialogtitle"), + PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.propertyerror"), + makeStatus(x)); + } + return control; + } + + public boolean performOk() { + try { + writeProperties(); + } catch (CoreException x) { + ErrorDialog.openError( + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.dialogtitle"), + PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.propertyerror"), + makeStatus(x)); + } + return super.performOk(); + } + + public void performApply() { + try { + writeProperties(); + } catch (CoreException x) { + ErrorDialog.openError( + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.dialogtitle"), + PHPPreferencesMessages.getString("PHPObfuscatorPropertyPage.propertyerror"), + makeStatus(x)); + } + super.performApply(); + } /** * Create an IStatus object from an exception. * @param x exception to process * @return IStatus status object for the above exception */ - public static IStatus makeStatus(Exception x) - { -// Throwable t = popThrowables(x); -// if(t instanceof CoreException) -// return ((CoreException)t).getStatus(); -// else - return new Status(IStatus.ERROR, - PHPeclipsePlugin.PLUGIN_ID, - IStatus.ERROR, - x.getMessage(), - x); + public static IStatus makeStatus(Exception x) { + // Throwable t = popThrowables(x); + // if(t instanceof CoreException) + // return ((CoreException)t).getStatus(); + // else + return new Status(IStatus.ERROR, PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, x.getMessage(), x); + } + public void performDefaults() { + // hasNature.setSelection(true); + publishText.setText(DEFAULT_PUBLISH_DIR); + super.performDefaults(); } - public void performDefaults() - { - // hasNature.setSelection(true); - publishText.setText(DEFAULT_PUBLISH_DIR); - super.performDefaults(); - } } \ No newline at end of file -- 1.7.1