KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005, 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
13 import org.eclipse.jface.dialogs.StatusDialog;
14 import org.eclipse.pde.core.plugin.IPluginImport;
15 import org.eclipse.pde.internal.core.text.bundle.ExportPackageObject;
16 import org.eclipse.pde.internal.core.text.bundle.ImportPackageObject;
17 import org.eclipse.pde.internal.ui.PDEPlugin;
18 import org.eclipse.pde.internal.ui.PDEUIMessages;
19 import org.eclipse.pde.internal.ui.parts.PluginVersionPart;
20 import org.eclipse.swt.SWT;
21 import org.eclipse.swt.events.ModifyEvent;
22 import org.eclipse.swt.events.ModifyListener;
23 import org.eclipse.swt.layout.GridData;
24 import org.eclipse.swt.layout.GridLayout;
25 import org.eclipse.swt.widgets.Button;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.swt.widgets.Control;
28 import org.eclipse.swt.widgets.Group;
29
30 public class DependencyPropertiesDialog extends StatusDialog {
31
32     private Button fReexportButton;
33     private Button fOptionalButton;
34     private boolean fEditable;
35     private boolean fShowReexport;
36     
37     private boolean fExported;
38     private boolean fOptional;
39
40     private PluginVersionPart fVersionPart;
41     
42     private boolean fShowOptional;
43     private String JavaDoc fVersion;
44
45     public DependencyPropertiesDialog(boolean editable, IPluginImport plugin) {
46         this (editable, true, plugin.isReexported(), plugin.isOptional(), plugin.getVersion(), true, true);
47     }
48     
49     public DependencyPropertiesDialog(boolean editable, ImportPackageObject object) {
50         this (editable, false, false, object.isOptional(), object.getVersion(), true, true);
51     }
52
53     public DependencyPropertiesDialog(boolean editable, ExportPackageObject object) {
54         this (editable, false, false, false, object.getVersion(), false, false);
55     }
56
57     public DependencyPropertiesDialog(boolean editable, boolean showReexport, boolean export, boolean optional, String JavaDoc version, boolean showOptional, boolean isImport) {
58         super(PDEPlugin.getActiveWorkbenchShell());
59         fEditable = editable;
60         fShowReexport = showReexport;
61         fExported = export;
62         fOptional = optional;
63         fShowOptional = showOptional;
64         if (isImport)
65             fVersionPart = new PluginVersionPart(true);
66         else
67             fVersionPart = new PluginVersionPart(false) {
68                 protected String JavaDoc getGroupText() {
69                     return PDEUIMessages.DependencyPropertiesDialog_exportGroupText;
70                 }
71             };
72         fVersionPart.setVersion(version);
73     }
74
75
76     protected void createButtonsForButtonBar(Composite parent) {
77         super.createButtonsForButtonBar(parent);
78     }
79     
80     protected Control createDialogArea(Composite parent) {
81         Composite comp = (Composite)super.createDialogArea(parent);
82         
83         if (fShowOptional || fShowReexport) {
84             Group container = new Group(comp, SWT.NONE);
85             container.setText(PDEUIMessages.DependencyPropertiesDialog_properties);
86             container.setLayout(new GridLayout());
87             container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
88         
89             if (fShowOptional) {
90                 fOptionalButton = new Button(container, SWT.CHECK);
91                 fOptionalButton.setText(PDEUIMessages.DependencyPropertiesDialog_optional);
92                 GridData gd = new GridData();
93                 gd.horizontalSpan = 2;
94                 fOptionalButton.setLayoutData(gd);
95                 fOptionalButton.setEnabled(fEditable);
96                 fOptionalButton.setSelection(fOptional);
97             }
98             
99             if (fShowReexport) {
100                 fReexportButton = new Button(container, SWT.CHECK);
101                 fReexportButton.setText(PDEUIMessages.DependencyPropertiesDialog_reexport);
102                 GridData gd = new GridData();
103                 gd.horizontalSpan = 2;
104                 fReexportButton.setLayoutData(gd);
105                 fReexportButton.setEnabled(fEditable);
106                 fReexportButton.setSelection(fExported);
107             }
108         }
109         
110         fVersionPart.createVersionFields(comp, true, fEditable);
111         ModifyListener ml = new ModifyListener() {
112             public void modifyText(ModifyEvent e) {
113                 updateStatus(fVersionPart.validateFullVersionRangeText(true));
114             }
115         };
116         fVersionPart.addListeners(ml, ml);
117         
118         return comp;
119     }
120     
121
122     public boolean isReexported() {
123         return fExported;
124     }
125     
126     public boolean isOptional() {
127         return fOptional;
128     }
129     
130     public String JavaDoc getVersion() {
131         return fVersion;
132     }
133     
134     protected void okPressed() {
135         fOptional = (fOptionalButton == null) ? false : fOptionalButton.getSelection();
136         fExported = (fReexportButton == null) ? false : fReexportButton.getSelection();
137         
138         fVersion = fVersionPart.getVersion();
139         
140         super.okPressed();
141     }
142 }
143
Popular Tags