001: /*******************************************************************************
002: * Copyright (c) 2003, 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.plugin;
011:
012: import java.util.ArrayList;
013:
014: import org.eclipse.pde.internal.ui.IHelpContextIds;
015: import org.eclipse.pde.internal.ui.IPDEUIConstants;
016: import org.eclipse.pde.internal.ui.PDEPlugin;
017: import org.eclipse.pde.internal.ui.PDEPluginImages;
018: import org.eclipse.pde.internal.ui.PDEUIMessages;
019: import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
020: import org.eclipse.pde.internal.ui.editor.PDEFormPage;
021: import org.eclipse.swt.SWT;
022: import org.eclipse.swt.layout.GridData;
023: import org.eclipse.swt.widgets.Composite;
024: import org.eclipse.ui.PlatformUI;
025: import org.eclipse.ui.forms.IManagedForm;
026: import org.eclipse.ui.forms.editor.FormEditor;
027: import org.eclipse.ui.forms.widgets.ExpandableComposite;
028: import org.eclipse.ui.forms.widgets.FormToolkit;
029: import org.eclipse.ui.forms.widgets.ScrolledForm;
030:
031: public class DependenciesPage extends PDEFormPage {
032:
033: public static final String PAGE_ID = "dependencies"; //$NON-NLS-1$
034:
035: public DependenciesPage(FormEditor editor) {
036: super (editor, PAGE_ID, PDEUIMessages.DependenciesPage_tabName);
037: }
038:
039: /* (non-Javadoc)
040: * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#getHelpResource()
041: */
042: protected String getHelpResource() {
043: return IPDEUIConstants.PLUGIN_DOC_ROOT
044: + "guide/tools/editors/manifest_editor/dependencies.htm"; //$NON-NLS-1$
045: }
046:
047: protected void createFormContent(IManagedForm managedForm) {
048: super .createFormContent(managedForm);
049: boolean isBundle = isBundle();
050: ScrolledForm form = managedForm.getForm();
051: form.setImage(PDEPlugin.getDefault().getLabelProvider().get(
052: PDEPluginImages.DESC_REQ_PLUGINS_OBJ));
053: form.setText(PDEUIMessages.DependenciesPage_title);
054: Composite body = form.getBody();
055: body.setLayout(FormLayoutFactory.createFormGridLayout(isBundle,
056: 2));
057: Composite left, right;
058: FormToolkit toolkit = managedForm.getToolkit();
059: left = toolkit.createComposite(body, SWT.NONE);
060: left.setLayout(FormLayoutFactory.createFormPaneGridLayout(
061: false, 1));
062: left.setLayoutData(new GridData(GridData.FILL_BOTH));
063: right = toolkit.createComposite(body, SWT.NONE);
064: right.setLayout(FormLayoutFactory.createFormPaneGridLayout(
065: false, 1));
066: right.setLayoutData(new GridData(GridData.FILL_BOTH));
067:
068: managedForm.addPart(new RequiresSection(this , left,
069: getRequiredSectionLabels()));
070:
071: DependencyAnalysisSection section;
072: GridData gd = new GridData(GridData.FILL_HORIZONTAL
073: | GridData.VERTICAL_ALIGN_BEGINNING);
074: gd.widthHint = 150;
075: if (isBundle) {
076: managedForm.addPart(new ImportPackageSection(this , right));
077: if (getModel().isEditable())
078: managedForm.addPart(new DependencyManagementSection(
079: this , left));
080: else
081: gd.horizontalSpan = 2;
082: section = new DependencyAnalysisSection(this , right,
083: ExpandableComposite.COMPACT);
084: } else {
085: // No MANIFEST.MF (not a Bundle)
086: // Create a new plug-in project targeted for 3.0 using the hello
087: // world template to see this section (no MANIFEST.MF is created)
088: managedForm.addPart(new MatchSection(this , right, true));
089: section = new DependencyAnalysisSection(this , right,
090: ExpandableComposite.EXPANDED);
091: }
092: section.getSection().setLayoutData(gd);
093: PlatformUI.getWorkbench().getHelpSystem().setHelp(
094: form.getBody(),
095: IHelpContextIds.MANIFEST_PLUGIN_DEPENDENCIES);
096: }
097:
098: private boolean isBundle() {
099: return getPDEEditor().getContextManager().findContext(
100: BundleInputContext.CONTEXT_ID) != null;
101: }
102:
103: private String[] getRequiredSectionLabels() {
104: ArrayList labels = new ArrayList();
105: labels.add(PDEUIMessages.RequiresSection_add);
106: labels.add(PDEUIMessages.RequiresSection_delete);
107: labels.add(PDEUIMessages.RequiresSection_up);
108: labels.add(PDEUIMessages.RequiresSection_down);
109: if (isBundle())
110: labels.add(PDEUIMessages.DependenciesPage_properties);
111: return (String[]) labels.toArray(new String[labels.size()]);
112: }
113:
114: }
|