1 11 package org.eclipse.pde.internal.ui.editor.plugin; 12 import org.eclipse.jface.text.source.ISourceViewer; 13 import org.eclipse.jface.viewers.StructuredSelection; 14 import org.eclipse.pde.core.plugin.IPluginExtensionPoint; 15 import org.eclipse.pde.internal.core.text.IDocumentAttribute; 16 import org.eclipse.pde.internal.core.text.IDocumentRange; 17 import org.eclipse.pde.internal.ui.IHelpContextIds; 18 import org.eclipse.pde.internal.ui.IPDEUIConstants; 19 import org.eclipse.pde.internal.ui.PDEPlugin; 20 import org.eclipse.pde.internal.ui.PDEPluginImages; 21 import org.eclipse.pde.internal.ui.PDEUIMessages; 22 import org.eclipse.pde.internal.ui.editor.PDEFormPage; 23 import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock; 24 import org.eclipse.pde.internal.ui.editor.PDESection; 25 import org.eclipse.swt.custom.StyledText; 26 import org.eclipse.swt.widgets.Composite; 27 import org.eclipse.ui.PlatformUI; 28 import org.eclipse.ui.forms.DetailsPart; 29 import org.eclipse.ui.forms.IDetailsPage; 30 import org.eclipse.ui.forms.IDetailsPageProvider; 31 import org.eclipse.ui.forms.IManagedForm; 32 import org.eclipse.ui.forms.editor.FormEditor; 33 import org.eclipse.ui.forms.editor.IFormPage; 34 import org.eclipse.ui.forms.widgets.ScrolledForm; 35 36 public class ExtensionPointsPage extends PDEFormPage { 37 38 public static final String PAGE_ID = "ex-points"; 40 private ExtensionPointsSection fExtensionPointsSection; 41 private ExtensionPointsBlock fBlock; 42 43 public class ExtensionPointsBlock extends PDEMasterDetailsBlock { 44 45 public ExtensionPointsBlock() { 46 super(ExtensionPointsPage.this); 47 } 48 49 protected PDESection createMasterSection(IManagedForm managedForm, 50 Composite parent) { 51 fExtensionPointsSection = new ExtensionPointsSection(getPage(), parent); 52 return fExtensionPointsSection; 53 } 54 55 protected void registerPages(DetailsPart detailsPart) { 56 detailsPart.setPageProvider(new IDetailsPageProvider() { 57 public Object getPageKey(Object object) { 58 if (object instanceof IPluginExtensionPoint) 59 return IPluginExtensionPoint.class; 60 return object.getClass(); 61 } 62 public IDetailsPage getPage(Object key) { 63 if (key.equals(IPluginExtensionPoint.class)) 64 return new ExtensionPointDetails(); 65 return null; 66 } 67 }); 68 } 69 } 70 71 public ExtensionPointsPage(FormEditor editor) { 72 super(editor, PAGE_ID, PDEUIMessages.ExtensionPointsPage_tabName); 73 fBlock = new ExtensionPointsBlock(); 74 } 75 76 79 protected String getHelpResource() { 80 return IPDEUIConstants.PLUGIN_DOC_ROOT + "guide/tools/editors/manifest_editor/extension_points.htm"; } 82 83 protected void createFormContent(IManagedForm managedForm) { 84 super.createFormContent(managedForm); 85 ScrolledForm form = managedForm.getForm(); 86 form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_EXT_POINTS_OBJ)); 87 form.setText(PDEUIMessages.ExtensionPointsPage_title); 88 fBlock.createContent(managedForm); 89 fExtensionPointsSection.fireSelection(); 90 PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.MANIFEST_PLUGIN_EXT_POINTS); 91 } 92 93 public void updateFormSelection() { 94 super.updateFormSelection(); 95 IFormPage page = getPDEEditor().findPage(PluginInputContext.CONTEXT_ID); 96 if (page instanceof ManifestSourcePage) { 97 ISourceViewer viewer = ((ManifestSourcePage)page).getViewer(); 98 if (viewer == null) 99 return; 100 StyledText text = viewer.getTextWidget(); 101 if (text == null) 102 return; 103 int offset = text.getCaretOffset(); 104 if (offset < 0) 105 return; 106 107 IDocumentRange range = ((ManifestSourcePage)page).getRangeElement(offset, true); 108 if (range instanceof IDocumentAttribute) 109 range = ((IDocumentAttribute)range).getEnclosingElement(); 110 if (range instanceof IPluginExtensionPoint) 111 fExtensionPointsSection.selectExtensionPoint(new StructuredSelection(range)); 112 } 113 } 114 } 115 | Popular Tags |