01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.schema;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.jface.action.IMenuManager;
14: import org.eclipse.jface.action.Separator;
15: import org.eclipse.pde.internal.ui.PDEUIMessages;
16: import org.eclipse.pde.internal.ui.editor.PDEFormTextEditorContributor;
17: import org.eclipse.pde.internal.ui.util.SWTUtil;
18: import org.eclipse.swt.custom.BusyIndicator;
19: import org.eclipse.swt.dnd.Clipboard;
20:
21: public class SchemaEditorContributor extends
22: PDEFormTextEditorContributor {
23: private PreviewAction fPreviewAction;
24:
25: class PreviewAction extends Action {
26: public PreviewAction() {
27: }
28:
29: public void run() {
30: if (getEditor() != null) {
31: final SchemaEditor schemaEditor = (SchemaEditor) getEditor();
32: BusyIndicator.showWhile(SWTUtil.getStandardDisplay(),
33: new Runnable() {
34: public void run() {
35: schemaEditor.previewReferenceDocument();
36: }
37: });
38: }
39: }
40: }
41:
42: public SchemaEditorContributor() {
43: super ("&Schema"); //$NON-NLS-1$
44: }
45:
46: protected boolean hasKnownTypes(Clipboard clipboard) {
47: return true;
48: }
49:
50: public void contextMenuAboutToShow(IMenuManager mm,
51: boolean addClipboard) {
52: super .contextMenuAboutToShow(mm, addClipboard);
53: mm.add(new Separator());
54: mm.add(fPreviewAction);
55: }
56:
57: public Action getPreviewAction() {
58: return fPreviewAction;
59: }
60:
61: protected void makeActions() {
62: super .makeActions();
63: fPreviewAction = new PreviewAction();
64: fPreviewAction
65: .setText(PDEUIMessages.SchemaEditorContributor_previewAction);
66: }
67: }
|