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