Author: yzhishko
Date: 2010-01-31 11:54:30 -0500 (Sun, 31 Jan 2010)
New Revision: 20036
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ProjectNaturesChecker.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5701 - ProjectNaturesCheaker as a singleton.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2010-01-30
15:09:06 UTC (rev 20035)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2010-01-31
16:54:30 UTC (rev 20036)
@@ -12,14 +12,12 @@
import java.io.IOException;
import java.net.URL;
-
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.IStartup;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
import org.jboss.tools.common.reporting.ProblemReportingHelper;
-import org.jboss.tools.vpe.editor.util.ProjectNaturesChecker;
import org.jboss.tools.vpe.xulrunner.browser.XulRunnerBrowser;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -35,7 +33,6 @@
//The shared instance.
private static VpePlugin plugin;
- private ProjectNaturesChecker projectNaturesChecker;
/**
* The constructor.
@@ -56,10 +53,6 @@
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
- if (projectNaturesChecker != null) {
- projectNaturesChecker.dispose();
- projectNaturesChecker = null;
- }
super.stop(context);
}
@@ -122,11 +115,4 @@
return (url == null) ? null : url.getPath();
}
- public ProjectNaturesChecker getProjectNaturesChecker() {
- return projectNaturesChecker;
- }
-
- public void setProjectNaturesChecker(ProjectNaturesChecker naturesChecker) {
- this.projectNaturesChecker = naturesChecker;
- }
}
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2010-01-30
15:09:06 UTC (rev 20035)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2010-01-31
16:54:30 UTC (rev 20036)
@@ -913,6 +913,10 @@
@Override
public void dispose() {
deactivateServices();
+ if (naturesChecker != null) {
+ naturesChecker.dispose();
+ naturesChecker = null;
+ }
sourceActivation = null;
sourceMaxmin = null;
visualActivation = null;
@@ -1013,11 +1017,7 @@
try {
IEditorInput editorInput = multiPageEditor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
- naturesChecker = VpePlugin.getDefault().getProjectNaturesChecker();
- if (naturesChecker == null) {
- naturesChecker = new ProjectNaturesChecker();
- VpePlugin.getDefault().setProjectNaturesChecker(naturesChecker);
- }
+ naturesChecker = ProjectNaturesChecker.getInstance();
naturesChecker.checkNatures(((IFileEditorInput)editorInput).getFile().getProject());
}
} catch (CoreException e) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ProjectNaturesChecker.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ProjectNaturesChecker.java 2010-01-30
15:09:06 UTC (rev 20035)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ProjectNaturesChecker.java 2010-01-31
16:54:30 UTC (rev 20036)
@@ -46,7 +46,16 @@
private static final String JSF_NATURE = "JavaServer Faces Nature";
//$NON-NLS-1$
private static final String KB_NATURE = "Knowledge Base Nature";
//$NON-NLS-1$
- public ProjectNaturesChecker() {
+ private static ProjectNaturesChecker checker;
+
+ public static ProjectNaturesChecker getInstance(){
+ if (checker == null) {
+ checker = new ProjectNaturesChecker();
+ }
+ return checker;
+ }
+
+ private ProjectNaturesChecker() {
projectsCollection = new HashSet<IProject>(0);
ResourcesPlugin.getWorkspace().addResourceChangeListener(this,
IResourceChangeEvent.POST_CHANGE);