KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > site > FeaturePropertiesDialog


1 /*******************************************************************************
2  * Copyright (c) 2003, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor.site;
12
13 import org.eclipse.core.runtime.*;
14 import org.eclipse.pde.internal.core.isite.*;
15 import org.eclipse.pde.internal.ui.*;
16 import org.eclipse.swt.*;
17 import org.eclipse.swt.events.*;
18 import org.eclipse.swt.layout.*;
19 import org.eclipse.swt.widgets.*;
20
21 /**
22  * @author melhem
23  *
24  */

25 public class FeaturePropertiesDialog extends BaseNewDialog {
26     
27     private Text fURLText;
28     private Text fIdText;
29     private Text fVersionText;
30     private Text fLabelText;
31     private Text fTypeText;
32     private Text fOSText;
33     private Text fWSText;
34     private Text fNLText;
35     private Text fArchText;
36     private Button fIsPatch;
37     
38     /**
39      * @param shell
40      * @param siteModel
41      * @param siteObject
42      */

43     public FeaturePropertiesDialog(Shell shell, ISiteModel siteModel,
44             ISiteFeature siteObject) {
45         super(shell, siteModel, siteObject);
46     }
47     /* (non-Javadoc)
48      * @see org.eclipse.pde.internal.ui.editor.site.BaseNewDialog#getDialogTitle()
49      */

50     protected String JavaDoc getDialogTitle() {
51         return PDEPlugin.getResourceString("FeaturePropertiesDialog.title"); //$NON-NLS-1$
52
}
53     /* (non-Javadoc)
54      * @see org.eclipse.pde.internal.ui.editor.site.BaseNewDialog#getHelpId()
55      */

56     protected String JavaDoc getHelpId() {
57         return null;
58     }
59     /* (non-Javadoc)
60      * @see org.eclipse.pde.internal.ui.editor.site.BaseNewDialog#createEntries(org.eclipse.swt.widgets.Composite)
61      */

62     protected void createEntries(Composite container) {
63         ISiteFeature feature = (ISiteFeature)getSiteObject();
64         
65         Label label = new Label(container, SWT.NONE);
66         label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.url")); //$NON-NLS-1$
67
fURLText = new Text(container, SWT.SINGLE | SWT.BORDER);
68         GridData gd = new GridData(GridData.FILL_HORIZONTAL);
69         gd.widthHint = 250;
70         fURLText.setLayoutData(gd);
71         setIfDefined(fURLText, feature.getURL());
72         
73         label = new Label(container, SWT.NONE);
74         label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.id")); //$NON-NLS-1$
75
fIdText = new Text(container, SWT.SINGLE | SWT.BORDER);
76         fIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
77         fIdText.setEnabled(false);
78         setIfDefined(fIdText, feature.getId());
79         
80         label = new Label(container, SWT.NONE);
81         label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.version")); //$NON-NLS-1$
82
fVersionText = new Text(container, SWT.SINGLE | SWT.BORDER);
83         fVersionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
84         fVersionText.setEnabled(false);
85         setIfDefined(fVersionText, feature.getVersion());
86         
87         label = new Label(container, SWT.NONE);
88         label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.label")); //$NON-NLS-1$
89
fLabelText = new Text(container, SWT.SINGLE | SWT.BORDER);
90         fLabelText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
91         setIfDefined(fLabelText, feature.getLabel());
92         
93         label = new Label(container, SWT.NONE);
94         label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.type")); //$NON-NLS-1$
95
fTypeText = new Text(container, SWT.SINGLE | SWT.BORDER);
96         fTypeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
97         setIfDefined(fTypeText, feature.getType());
98         
99         label = new Label(container, SWT.NONE);
100         label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.os")); //$NON-NLS-1$
101
fOSText = new Text(container, SWT.SINGLE | SWT.BORDER);
102         fOSText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
103         setIfDefined(fOSText, feature.getOS());
104         
105         label = new Label(container, SWT.NONE);
106         label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.ws")); //$NON-NLS-1$
107
fWSText = new Text(container, SWT.SINGLE | SWT.BORDER);
108         fWSText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
109         setIfDefined(fWSText, feature.getWS());
110         
111         label = new Label(container, SWT.NONE);
112         label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.nl")); //$NON-NLS-1$
113
fNLText = new Text(container, SWT.SINGLE | SWT.BORDER);
114         fNLText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
115         setIfDefined(fNLText, feature.getNL());
116         
117         label = new Label(container, SWT.NONE);
118         label.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.arch")); //$NON-NLS-1$
119
fArchText = new Text(container, SWT.SINGLE | SWT.BORDER);
120         fArchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
121         setIfDefined(fArchText, feature.getArch());
122         
123         fIsPatch = new Button(container, SWT.CHECK);
124         fIsPatch.setText(PDEPlugin.getResourceString("FeaturePropertiesDialog.patch")); //$NON-NLS-1$
125
gd = new GridData();
126         gd.horizontalSpan = 2;
127         fIsPatch.setLayoutData(gd);
128         fIsPatch.setSelection(feature.isPatch());
129         
130     }
131     /* (non-Javadoc)
132      * @see org.eclipse.pde.internal.ui.editor.site.BaseNewDialog#hookListeners(org.eclipse.swt.events.ModifyListener)
133      */

134     protected void hookListeners(ModifyListener listener) {
135         fURLText.addModifyListener(listener);
136     }
137     /* (non-Javadoc)
138      * @see org.eclipse.pde.internal.ui.editor.site.BaseNewDialog#dialogChanged()
139      */

140     protected void dialogChanged() {
141         IStatus status = (fURLText.getText().trim().length() == 0) ? createErrorStatus(getEmptyErrorMessage()) : getOKStatus();
142         updateStatus(status);
143     }
144     /* (non-Javadoc)
145      * @see org.eclipse.pde.internal.ui.editor.site.BaseNewDialog#getEmptyErrorMessage()
146      */

147     protected String JavaDoc getEmptyErrorMessage() {
148         return PDEPlugin.getResourceString("FeaturePropertiesDialog.requiredURL"); //$NON-NLS-1$
149
}
150     /* (non-Javadoc)
151      * @see org.eclipse.pde.internal.ui.editor.site.BaseNewDialog#execute()
152      */

153     protected void execute() {
154         try {
155             ISiteFeature feature = (ISiteFeature)getSiteObject();
156             feature.setIsPatch(fIsPatch.getSelection());
157             feature.setURL(fURLText.getText().trim());
158             
159             String JavaDoc text = fLabelText.getText().trim();
160             feature.setLabel(text.length() == 0 ? null : text);
161             
162             text = fTypeText.getText().trim();
163             feature.setType(text.length() == 0 ? null : text);
164             
165             text = fOSText.getText().trim();
166             feature.setOS(text.length() == 0 ? null : text);
167             
168             text = fWSText.getText().trim();
169             feature.setWS(text.length() == 0 ? null : text);
170             
171             text = fNLText.getText().trim();
172             feature.setNL(text.length() == 0 ? null : text);
173             
174             text = fArchText.getText().trim();
175             feature.setArch(text.length() == 0 ? null : text);
176         } catch (CoreException e) {
177         }
178     }
179 }
180
Popular Tags