1 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 () { 33 public void run() { 34 schemaEditor.previewReferenceDocument(); 35 } 36 }); 37 } 38 } 39 } 40 41 public SchemaEditorContributor() { 42 super("&Schema"); } 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 |