KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > plugin > ManifestEditorContributor


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 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.pde.internal.ui.editor.plugin;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.action.IMenuManager;
15 import org.eclipse.jface.action.Separator;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.jface.viewers.StructuredSelection;
18 import org.eclipse.pde.core.IBaseModel;
19 import org.eclipse.pde.internal.ui.PDEUIMessages;
20 import org.eclipse.pde.internal.ui.editor.PDEFormTextEditorContributor;
21 import org.eclipse.pde.internal.ui.nls.GetNonExternalizedStringsAction;
22 import org.eclipse.pde.internal.ui.util.SWTUtil;
23 import org.eclipse.swt.custom.BusyIndicator;
24
25 public class ManifestEditorContributor extends PDEFormTextEditorContributor {
26     
27     private ExternalizeAction fExternalizeAction;
28
29     class ExternalizeAction extends Action {
30         public ExternalizeAction() {
31         }
32         public void run() {
33             if (getEditor() != null) {
34                 BusyIndicator.showWhile(SWTUtil.getStandardDisplay(), new Runnable JavaDoc() {
35                     public void run() {
36                         GetNonExternalizedStringsAction fGetExternAction = new GetNonExternalizedStringsAction();
37                         IStructuredSelection selection = new StructuredSelection(getEditor().getCommonProject());
38                         fGetExternAction.selectionChanged(ExternalizeAction.this, selection);
39                         fGetExternAction.run(ExternalizeAction.this);
40                     }
41                 });
42             }
43         }
44     }
45     
46     public ManifestEditorContributor() {
47         super("&Plugin"); //$NON-NLS-1$
48
}
49
50     public void contextMenuAboutToShow(IMenuManager mm, boolean addClipboard) {
51         super.contextMenuAboutToShow(mm, addClipboard);
52         IBaseModel model = getEditor().getAggregateModel();
53         if (model != null && model.isEditable()) {
54             mm.add(new Separator());
55             mm.add(fExternalizeAction);
56         }
57     }
58
59     protected void makeActions() {
60         super.makeActions();
61         fExternalizeAction = new ExternalizeAction();
62         fExternalizeAction.setText(PDEUIMessages.ManifestEditorContributor_externStringsActionName);
63     }
64     
65     public boolean supportsContentAssist() {
66         return true;
67     }
68     
69     public boolean supportsFormatAction() {
70         return true;
71     }
72     
73     public boolean supportsCorrectionAssist() {
74         return true;
75     }
76     
77     public boolean supportsHyperlinking() {
78         return true;
79     }
80 }
81
Popular Tags