KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > plugin > DependenciesPage


1 /*******************************************************************************
2  * Copyright (c) 2003, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor.plugin;
12 import java.util.ArrayList JavaDoc;
13
14 import org.eclipse.pde.internal.ui.IHelpContextIds;
15 import org.eclipse.pde.internal.ui.IPDEUIConstants;
16 import org.eclipse.pde.internal.ui.PDEPlugin;
17 import org.eclipse.pde.internal.ui.PDEPluginImages;
18 import org.eclipse.pde.internal.ui.PDEUIMessages;
19 import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
20 import org.eclipse.pde.internal.ui.editor.PDEFormPage;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.layout.GridData;
23 import org.eclipse.swt.widgets.Composite;
24 import org.eclipse.ui.PlatformUI;
25 import org.eclipse.ui.forms.IManagedForm;
26 import org.eclipse.ui.forms.editor.FormEditor;
27 import org.eclipse.ui.forms.widgets.ExpandableComposite;
28 import org.eclipse.ui.forms.widgets.FormToolkit;
29 import org.eclipse.ui.forms.widgets.ScrolledForm;
30
31 public class DependenciesPage extends PDEFormPage {
32     
33     public static final String JavaDoc PAGE_ID = "dependencies"; //$NON-NLS-1$
34

35     public DependenciesPage(FormEditor editor) {
36         super(editor, PAGE_ID, PDEUIMessages.DependenciesPage_tabName);
37     }
38     
39     /* (non-Javadoc)
40      * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#getHelpResource()
41      */

42     protected String JavaDoc getHelpResource() {
43         return IPDEUIConstants.PLUGIN_DOC_ROOT + "guide/tools/editors/manifest_editor/dependencies.htm"; //$NON-NLS-1$
44
}
45     
46     protected void createFormContent(IManagedForm managedForm) {
47         super.createFormContent(managedForm);
48         boolean isBundle = isBundle();
49         ScrolledForm form = managedForm.getForm();
50         form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_REQ_PLUGINS_OBJ));
51         form.setText(PDEUIMessages.DependenciesPage_title);
52         Composite body = form.getBody();
53         body.setLayout(FormLayoutFactory.createFormGridLayout(isBundle, 2));
54         Composite left, right;
55         FormToolkit toolkit = managedForm.getToolkit();
56         left = toolkit.createComposite(body, SWT.NONE);
57         left.setLayout(FormLayoutFactory.createFormPaneGridLayout(false, 1));
58         left.setLayoutData(new GridData(GridData.FILL_BOTH));
59         right = toolkit.createComposite(body, SWT.NONE);
60         right.setLayout(FormLayoutFactory.createFormPaneGridLayout(false, 1));
61         right.setLayoutData(new GridData(GridData.FILL_BOTH));
62         
63         managedForm.addPart(new RequiresSection(this, left, getRequiredSectionLabels()));
64         
65         DependencyAnalysisSection section;
66         GridData gd = new GridData(GridData.FILL_HORIZONTAL|GridData.VERTICAL_ALIGN_BEGINNING);
67         gd.widthHint = 150;
68         if (isBundle) {
69             managedForm.addPart(new ImportPackageSection(this, right));
70             if (getModel().isEditable())
71                 managedForm.addPart(new DependencyManagementSection(this, left));
72             else
73                 gd.horizontalSpan = 2;
74             section = new DependencyAnalysisSection(this, right, ExpandableComposite.COMPACT);
75         } else {
76             // No MANIFEST.MF (not a Bundle)
77
// Create a new plug-in project targeted for 3.0 using the hello
78
// world template to see this section (no MANIFEST.MF is created)
79
managedForm.addPart(new MatchSection(this, right, true));
80             section = new DependencyAnalysisSection(this, right, ExpandableComposite.EXPANDED);
81         }
82         section.getSection().setLayoutData(gd);
83         PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.MANIFEST_PLUGIN_DEPENDENCIES);
84     }
85     
86     private boolean isBundle() {
87         return getPDEEditor().getContextManager().findContext(BundleInputContext.CONTEXT_ID) != null;
88     }
89     
90     private String JavaDoc[] getRequiredSectionLabels() {
91         ArrayList JavaDoc labels = new ArrayList JavaDoc();
92         labels.add(PDEUIMessages.RequiresSection_add);
93         labels.add(PDEUIMessages.RequiresSection_delete);
94         labels.add(PDEUIMessages.RequiresSection_up);
95         labels.add(PDEUIMessages.RequiresSection_down);
96         if (isBundle())
97             labels.add(PDEUIMessages.DependenciesPage_properties);
98         return (String JavaDoc[])labels.toArray(new String JavaDoc[labels.size()]);
99     }
100
101 }
102
Popular Tags