1 11 package org.eclipse.jdt.internal.debug.ui.snippeteditor; 12 13 import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds; 14 import org.eclipse.jdt.ui.ISharedImages; 15 import org.eclipse.jdt.ui.JavaUI; 16 import org.eclipse.jface.dialogs.Dialog; 17 import org.eclipse.ui.PlatformUI; 18 19 public class SelectImportsAction extends SnippetAction { 20 21 public SelectImportsAction(JavaSnippetEditor editor) { 22 super(editor); 23 setText(SnippetMessages.getString("SelectImports.label")); setToolTipText(SnippetMessages.getString("SelectImports.tooltip")); setDescription(SnippetMessages.getString("SelectImports.description")); ISharedImages sharedImages= JavaUI.getSharedImages(); 27 setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_OBJS_IMPCONT)); 28 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaDebugHelpContextIds.SCRAPBOOK_IMPORTS_ACTION); 29 } 30 31 34 public void run() { 35 if (!getEditor().isInJavaProject()) { 36 getEditor().reportNotInJavaProjectError(); 37 return; 38 } 39 chooseImports(); 40 } 41 42 private void chooseImports() { 43 String [] imports= getEditor().getImports(); 44 Dialog dialog= new SelectImportsDialog(getEditor(), imports); 45 dialog.open(); 46 } 47 48 51 public void snippetStateChanged(JavaSnippetEditor editor) { 52 setEnabled(editor != null && !editor.isEvaluating()); 53 } 54 } 55 | Popular Tags |