KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > snippeteditor > SelectImportsAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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")); //$NON-NLS-1$
24
setToolTipText(SnippetMessages.getString("SelectImports.tooltip")); //$NON-NLS-1$
25
setDescription(SnippetMessages.getString("SelectImports.description")); //$NON-NLS-1$
26
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     /**
32      * @see IAction#run()
33      */

34     public void run() {
35         if (!getEditor().isInJavaProject()) {
36             getEditor().reportNotInJavaProjectError();
37             return;
38         }
39         chooseImports();
40     }
41     
42     private void chooseImports() {
43         String JavaDoc[] imports= getEditor().getImports();
44         Dialog dialog= new SelectImportsDialog(getEditor(), imports);
45         dialog.open();
46     }
47     
48     /**
49      * @see ISnippetStateChangedListener#snippetStateChanged(JavaSnippetEditor)
50      */

51     public void snippetStateChanged(JavaSnippetEditor editor) {
52         setEnabled(editor != null && !editor.isEvaluating());
53     }
54 }
55
Popular Tags