KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > schema > SchemaEditorContributor


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.schema;
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.pde.internal.ui.PDEUIMessages;
17 import org.eclipse.pde.internal.ui.editor.PDEFormTextEditorContributor;
18 import org.eclipse.pde.internal.ui.util.SWTUtil;
19 import org.eclipse.swt.custom.BusyIndicator;
20 import org.eclipse.swt.dnd.Clipboard;
21
22 public class SchemaEditorContributor extends PDEFormTextEditorContributor {
23     private PreviewAction fPreviewAction;
24
25     class PreviewAction extends Action {
26         public PreviewAction() {
27         }
28         public void run() {
29             if (getEditor() != null) {
30                 final SchemaEditor schemaEditor = (SchemaEditor) getEditor();
31                 BusyIndicator
32                     .showWhile(SWTUtil.getStandardDisplay(), new Runnable JavaDoc() {
33                     public void run() {
34                         schemaEditor.previewReferenceDocument();
35                     }
36                 });
37             }
38         }
39     }
40
41     public SchemaEditorContributor() {
42         super("&Schema"); //$NON-NLS-1$
43
}
44
45     protected boolean hasKnownTypes(Clipboard clipboard) {
46         return true;
47     }
48
49     public void contextMenuAboutToShow(IMenuManager mm, boolean addClipboard) {
50         super.contextMenuAboutToShow(mm, addClipboard);
51         mm.add(new Separator());
52         mm.add(fPreviewAction);
53     }
54     
55     public Action getPreviewAction() {
56         return fPreviewAction;
57     }
58
59     protected void makeActions() {
60         super.makeActions();
61         fPreviewAction = new PreviewAction();
62         fPreviewAction.setText(PDEUIMessages.SchemaEditorContributor_previewAction);
63     }
64 }
65
Popular Tags