]>
Commit | Line | Data |
---|---|---|
06a19cee | 1 | /** @file\r |
2 | \r | |
3f62225f | 3 | The file is used to create, update Protocol of section of the MSA file\r |
06a19cee | 4 | \r |
5 | Copyright (c) 2006, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | package org.tianocore.frameworkwizard.module.ui.dialog;\r | |
17 | \r | |
18 | import java.awt.event.ActionEvent;\r | |
19 | import java.awt.event.ItemEvent;\r | |
20 | import java.awt.event.ItemListener;\r | |
21 | import java.util.Vector;\r | |
22 | \r | |
23 | import javax.swing.JButton;\r | |
24 | import javax.swing.JComboBox;\r | |
25 | import javax.swing.JLabel;\r | |
26 | import javax.swing.JPanel;\r | |
27 | import javax.swing.JScrollPane;\r | |
28 | import javax.swing.JTextField;\r | |
7ab6baa9 | 29 | import javax.swing.JTextArea;\r |
06a19cee | 30 | \r |
31 | import org.tianocore.frameworkwizard.common.DataType;\r | |
32 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
33 | import org.tianocore.frameworkwizard.common.EnumerationData;\r | |
34 | import org.tianocore.frameworkwizard.common.Log;\r | |
35 | import org.tianocore.frameworkwizard.common.Tools;\r | |
36 | import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;\r | |
37 | import org.tianocore.frameworkwizard.common.ui.IDialog;\r | |
38 | import org.tianocore.frameworkwizard.common.ui.IFrame;\r | |
39 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
c25ad66c | 40 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r |
06a19cee | 41 | import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsIdentification;\r |
c25ad66c | 42 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r |
06a19cee | 43 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r |
44 | \r | |
45 | /**\r | |
ccb063b1 | 46 | * The class is used to create, update Protocol of MSA file\r |
47 | * \r | |
48 | * It extends IDialog\r | |
7ab6baa9 | 49 | * \r |
50 | */\r | |
51 | public class ProtocolsDlg extends IDialog implements ItemListener {\r | |
06a19cee | 52 | \r |
a929458e | 53 | // /\r |
54 | // / Define class Serial Version UID\r | |
55 | // /\r | |
56 | private static final long serialVersionUID = -9084913640747858848L;\r | |
06a19cee | 57 | \r |
a929458e | 58 | //\r |
59 | // Define class members\r | |
60 | //\r | |
61 | private JPanel jContentPane = null;\r | |
06a19cee | 62 | \r |
a929458e | 63 | private JLabel jLabelC_Name = null;\r |
06a19cee | 64 | \r |
a929458e | 65 | private JLabel jLabelFeatureFlag = null;\r |
06a19cee | 66 | \r |
a929458e | 67 | private JTextField jTextFieldFeatureFlag = null;\r |
06a19cee | 68 | \r |
a929458e | 69 | private JLabel jLabelUsage = null;\r |
06a19cee | 70 | \r |
a929458e | 71 | private JComboBox jComboBoxUsage = null;\r |
06a19cee | 72 | \r |
a929458e | 73 | private StarLabel jStarLabel1 = null;\r |
06a19cee | 74 | \r |
a929458e | 75 | private StarLabel jStarLabel2 = null;\r |
06a19cee | 76 | \r |
a929458e | 77 | private StarLabel jStarLabel3 = null;\r |
06a19cee | 78 | \r |
a929458e | 79 | private JLabel jLabelProtocolType = null;\r |
06a19cee | 80 | \r |
a929458e | 81 | private JLabel jLabelArch = null;\r |
06a19cee | 82 | \r |
a929458e | 83 | private JScrollPane jScrollPane = null;\r |
06a19cee | 84 | \r |
a929458e | 85 | private JComboBox jComboBoxProtocolType = null;\r |
06a19cee | 86 | \r |
a929458e | 87 | private JComboBox jComboBoxCName = null;\r |
06a19cee | 88 | \r |
a929458e | 89 | private JLabel jLabelHelpText = null;\r |
06a19cee | 90 | \r |
a929458e | 91 | private JTextArea jTextAreaHelpText = null;\r |
06a19cee | 92 | \r |
a929458e | 93 | private JScrollPane jScrollPaneHelpText = null;\r |
06a19cee | 94 | \r |
a929458e | 95 | private ArchCheckBox jArchCheckBox = null;\r |
06a19cee | 96 | \r |
a929458e | 97 | private JButton jButtonOk = null;\r |
06a19cee | 98 | \r |
a929458e | 99 | private JButton jButtonCancel = null;\r |
06a19cee | 100 | \r |
a929458e | 101 | //\r |
102 | // Not used by UI\r | |
103 | //\r | |
104 | private ProtocolsIdentification id = null;\r | |
105 | \r | |
106 | private WorkspaceTools wt = new WorkspaceTools();\r | |
107 | \r | |
108 | private EnumerationData ed = new EnumerationData();\r | |
109 | \r | |
110 | /**\r | |
111 | * This method initializes jTextFieldFeatureFlag\r | |
112 | * \r | |
113 | * @return javax.swing.JTextField jTextFieldFeatureFlag\r | |
114 | * \r | |
115 | */\r | |
116 | private JTextField getJTextFieldFeatureFlag() {\r | |
117 | if (jTextFieldFeatureFlag == null) {\r | |
118 | jTextFieldFeatureFlag = new JTextField();\r | |
21b42c66 | 119 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(168, 157, 320, 20));\r |
a929458e | 120 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r |
121 | jTextFieldFeatureFlag.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");\r | |
21b42c66 | 122 | jTextFieldFeatureFlag.setEnabled(false);\r |
a929458e | 123 | }\r |
124 | return jTextFieldFeatureFlag;\r | |
125 | }\r | |
06a19cee | 126 | \r |
a929458e | 127 | /**\r |
128 | * This method initializes jComboBoxUsage\r | |
129 | * \r | |
130 | * @return javax.swing.JComboBox jComboBoxUsage\r | |
131 | * \r | |
132 | */\r | |
133 | private JComboBox getJComboBoxProtocolUsage() {\r | |
134 | if (jComboBoxUsage == null) {\r | |
135 | jComboBoxUsage = new JComboBox();\r | |
3f62225f | 136 | jComboBoxUsage.setBounds(new java.awt.Rectangle(168, 62, 320, 20));\r |
a929458e | 137 | jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));\r |
138 | jComboBoxUsage\r | |
139 | .setToolTipText("<html><table><tr><td colspan=2 align=center><b>Protocol</b></td></tr>"\r | |
140 | + "<tr><td>ALWAYS_CONSUMED</td><td>Module always consumes the protocol</td></tr>"\r | |
141 | + "<tr><td>SOMETIMES_CONSUMES</td><td>Module sometimes consumes the protocol</td></tr>"\r | |
142 | + "<tr><td>ALWAYS_PRODUCED</td><td>Module always produces the protocol</td></tr>"\r | |
143 | + "<tr><td>SOMETIMES_PRODUCED</td><td>Module sometimes produces the protocol</td></tr>"\r | |
144 | + "<tr><td>TO_START</td><td>The protocol is consumed by a Driver Binding protocol <b>Start</b><br>function. The protocol is used in EFI 1.10 driver model</td></tr>"\r | |
145 | + "<tr><td>BY_START</td><td>Protocol is produced by a Driver Binding protocol <b>Start</b><br>function. The protocol is used in EFI 1.10 driver model</td></tr>"\r | |
146 | + "<tr><td colspan=2 align=center><b>Protocol Notify</b></td></tr>"\r | |
147 | + "<tr><td>SOMETIMES_CONSUMED</td><td>Module will consume the protocol if it is produced.<br>Consumption is defined by executing the protocol notify<br>function.</td></tr></table></html>");\r | |
148 | }\r | |
149 | return jComboBoxUsage;\r | |
150 | }\r | |
06a19cee | 151 | \r |
a929458e | 152 | /**\r |
153 | * This method initializes jScrollPane\r | |
154 | * \r | |
155 | * @return javax.swing.JScrollPane\r | |
156 | */\r | |
157 | private JScrollPane getJScrollPane() {\r | |
158 | if (jScrollPane == null) {\r | |
159 | jScrollPane = new JScrollPane();\r | |
160 | jScrollPane.setViewportView(getJContentPane());\r | |
161 | }\r | |
162 | return jScrollPane;\r | |
163 | }\r | |
06a19cee | 164 | \r |
a929458e | 165 | /**\r |
166 | * This method initializes jComboBoxProtocolType\r | |
167 | * \r | |
168 | * @return javax.swing.JComboBox\r | |
169 | */\r | |
170 | private JComboBox getJComboBoxProtocolType() {\r | |
171 | if (jComboBoxProtocolType == null) {\r | |
172 | jComboBoxProtocolType = new JComboBox();\r | |
3f62225f | 173 | jComboBoxProtocolType.setBounds(new java.awt.Rectangle(168, 12, 320, 20));\r |
a929458e | 174 | jComboBoxProtocolType.setPreferredSize(new java.awt.Dimension(320, 20));\r |
175 | jComboBoxProtocolType.addItemListener(this);\r | |
176 | jComboBoxProtocolType\r | |
177 | .setToolTipText("<html>Select Protocol Type<br>Protocol Notify is a register protocol notify mechanism.");\r | |
178 | }\r | |
179 | return jComboBoxProtocolType;\r | |
06a19cee | 180 | }\r |
a929458e | 181 | \r |
182 | /**\r | |
183 | * This method initializes jComboBoxCName\r | |
184 | * \r | |
185 | * @return javax.swing.JComboBox\r | |
186 | */\r | |
187 | private JComboBox getJComboBoxCName() {\r | |
188 | if (jComboBoxCName == null) {\r | |
189 | jComboBoxCName = new JComboBox();\r | |
3f62225f | 190 | jComboBoxCName.setBounds(new java.awt.Rectangle(168, 37, 320, 20));\r |
a929458e | 191 | jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));\r |
192 | jComboBoxCName.setToolTipText("Select Guid C Name of the Protocol");\r | |
193 | \r | |
194 | }\r | |
195 | return jComboBoxCName;\r | |
06a19cee | 196 | }\r |
a929458e | 197 | \r |
198 | /**\r | |
199 | * This method initializes jTextAreaHelpText\r | |
200 | * \r | |
201 | * @return javax.swing.JTextArea\r | |
202 | * \r | |
203 | */\r | |
204 | private JTextArea getJTextAreaHelpText() {\r | |
205 | if (jTextAreaHelpText == null) {\r | |
206 | jTextAreaHelpText = new JTextArea();\r | |
207 | jTextAreaHelpText.setLineWrap(true);\r | |
208 | jTextAreaHelpText.setWrapStyleWord(true);\r | |
209 | }\r | |
210 | return jTextAreaHelpText;\r | |
06a19cee | 211 | }\r |
a929458e | 212 | \r |
213 | /**\r | |
214 | * This method initializes jScrollPaneHelpText\r | |
215 | * \r | |
216 | * @return javax.swing.JScrollPane\r | |
217 | * \r | |
218 | */\r | |
219 | private JScrollPane getJScrollPaneHelpText() {\r | |
220 | if (jScrollPaneHelpText == null) {\r | |
221 | jScrollPaneHelpText = new JScrollPane();\r | |
222 | jScrollPaneHelpText.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r | |
223 | jScrollPaneHelpText.setSize(new java.awt.Dimension(320, 40));\r | |
224 | jScrollPaneHelpText.setPreferredSize(new java.awt.Dimension(320, 40));\r | |
3f62225f | 225 | jScrollPaneHelpText.setLocation(new java.awt.Point(168, 87));\r |
a929458e | 226 | jScrollPaneHelpText.setViewportView(getJTextAreaHelpText());\r |
227 | }\r | |
228 | return jScrollPaneHelpText;\r | |
06a19cee | 229 | }\r |
06a19cee | 230 | \r |
a929458e | 231 | /**\r |
232 | * This method initializes jButtonOk\r | |
233 | * \r | |
234 | * @return javax.swing.JButton\r | |
235 | * \r | |
236 | */\r | |
237 | private JButton getJButtonOk() {\r | |
238 | if (jButtonOk == null) {\r | |
239 | jButtonOk = new JButton();\r | |
3f62225f | 240 | jButtonOk.setBounds(new java.awt.Rectangle(290, 187, 90, 20));\r |
a929458e | 241 | jButtonOk.setText("Ok");\r |
242 | jButtonOk.addActionListener(this);\r | |
243 | }\r | |
244 | return jButtonOk;\r | |
06a19cee | 245 | }\r |
a929458e | 246 | \r |
247 | /**\r | |
248 | * This method initializes jButtonCancel\r | |
249 | * \r | |
250 | * @return javax.swing.JButton\r | |
251 | * \r | |
252 | */\r | |
253 | private JButton getJButtonCancel() {\r | |
254 | if (jButtonCancel == null) {\r | |
255 | jButtonCancel = new JButton();\r | |
3f62225f | 256 | jButtonCancel.setBounds(new java.awt.Rectangle(390, 187, 90, 20));\r |
a929458e | 257 | jButtonCancel.setText("Cancel");\r |
258 | jButtonCancel.addActionListener(this);\r | |
259 | }\r | |
260 | return jButtonCancel;\r | |
06a19cee | 261 | }\r |
a929458e | 262 | \r |
263 | public static void main(String[] args) {\r | |
264 | \r | |
06a19cee | 265 | }\r |
a929458e | 266 | \r |
267 | /**\r | |
268 | * This method initializes this\r | |
269 | * \r | |
270 | */\r | |
271 | private void init() {\r | |
3f62225f | 272 | // Width must be 20 larger than Content Pane PreferredSize width for MSFT\r |
273 | // Height must be 45 larger than ContentPane PreferredSize height for MSFT\r | |
274 | this.setSize(505, 260);\r | |
a929458e | 275 | this.setContentPane(getJScrollPane());\r |
276 | this.setTitle("Protocols");\r | |
277 | initFrame();\r | |
278 | this.setViewMode(false);\r | |
279 | this.centerWindow();\r | |
06a19cee | 280 | }\r |
a929458e | 281 | \r |
282 | /**\r | |
283 | * This method initializes this Fill values to all fields if these values are\r | |
284 | * not empty\r | |
285 | * \r | |
286 | * @param inProtocolsId\r | |
287 | * \r | |
288 | */\r | |
c25ad66c | 289 | private void init(ProtocolsIdentification inProtocolsId, ModuleIdentification mid) {\r |
a929458e | 290 | init();\r |
291 | this.id = inProtocolsId;\r | |
c25ad66c | 292 | \r |
e08433ef | 293 | //\r |
294 | // Init arch with module's arch\r | |
295 | //\r | |
296 | this.jArchCheckBox.setEnabledItems(wt.getModuleArch(mid));\r | |
297 | \r | |
298 | //\r | |
299 | // Get defined protocols from dependent packages\r | |
300 | //\r | |
c25ad66c | 301 | Vector<PackageIdentification> vpid = wt.getPackageDependenciesOfModule(mid);\r |
302 | if (vpid.size() <= 0) {\r | |
303 | Log.wrn("Init Protocol", "This module hasn't defined any package dependency, so there is no protocol can be added");\r | |
304 | }\r | |
305 | \r | |
306 | Tools.generateComboBoxByVector(this.jComboBoxCName,\r | |
307 | wt.getAllProtocolDeclarationsFromPackages(wt.getPackageDependenciesOfModule(mid)));\r | |
a929458e | 308 | \r |
309 | if (this.id != null) {\r | |
310 | this.jComboBoxCName.setSelectedItem(id.getName());\r | |
311 | this.jComboBoxProtocolType.setSelectedItem(id.getType());\r | |
312 | this.jComboBoxUsage.setSelectedItem(id.getUsage());\r | |
313 | this.jTextAreaHelpText.setText(id.getHelp());\r | |
314 | this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());\r | |
315 | this.jArchCheckBox.setSelectedItems(id.getSupArchList());\r | |
316 | }\r | |
06a19cee | 317 | }\r |
a929458e | 318 | \r |
319 | /**\r | |
320 | * This is the override edit constructor\r | |
321 | * \r | |
322 | * @param inProtocolsIdentification\r | |
323 | * @param iFrame\r | |
324 | * \r | |
325 | */\r | |
c25ad66c | 326 | public ProtocolsDlg(ProtocolsIdentification inProtocolsIdentification, IFrame iFrame, ModuleIdentification mid) {\r |
a929458e | 327 | super(iFrame, true);\r |
c25ad66c | 328 | init(inProtocolsIdentification, mid);\r |
06a19cee | 329 | }\r |
a929458e | 330 | \r |
331 | /**\r | |
332 | * Disable all components when the mode is view\r | |
333 | * \r | |
334 | * @param isView\r | |
335 | * true - The view mode; false - The non-view mode\r | |
336 | * \r | |
337 | */\r | |
338 | public void setViewMode(boolean isView) {\r | |
339 | if (isView) {\r | |
340 | this.jComboBoxUsage.setEnabled(!isView);\r | |
341 | this.jTextFieldFeatureFlag.setEnabled(!isView);\r | |
342 | }\r | |
06a19cee | 343 | }\r |
a929458e | 344 | \r |
345 | /**\r | |
346 | * This method initializes jContentPane\r | |
347 | * \r | |
348 | * @return javax.swing.JPanel jContentPane\r | |
349 | * \r | |
350 | */\r | |
351 | private JPanel getJContentPane() {\r | |
352 | if (jContentPane == null) {\r | |
353 | jStarLabel1 = new StarLabel();\r | |
3f62225f | 354 | jStarLabel1.setLocation(new java.awt.Point(2, 12));\r |
a929458e | 355 | jLabelProtocolType = new JLabel();\r |
3f62225f | 356 | jLabelProtocolType.setBounds(new java.awt.Rectangle(12, 12, 155, 20));\r |
a929458e | 357 | jLabelProtocolType.setText("Select Protocol Type");\r |
358 | \r | |
359 | jStarLabel2 = new StarLabel();\r | |
3f62225f | 360 | jStarLabel2.setLocation(new java.awt.Point(2, 37));\r |
a929458e | 361 | jLabelC_Name = new JLabel();\r |
362 | jLabelC_Name.setText("Protocol Guid C Name");\r | |
3f62225f | 363 | jLabelC_Name.setBounds(new java.awt.Rectangle(12, 37, 155, 20));\r |
a929458e | 364 | \r |
365 | jStarLabel3 = new StarLabel();\r | |
3f62225f | 366 | jStarLabel3.setLocation(new java.awt.Point(2, 62));\r |
a929458e | 367 | jLabelUsage = new JLabel();\r |
368 | jLabelUsage.setText("Usage");\r | |
3f62225f | 369 | jLabelUsage.setBounds(new java.awt.Rectangle(12, 62, 155, 20));\r |
a929458e | 370 | \r |
371 | jLabelHelpText = new JLabel();\r | |
3f62225f | 372 | jLabelHelpText.setBounds(new java.awt.Rectangle(12, 87, 155, 20));\r |
a929458e | 373 | jLabelHelpText.setText("Help Text");\r |
374 | \r | |
375 | jLabelFeatureFlag = new JLabel();\r | |
376 | jLabelFeatureFlag.setText("Feature Flag Expression");\r | |
21b42c66 | 377 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(12, 157, 155, 20));\r |
378 | jLabelFeatureFlag.setEnabled(false);\r | |
a929458e | 379 | \r |
380 | jLabelArch = new JLabel();\r | |
21b42c66 | 381 | jLabelArch.setBounds(new java.awt.Rectangle(12, 132, 155, 20));\r |
a929458e | 382 | jLabelArch.setText("Supported Architectures");\r |
383 | jArchCheckBox = new ArchCheckBox();\r | |
21b42c66 | 384 | jArchCheckBox.setBounds(new java.awt.Rectangle(168, 132, 320, 20));\r |
a929458e | 385 | jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));\r |
386 | \r | |
387 | jContentPane = new JPanel();\r | |
388 | jContentPane.setLayout(null);\r | |
3f62225f | 389 | jContentPane.setPreferredSize(new java.awt.Dimension(485, 215));\r |
a929458e | 390 | \r |
391 | jContentPane.add(jStarLabel1, null);\r | |
392 | jContentPane.add(jLabelProtocolType, null);\r | |
393 | jContentPane.add(getJComboBoxProtocolType(), null);\r | |
394 | jContentPane.add(jStarLabel2, null);\r | |
395 | jContentPane.add(jLabelC_Name, null);\r | |
396 | jContentPane.add(getJComboBoxCName(), null);\r | |
397 | jContentPane.add(jStarLabel3, null);\r | |
398 | jContentPane.add(jLabelUsage, null);\r | |
399 | jContentPane.add(getJComboBoxProtocolUsage(), null);\r | |
400 | jContentPane.add(jLabelHelpText, null);\r | |
401 | jContentPane.add(getJScrollPaneHelpText(), null);\r | |
402 | jContentPane.add(jLabelFeatureFlag, null);\r | |
403 | jContentPane.add(getJTextFieldFeatureFlag(), null);\r | |
404 | jContentPane.add(jLabelArch, null);\r | |
405 | jContentPane.add(jArchCheckBox, null);\r | |
406 | jContentPane.add(getJButtonOk(), null);\r | |
407 | jContentPane.add(getJButtonCancel(), null);\r | |
408 | }\r | |
409 | return jContentPane;\r | |
06a19cee | 410 | }\r |
a929458e | 411 | \r |
412 | /**\r | |
413 | * This method initializes Usage type\r | |
414 | * \r | |
415 | */\r | |
416 | private void initFrame() {\r | |
417 | Tools.generateComboBoxByVector(jComboBoxProtocolType, ed.getVProtocolType());\r | |
a929458e | 418 | Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVProtocolUsage());\r |
06a19cee | 419 | }\r |
420 | \r | |
a929458e | 421 | /*\r |
422 | * (non-Javadoc)\r | |
423 | * \r | |
424 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
425 | * \r | |
426 | * Override actionPerformed to listen all actions\r | |
427 | * \r | |
428 | */\r | |
429 | public void actionPerformed(ActionEvent arg0) {\r | |
430 | if (arg0.getSource() == jButtonOk) {\r | |
431 | if (checkAdd()) {\r | |
432 | getCurrentProtocols();\r | |
433 | this.returnType = DataType.RETURN_TYPE_OK;\r | |
434 | this.setVisible(false);\r | |
435 | }\r | |
436 | }\r | |
437 | \r | |
438 | if (arg0.getSource() == jButtonCancel) {\r | |
439 | this.returnType = DataType.RETURN_TYPE_CANCEL;\r | |
440 | this.setVisible(false);\r | |
441 | }\r | |
06a19cee | 442 | }\r |
443 | \r | |
a929458e | 444 | /**\r |
445 | * Data validation for all fields\r | |
446 | * \r | |
447 | * @retval true - All datas are valid\r | |
448 | * @retval false - At least one data is invalid\r | |
449 | * \r | |
450 | */\r | |
451 | public boolean checkAdd() {\r | |
452 | //\r | |
453 | // Check if all fields have correct data types\r | |
454 | //\r | |
455 | \r | |
456 | //\r | |
457 | // Check Name\r | |
458 | //\r | |
c25ad66c | 459 | if (this.jComboBoxCName.getSelectedItem() == null) {\r |
460 | Log.wrn("Update protocols", "Please select one Protocol/ProtocolNotify Name");\r | |
461 | return false;\r | |
462 | }\r | |
463 | \r | |
a929458e | 464 | if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {\r |
465 | if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {\r | |
466 | Log.wrn("Update Protocols", "Incorrect data type for Protocol/ProtocolNotify Name");\r | |
467 | return false;\r | |
468 | }\r | |
469 | }\r | |
470 | \r | |
471 | //\r | |
472 | // Check FeatureFlag\r | |
473 | //\r | |
474 | if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r | |
475 | if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r | |
476 | Log.wrn("Update Protocols", "Incorrect data type for Feature Flag");\r | |
477 | return false;\r | |
478 | }\r | |
479 | }\r | |
480 | \r | |
481 | return true;\r | |
06a19cee | 482 | }\r |
483 | \r | |
a929458e | 484 | private ProtocolsIdentification getCurrentProtocols() {\r |
485 | String arg0 = this.jComboBoxCName.getSelectedItem().toString();\r | |
486 | String arg1 = this.jComboBoxProtocolType.getSelectedItem().toString();\r | |
487 | String arg2 = this.jComboBoxUsage.getSelectedItem().toString();\r | |
488 | \r | |
489 | String arg3 = this.jTextFieldFeatureFlag.getText();\r | |
490 | Vector<String> arg4 = this.jArchCheckBox.getSelectedItemsVector();\r | |
491 | String arg5 = this.jTextAreaHelpText.getText();\r | |
492 | id = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r | |
493 | return id;\r | |
06a19cee | 494 | }\r |
495 | \r | |
a929458e | 496 | /*\r |
497 | * (non-Javadoc)\r | |
498 | * \r | |
499 | * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)\r | |
500 | * \r | |
501 | * Reflesh the frame when selected item changed\r | |
502 | * \r | |
503 | */\r | |
504 | \r | |
505 | public void itemStateChanged(ItemEvent arg0) {\r | |
506 | if (arg0.getSource() == this.jComboBoxProtocolType && arg0.getStateChange() == ItemEvent.SELECTED) {\r | |
507 | if (this.jComboBoxProtocolType.getSelectedItem().toString().equals(ed.getVProtocolType().get(0))) {\r | |
508 | Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolUsage());\r | |
509 | } else {\r | |
510 | Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolNotifyUsage());\r | |
511 | }\r | |
512 | }\r | |
06a19cee | 513 | }\r |
7ab6baa9 | 514 | \r |
a929458e | 515 | public ProtocolsIdentification getId() {\r |
516 | return id;\r | |
517 | }\r | |
7ab6baa9 | 518 | \r |
a929458e | 519 | public void setId(ProtocolsIdentification id) {\r |
520 | this.id = id;\r | |
521 | }\r | |
06a19cee | 522 | }\r |