1 11 package org.eclipse.pde.internal.ui.editor.feature; 12 13 import org.eclipse.jface.action.IStatusLineManager; 14 import org.eclipse.pde.internal.core.ifeature.IFeature; 15 import org.eclipse.pde.internal.core.ifeature.IFeatureModel; 16 import org.eclipse.pde.internal.ui.IHelpContextIds; 17 import org.eclipse.pde.internal.ui.IPDEUIConstants; 18 import org.eclipse.pde.internal.ui.PDELabelProvider; 19 import org.eclipse.pde.internal.ui.PDEPlugin; 20 import org.eclipse.pde.internal.ui.PDEPluginImages; 21 import org.eclipse.pde.internal.ui.PDEUIMessages; 22 import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; 23 import org.eclipse.pde.internal.ui.editor.PDEFormEditor; 24 import org.eclipse.pde.internal.ui.editor.PDEFormPage; 25 import org.eclipse.pde.internal.ui.editor.build.BuildPage; 26 import org.eclipse.pde.internal.ui.util.SharedLabelProvider; 27 import org.eclipse.swt.SWTException; 28 import org.eclipse.swt.custom.BusyIndicator; 29 import org.eclipse.swt.layout.GridData; 30 import org.eclipse.swt.widgets.Composite; 31 import org.eclipse.ui.PlatformUI; 32 import org.eclipse.ui.forms.IManagedForm; 33 import org.eclipse.ui.forms.events.HyperlinkEvent; 34 import org.eclipse.ui.forms.events.IHyperlinkListener; 35 import org.eclipse.ui.forms.widgets.ExpandableComposite; 36 import org.eclipse.ui.forms.widgets.FormText; 37 import org.eclipse.ui.forms.widgets.FormToolkit; 38 import org.eclipse.ui.forms.widgets.ScrolledForm; 39 import org.eclipse.ui.forms.widgets.Section; 40 import org.eclipse.ui.forms.widgets.TableWrapData; 41 42 45 public class FeatureFormPage extends PDEFormPage implements IHyperlinkListener { 46 public static final String PAGE_ID = "feature"; 48 private FeatureSpecSection fSpecSection; 49 50 private PortabilitySection fPortabilitySection; 51 52 public FeatureFormPage(PDEFormEditor editor, String title) { 53 super(editor, PAGE_ID, title); 54 } 55 56 59 protected String getHelpResource() { 60 return IPDEUIConstants.PLUGIN_DOC_ROOT + "guide/tools/editors/feature_editor/overview.htm"; } 62 63 protected void createFormContent(IManagedForm managedForm) { 64 super.createFormContent(managedForm); 65 ScrolledForm form = managedForm.getForm(); 66 FormToolkit toolkit = managedForm.getToolkit(); 67 form.getBody().setLayout(FormLayoutFactory.createFormTableWrapLayout(true, 2)); 68 form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_FTR_XML_OBJ)); 70 71 TableWrapData twd; 72 73 Composite left = toolkit.createComposite(form.getBody()); 74 left.setLayout(FormLayoutFactory.createFormPaneTableWrapLayout(false, 1)); 75 76 twd = new TableWrapData(TableWrapData.FILL_GRAB); 77 left.setLayoutData(twd); 78 79 Composite right = toolkit.createComposite(form.getBody()); 80 right.setLayout(FormLayoutFactory.createFormPaneTableWrapLayout(false, 1)); 81 82 twd = new TableWrapData(TableWrapData.FILL_GRAB); 83 right.setLayoutData(twd); 84 85 fSpecSection = new FeatureSpecSection(this, left); 86 fPortabilitySection = new PortabilitySection(this, left); 87 twd = new TableWrapData(); 88 twd.grabHorizontal = true; 89 fPortabilitySection.getSection().setLayoutData(twd); 90 91 createContentSection(managedForm, right, toolkit); 92 createPackagingSection(managedForm, right, toolkit); 93 createPublishingSection(managedForm, right, toolkit); 94 95 managedForm.addPart(fSpecSection); 96 managedForm.addPart(fPortabilitySection); 97 98 PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(),IHelpContextIds.MANIFEST_FEATURE_OVERVIEW); 99 initialize(); 100 } 101 102 public void initialize() { 103 IFeatureModel model = (IFeatureModel) getModel(); 104 IFeature feature = model.getFeature(); 105 getManagedForm().getForm().setText( 106 model.getResourceString(feature.getLabel())); 107 } 108 109 private Section createContentSection(IManagedForm managedForm, 110 Composite parent, FormToolkit toolkit) { 111 Section section = createStaticSection(parent, toolkit); 112 FormText text; 113 section 114 .setText(PDEUIMessages.FeatureEditor_InfoPage_ContentSection_title); 115 text = createClient(section, PDEUIMessages.FeatureEditor_InfoPage_ContentSection_text, toolkit); 116 PDELabelProvider lp = PDEPlugin.getDefault().getLabelProvider(); 117 text.setImage("page", lp.get(PDEPluginImages.DESC_PAGE_OBJ, SharedLabelProvider.F_EDIT)); 119 return section; 120 } 121 122 private Section createPackagingSection(IManagedForm managedForm, 123 Composite parent, FormToolkit toolkit) { 124 Section section = createStaticSection(parent, toolkit); 125 section 126 .setText(PDEUIMessages.FeatureEditor_InfoPage_PackagingSection_title); 127 createClient(section, PDEUIMessages.FeatureEditor_InfoPage_PackagingSection_text, toolkit); 142 return section; 143 } 144 145 private Section createPublishingSection(IManagedForm managedForm, 146 Composite parent, FormToolkit toolkit) { 147 Section section = createStaticSection(parent, toolkit); 148 section 149 .setText(PDEUIMessages.FeatureEditor_InfoPage_PublishingSection_title); 150 createClient(section, PDEUIMessages.FeatureEditor_InfoPage_PublishingSection_text, toolkit); 165 return section; 166 } 167 168 private FormText createClient(Section section, String content, 169 FormToolkit toolkit) { 170 FormText text = toolkit.createFormText(section, true); 171 try { 172 text.setText(content, true, false); 173 } catch (SWTException e) { 174 text.setText(e.getMessage(), false, false); 175 } 176 section.setClient(text); 177 section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); 178 text.addHyperlinkListener(this); 179 return text; 180 } 181 182 private Section createStaticSection(Composite parent, FormToolkit toolkit) { 183 Section section = toolkit.createSection(parent, 184 ExpandableComposite.TITLE_BAR); 185 section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING; 186 section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); 187 GridData data = new GridData(GridData.FILL_HORIZONTAL); 188 section.setLayoutData(data); 189 return section; 191 } 192 193 198 public void linkActivated(HyperlinkEvent e) { 199 String href = (String ) e.getHref(); 200 if (href.equals("info")) getEditor().setActivePage(InfoFormPage.PAGE_ID); 203 if (href.equals("plugins")) getEditor().setActivePage(FeatureReferencePage.PAGE_ID); 205 else if (href.equals("features")) getEditor().setActivePage(FeatureIncludesPage.PAGE_ID); 207 else if (href.equals("dependencies")) getEditor().setActivePage(FeatureDependenciesPage.PAGE_ID); 209 else if (href.equals("installHandler")) getEditor().setActivePage(FeatureAdvancedPage.PAGE_ID); 211 else if (href.equals("build")) getEditor().setActivePage(BuildPage.PAGE_ID); 213 else if (href.equals("synchronize")) { getEditor().setActivePage(FeatureReferencePage.PAGE_ID); 215 final FeatureEditorContributor contributor = (FeatureEditorContributor) getPDEEditor() 216 .getContributor(); 217 BusyIndicator.showWhile(e.display, new Runnable () { 218 public void run() { 219 contributor.getSynchronizeAction().run(); 220 } 221 }); 222 } else if (href.equals("export")) { getEditor().doSave(null); 224 final FeatureEditorContributor contributor = (FeatureEditorContributor) getPDEEditor() 225 .getContributor(); 226 BusyIndicator.showWhile(e.display, new Runnable () { 227 public void run() { 228 contributor.getBuildAction().run(); 229 } 230 }); 231 } else if (href.equals("siteProject")) { getEditor().doSave(null); 233 final FeatureEditorContributor contributor = (FeatureEditorContributor) getPDEEditor() 234 .getContributor(); 235 BusyIndicator.showWhile(e.display, new Runnable () { 236 public void run() { 237 contributor.getNewSiteAction().run(); 238 } 239 }); 240 } 241 } 242 243 248 public void linkEntered(HyperlinkEvent e) { 249 IStatusLineManager mng = getEditor().getEditorSite().getActionBars() 250 .getStatusLineManager(); 251 mng.setMessage(e.getLabel()); 252 } 253 254 259 public void linkExited(HyperlinkEvent e) { 260 IStatusLineManager mng = getEditor().getEditorSite().getActionBars() 261 .getStatusLineManager(); 262 mng.setMessage(null); 263 } 264 } 265 | Popular Tags |