1 11 package org.eclipse.pde.internal.ui.editor.site; 12 import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition; 13 import org.eclipse.pde.internal.ui.IHelpContextIds; 14 import org.eclipse.pde.internal.ui.IPDEUIConstants; 15 import org.eclipse.pde.internal.ui.PDEPlugin; 16 import org.eclipse.pde.internal.ui.PDEPluginImages; 17 import org.eclipse.pde.internal.ui.PDEUIMessages; 18 import org.eclipse.pde.internal.ui.editor.PDEDetailsSections; 19 import org.eclipse.pde.internal.ui.editor.PDEFormEditor; 20 import org.eclipse.pde.internal.ui.editor.PDEFormPage; 21 import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock; 22 import org.eclipse.pde.internal.ui.editor.PDESection; 23 import org.eclipse.swt.widgets.Composite; 24 import org.eclipse.ui.PlatformUI; 25 import org.eclipse.ui.forms.DetailsPart; 26 import org.eclipse.ui.forms.IDetailsPage; 27 import org.eclipse.ui.forms.IDetailsPageProvider; 28 import org.eclipse.ui.forms.IManagedForm; 29 import org.eclipse.ui.forms.widgets.ScrolledForm; 30 34 public class FeaturesPage extends PDEFormPage { 35 public static final String PAGE_ID = "features"; private CategorySection fCategorySection; 37 private SiteFeaturesBlock fBlock; 38 public class SiteFeaturesBlock extends PDEMasterDetailsBlock { 39 public SiteFeaturesBlock() { 40 super(FeaturesPage.this); 41 } 42 protected PDESection createMasterSection(IManagedForm managedForm, 43 Composite parent) { 44 fCategorySection = new CategorySection(getPage(), parent); 45 return fCategorySection; 46 } 47 protected void registerPages(DetailsPart detailsPart) { 48 detailsPart.setPageProvider(new IDetailsPageProvider() { 49 public Object getPageKey(Object object) { 50 if (object instanceof SiteFeatureAdapter) 51 return SiteFeatureAdapter.class; 52 if (object instanceof ISiteCategoryDefinition) 53 return ISiteCategoryDefinition.class; 54 return object.getClass(); 55 } 56 public IDetailsPage getPage(Object key) { 57 if (key.equals(SiteFeatureAdapter.class)) 58 return createFeatureDetails(); 59 if (key.equals(ISiteCategoryDefinition.class)) 60 return createCategoryDetails(); 61 return null; 62 } 63 }); 64 } 65 } 66 67 public FeaturesPage(PDEFormEditor editor) { 68 super(editor, PAGE_ID, PDEUIMessages.FeaturesPage_title); 69 fBlock = new SiteFeaturesBlock(); 70 } 71 protected void createFormContent(IManagedForm managedForm) { 72 super.createFormContent(managedForm); 73 ScrolledForm form = managedForm.getForm(); 74 form.setText(PDEUIMessages.FeaturesPage_header); 75 form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_SITE_XML_OBJ)); 76 fBlock.createContent(managedForm); 77 fCategorySection.fireSelection(); 78 PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.MANIFEST_SITE_FEATURES); 79 } 80 83 private IDetailsPage createFeatureDetails() { 84 return new PDEDetailsSections() { 85 protected PDESection[] createSections( 86 PDEFormPage page, Composite parent) { 87 return new PDESection[] { 88 new FeatureDetailsSection(getPage(), 89 parent), 90 new PortabilitySection(getPage(), 91 parent) }; 92 } 93 94 public String getContextId() { 95 return SiteInputContext.CONTEXT_ID; 96 } 97 }; 98 } 99 100 private IDetailsPage createCategoryDetails() { 101 return new PDEDetailsSections() { 102 protected PDESection[] createSections( 103 PDEFormPage page, Composite parent) { 104 return new PDESection[] { new CategoryDetailsSection( 105 getPage(), parent) }; 106 } 107 108 public String getContextId() { 109 return SiteInputContext.CONTEXT_ID; 110 } 111 }; 112 } 113 114 protected String getHelpResource() { 115 return IPDEUIConstants.PLUGIN_DOC_ROOT + "guide/tools/editors/site_editor/site_map.htm"; } 117 } 118 | Popular Tags |