Author: scabanovich
Date: 2008-09-11 05:20:50 -0400 (Thu, 11 Sep 2008)
New Revision: 10194
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java
Log:
JBIDE-2727
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java 2008-09-11
07:36:58 UTC (rev 10193)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java 2008-09-11
09:20:50 UTC (rev 10194)
@@ -56,6 +56,10 @@
*/
public void setEditor(ITextEditor editor) {
super.setEditor(editor);
+ if(editor == null) {
+ dispose();
+ return;
+ }
fOccurrencePreferenceProvider = null;
StructuredTextEditor sse = getStructuredTextEditor(getTextEditor());
if (sse != null && sse instanceof IOccurrencePreferenceProvider) {
@@ -126,6 +130,7 @@
fPreferenceStore.setValue(fKey, !markOccurences);
}
+ static int listenerCount = 0;
/**
* Enables and initialzies the action, or disables.
* @see org.eclipse.ui.texteditor.TextEditorAction#update()
@@ -137,11 +142,13 @@
|| fOccurrencePreferenceProvider.getOccurrencePreferenceProvider() == null)
? null :
fOccurrencePreferenceProvider.getOccurrencePreferenceProvider().getPreferenceStore());
if (newStore != fPreferenceStore) {
- if (fPreferenceStore != null)
+ if (fPreferenceStore != null) {
fPreferenceStore.removePropertyChangeListener(this);
+ }
fPreferenceStore = newStore;
- if (fPreferenceStore != null)
+ if (fPreferenceStore != null) {
fPreferenceStore.addPropertyChangeListener(this);
+ }
}
boolean markOccurences = false;
@@ -163,11 +170,6 @@
update();
}
- protected void finalize() throws Throwable {
- if (fPreferenceStore != null) fPreferenceStore.removePropertyChangeListener(this);
- }
-
-
private static URL makeIconFileURL(String prefix, String name) throws
MalformedURLException {
URL base = null;
try {
@@ -182,4 +184,12 @@
return new URL(base, buffer.toString());
}
+ public void dispose() {
+ if (fPreferenceStore != null) {
+ fPreferenceStore.removePropertyChangeListener(this);
+ fPreferenceStore = null;
+ }
+ fOccurrencePreferenceProvider = null;
+ }
+
}
Show replies by date