1 11 package org.eclipse.pde.internal.ui.editor.plugin; 12 import java.util.ArrayList ; 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 PAGE_ID = "dependencies"; 35 public DependenciesPage(FormEditor editor) { 36 super(editor, PAGE_ID, PDEUIMessages.DependenciesPage_tabName); 37 } 38 39 42 protected String getHelpResource() { 43 return IPDEUIConstants.PLUGIN_DOC_ROOT + "guide/tools/editors/manifest_editor/dependencies.htm"; } 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 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 [] getRequiredSectionLabels() { 91 ArrayList labels = new ArrayList (); 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 [])labels.toArray(new String [labels.size()]); 99 } 100 101 } 102 | Popular Tags |