001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.site;
011:
012: import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition;
013: import org.eclipse.pde.internal.ui.IHelpContextIds;
014: import org.eclipse.pde.internal.ui.IPDEUIConstants;
015: import org.eclipse.pde.internal.ui.PDEPlugin;
016: import org.eclipse.pde.internal.ui.PDEPluginImages;
017: import org.eclipse.pde.internal.ui.PDEUIMessages;
018: import org.eclipse.pde.internal.ui.editor.PDEDetailsSections;
019: import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
020: import org.eclipse.pde.internal.ui.editor.PDEFormPage;
021: import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock;
022: import org.eclipse.pde.internal.ui.editor.PDESection;
023: import org.eclipse.swt.widgets.Composite;
024: import org.eclipse.ui.PlatformUI;
025: import org.eclipse.ui.forms.DetailsPart;
026: import org.eclipse.ui.forms.IDetailsPage;
027: import org.eclipse.ui.forms.IDetailsPageProvider;
028: import org.eclipse.ui.forms.IManagedForm;
029: import org.eclipse.ui.forms.widgets.ScrolledForm;
030:
031: /**
032: *
033: * Features page.
034: */
035: public class FeaturesPage extends PDEFormPage {
036: public static final String PAGE_ID = "features"; //$NON-NLS-1$
037: private CategorySection fCategorySection;
038: private SiteFeaturesBlock fBlock;
039:
040: public class SiteFeaturesBlock extends PDEMasterDetailsBlock {
041: public SiteFeaturesBlock() {
042: super (FeaturesPage.this );
043: }
044:
045: protected PDESection createMasterSection(
046: IManagedForm managedForm, Composite parent) {
047: fCategorySection = new CategorySection(getPage(), parent);
048: return fCategorySection;
049: }
050:
051: protected void registerPages(DetailsPart detailsPart) {
052: detailsPart.setPageProvider(new IDetailsPageProvider() {
053: public Object getPageKey(Object object) {
054: if (object instanceof SiteFeatureAdapter)
055: return SiteFeatureAdapter.class;
056: if (object instanceof ISiteCategoryDefinition)
057: return ISiteCategoryDefinition.class;
058: return object.getClass();
059: }
060:
061: public IDetailsPage getPage(Object key) {
062: if (key.equals(SiteFeatureAdapter.class))
063: return createFeatureDetails();
064: if (key.equals(ISiteCategoryDefinition.class))
065: return createCategoryDetails();
066: return null;
067: }
068: });
069: }
070: }
071:
072: public FeaturesPage(PDEFormEditor editor) {
073: super (editor, PAGE_ID, PDEUIMessages.FeaturesPage_title);
074: fBlock = new SiteFeaturesBlock();
075: }
076:
077: protected void createFormContent(IManagedForm managedForm) {
078: super .createFormContent(managedForm);
079: ScrolledForm form = managedForm.getForm();
080: form.setText(PDEUIMessages.FeaturesPage_header);
081: form.setImage(PDEPlugin.getDefault().getLabelProvider().get(
082: PDEPluginImages.DESC_SITE_XML_OBJ));
083: fBlock.createContent(managedForm);
084: fCategorySection.fireSelection();
085: PlatformUI.getWorkbench().getHelpSystem().setHelp(
086: form.getBody(), IHelpContextIds.MANIFEST_SITE_FEATURES);
087: }
088:
089: /**
090: * @return
091: */
092: private IDetailsPage createFeatureDetails() {
093: return new PDEDetailsSections() {
094: protected PDESection[] createSections(PDEFormPage page,
095: Composite parent) {
096: return new PDESection[] {
097: new FeatureDetailsSection(getPage(), parent),
098: new PortabilitySection(getPage(), parent) };
099: }
100:
101: public String getContextId() {
102: return SiteInputContext.CONTEXT_ID;
103: }
104: };
105: }
106:
107: private IDetailsPage createCategoryDetails() {
108: return new PDEDetailsSections() {
109: protected PDESection[] createSections(PDEFormPage page,
110: Composite parent) {
111: return new PDESection[] { new CategoryDetailsSection(
112: getPage(), parent) };
113: }
114:
115: public String getContextId() {
116: return SiteInputContext.CONTEXT_ID;
117: }
118: };
119: }
120:
121: protected String getHelpResource() {
122: return IPDEUIConstants.PLUGIN_DOC_ROOT
123: + "guide/tools/editors/site_editor/site_map.htm"; //$NON-NLS-1$
124: }
125: }
|