From 0ed0e8e23bdd2146215db6c5aaba1cd0fe31412b Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Tue, 15 May 2007 13:17:31 +0000 Subject: [PATCH] Improve Property dialog size & position saving mechanism. --- .../ui/preferences/PropertyPageDefsTab.java | 42 +++++++++++++++---- .../eclipse/cdt/ui/newui/AbstractPage.java | 26 ++++++++---- .../org/eclipse/cdt/ui/newui/CDTPrefUtil.java | 6 ++- .../cdt/ui/newui/PluginResources.properties | 5 ++- 4 files changed, 61 insertions(+), 18 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/preferences/PropertyPageDefsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/preferences/PropertyPageDefsTab.java index 6b15754c650..30b5bf2ac83 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/preferences/PropertyPageDefsTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/preferences/PropertyPageDefsTab.java @@ -29,14 +29,19 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab { private Button show_tree; // private Button show_mul; private Button show_mng; - private Button show_sav; private Button show_tool; private Button show_exp; + private Button b_0; private Button b_1; private Button b_2; private Button b_3; + private Button s_0; + private Button s_1; + private Button s_2; + + public void createControls(Composite parent) { super.createControls(parent); usercomp.setLayout(new GridLayout(1, false)); @@ -45,10 +50,6 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab { show_mng.setText(UIMessages.getString("PropertyPageDefsTab.0")); //$NON-NLS-1$ show_mng.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - show_sav = new Button(usercomp, SWT.CHECK); - show_sav.setText(UIMessages.getString("PropertyPageDefsTab.3")); //$NON-NLS-1$ - show_sav.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - // show_mul = new Button(usercomp, SWT.CHECK); // show_mul.setText(UIMessages.getString("PropertyPageDefsTab.2")); //$NON-NLS-1$ // show_mul.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -65,10 +66,26 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab { show_exp.setText(UIMessages.getString("PropertyPageDefsTab.10")); //$NON-NLS-1$ show_exp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Group saveGrp = new Group(usercomp, SWT.NONE); + saveGrp.setText(UIMessages.getString("PropertyPageDefsTab.11")); //$NON-NLS-1$ + saveGrp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + FillLayout fl = new FillLayout(SWT.VERTICAL); + fl.spacing = SPACING; + fl.marginHeight = SPACING; + fl.marginWidth = SPACING; + saveGrp.setLayout(fl); + + s_0 = new Button(saveGrp, SWT.RADIO); + s_0.setText(UIMessages.getString("PropertyPageDefsTab.12")); //$NON-NLS-1$ + s_1 = new Button(saveGrp, SWT.RADIO); + s_1.setText(UIMessages.getString("PropertyPageDefsTab.13")); //$NON-NLS-1$ + s_2 = new Button(saveGrp, SWT.RADIO); + s_2.setText(UIMessages.getString("PropertyPageDefsTab.14")); //$NON-NLS-1$ + Group discGrp = new Group(usercomp, SWT.NONE); discGrp.setText(UIMessages.getString("PropertyPageDefsTab.5")); //$NON-NLS-1$ discGrp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - FillLayout fl = new FillLayout(SWT.VERTICAL); + fl = new FillLayout(SWT.VERTICAL); fl.spacing = SPACING; fl.marginHeight = SPACING; fl.marginWidth = SPACING; @@ -86,7 +103,6 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab { show_tree.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_DTREE)); // show_mul.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_MULTI)); show_mng.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG)); - show_sav.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSAVE)); show_tool.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOTOOLM)); show_exp.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_EXPORT)); @@ -96,13 +112,18 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab { case CDTPrefUtil.DISC_NAMING_ALWAYS_BOTH: b_2.setSelection(true); break; case CDTPrefUtil.DISC_NAMING_ALWAYS_IDS: b_3.setSelection(true); break; } + + switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_POSSAVE)) { + case CDTPrefUtil.POSITION_SAVE_BOTH: s_0.setSelection(true); break; + case CDTPrefUtil.POSITION_SAVE_SIZE: s_1.setSelection(true); break; + case CDTPrefUtil.POSITION_SAVE_NONE: s_2.setSelection(true); break; + } } protected void performOK() { CDTPrefUtil.setBool(CDTPrefUtil.KEY_DTREE, show_tree.getSelection()); // CDTPrefUtil.setBool(CDTPrefUtil.KEY_MULTI, show_mul.getSelection()); CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOMNG, !show_mng.getSelection()); - CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOSAVE, !show_sav.getSelection()); CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOTOOLM, !show_tool.getSelection()); CDTPrefUtil.setBool(CDTPrefUtil.KEY_EXPORT, show_exp.getSelection()); int x = 0; @@ -110,6 +131,11 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab { else if (b_2.getSelection()) x = 2; else if (b_3.getSelection()) x = 3; CDTPrefUtil.setInt(CDTPrefUtil.KEY_DISC_NAMES, x); + + if (s_0.getSelection()) x = 0; + else if (s_1.getSelection()) x = 1; + else if (s_2.getSelection()) x = 2; + CDTPrefUtil.setInt(CDTPrefUtil.KEY_POSSAVE, x); } protected void performDefaults() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java index 4c82affad73..848c23f0c7c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java @@ -145,6 +145,8 @@ implements protected ArrayList itabs = new ArrayList(); protected ICPropertyTab currentTab; + private boolean isNewOpening = true; + protected class InternalTab { Composite comp; String text; @@ -535,7 +537,7 @@ implements public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { - handleResize(visible); + handleResize(true); displayedConfig = true; if (excludeFromBuildCheck != null && resd != null) excludeFromBuildCheck.setSelection(resd.isExcluded()); @@ -552,8 +554,11 @@ implements } protected void handleResize(boolean visible) { - if (CDTPropertyManager.getPagesCount() > 1) return; // do not duplicate - if (CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSAVE)) return; + if (visible && !isNewOpening) return; // do not duplicate + isNewOpening = false; + + int saveMode = CDTPrefUtil.getInt(CDTPrefUtil.KEY_POSSAVE); + if (saveMode == CDTPrefUtil.POSITION_SAVE_NONE) return; if (internalElement == null && !checkElement()) return; // not initialized. Do not process @@ -569,12 +574,14 @@ implements if (visible) { String w = prj.getPersistentProperty(WIDTH); String h = prj.getPersistentProperty(HEIGHT); - String x = prj.getPersistentProperty(XKEY); - String y = prj.getPersistentProperty(YKEY); if (w != null) r.width = Integer.parseInt(w); if (h != null) r.height = Integer.parseInt(h); - if (x != null) r.x = Integer.parseInt(x); - if (y != null) r.y = Integer.parseInt(y); + if (saveMode == CDTPrefUtil.POSITION_SAVE_BOTH) { + String x = prj.getPersistentProperty(XKEY); + String y = prj.getPersistentProperty(YKEY); + if (x != null) r.x = Integer.parseInt(x); + if (y != null) r.y = Integer.parseInt(y); + } getShell().setBounds(r); } else { prj.setPersistentProperty(WIDTH, String.valueOf(r.width)); @@ -687,7 +694,10 @@ implements public void dispose() { if (displayedConfig) forEach(ICPropertyTab.DISPOSE); - handleResize(false); // save page size + + if (!isNewOpening) + handleResize(false); // save page size + isNewOpening = true; // clear static variables if (CDTPropertyManager.getPagesCount() == 0) { resd = null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java index 4330eb9d2d6..68b775dc07a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java @@ -25,12 +25,16 @@ public class CDTPrefUtil { public static final String KEY_NOMNG = "properties.manage.config.disable"; //$NON-NLS-1$ public static final String KEY_MULTI = "properties.multi.config.enable"; //$NON-NLS-1$ public static final String KEY_DTREE = "properties.data.hierarchy.enable"; //$NON-NLS-1$ - public static final String KEY_NOSAVE = "properties.save.position.disable"; //$NON-NLS-1$ public static final String KEY_NOTOOLM = "properties.toolchain.modification.disable"; //$NON-NLS-1$ public static final String KEY_EXPORT = "properties.export.page.enable"; //$NON-NLS-1$ // string keys public static final String KEY_PREFTC = "wizard.preferred.toolchains"; //$NON-NLS-1$ // integer keys + public static final String KEY_POSSAVE = "properties.save.position"; //$NON-NLS-1$ + public static final int POSITION_SAVE_BOTH = 0; + public static final int POSITION_SAVE_SIZE = 1; + public static final int POSITION_SAVE_NONE = 2; + public static final String KEY_DISC_NAMES = "properties.discovery.naming"; //$NON-NLS-1$ public static final int DISC_NAMING_UNIQUE_OR_BOTH = 0; public static final int DISC_NAMING_UNIQUE_OR_IDS = 1; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties index 2ed8a7cf815..84dde861b49 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties @@ -339,8 +339,11 @@ ProjectConvert.title=Project Converters for {0} PropertyPageDefsTab.0=Show button PropertyPageDefsTab.1=Display "Data hierarchy" tab PropertyPageDefsTab.10=Display "Export settings" tab +PropertyPageDefsTab.11=Save property dialog bounds +PropertyPageDefsTab.12=Save size and position +PropertyPageDefsTab.13=Save size only +PropertyPageDefsTab.14=Do not save at all PropertyPageDefsTab.2=Enable multiple configurations setting -PropertyPageDefsTab.3=Save property dialog size and position PropertyPageDefsTab.4=Display "Tool chain editor" tab PropertyPageDefsTab.5=Discovery profiles naming rule PropertyPageDefsTab.6=Show disc. page names if they're unique. Else names + profile IDs.