01: /*******************************************************************************
02: * Copyright (c) 2005, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.product;
11:
12: import org.eclipse.pde.internal.ui.IHelpContextIds;
13: import org.eclipse.pde.internal.ui.IPDEUIConstants;
14: import org.eclipse.pde.internal.ui.PDEPlugin;
15: import org.eclipse.pde.internal.ui.PDEPluginImages;
16: import org.eclipse.pde.internal.ui.PDEUIMessages;
17: import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
18: import org.eclipse.pde.internal.ui.editor.PDEFormPage;
19: import org.eclipse.swt.widgets.Composite;
20: import org.eclipse.ui.PlatformUI;
21: import org.eclipse.ui.forms.IManagedForm;
22: import org.eclipse.ui.forms.editor.FormEditor;
23: import org.eclipse.ui.forms.widgets.FormToolkit;
24: import org.eclipse.ui.forms.widgets.ScrolledForm;
25:
26: public class ConfigurationPage extends PDEFormPage {
27:
28: public static final String PLUGIN_ID = "plugin-configuration"; //$NON-NLS-1$
29: public static final String FEATURE_ID = "feature-configuration"; //$NON-NLS-1$
30:
31: private boolean fUseFeatures;
32: private PluginSection fPluginSection = null;
33:
34: public ConfigurationPage(FormEditor editor, boolean useFeatures) {
35: super (editor, useFeatures ? FEATURE_ID : PLUGIN_ID,
36: PDEUIMessages.Product_ConfigurationPage_title);
37: fUseFeatures = useFeatures;
38: }
39:
40: /* (non-Javadoc)
41: * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#getHelpResource()
42: */
43: protected String getHelpResource() {
44: return IPDEUIConstants.PLUGIN_DOC_ROOT
45: + "guide/tools/editors/product_editor/configuration.htm"; //$NON-NLS-1$
46: }
47:
48: /* (non-Javadoc)
49: * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
50: */
51: protected void createFormContent(IManagedForm managedForm) {
52: super .createFormContent(managedForm);
53: ScrolledForm form = managedForm.getForm();
54: FormToolkit toolkit = managedForm.getToolkit();
55: form.setImage(PDEPlugin.getDefault().getLabelProvider().get(
56: PDEPluginImages.DESC_FEATURE_OBJ));
57: form.setText(PDEUIMessages.Product_ConfigurationPage_title);
58: fillBody(managedForm, toolkit);
59: PlatformUI.getWorkbench().getHelpSystem().setHelp(
60: form.getBody(), IHelpContextIds.CONFIGURATION_PAGE);
61: }
62:
63: private void fillBody(IManagedForm managedForm, FormToolkit toolkit) {
64: Composite body = managedForm.getForm().getBody();
65: body
66: .setLayout(FormLayoutFactory.createFormGridLayout(
67: false, 1));
68:
69: // sections
70: if (fUseFeatures)
71: managedForm.addPart(new FeatureSection(this , body));
72: else
73: managedForm.addPart(fPluginSection = new PluginSection(
74: this , body));
75: managedForm.addPart(new ConfigurationSection(this , body));
76: }
77:
78: public boolean includeOptionalDependencies() {
79: return (fPluginSection != null) ? fPluginSection
80: .includeOptionalDependencies() : false;
81: }
82: }
|