Changeset 3883 for devel-tools
- Timestamp:
- Jul 28, 2008, 2:38:35 PM (12 years ago)
- Location:
- devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/editor/RfpEditor.java
r3875 r3883 127 127 if (input instanceof IFileEditorInput) { 128 128 IProject project = ((IFileEditorInput) input).getFile().getProject(); 129 stores.add(RfpUI.getProjectPr opertiesStore(project));129 stores.add(RfpUI.getProjectPreferenceStore(project)); 130 130 } 131 131 -
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/RfpUI.java
r3879 r3883 1 1 package org.refal.rfpdt.ui; 2 3 import java.util.HashMap;4 2 5 3 import org.eclipse.core.resources.IProject; … … 13 11 import org.eclipse.ui.IWorkbenchWindow; 14 12 import org.eclipse.ui.plugin.AbstractUIPlugin; 15 import org.eclipse.ui.preferences.ScopedPreferenceStore;16 import org.osgi.framework.BundleContext;17 13 import org.refal.rfpdt.core.RfpCore; 18 14 import org.refal.rfpdt.editor.RfpPartitionScanner; 19 import org.refal.rfpdt.ui.preferences.ProjectPropertiesStore;20 15 import org.refal.rfpdt.ui.preferences.RfpProjectPreferences; 21 16 … … 32 27 // The shared instance 33 28 private static RfpUI plugin = null; 34 private static HashMap<IProject, ProjectPropertiesStore> stores = null;35 29 private static RfpPartitionScanner partitionScanner = null; 36 30 … … 62 56 } 63 57 64 /* 65 * (non-Javadoc) 66 * 67 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) 68 */ 69 public void start (BundleContext context) throws Exception { 70 super.start(context); 71 stores = new HashMap<IProject, ProjectPropertiesStore>(); 72 } 73 74 /* 75 * (non-Javadoc) 76 * 77 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) 78 */ 79 public void stop (BundleContext context) throws Exception { 80 for (ScopedPreferenceStore store : stores.values()) 81 store.save(); 82 stores = null; 83 super.stop(context); 84 } 58 // public void start (BundleContext context) throws Exception { 59 // super.start(context); 60 // } 61 // 62 // public void stop (BundleContext context) throws Exception { 63 // for (ScopedPreferenceStore store : stores.values()) 64 // store.save(); 65 // super.stop(context); 66 // } 85 67 86 68 /** … … 128 110 } 129 111 130 public static ProjectPropertiesStore getProjectPropertiesStore (IProject project) { 131 if (stores == null) 132 return null; 133 ProjectPropertiesStore store = stores.get(project); 134 if (store == null) { 135 store = new ProjectPropertiesStore(project); 136 stores.put(project, store); 137 } 138 return store; 139 } 140 public static RfpProjectPreferences getRfpProjectPreferences (IProject project, String qualifier) { 141 return new RfpProjectPreferences(RfpCore.getRfpProject(project), qualifier); 112 public static RfpProjectPreferences getProjectPreferenceStore (IProject project) { 113 return new RfpProjectPreferences(RfpCore.getRfpProject(project), PLUGIN_ID); 142 114 } 143 115 -
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/preferences/CodeStylePreferencePage.java
r3881 r3883 1 1 package org.refal.rfpdt.ui.preferences; 2 2 3 import org.refal.rfpdt.ui.preferences.SyntaxColoringPreferencePage.ModifiableBooleanFieldEditor; 4 import org.refal.rfpdt.ui.preferences.SyntaxColoringPreferencePage.ModifiableIntegerFieldEditor; 3 import org.eclipse.jface.preference.BooleanFieldEditor; 4 import org.eclipse.jface.preference.IntegerFieldEditor; 5 import org.eclipse.swt.SWT; 6 import org.eclipse.swt.layout.GridData; 7 import org.eclipse.swt.layout.GridLayout; 8 import org.eclipse.swt.widgets.Composite; 9 import org.eclipse.swt.widgets.Control; 10 import org.eclipse.swt.widgets.Group; 5 11 6 12 public class CodeStylePreferencePage extends PropertiesAndPreferencePage { 7 private ModifiableBooleanFieldEditor booleanFieldEditor; 8 private ModifiableIntegerFieldEditor integerFieldEditor; 13 private static String[] keys = new String[] { IPreferenceConstants.SPACES_FOR_TABS, IPreferenceConstants.TAB_WIDTH }; 9 14 10 15 protected String propertiesUrl () { … … 16 21 } 17 22 18 protected void createFields () { 19 booleanFieldEditor = new ModifiableBooleanFieldEditor(IPreferenceConstants.SPACES_FOR_TABS, 23 protected String[] keys () { 24 return keys; 25 } 26 27 protected Control createFields (Composite parent) { 28 Composite mainComposite = new Composite(parent, SWT.NONE); 29 GridLayout layout = new GridLayout(); 30 layout.marginHeight = 0; 31 layout.marginWidth = 0; 32 mainComposite.setLayout(layout); 33 mainComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 34 35 Group group = new Group(mainComposite, SWT.NONE); 36 group.setText("Formatter settings"); 37 layout = new GridLayout(); 38 group.setLayout(layout); 39 group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 40 41 Composite codeStyle = new Composite(group, SWT.NONE); 42 codeStyle.setLayout(new GridLayout()); 43 codeStyle.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 44 45 BooleanFieldEditor booleanFieldEditor = new BooleanFieldEditor(IPreferenceConstants.SPACES_FOR_TABS, 20 46 "Use spaces instead of tabs for indentation", codeStyle); 21 integerFieldEditor = new ModifiableIntegerFieldEditor(IPreferenceConstants.TAB_WIDTH, "Indentation size:",22 codeStyle);47 IntegerFieldEditor integerFieldEditor = new IntegerFieldEditor(IPreferenceConstants.TAB_WIDTH, 48 "Indentation size:", codeStyle); 23 49 integerFieldEditor.setValidRange(1, 16); 24 50 addField(booleanFieldEditor); 25 51 addField(integerFieldEditor); 26 }27 52 28 protected void loadDefaults () { 29 booleanFieldEditor.setBooleanValue(store.getBoolean(booleanFieldEditor.getPreferenceName())); 30 integerFieldEditor.setIntValue(store.getInt(integerFieldEditor.getPreferenceName())); 53 return mainComposite; 31 54 } 32 55 } -
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/preferences/CompilerPreferencePage.java
r3881 r3883 1 1 package org.refal.rfpdt.ui.preferences; 2 2 3 import org.refal.rfpdt.ui.preferences.SyntaxColoringPreferencePage.ModifiableBooleanFieldEditor; 3 import org.eclipse.jface.preference.BooleanFieldEditor; 4 import org.eclipse.swt.SWT; 5 import org.eclipse.swt.layout.GridData; 6 import org.eclipse.swt.layout.GridLayout; 7 import org.eclipse.swt.widgets.Composite; 8 import org.eclipse.swt.widgets.Control; 9 import org.eclipse.swt.widgets.Group; 4 10 5 11 public class CompilerPreferencePage extends PropertiesAndPreferencePage { 6 private ModifiableBooleanFieldEditor varNamesFieldEditor; 7 private ModifiableBooleanFieldEditor lineNumbersFieldEditor; 8 private ModifiableBooleanFieldEditor sourceFieldEditor; 12 private static String[] keys = new String[] { IPreferenceConstants.COMPILER_ADD_VARIABLE_NAMES, 13 IPreferenceConstants.COMPILER_ADD_LINE_NUMBERS, IPreferenceConstants.COMPILER_ADD_SOURCE }; 9 14 10 15 protected String propertiesUrl () { … … 16 21 } 17 22 18 protected void createFields () { 19 varNamesFieldEditor = new ModifiableBooleanFieldEditor(IPreferenceConstants.COMPILER_ADD_VARIABLE_NAMES, 23 protected String[] keys () { 24 return keys; 25 } 26 27 protected Control createFields (Composite parent) { 28 Composite mainComposite = new Composite(parent, SWT.NONE); 29 GridLayout layout = new GridLayout(); 30 layout.marginHeight = 0; 31 layout.marginWidth = 0; 32 mainComposite.setLayout(layout); 33 mainComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 34 35 Group group = new Group(mainComposite, SWT.NONE); 36 group.setText("Compiler settings"); 37 layout = new GridLayout(); 38 group.setLayout(layout); 39 group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 40 41 Composite codeStyle = new Composite(group, SWT.NONE); 42 codeStyle.setLayout(new GridLayout()); 43 codeStyle.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 44 45 BooleanFieldEditor varNamesFieldEditor = new BooleanFieldEditor( 46 IPreferenceConstants.COMPILER_ADD_VARIABLE_NAMES, 20 47 "Add variable attributes to generated class files (used by the debugger)", codeStyle); 21 lineNumbersFieldEditor = new ModifiableBooleanFieldEditor(IPreferenceConstants.COMPILER_ADD_LINE_NUMBERS, 48 BooleanFieldEditor lineNumbersFieldEditor = new BooleanFieldEditor( 49 IPreferenceConstants.COMPILER_ADD_LINE_NUMBERS, 22 50 "Add line number to generated class files (used by the debugger)", codeStyle); 23 sourceFieldEditor = new ModifiableBooleanFieldEditor(IPreferenceConstants.COMPILER_ADD_SOURCE,51 BooleanFieldEditor sourceFieldEditor = new BooleanFieldEditor(IPreferenceConstants.COMPILER_ADD_SOURCE, 24 52 "Add source file name to generated class files (used by the debugger)", codeStyle); 25 53 addField(varNamesFieldEditor); 26 54 addField(lineNumbersFieldEditor); 27 55 addField(sourceFieldEditor); 28 }29 56 30 protected void loadDefaults () { 31 varNamesFieldEditor.setBooleanValue(store.getBoolean(varNamesFieldEditor.getPreferenceName())); 32 lineNumbersFieldEditor.setBooleanValue(store.getBoolean(lineNumbersFieldEditor.getPreferenceName())); 33 sourceFieldEditor.setBooleanValue(store.getBoolean(sourceFieldEditor.getPreferenceName())); 57 return mainComposite; 34 58 } 35 59 } -
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/preferences/PropertiesAndPreferencePage.java
r3882 r3883 1 1 package org.refal.rfpdt.ui.preferences; 2 2 3 import java.io.IOException; 3 4 import java.util.ArrayList; 4 5 … … 12 13 import org.eclipse.jface.dialogs.MessageDialog; 13 14 import org.eclipse.jface.preference.FieldEditorPreferencePage; 14 import org.eclipse.jface.preference.IPreferenceStore;15 15 import org.eclipse.jface.window.Window; 16 16 import org.eclipse.swt.SWT; … … 21 21 import org.eclipse.swt.layout.GridLayout; 22 22 import org.eclipse.swt.widgets.Composite; 23 import org.eclipse.swt.widgets. Group;23 import org.eclipse.swt.widgets.Control; 24 24 import org.eclipse.swt.widgets.Label; 25 25 import org.eclipse.swt.widgets.Link; … … 39 39 private SelectionListener projectSpecificListner; 40 40 private ModifiableBooleanFieldEditor projectPropertiesField; 41 private ControlEnableState fBlockEnableState; 42 43 protected IPreferenceStore store; 44 protected Composite codeStyle; 41 private Control control; 42 private ControlEnableState controlEnableState; 43 private RfpProjectPreferences store; 45 44 46 45 public PropertiesAndPreferencePage () { 47 46 super(GRID); 48 store = RfpUI.getPluginPreferenceStore(); 49 setPreferenceStore(store); 47 setPreferenceStore(RfpUI.getPluginPreferenceStore()); 50 48 } 51 49 … … 54 52 protected abstract String preferenceUrl (); 55 53 56 protected abstract void createFields ();57 58 protected abstract void loadDefaults ();59 54 protected abstract Control createFields (Composite parent); 55 56 protected abstract String[] keys (); 57 60 58 private void enableFields () { 61 if ( fBlockEnableState != null) {62 fBlockEnableState.restore();63 fBlockEnableState= null;59 if (controlEnableState != null) { 60 controlEnableState.restore(); 61 controlEnableState = null; 64 62 } 65 63 } 66 64 67 65 private void disableFields () { 68 if ( fBlockEnableState == null)69 fBlockEnableState= ControlEnableState.disable(getFieldEditorParent());66 if (controlEnableState == null) 67 controlEnableState = ControlEnableState.disable(control); 70 68 } 71 69 72 70 protected void performDefaults () { 73 71 super.performDefaults(); 74 if (projectSpecificListner != null) {72 if (projectSpecificListner != null) 75 73 disableFields(); 76 loadDefaults(); 77 } 74 } 75 76 public boolean performOk () { 77 if (projectPropertiesField != null) { 78 if (projectPropertiesField.getBooleanValue()) { 79 store.init(keys()); 80 boolean res = super.performOk(); 81 try { 82 store.save(); 83 } catch (IOException e) { 84 RfpUI.log(e); 85 } 86 return res; 87 } else { 88 store.clear(keys()); 89 try { 90 store.save(); 91 } catch (IOException e) { 92 RfpUI.log(e); 93 } 94 return true; 95 } 96 } else 97 return super.performOk(); 78 98 } 79 99 … … 157 177 158 178 public void createFieldEditors () { 159 final Composite parent = getFieldEditorParent(); 160 161 Composite mainComposite = parent;//new Composite(parent, SWT.NONE); 162 GridLayout layout = new GridLayout(); 163 layout.marginHeight = 0; 164 layout.marginWidth = 0; 165 mainComposite.setLayout(layout); 166 mainComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 167 168 Group group = new Group(mainComposite, SWT.NONE); 169 group.setText("Formatter settings"); 170 layout = new GridLayout(); 171 group.setLayout(layout); 172 group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 173 174 codeStyle = new Composite(group, SWT.NONE); 175 codeStyle.setLayout(new GridLayout()); 176 codeStyle.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 177 178 createFields(); 179 179 Composite parent = getFieldEditorParent(); 180 control = createFields(parent); 180 181 Dialog.applyDialogFont(parent); 181 182 } … … 189 190 public void setElement (IAdaptable element) { 190 191 project = (IProject) element.getAdapter(IResource.class); 191 ProjectPropertiesStore projectStore = RfpUI.getProjectPropertiesStore(project);192 setPreferenceStore( projectStore);192 store = RfpUI.getProjectPreferenceStore(project); 193 setPreferenceStore(store); 193 194 } 194 195 -
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/preferences/RfpProjectPreferences.java
r3879 r3883 4 4 5 5 import org.eclipse.core.runtime.ListenerList; 6 import org.eclipse.core.runtime.preferences.DefaultScope;7 6 import org.eclipse.core.runtime.preferences.IEclipsePreferences; 8 7 import org.eclipse.jface.preference.IPersistentPreferenceStore; 8 import org.eclipse.jface.preference.IPreferenceStore; 9 9 import org.eclipse.jface.util.IPropertyChangeListener; 10 10 import org.eclipse.jface.util.PropertyChangeEvent; … … 18 18 private final IEclipsePreferences.IPreferenceChangeListener preferenceListner; 19 19 private final ListenerList listeners; 20 private final I EclipsePreferences defaultPref;20 private final IPreferenceStore defaultStore; 21 21 22 22 private void firePropertyChangeEvent (IEclipsePreferences.PreferenceChangeEvent event) { … … 39 39 }; 40 40 listeners = new ListenerList(ListenerList.IDENTITY); 41 default Pref = new DefaultScope().getNode(qualifier);41 defaultStore = RfpUI.getPluginPreferenceStore(); 42 42 } 43 43 44 44 public void init (String[] keys) { 45 45 for (String key : keys) 46 46 setToDefault(key); 47 48 47 } 49 48 50 public void clear () { 51 try { 52 preference.clear(); 53 } catch (BackingStoreException e) { 54 RfpUI.log(e); 55 } 49 public void clear (String[] keys) { 50 for (String key : keys) 51 preference.remove(key); 56 52 } 57 53 58 54 public void addPropertyChangeListener (IPropertyChangeListener listener) { 59 55 if (listeners.size() == 0) … … 80 76 81 77 public boolean getDefaultBoolean (String key) { 82 return default Pref.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT);78 return defaultStore.getBoolean(key); 83 79 } 84 80 85 81 public double getDefaultDouble (String key) { 86 return default Pref.getDouble(key, DOUBLE_DEFAULT_DEFAULT);82 return defaultStore.getDouble(key); 87 83 } 88 84 89 85 public float getDefaultFloat (String key) { 90 return default Pref.getFloat(key, FLOAT_DEFAULT_DEFAULT);86 return defaultStore.getFloat(key); 91 87 } 92 88 93 89 public int getDefaultInt (String key) { 94 return default Pref.getInt(key, INT_DEFAULT_DEFAULT);90 return defaultStore.getInt(key); 95 91 } 96 92 97 93 public long getDefaultLong (String key) { 98 return default Pref.getLong(key, LONG_DEFAULT_DEFAULT);94 return defaultStore.getLong(key); 99 95 } 100 96 101 97 public String getDefaultString (String key) { 102 return default Pref.get(key, STRING_DEFAULT_DEFAULT);98 return defaultStore.getString(key); 103 99 } 104 100 … … 165 161 166 162 public void setToDefault (String key) { 167 preference.put(key, default Pref.get(key, STRING_DEFAULT_DEFAULT));163 preference.put(key, defaultStore.getString(key)); 168 164 } 169 165 … … 196 192 preference.flush(); 197 193 } catch (BackingStoreException e) { 198 RfpUI.log(e);194 throw new IOException(e.getMessage()); 199 195 } 200 196 }
Note: See TracChangeset
for help on using the changeset viewer.