1 11 package org.eclipse.jdt.internal.debug.ui.snippeteditor; 12 13 import org.eclipse.jface.action.Action; 14 15 18 public abstract class SnippetAction extends Action implements ISnippetStateChangedListener { 19 20 private JavaSnippetEditor fEditor; 21 22 public SnippetAction(JavaSnippetEditor editor) { 23 setEditor(editor); 24 } 25 26 public void setEditor(JavaSnippetEditor editor) { 27 if (fEditor != null) { 28 fEditor.removeSnippetStateChangedListener(this); 29 } 30 fEditor= editor; 31 32 if (fEditor != null) { 33 if (fEditor.getFile() == null) { setEnabled(false); 35 return; 36 } 37 fEditor.addSnippetStateChangedListener(this); 38 } 39 snippetStateChanged(fEditor); 40 } 41 42 protected JavaSnippetEditor getEditor() { 43 return fEditor; 44 } 45 } 46 | Popular Tags |