Skip to content

Commit 9499ef5

Browse files
committed
Reduce static access methods in AbstractActivatorUI
Giving static access to supposedly DI managed objects is a recipe for problems. As these are unused anyway, this should be safe and allow to better understand how to further reduce this antipattern.
1 parent 5ec95d6 commit 9499ef5

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

chemclipse/plugins/org.eclipse.chemclipse.rcp.app.ui/src/org/eclipse/chemclipse/rcp/app/ui/handlers/PerspectiveSwitchHandler.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
1212
*******************************************************************************/
@@ -15,7 +15,6 @@
1515
import java.util.ArrayList;
1616
import java.util.List;
1717

18-
import org.eclipse.chemclipse.rcp.app.ui.Activator;
1918
import org.eclipse.chemclipse.rcp.app.ui.dialogs.PerspectiveChooserDialog;
2019
import org.eclipse.chemclipse.rcp.app.ui.dialogs.PerspectiveSwitcherDialog;
2120
import org.eclipse.chemclipse.rcp.app.ui.preferences.PreferenceSupplier;
@@ -97,12 +96,6 @@ public static void focusPerspectiveAndView(String perspectiveId, List<String> vi
9796
}
9897
}
9998

100-
public static boolean isActivePerspective(String perspectiveId) {
101-
102-
String activePerspective = Activator.getDefault().getActivePerspective();
103-
return activePerspective.equals(perspectiveId);
104-
}
105-
10699
/*
107100
* Show a dialog if requested. The boolean values: P_SHOW_PERSPECTIVE_DIALOG
108101
* P_CHANGE_PERSPECTIVE_AUTOMATICALLY can be edited by the user.

chemclipse/plugins/org.eclipse.chemclipse.support.ui/src/org/eclipse/chemclipse/support/ui/activator/AbstractActivatorUI.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
1212
*******************************************************************************/
@@ -71,7 +71,7 @@ public IPreferenceStore getPreferenceStore() {
7171
* Returns the image given by the key.
7272
* Please initialize the image registry before using this function.
7373
* Use the method e.g.:
74-
*
74+
*
7575
* getImage(ICON_WARN)
7676
*/
7777
public Image getImage(String key) {
@@ -99,11 +99,6 @@ public EPartService getPartService() {
9999
return getEclipseContext().get(EPartService.class);
100100
}
101101

102-
public PartSupport getPartSupport() {
103-
104-
return getEclipseContext().get(PartSupport.class);
105-
}
106-
107102
public PerspectiveSupport getPerspectiveSupport() {
108103

109104
return getEclipseContext().get(PerspectiveSupport.class);
@@ -168,16 +163,6 @@ public IEclipseContext getEclipseContext() {
168163
return eclipseContext;
169164
}
170165

171-
public boolean saveDirtyParts() {
172-
173-
return getPartSupport().saveDirtyParts();
174-
}
175-
176-
public String getActivePerspective() {
177-
178-
return getPerspectiveSupport().getActivePerspective();
179-
}
180-
181166
/**
182167
* Initialize the preference store.
183168
*/
@@ -198,14 +183,14 @@ protected void initializePreferenceStore(IPreferenceSupplier preferenceSupplier)
198183
/**
199184
* Initialize the image registry.
200185
* Please supply a HashMap of used images/icons, e.g.:
201-
*
186+
*
202187
* <pre><code>
203188
* public static final String ICON_WARN = "ICON_WARN";
204-
*
189+
*
205190
* Map&lt;String, String&gt; imageHashMap = new HashMap&lt;&gt;();
206191
* imageHashMap.put(ICON_WARN, "icons/16x16/warn.gif");
207192
* </code></pre>
208-
*
193+
*
209194
* The icon path is set relative to the calling plugin.
210195
*/
211196
protected void initializeImageRegistry(Map<String, String> imageHashMap) {

0 commit comments

Comments
 (0)