001: /*******************************************************************************
002: * Copyright (c) 2005, 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 org.eclipse.jface.dialogs.StatusDialog;
013: import org.eclipse.pde.core.plugin.IPluginImport;
014: import org.eclipse.pde.internal.core.text.bundle.ExportPackageObject;
015: import org.eclipse.pde.internal.core.text.bundle.ImportPackageObject;
016: import org.eclipse.pde.internal.ui.PDEPlugin;
017: import org.eclipse.pde.internal.ui.PDEUIMessages;
018: import org.eclipse.pde.internal.ui.parts.PluginVersionPart;
019: import org.eclipse.swt.SWT;
020: import org.eclipse.swt.events.ModifyEvent;
021: import org.eclipse.swt.events.ModifyListener;
022: import org.eclipse.swt.layout.GridData;
023: import org.eclipse.swt.layout.GridLayout;
024: import org.eclipse.swt.widgets.Button;
025: import org.eclipse.swt.widgets.Composite;
026: import org.eclipse.swt.widgets.Control;
027: import org.eclipse.swt.widgets.Group;
028:
029: public class DependencyPropertiesDialog extends StatusDialog {
030:
031: private Button fReexportButton;
032: private Button fOptionalButton;
033: private boolean fEditable;
034: private boolean fShowReexport;
035:
036: private boolean fExported;
037: private boolean fOptional;
038:
039: private PluginVersionPart fVersionPart;
040:
041: private boolean fShowOptional;
042: private String fVersion;
043:
044: public DependencyPropertiesDialog(boolean editable,
045: IPluginImport plugin) {
046: this (editable, true, plugin.isReexported(),
047: plugin.isOptional(), plugin.getVersion(), true, true);
048: }
049:
050: public DependencyPropertiesDialog(boolean editable,
051: ImportPackageObject object) {
052: this (editable, false, false, object.isOptional(), object
053: .getVersion(), true, true);
054: }
055:
056: public DependencyPropertiesDialog(boolean editable,
057: ExportPackageObject object) {
058: this (editable, false, false, false, object.getVersion(), false,
059: false);
060: }
061:
062: public DependencyPropertiesDialog(boolean editable,
063: boolean showReexport, boolean export, boolean optional,
064: String version, boolean showOptional, boolean isImport) {
065: super (PDEPlugin.getActiveWorkbenchShell());
066: fEditable = editable;
067: fShowReexport = showReexport;
068: fExported = export;
069: fOptional = optional;
070: fShowOptional = showOptional;
071: if (isImport)
072: fVersionPart = new PluginVersionPart(true);
073: else
074: fVersionPart = new PluginVersionPart(false) {
075: protected String getGroupText() {
076: return PDEUIMessages.DependencyPropertiesDialog_exportGroupText;
077: }
078: };
079: fVersionPart.setVersion(version);
080: }
081:
082: protected void createButtonsForButtonBar(Composite parent) {
083: super .createButtonsForButtonBar(parent);
084: }
085:
086: protected Control createDialogArea(Composite parent) {
087: Composite comp = (Composite) super .createDialogArea(parent);
088:
089: if (fShowOptional || fShowReexport) {
090: Group container = new Group(comp, SWT.NONE);
091: container
092: .setText(PDEUIMessages.DependencyPropertiesDialog_properties);
093: container.setLayout(new GridLayout());
094: container.setLayoutData(new GridData(
095: GridData.FILL_HORIZONTAL));
096:
097: if (fShowOptional) {
098: fOptionalButton = new Button(container, SWT.CHECK);
099: fOptionalButton
100: .setText(PDEUIMessages.DependencyPropertiesDialog_optional);
101: GridData gd = new GridData();
102: gd.horizontalSpan = 2;
103: fOptionalButton.setLayoutData(gd);
104: fOptionalButton.setEnabled(fEditable);
105: fOptionalButton.setSelection(fOptional);
106: }
107:
108: if (fShowReexport) {
109: fReexportButton = new Button(container, SWT.CHECK);
110: fReexportButton
111: .setText(PDEUIMessages.DependencyPropertiesDialog_reexport);
112: GridData gd = new GridData();
113: gd.horizontalSpan = 2;
114: fReexportButton.setLayoutData(gd);
115: fReexportButton.setEnabled(fEditable);
116: fReexportButton.setSelection(fExported);
117: }
118: }
119:
120: fVersionPart.createVersionFields(comp, true, fEditable);
121: ModifyListener ml = new ModifyListener() {
122: public void modifyText(ModifyEvent e) {
123: updateStatus(fVersionPart
124: .validateFullVersionRangeText(true));
125: }
126: };
127: fVersionPart.addListeners(ml, ml);
128:
129: return comp;
130: }
131:
132: public boolean isReexported() {
133: return fExported;
134: }
135:
136: public boolean isOptional() {
137: return fOptional;
138: }
139:
140: public String getVersion() {
141: return fVersion;
142: }
143:
144: protected void okPressed() {
145: fOptional = (fOptionalButton == null) ? false : fOptionalButton
146: .getSelection();
147: fExported = (fReexportButton == null) ? false : fReexportButton
148: .getSelection();
149:
150: fVersion = fVersionPart.getVersion();
151:
152: super.okPressed();
153: }
154: }
|