Skip to content

Commit a8434ca

Browse files
committed
Use getPreferenceStore() instead of static field PREFERENCES
- We want to avoid using these global static fields
1 parent eeb4dcb commit a8434ca

File tree

86 files changed

+204
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+204
-230
lines changed

com.archimatetool.canvas/src/com/archimatetool/canvas/figures/CanvasStickyFigure.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ protected void paintFigure(Graphics graphics) {
185185

186186
@Override
187187
public IFigure getToolTip() {
188-
if(!ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.VIEW_TOOLTIPS)) {
188+
if(!ArchiPlugin.INSTANCE.getPreferenceStore().getBoolean(IPreferenceConstants.VIEW_TOOLTIPS)) {
189189
return null;
190190
}
191191

com.archimatetool.editor/src/com/archimatetool/editor/ArchiPlugin.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
import org.eclipse.core.runtime.FileLocator;
1616
import org.eclipse.core.runtime.Platform;
17-
import org.eclipse.jface.preference.IPreferenceStore;
1817
import org.eclipse.osgi.service.datalocation.Location;
1918
import org.eclipse.ui.plugin.AbstractUIPlugin;
20-
import org.osgi.framework.BundleContext;
2119
import org.osgi.framework.Version;
2220

2321

@@ -49,34 +47,10 @@ public class ArchiPlugin extends AbstractUIPlugin {
4947
*/
5048
public static ArchiPlugin INSTANCE;
5149

52-
/**
53-
* The shared Preference store
54-
*/
55-
public static IPreferenceStore PREFERENCES;
56-
5750
public ArchiPlugin() {
58-
}
59-
60-
/**
61-
* This method is called upon plug-in activation
62-
*/
63-
@Override
64-
public void start(BundleContext context) throws Exception {
65-
super.start(context);
66-
6751
INSTANCE = this;
68-
PREFERENCES = getPreferenceStore();
6952
}
7053

71-
/**
72-
* This method is called when the plug-in is stopped
73-
*/
74-
@Override
75-
public void stop(BundleContext context) throws Exception {
76-
// super must be *last*
77-
super.stop(context);
78-
}
79-
8054
/**
8155
* @return The User data folder use for Archi data
8256
*/

com.archimatetool.editor/src/com/archimatetool/editor/ArchiWorkbenchAdvisor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void initialize(IWorkbenchConfigurer configurer) {
5151
"true".equals(System.getProperty("showheap")));
5252

5353
// Edge Browser on Windows
54-
if(PlatformUtils.isWindows() && ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.EDGE_BROWSER)) {
54+
if(PlatformUtils.isWindows() && ArchiPlugin.INSTANCE.getPreferenceStore().getBoolean(IPreferenceConstants.EDGE_BROWSER)) {
5555
System.setProperty("org.eclipse.swt.browser.DefaultType", "edge");
5656
}
5757

com.archimatetool.editor/src/com/archimatetool/editor/ArchiWorkbenchWindowAdvisor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public ArchiWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
3131
super(configurer);
3232

3333
// Status Line
34-
boolean doShowStatusLine = ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.SHOW_STATUS_LINE);
34+
boolean doShowStatusLine = ArchiPlugin.INSTANCE.getPreferenceStore().getBoolean(IPreferenceConstants.SHOW_STATUS_LINE);
3535
configurer.setShowStatusLine(doShowStatusLine);
3636
}
3737

com.archimatetool.editor/src/com/archimatetool/editor/actions/CheckForNewVersionAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ String getOnlineVersion(URL url) throws IOException {
6464
@Override
6565
public void run() {
6666
try {
67-
String versionFile = ArchiPlugin.PREFERENCES.getString(IPreferenceConstants.UPDATE_URL);
67+
String versionFile = ArchiPlugin.INSTANCE.getPreferenceStore().getString(IPreferenceConstants.UPDATE_URL);
6868

6969
if(!StringUtils.isSet(versionFile)) {
7070
return;
@@ -76,7 +76,7 @@ public void run() {
7676
String thisVersion = ArchiPlugin.INSTANCE.getVersion();
7777

7878
if(StringUtils.compareVersionNumbers(newVersion, thisVersion) > 0) {
79-
String downloadURL = ArchiPlugin.PREFERENCES.getString(IPreferenceConstants.DOWNLOAD_URL);
79+
String downloadURL = ArchiPlugin.INSTANCE.getPreferenceStore().getString(IPreferenceConstants.DOWNLOAD_URL);
8080

8181
// No download URL
8282
if(!StringUtils.isSet(downloadURL)) {
@@ -115,7 +115,7 @@ public void run() {
115115

116116
@Override
117117
public boolean isEnabled() {
118-
String versionFile = ArchiPlugin.PREFERENCES.getString(IPreferenceConstants.UPDATE_URL);
118+
String versionFile = ArchiPlugin.INSTANCE.getPreferenceStore().getString(IPreferenceConstants.UPDATE_URL);
119119
return StringUtils.isSet(versionFile);
120120
}
121121

com.archimatetool.editor/src/com/archimatetool/editor/actions/MRUMenuManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private List<File> loadMRUListFromPreferenceStore() {
6060
List<File> list = new ArrayList<File>();
6161

6262
for(int i = 0; i < getPreferencesMRUMax(); i++) {
63-
String path = ArchiPlugin.PREFERENCES.getString(MRU_PREFS_KEY + i);
63+
String path = ArchiPlugin.INSTANCE.getPreferenceStore().getString(MRU_PREFS_KEY + i);
6464
if(StringUtils.isSet(path)) {
6565
list.add(new File(path));
6666
}
@@ -96,12 +96,12 @@ void addToList(File file) {
9696
private void saveList() {
9797
// Clear
9898
for(int i = 0; i < 50; i++) {
99-
ArchiPlugin.PREFERENCES.setValue(MRU_PREFS_KEY + i, "");
99+
ArchiPlugin.INSTANCE.getPreferenceStore().setValue(MRU_PREFS_KEY + i, "");
100100
}
101101

102102
// Save
103103
for(int i = 0; i < getMRUList().size(); i++) {
104-
ArchiPlugin.PREFERENCES.setValue(MRU_PREFS_KEY + i, getMRUList().get(i).getAbsolutePath());
104+
ArchiPlugin.INSTANCE.getPreferenceStore().setValue(MRU_PREFS_KEY + i, getMRUList().get(i).getAbsolutePath());
105105
}
106106
}
107107

@@ -129,7 +129,7 @@ void clearAll() {
129129
}
130130

131131
int getPreferencesMRUMax() {
132-
int max = ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.MRU_MAX);
132+
int max = ArchiPlugin.INSTANCE.getPreferenceStore().getInt(IPreferenceConstants.MRU_MAX);
133133
if(max < 3) {
134134
max = 3;
135135
}

com.archimatetool.editor/src/com/archimatetool/editor/actions/SetConceptTypeExtensionContributionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private void changeElementTypes(EClass eClass, Set<IArchimateElement> elements)
222222
for(Entry<IArchimateModel, Set<IArchimateElement>> entry : elementsMap.entrySet()) {
223223
CommandStack stack = (CommandStack)entry.getKey().getAdapter(CommandStack.class);
224224
CompoundCommand cmd = SetConceptTypeCommandFactory.createSetElementTypeCommand(eClass, entry.getValue(),
225-
ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE));
225+
ArchiPlugin.INSTANCE.getPreferenceStore().getBoolean(IPreferenceConstants.ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE));
226226
if(stack != null && cmd != null) {
227227
// Wrap the command in a NonNotifyingCompoundCommand to minimise event noise
228228
stack.execute(new NonNotifyingCompoundCommand(cmd));

com.archimatetool.editor/src/com/archimatetool/editor/diagram/AbstractDiagramEditor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public CommandStack getCommandStack() {
261261
setPartName(input.getName());
262262

263263
// Listen to App Prefs changes
264-
ArchiPlugin.PREFERENCES.addPropertyChangeListener(appPreferencesListener);
264+
ArchiPlugin.INSTANCE.getPreferenceStore().addPropertyChangeListener(appPreferencesListener);
265265
}
266266

267267
@Override
@@ -448,7 +448,7 @@ protected void setProperties() {
448448
* Apply grid Prefs
449449
*/
450450
protected void applyUserGridPreferences() {
451-
IPreferenceStore store = ArchiPlugin.PREFERENCES;
451+
IPreferenceStore store = ArchiPlugin.INSTANCE.getPreferenceStore();
452452

453453
// Grid Spacing
454454
int gridSize = store.getInt(IPreferenceConstants.GRID_SIZE);
@@ -471,7 +471,7 @@ protected void applyUserGridPreferences() {
471471
@Override
472472
protected PaletteViewerProvider createPaletteViewerProvider() {
473473
// Ensure palette is showing or not
474-
boolean showPalette = ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.PALETTE_STATE);
474+
boolean showPalette = ArchiPlugin.INSTANCE.getPreferenceStore().getBoolean(IPreferenceConstants.PALETTE_STATE);
475475
getPalettePreferences().setPaletteState(showPalette ? FlyoutPaletteComposite.STATE_PINNED_OPEN : FlyoutPaletteComposite.STATE_COLLAPSED);
476476

477477
return new PaletteViewerProvider(getEditDomain()) {
@@ -1060,7 +1060,7 @@ public void dispose() {
10601060
super.dispose();
10611061

10621062
// Remove Preference listener
1063-
ArchiPlugin.PREFERENCES.removePropertyChangeListener(appPreferencesListener);
1063+
ArchiPlugin.INSTANCE.getPreferenceStore().removePropertyChangeListener(appPreferencesListener);
10641064

10651065
// Remove eCore adapter listener objects
10661066
eCoreAdapter.remove(getModel(), getModel() != null ? getModel().getArchimateModel() : null);

com.archimatetool.editor/src/com/archimatetool/editor/diagram/ArchimateDiagramEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected void setViewpoint() {
7171
getPaletteRoot().updateViewpoint();
7272

7373
// If the preference is to hide elements then refresh the model contents
74-
if(!ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.VIEWPOINTS_GHOST_DIAGRAM_ELEMENTS)) {
74+
if(!ArchiPlugin.INSTANCE.getPreferenceStore().getBoolean(IPreferenceConstants.VIEWPOINTS_GHOST_DIAGRAM_ELEMENTS)) {
7575
getGraphicalViewer().setContents(getModel());
7676
}
7777
}

com.archimatetool.editor/src/com/archimatetool/editor/diagram/ArchimateDiagramEditorPalette.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ private void createSpecializationsGroup() {
198198
}
199199
fSpecializationEntries.clear();
200200

201-
if(!ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.SHOW_SPECIALIZATIONS_IN_PALETTE)) {
201+
if(!ArchiPlugin.INSTANCE.getPreferenceStore().getBoolean(IPreferenceConstants.SHOW_SPECIALIZATIONS_IN_PALETTE)) {
202202
fDiagramModel.getArchimateModel().eAdapters().remove(eAdapter);
203203
return;
204204
}
@@ -304,7 +304,7 @@ private void createArchimateElementGroup(String title, EClass[] types) {
304304

305305
private boolean isAllowedConceptForViewpoint(EClass eClass) {
306306
// Preference to show all pallette elements regardless of Viewpoint
307-
if(!ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.VIEWPOINTS_HIDE_PALETTE_ELEMENTS)) {
307+
if(!ArchiPlugin.INSTANCE.getPreferenceStore().getBoolean(IPreferenceConstants.VIEWPOINTS_HIDE_PALETTE_ELEMENTS)) {
308308
return true;
309309
}
310310

0 commit comments

Comments
 (0)