1
19 package com.qasystems.qstudio.java.gui.dialog;
20
21 import com.qasystems.international.MessageResource;
22 import com.qasystems.qstudio.java.QStudioGlobal;
23 import com.qasystems.qstudio.java.browser.BrowserHelpContext;
24 import com.qasystems.qstudio.java.gui.CheckPropertiesControl;
25 import com.qasystems.qstudio.java.gui.GeneralPropertiesControl;
26 import com.qasystems.qstudio.java.gui.Project;
27 import com.qasystems.qstudio.java.gui.ProjectPropertiesPane;
28 import com.qasystems.qstudio.java.gui.RegExpr;
29 import com.qasystems.qstudio.java.gui.RuleSet;
30
31 import java.awt.Dimension;
32 import java.io.File;
33 import java.util.Vector;
34
35 import javax.swing.JTabbedPane;
36 import javax.swing.event.ChangeEvent;
37 import javax.swing.event.ChangeListener;
38
39
42 public class ProjectPropertiesDialog extends HelpButtonDialog {
43 private static final MessageResource RESOURCES =
44 MessageResource.getClientInstance();
45
46
47 public final static int OK = 0;
48
49
50 public final static int CANCEL = 1;
51 private final static String TITLE = RESOURCES.getString("WINDOWTITLE_029");
52 private final static String[] BUTTONS =
53 { RESOURCES.getString("BUTTON_005"), RESOURCES.getString("BUTTON_001") };
54 private ProjectPropertiesPane propertiesPane = null;
55 private BrowserHelpContext helpContext = new BrowserHelpContext();
56
57
60 public ProjectPropertiesDialog() {
61 super(new QStudioGlobal().getFrame());
62 jbInit();
63 pack();
64 }
65
66
69 public void pack() {
70 super.pack();
71 setSize(getMyPrefferedSize());
72 }
73
74
77 protected void cancelDialog() {
78 getChecksTabControl().cleanup();
79 super.cancelDialog();
80 }
81
82
86 protected void onActionPerformed(int action) {
87 if (action == OK) {
88 checkRegularExpressions(action);
89 } else {
90 getChecksTabControl().cleanup();
91 super.onActionPerformed(action);
92 }
93 }
94
95 private void checkRegularExpressions(int action) {
96 final RegExpr regExpr = new RegExpr(this);
97
98 if (
99 propertiesPane.getProductIdentification().equals(
100 Project.LOCAL_PRODUCT_ID
101 )
102 ) {
103 regExpr.setExtendedErrorMessage(true);
104 }
105
106 regExpr.checkRegularExpressions(propertiesPane.getRules());
107
108 if (regExpr.isCancel()) {
109 setResultValue(CANCEL);
110 onActionPerformed(CANCEL);
111 } else if (regExpr.isOK()) {
112 getChecksTabControl().cleanup();
113 super.onActionPerformed(action);
114 } else {
115 }
117 }
118
119
124 public void upload(Project project) {
125 propertiesPane.upload(project);
126 }
127
128
133 public void download(Project project) {
134 propertiesPane.download(project);
135 }
136
137
142 public synchronized void setRules(RuleSet rules) {
143 propertiesPane.setRules(rules);
144 }
145
146
151 public RuleSet getRules() {
152 return (propertiesPane.getRules());
153 }
154
155
160 public synchronized void setStandards(Object newRuleSets) {
161 propertiesPane.setStandards(newRuleSets);
162 }
163
164
169 public void setSourcePath(Vector paths) {
170 propertiesPane.setSourcePath(paths);
171 }
172
173
178 public Vector getSourcePath() {
179 return (propertiesPane.getSourcePath());
180 }
181
182
187 public void setClassPath(Vector paths) {
188 propertiesPane.setClassPath(paths);
189 }
190
191
196 public Vector getClassPath() {
197 return (propertiesPane.getClassPath());
198 }
199
200
205 public void setOutputPath(File newPath) {
206 propertiesPane.setOutputPath(newPath);
207 }
208
209
214 public File getOutputPath() {
215 return (propertiesPane.getOutputPath());
216 }
217
218
223 public void setProjectName(String name) {
224 propertiesPane.getGeneralTabControl().setName(name);
225 }
226
227
232 public String getProjectName() {
233 return (propertiesPane.getGeneralTabControl().getName());
234 }
235
236
241 public void setJavaVersion(String version) {
242 propertiesPane.getGeneralTabControl().setJavaVersion(version);
243 }
244
245
250 public String getJavaVersion() {
251 return (propertiesPane.getGeneralTabControl().getJavaVersion());
252 }
253
254
261 public void setTabVisible(String tab, boolean visible) {
262 propertiesPane.setTabVisible(tab, visible);
263 }
264
265
270 public GeneralPropertiesControl getGeneralTabControl() {
271 return (propertiesPane.getGeneralTabControl());
272 }
273
274
279 public CheckPropertiesControl getChecksTabControl() {
280 return (propertiesPane.getChecksTabControl());
281 }
282
283
288 public void displayTab(String tab) {
289 propertiesPane.displayTab(tab);
290 }
291
292 private synchronized void jbInit() {
293 setModal(true);
294 setResizable(true);
295 setTitle(TITLE);
296 setButtons(BUTTONS);
297 setInitialButton(OK);
298 initPropertiesPane();
299 setContent(propertiesPane);
300 }
301
302
306 private void initPropertiesPane() {
307 propertiesPane = new ProjectPropertiesPane(this);
308 helpContext.setContext(BrowserHelpContext.HELP_TOUR_5);
309 setHelpContext(helpContext);
310 propertiesPane.addChangeListener(
311 new ChangeListener() {
312 public void stateChanged(ChangeEvent e) {
313 final JTabbedPane pane = (JTabbedPane) e.getSource();
314 final String title = pane.getTitleAt(pane.getSelectedIndex());
315
316 if (ProjectPropertiesPane.GENERAL_TAB.equals(title)) {
317 helpContext.setContext(BrowserHelpContext.HELP_TOUR_5);
318 setHelpContext(helpContext);
319 } else if (ProjectPropertiesPane.PATHS_TAB.equals(title)) {
320 helpContext.setContext(BrowserHelpContext.HELP_TOUR_3);
321 setHelpContext(helpContext);
322 } else if (ProjectPropertiesPane.CHECKS_TAB.equals(title)) {
323 helpContext.setContext(BrowserHelpContext.HELP_TOUR_7);
324 setHelpContext(helpContext);
325 } else {
326 helpContext.setContext(BrowserHelpContext.HELP);
327 setHelpContext(helpContext);
328 }
329 }
330 }
331 );
332 }
333
334 private Dimension getMyPrefferedSize() {
335 return (new Dimension(750, 600));
336 }
337 }
338