]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdPlatformDefs.java
Fix EDKT352: Scroll bar should be displayed when the table is out of screen scope
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdPlatformDefs.java
1 /** @file
2 Java class FpdPlatformDefs is GUI for Flash element operation in SPD file.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13 package org.tianocore.frameworkwizard.platform.ui;
14
15 import java.awt.BorderLayout;
16 import javax.swing.JPanel;
17
18 import javax.swing.JFrame;
19 import javax.swing.JTabbedPane;
20 import javax.swing.JButton;
21 import javax.swing.ListSelectionModel;
22
23 import org.tianocore.PlatformSurfaceAreaDocument;
24 import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
25 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
26 import org.tianocore.frameworkwizard.toolchain.ToolChainId;
27
28 import javax.swing.JCheckBox;
29 import javax.swing.JOptionPane;
30 import javax.swing.JTextField;
31 import javax.swing.JLabel;
32 import javax.swing.JScrollPane;
33 import javax.swing.JTable;
34 import javax.swing.event.InternalFrameAdapter;
35 import javax.swing.event.InternalFrameEvent;
36 //import javax.swing.event.ListSelectionEvent;
37 //import javax.swing.event.ListSelectionListener;
38 import javax.swing.event.TableModelEvent;
39 import javax.swing.event.TableModelListener;
40 import javax.swing.table.DefaultTableModel;
41 import javax.swing.table.TableModel;
42 import javax.swing.JComboBox;
43 import java.awt.Dimension;
44 import java.util.Vector;
45
46 public class FpdPlatformDefs extends IInternalFrame {
47
48 private static boolean Debug = false;
49
50 private final int dialogWidth = 600;
51
52 private final int oneRowHeight = 20;
53
54 private final int twoRowHeight = 40;
55
56 // private final int threeRowHeight = 60;
57
58 private final int fourRowHeight = 80;
59
60 private final int sepHeight = 6;
61
62 // private final int sepWidth = 10;
63
64 private final int buttonWidth = 90;
65
66 private final int rowOne = 12;
67
68 private final int rowTwo = rowOne + oneRowHeight + sepHeight * 3;
69
70 private final int rowThree = rowTwo + oneRowHeight + sepHeight;
71
72 private final int rowFour = rowThree + oneRowHeight + sepHeight;
73
74 private final int rowFive = rowFour + fourRowHeight + sepHeight * 3;
75
76 private final int rowSix = rowFive + oneRowHeight + sepHeight;
77
78 private final int rowSeven = rowSix + oneRowHeight + sepHeight;
79
80 private final int rowEight = rowSeven + oneRowHeight + sepHeight;
81
82 private final int rowNine = rowEight + oneRowHeight + sepHeight;
83
84 private final int rowTen = rowNine + fourRowHeight + sepHeight + sepHeight * 3;
85
86 private final int rowEleven = rowTen + oneRowHeight + sepHeight;
87
88 private final int rowTwelve = rowEleven + oneRowHeight + sepHeight;
89
90 private final int dialogHeight = rowTwelve + twoRowHeight;
91
92 private final int labelColumn = 12;
93
94 private final int valueColumn = 168;
95
96 private final int labelWidth = 155;
97
98 private final int valueWidth = 320;
99
100 private final int valueCenter = valueColumn + (valueWidth / 2);
101
102 private final int tableHeight = fourRowHeight;
103
104 private final int tableWidth = valueWidth;
105
106 static JFrame frame;
107
108 private JPanel jContentPane = null;
109
110 private JTabbedPane jTabbedPane = null;
111
112 private TargetTableModel buildTargetTableModel = null;
113
114 private SkuInfoTableModel skuInfoTableModel = null;
115
116 private OpeningPlatformType docConsole = null;
117
118 private FpdFileContents ffc = null;
119
120 private JPanel jPanelGeneralTab = null;
121
122 private JPanel jPanelGeneralContainer = null;
123
124 private JLabel jLabelSupArch = null;
125
126 private JCheckBox jCheckBoxIa32 = null;
127
128 private JCheckBox jCheckBoxX64 = null;
129
130 private JCheckBox jCheckBoxIpf = null;
131
132 private JComboBox jComboBoxInterDir = null;
133
134 private JComboBox jBuildTargetComboBox = null;
135
136 private JTable jTableBuildTargets = null;
137
138 private JPanel jArchitectureSelections = null;
139
140 private JLabel jLabelBuildTargets = null;
141
142 // private JTextField jTextFieldBuildTarget = null;
143
144 private JButton jButtonAddBuildTarget = null;
145
146 private JButton jButtonDelBuildTarget = null;
147
148 private JScrollPane jScrollPaneBuildTargets = null;
149
150 private JScrollPane jScrollPaneSkuInfo = null;
151
152 private JTable jTableSkuInfo = null;
153
154 private JCheckBox jCheckBoxEbc = null;
155
156 private JCheckBox jCheckBoxArm = null;
157
158 private JCheckBox jCheckBoxPpc = null;
159
160 private JLabel jLabelSkuInfo = null;
161
162 private JLabel jLabelSkuId = null;
163
164 private JTextField jTextFieldSkuId = null;
165
166 private JLabel jLabelSkuName = null;
167
168 private JTextField jTextFieldSkuName = null;
169
170 private JButton jButtonSkuAdd = null;
171
172 private JButton jButtonSkuDel = null;
173
174 private JLabel jLabelIntermediateDirs = null;
175
176 private JLabel jLabelOutputDir = null;
177
178 private JTextField jTextFieldOutputDir = null;
179
180 private JLabel jLabelOutputInfo = null;
181
182 private int selectedRow = -1;
183
184 /**
185 * The following are not used by the UI
186 */
187 private static final long serialVersionUID = 1L;
188
189 private ToolChainId tid = new ToolChainId();
190
191 public FpdPlatformDefs() {
192 super();
193 initialize();
194 this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
195 this.setVisible(true);
196 }
197
198 public FpdPlatformDefs(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {
199 this();
200 ffc = new FpdFileContents(fpd);
201 init(ffc);
202 }
203
204 public FpdPlatformDefs(OpeningPlatformType opt) {
205 this(opt.getXmlFpd());
206 docConsole = opt;
207 }
208
209 /**
210 * This method initializes jTabbedPane
211 *
212 * @return javax.swing.JTabbedPane
213 */
214 private JTabbedPane getJTabbedPane() {
215 if (jTabbedPane == null) {
216 jTabbedPane = new JTabbedPane();
217 jTabbedPane.addTab("General", null, getJPanelGeneralTab(), null);
218 }
219 return jTabbedPane;
220 }
221
222 /**
223 * This method initializes this
224 *
225 * @return void
226 */
227 private void initialize() {
228 this.setSize(dialogWidth, dialogHeight);
229 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
230 this.setTitle("FPD Platform Definitions");
231 this.setContentPane(getJContentPane());
232 this.addInternalFrameListener(new InternalFrameAdapter() {
233 public void internalFrameDeactivated(InternalFrameEvent e) {
234 if (jTableBuildTargets.isEditing()) {
235 jTableBuildTargets.getCellEditor().stopCellEditing();
236 }
237 if (jTableSkuInfo.isEditing()) {
238 jTableSkuInfo.getCellEditor().stopCellEditing();
239 }
240
241 }
242 });
243 }
244
245 private void init(FpdFileContents ffc) {
246 Vector<Object> v = new Vector<Object>();
247 ffc.getPlatformDefsSupportedArchs(v);
248 showSupportedArchitectures(v);
249 v.removeAllElements();
250
251 ffc.getPlatformDefsBuildTargets(v);
252 buildTargetTableModel.setRowCount(0);
253 for (int i = 0; i < v.size(); ++i) {
254 Object[] row = { v.get(i) };
255 buildTargetTableModel.addRow(row);
256 }
257
258 String[][] saa = new String[ffc.getPlatformDefsSkuInfoCount()][2];
259 ffc.getPlatformDefsSkuInfos(saa);
260 for (int i = 0; i < saa.length; ++i) {
261 skuInfoTableModel.addRow(saa[i]);
262 }
263
264 String interDir = ffc.getPlatformDefsInterDir();
265 if (interDir != null) {
266 jComboBoxInterDir.setSelectedItem(interDir);
267 }
268
269 String outputDir = ffc.getPlatformDefsOutputDir();
270 if (outputDir != null) {
271 jTextFieldOutputDir.setText(outputDir);
272 }
273 }
274
275 private void showSupportedArchitectures(Vector<Object> v) {
276 if (v.contains("IA32")) {
277 jCheckBoxIa32.setSelected(true);
278 } else {
279 jCheckBoxIa32.setSelected(false);
280 }
281 if (v.contains("X64")) {
282 jCheckBoxX64.setSelected(true);
283 } else {
284 jCheckBoxX64.setSelected(false);
285 }
286 if (v.contains("IPF")) {
287 jCheckBoxIpf.setSelected(true);
288 } else {
289 jCheckBoxIpf.setSelected(false);
290 }
291 if (v.contains("EBC")) {
292 jCheckBoxEbc.setSelected(true);
293 } else {
294 jCheckBoxEbc.setSelected(false);
295 }
296 if (v.contains("ARM")) {
297 jCheckBoxArm.setSelected(true);
298 } else {
299 jCheckBoxArm.setSelected(false);
300 }
301 if (v.contains("PPC")) {
302 jCheckBoxPpc.setSelected(true);
303 } else {
304 jCheckBoxPpc.setSelected(false);
305 }
306 }
307
308 private void getSupportedArchitectures(Vector<Object> v) {
309 if (docConsole != null) {
310 docConsole.setSaved(false);
311 }
312 v.removeAllElements();
313 if (jCheckBoxIa32.isSelected()) {
314 v.add("IA32");
315 }
316 if (jCheckBoxX64.isSelected()) {
317 v.add("X64");
318 }
319 if (jCheckBoxIpf.isSelected()) {
320 v.add("IPF");
321 }
322 if (jCheckBoxEbc.isSelected()) {
323 v.add("EBC");
324 }
325 if (jCheckBoxArm.isSelected()) {
326 v.add("ARM");
327 }
328 if (jCheckBoxPpc.isSelected()) {
329 v.add("PPC");
330 }
331
332 }
333
334 /**
335 * This method initializes jContentPane
336 *
337 * @return javax.swing.JPanel
338 */
339 private JPanel getJContentPane() {
340 if (jContentPane == null) {
341 jContentPane = new JPanel();
342 jContentPane.setLayout(new BorderLayout());
343 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
344 }
345 return jContentPane;
346 }
347
348 /**
349 * This method initializes jPanel4
350 *
351 * @return javax.swing.JPanel
352 */
353 private JPanel getJPanelGeneralTab() {
354 if (jPanelGeneralTab == null) {
355 jPanelGeneralTab = new JPanel();
356 jPanelGeneralTab.setBounds(new java.awt.Rectangle(0, 0, dialogWidth * 2, dialogHeight * 3));
357 jPanelGeneralTab.setPreferredSize(new java.awt.Dimension(dialogWidth + 10, (dialogHeight * 3) + 10));
358 jPanelGeneralTab.setAutoscrolls(true);
359 jPanelGeneralTab.setLocation(0, 0);
360 jPanelGeneralTab.setLayout(null);
361 jPanelGeneralTab.add(getJPanelGeneralContainer(), null);
362 }
363 return jPanelGeneralTab;
364 }
365
366 /**
367 * This method initializes jPanel5
368 *
369 * @return javax.swing.JPanel
370 */
371 private JPanel getJPanelGeneralContainer() {
372 if (jPanelGeneralContainer == null) {
373 jLabelSupArch = new JLabel();
374 jLabelSupArch.setText("Supported Architectures");
375 jLabelSupArch.setBounds(new java.awt.Rectangle(labelColumn, rowOne, labelWidth, oneRowHeight));
376 jLabelBuildTargets = new JLabel();
377 jLabelBuildTargets.setText("Build Targets");
378 jLabelBuildTargets.setBounds(new java.awt.Rectangle(labelColumn, rowTwo, labelWidth, oneRowHeight));
379 jLabelSkuInfo = new JLabel();
380 jLabelSkuInfo.setText("SKU Information");
381 jLabelSkuInfo.setBounds(new java.awt.Rectangle(labelColumn, rowFive, labelWidth, oneRowHeight));
382 jLabelSkuId = new JLabel();
383 jLabelSkuId.setText("SKU ID Number");
384 jLabelSkuId.setBounds(new java.awt.Rectangle(labelColumn + 10, rowSix, labelWidth, oneRowHeight));
385 jLabelSkuName = new JLabel();
386 jLabelSkuName.setText("SKU Name");
387 jLabelSkuName.setBounds(new java.awt.Rectangle(labelColumn + 10, rowSeven, labelWidth, oneRowHeight));
388 jLabelOutputInfo = new JLabel();
389 jLabelOutputInfo.setText("Output Directory Configuration");
390 jLabelOutputInfo.setBounds(new java.awt.Rectangle(labelColumn, rowTen, valueWidth, oneRowHeight));
391 jLabelIntermediateDirs = new JLabel();
392 jLabelIntermediateDirs.setText("Intermediate Build Directories");
393 jLabelIntermediateDirs.setBounds(new java.awt.Rectangle(labelColumn + 10, rowEleven, valueWidth,
394 oneRowHeight));
395 jLabelOutputDir = new JLabel();
396 jLabelOutputDir.setText("Name of the Output Directory");
397 jLabelOutputDir.setBounds(new java.awt.Rectangle(labelColumn + 10, rowTwelve, valueWidth, oneRowHeight));
398
399 jPanelGeneralContainer = new JPanel();
400 jPanelGeneralContainer.setLayout(null);
401 jPanelGeneralContainer.setLocation(new java.awt.Point(2, 2));
402 jPanelGeneralContainer.setBounds(new java.awt.Rectangle(2, 2, dialogWidth * 2, dialogHeight));
403 jPanelGeneralContainer.setPreferredSize(new java.awt.Dimension(dialogWidth, dialogHeight));
404
405 jPanelGeneralContainer.add(jLabelSupArch, null);
406 jPanelGeneralContainer.add(getArchitectureSelections(), null);
407
408 jPanelGeneralContainer.add(jLabelBuildTargets, null);
409 // jPanelGeneralContainer.add(getJTextFieldBuildTarget(), null);
410 jPanelGeneralContainer.add(getJBuildTargetComboBox(), null);
411
412 jPanelGeneralContainer.add(getJButtonAddBuildTarget(), null);
413 jPanelGeneralContainer.add(getJButtonDelBuildTarget(), null);
414 jPanelGeneralContainer.add(getJScrollPaneBuildTargets(), null);
415
416 jPanelGeneralContainer.add(jLabelSkuInfo, null);
417 jPanelGeneralContainer.add(jLabelSkuId, null);
418 jPanelGeneralContainer.add(getJTextFieldSkuId(), null);
419 jPanelGeneralContainer.add(jLabelSkuName, null);
420 jPanelGeneralContainer.add(getJTextFieldSkuName(), null);
421 jPanelGeneralContainer.add(getJButtonSkuAdd(), null);
422 jPanelGeneralContainer.add(getJButtonSkuDel(), null);
423 jPanelGeneralContainer.add(getJScrollPaneSkuInfo(), null);
424
425 jPanelGeneralContainer.add(jLabelOutputInfo, null);
426 jPanelGeneralContainer.add(jLabelIntermediateDirs, null);
427 jPanelGeneralContainer.add(getJComboBoxInterDir(), null);
428 jPanelGeneralContainer.add(jLabelOutputDir, null);
429 jPanelGeneralContainer.add(getJTextFieldOutputDir(), null);
430
431 }
432 return jPanelGeneralContainer;
433 }
434
435 /**
436 * This method initializes jArchitectureSelections Row 4
437 *
438 * @return jArchitectureSelections
439 */
440 private JPanel getArchitectureSelections() {
441 if (jArchitectureSelections == null) {
442 jArchitectureSelections = new JPanel();
443 jArchitectureSelections.setLayout(null);
444 jArchitectureSelections.add(getJCheckBoxIa32(), null);
445 jArchitectureSelections.add(getJCheckBoxX64(), null);
446 jArchitectureSelections.add(getJCheckBoxIpf(), null);
447 jArchitectureSelections.add(getJCheckBoxEbc(), null);
448 jArchitectureSelections.add(getJCheckBoxArm(), null);
449 jArchitectureSelections.add(getJCheckBoxPpc(), null);
450 jArchitectureSelections.setBounds(new java.awt.Rectangle(valueColumn, rowOne, valueWidth, oneRowHeight));
451 jArchitectureSelections.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
452 jArchitectureSelections.setLocation(new java.awt.Point(valueColumn, rowOne));
453 jArchitectureSelections.setToolTipText("<html>A Platform may support one or more architectures,"
454 + "<br>at least one architecture must be selected!</html>");
455 }
456 return jArchitectureSelections;
457 }
458
459 /**
460 * This method initializes jCheckBox1
461 *
462 * @return javax.swing.JCheckBox
463 */
464 private JCheckBox getJCheckBoxIa32() {
465 if (jCheckBoxIa32 == null) {
466 jCheckBoxIa32 = new JCheckBox();
467 jCheckBoxIa32.setText("IA32");
468 jCheckBoxIa32.setBounds(new java.awt.Rectangle(0, 0, 55, 20));
469 jCheckBoxIa32.addItemListener(new java.awt.event.ItemListener() {
470 public void itemStateChanged(java.awt.event.ItemEvent e) {
471 Vector<Object> v = new Vector<Object>();
472 getSupportedArchitectures(v);
473 if (v.size() == 0) {
474 JOptionPane.showMessageDialog(frame, "Platform must support at least ONE Architecture.");
475 return;
476 }
477 ffc.setPlatformDefsSupportedArchs(v);
478 }
479 });
480 }
481 return jCheckBoxIa32;
482 }
483
484 /**
485 * This method initializes jCheckBox2
486 *
487 * @return javax.swing.JCheckBox
488 */
489 private JCheckBox getJCheckBoxX64() {
490 if (jCheckBoxX64 == null) {
491 jCheckBoxX64 = new JCheckBox();
492 jCheckBoxX64.setText("X64");
493 jCheckBoxX64.setBounds(new java.awt.Rectangle(55, 0, 53, 20));
494 jCheckBoxX64.addItemListener(new java.awt.event.ItemListener() {
495 public void itemStateChanged(java.awt.event.ItemEvent e) {
496 Vector<Object> v = new Vector<Object>();
497 getSupportedArchitectures(v);
498 if (v.size() == 0) {
499 JOptionPane.showMessageDialog(frame, "Platform must support at least ONE Architecture.");
500 return;
501 }
502 ffc.setPlatformDefsSupportedArchs(v);
503 }
504 });
505 }
506 return jCheckBoxX64;
507 }
508
509 /**
510 * This method initializes jCheckBox3
511 *
512 * @return javax.swing.JCheckBox
513 */
514 private JCheckBox getJCheckBoxIpf() {
515 if (jCheckBoxIpf == null) {
516 jCheckBoxIpf = new JCheckBox();
517 jCheckBoxIpf.setText("IPF");
518 jCheckBoxIpf.setBounds(new java.awt.Rectangle(108, 0, 52, 20));
519 jCheckBoxIpf.addItemListener(new java.awt.event.ItemListener() {
520 public void itemStateChanged(java.awt.event.ItemEvent e) {
521 Vector<Object> v = new Vector<Object>();
522 getSupportedArchitectures(v);
523 if (v.size() == 0) {
524 JOptionPane.showMessageDialog(frame, "Platform must support at least ONE Architecture.");
525 return;
526 }
527 ffc.setPlatformDefsSupportedArchs(v);
528 }
529 });
530 }
531 return jCheckBoxIpf;
532 }
533
534 /**
535 * This method initializes jCheckBox
536 *
537 * @return javax.swing.JCheckBox
538 */
539 private JCheckBox getJCheckBoxEbc() {
540 if (jCheckBoxEbc == null) {
541 jCheckBoxEbc = new JCheckBox();
542 // jCheckBoxEbc.setPreferredSize(new java.awt.Dimension(50, 20));
543 jCheckBoxEbc.setBounds(new java.awt.Rectangle(160, 0, 53, 20));
544 jCheckBoxEbc.setText("EBC");
545 jCheckBoxEbc.setVisible(true);
546 jCheckBoxEbc.addItemListener(new java.awt.event.ItemListener() {
547 public void itemStateChanged(java.awt.event.ItemEvent e) {
548 Vector<Object> v = new Vector<Object>();
549 getSupportedArchitectures(v);
550 if (v.size() == 0) {
551 JOptionPane.showMessageDialog(frame, "Platform must support at least ONE Architecture.");
552 return;
553 }
554 ffc.setPlatformDefsSupportedArchs(v);
555 }
556 });
557 }
558 return jCheckBoxEbc;
559 }
560
561 /**
562 * This method initializes jCheckBox5
563 *
564 * @return javax.swing.JCheckBox
565 */
566 private JCheckBox getJCheckBoxArm() {
567 if (jCheckBoxArm == null) {
568 jCheckBoxArm = new JCheckBox();
569 // jCheckBoxArm.setPreferredSize(new java.awt.Dimension(52, 20));
570 jCheckBoxArm.setBounds(new java.awt.Rectangle(213, 0, 54, 20));
571 jCheckBoxArm.setText("ARM");
572 jCheckBoxArm.setVisible(true);
573 jCheckBoxArm.addItemListener(new java.awt.event.ItemListener() {
574 public void itemStateChanged(java.awt.event.ItemEvent e) {
575 Vector<Object> v = new Vector<Object>();
576 getSupportedArchitectures(v);
577 if (v.size() == 0) {
578 JOptionPane.showMessageDialog(frame, "Platform must support at least ONE Architecture.");
579 return;
580 }
581 ffc.setPlatformDefsSupportedArchs(v);
582 }
583 });
584 }
585 return jCheckBoxArm;
586 }
587
588 /**
589 * This method initializes jCheckBox6
590 *
591 * @return javax.swing.JCheckBox
592 */
593 private JCheckBox getJCheckBoxPpc() {
594 if (jCheckBoxPpc == null) {
595 jCheckBoxPpc = new JCheckBox();
596 // jCheckBoxPpc.setPreferredSize(new Dimension(50, 20));
597 jCheckBoxPpc.setBounds(new java.awt.Rectangle(267, 0, 53, 20));
598 jCheckBoxPpc.setText("PPC");
599 jCheckBoxPpc.setVisible(true);
600 jCheckBoxPpc.addItemListener(new java.awt.event.ItemListener() {
601 public void itemStateChanged(java.awt.event.ItemEvent e) {
602 Vector<Object> v = new Vector<Object>();
603 getSupportedArchitectures(v);
604 if (v.size() == 0) {
605 JOptionPane.showMessageDialog(frame, "Platform must support at least ONE Architecture.");
606 return;
607 }
608 ffc.setPlatformDefsSupportedArchs(v);
609 }
610 });
611 }
612 return jCheckBoxPpc;
613 }
614
615 /**
616 * Use a ComboBox for BuildTargets
617 *
618 * @return javax.swing.JComboBox jBuildTargetComboBox
619 */
620 private JComboBox getJBuildTargetComboBox() {
621 if (jBuildTargetComboBox == null) {
622 String toolBt = null;
623 if (tid.getToolsDefTargetNames() == null)
624 toolBt = "DEBUG RELEASE";
625 else
626 toolBt = tid.getToolsDefTargetNames().trim();
627
628 if ((toolBt.contains("*")) || (toolBt.length() < 1)) {
629 toolBt = "DEBUG RELEASE";
630 }
631 if (Debug)
632 System.out.println("Using Build Targets: " + toolBt.trim());
633
634 toolBt = toolBt.replaceAll(" ", ":");
635 toolBt = " :" + toolBt;
636 if (Debug)
637 System.out.println("Using Build Targets: " + toolBt.trim());
638 String[] buildTargets = toolBt.trim().split(":");
639
640 jBuildTargetComboBox = new JComboBox(buildTargets);
641 jBuildTargetComboBox.setEditable(true);
642 jBuildTargetComboBox.setPreferredSize(new Dimension(valueWidth, oneRowHeight));
643 jBuildTargetComboBox.setBounds(new java.awt.Rectangle(valueColumn, rowTwo, valueWidth, oneRowHeight));
644 jBuildTargetComboBox.setLocation(new java.awt.Point(valueColumn, rowTwo));
645 jBuildTargetComboBox.setToolTipText("<html>Select a defined Target and then click Add,<br>"
646 + "or enter a new, one word TargetName and then click Add.<br>"
647 + "Remember to define the Targetname in the tool defintion file."
648 + "</html>");
649
650 }
651 return jBuildTargetComboBox;
652 }
653
654 /**
655 * This method initializes jTextField1
656 *
657 * @return javax.swing.JTextField
658 */
659 // private JTextField getJTextFieldBuildTarget() {
660 // if (jTextFieldBuildTarget == null) {
661 // jTextFieldBuildTarget = new JTextField();
662 // jTextFieldBuildTarget.setPreferredSize(new Dimension(valueWidth, oneRowHeight));
663 // jTextFieldBuildTarget.setBounds(new java.awt.Rectangle(valueColumn, rowTwo, valueWidth, oneRowHeight));
664 // jTextFieldBuildTarget.setLocation(new java.awt.Point(valueColumn, rowTwo));
665 // }
666 // return jTextFieldBuildTarget;
667 // }
668 /**
669 * This method initializes jButton2
670 *
671 * @return javax.swing.JButton
672 */
673 private JButton getJButtonAddBuildTarget() {
674 if (jButtonAddBuildTarget == null) {
675 jButtonAddBuildTarget = new JButton();
676 jButtonAddBuildTarget.setPreferredSize(new Dimension(buttonWidth, oneRowHeight));
677 jButtonAddBuildTarget.setBounds(new java.awt.Rectangle(valueCenter - buttonWidth - 5, rowThree,
678 buttonWidth, oneRowHeight));
679 jButtonAddBuildTarget.setLocation(new java.awt.Point(valueCenter - buttonWidth - 5, rowThree));
680 jButtonAddBuildTarget.setText("Add");
681 jButtonAddBuildTarget.setVisible(true);
682
683 jButtonAddBuildTarget.addActionListener(new java.awt.event.ActionListener() {
684 public void actionPerformed(java.awt.event.ActionEvent e) {
685 // Used with Text Field
686 // if (jTextFieldBuildTarget.getText().length() > 0) {
687 // String[] row = { jTextFieldBuildTarget.getText() };
688 // jTextFieldBuildTarget.setText("");
689 // buildTargetTableModel.addRow(row);
690 // Vector<Object> v = new Vector<Object>();
691 // for (int i = 0; i < jTableBuildTargets.getRowCount(); ++i) {
692 // v.add(buildTargetTableModel.getValueAt(i, 0));
693 // }
694 // docConsole.setSaved(false);
695 // ffc.setPlatformDefsBuildTargets(v);
696 // }
697 // Use with ComboBox
698 if (jBuildTargetComboBox.getSelectedItem().toString().length() > 0) {
699 String[] row = { jBuildTargetComboBox.getSelectedItem().toString() };
700 buildTargetTableModel.addRow(row);
701 Vector<Object> v = new Vector<Object>();
702 for (int i = 0; i < jTableBuildTargets.getRowCount(); ++i) {
703 v.add(buildTargetTableModel.getValueAt(i, 0));
704 }
705 }
706 }
707 });
708 }
709 return jButtonAddBuildTarget;
710 }
711
712 /**
713 * This method initializes jButton3
714 *
715 * @return javax.swing.JButton
716 */
717 private JButton getJButtonDelBuildTarget() {
718 if (jButtonDelBuildTarget == null) {
719 jButtonDelBuildTarget = new JButton();
720 jButtonDelBuildTarget.setPreferredSize(new Dimension(buttonWidth, oneRowHeight));
721 jButtonDelBuildTarget
722 .setBounds(new java.awt.Rectangle(valueCenter + 5, rowThree, buttonWidth, oneRowHeight));
723 jButtonDelBuildTarget.setLocation(new java.awt.Point(valueCenter + 5, rowThree));
724 jButtonDelBuildTarget.setText("Delete");
725 jButtonDelBuildTarget.setVisible(true);
726
727 jButtonDelBuildTarget.addActionListener(new java.awt.event.ActionListener() {
728 public void actionPerformed(java.awt.event.ActionEvent e) {
729 if (jTableBuildTargets.getSelectedRow() < 0 || jTableBuildTargets.getSelectedRow() < 0) {
730 return;
731 }
732 buildTargetTableModel.removeRow(jTableBuildTargets.getSelectedRow());
733 Vector<Object> v = new Vector<Object>();
734 for (int i = 0; i < jTableBuildTargets.getRowCount(); ++i) {
735 v.remove(buildTargetTableModel.getValueAt(i, 0));
736 }
737 docConsole.setSaved(false);
738 ffc.setPlatformDefsBuildTargets(v);
739 }
740 });
741 }
742 return jButtonDelBuildTarget;
743 }
744
745 /**
746 * This method initializes jScrollPane2
747 *
748 * @return javax.swing.JScrollPane
749 */
750 private JScrollPane getJScrollPaneBuildTargets() {
751 if (jScrollPaneBuildTargets == null) {
752 jScrollPaneBuildTargets = new JScrollPane();
753 jScrollPaneBuildTargets.setPreferredSize(new Dimension(tableWidth - 20, tableHeight - 20));
754 jScrollPaneBuildTargets.setBounds(new java.awt.Rectangle(valueColumn, rowFour, tableWidth - 5,
755 tableHeight - 5));
756 jScrollPaneBuildTargets.setLocation(new java.awt.Point(valueColumn, rowFour));
757 jScrollPaneBuildTargets
758 .setBorder(javax.swing.BorderFactory
759 .createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
760
761 jScrollPaneBuildTargets.setViewportView(getJTableBuildTargets());
762 }
763 return jScrollPaneBuildTargets;
764 }
765
766 /**
767 * This method initializes jTable
768 *
769 * @return javax.swing.JTable
770 */
771 private JTable getJTableBuildTargets() {
772 if (jTableBuildTargets == null) {
773 buildTargetTableModel = new TargetTableModel();
774
775 jTableBuildTargets = new JTable(buildTargetTableModel);
776 jTableBuildTargets.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
777 jTableBuildTargets.setRowHeight(oneRowHeight);
778 jTableBuildTargets.setToolTipText("<html>Select one of the Targets from the table and<br>"
779 + "click Delete to remove the target from the platform.</html>");
780 buildTargetTableModel.addColumn("Build Target");
781
782 jTableBuildTargets.getModel().addTableModelListener(new TableModelListener() {
783 public void tableChanged(TableModelEvent arg0) {
784 // TODO Auto-generated method stub
785 selectedRow = jTableBuildTargets.getSelectedRow();
786 if (selectedRow < 0) {
787 return;
788 }
789 TableModel m = (TableModel) arg0.getSource();
790 if (arg0.getType() == TableModelEvent.UPDATE) {
791 //ToDo Data Validition check.
792 Vector<Object> v = new Vector<Object>();
793 for (int i = 0; i < jTableBuildTargets.getRowCount(); ++i) {
794 v.add(m.getValueAt(i, 0));
795 }
796 docConsole.setSaved(false);
797 ffc.setPlatformDefsBuildTargets(v);
798 }
799 }
800 });
801
802 }
803 return jTableBuildTargets;
804 }
805
806 /**
807 * This method initializes jTextField2
808 *
809 * @return javax.swing.JTextField
810 */
811 private JTextField getJTextFieldSkuId() {
812 if (jTextFieldSkuId == null) {
813 jTextFieldSkuId = new JTextField();
814 jTextFieldSkuId.setPreferredSize(new Dimension(40, oneRowHeight));
815 jTextFieldSkuId.setBounds(new java.awt.Rectangle(valueColumn, rowSix, 40, oneRowHeight));
816 jTextFieldSkuId.setLocation(new java.awt.Point(valueColumn, rowSix));
817 jTextFieldSkuId.setToolTipText("Enter a unique integer value.");
818 }
819 return jTextFieldSkuId;
820 }
821
822 /**
823 * This method initializes jTextField3
824 *
825 * @return javax.swing.JTextField
826 */
827 private JTextField getJTextFieldSkuName() {
828 if (jTextFieldSkuName == null) {
829 jTextFieldSkuName = new JTextField();
830 jTextFieldSkuName.setPreferredSize(new Dimension(valueWidth, oneRowHeight));
831 jTextFieldSkuName.setBounds(new java.awt.Rectangle(valueColumn, rowSeven, valueWidth, oneRowHeight));
832 jTextFieldSkuName.setLocation(new java.awt.Point(valueColumn, rowSeven));
833 jTextFieldSkuName.setToolTipText("<html>Enter a name to help identify this SKU.<br>"
834 + "This entry is not used by the build system, it is<br>"
835 + "used only by this user interface.</html>");
836 }
837 return jTextFieldSkuName;
838 }
839
840 /**
841 * This method initializes jButton
842 *
843 * @return javax.swing.JButton
844 */
845 private JButton getJButtonSkuAdd() {
846 if (jButtonSkuAdd == null) {
847 jButtonSkuAdd = new JButton();
848
849 jButtonSkuAdd.setPreferredSize(new Dimension(buttonWidth, oneRowHeight));
850 jButtonSkuAdd.setBounds(new java.awt.Rectangle(valueCenter - buttonWidth - 5, rowEight, buttonWidth,
851 oneRowHeight));
852 jButtonSkuAdd.setLocation(new java.awt.Point(valueCenter - buttonWidth - 5, rowEight));
853 jButtonSkuAdd.setText("Add");
854 jButtonSkuAdd.setVisible(true);
855
856 jButtonSkuAdd.addActionListener(new java.awt.event.ActionListener() {
857 public void actionPerformed(java.awt.event.ActionEvent e) {
858 if (jTextFieldSkuId.getText().length() > 0) {
859 String[] row = { jTextFieldSkuId.getText(), jTextFieldSkuName.getText() };
860 skuInfoTableModel.addRow(row);
861 docConsole.setSaved(false);
862 ffc.genPlatformDefsSkuInfo(row[0], row[1]);
863 }
864 }
865 });
866 }
867 return jButtonSkuAdd;
868 }
869
870 /**
871 * This method initializes jButton1
872 *
873 * @return javax.swing.JButton
874 */
875 private JButton getJButtonSkuDel() {
876 if (jButtonSkuDel == null) {
877 jButtonSkuDel = new JButton();
878 jButtonSkuDel.setPreferredSize(new Dimension(buttonWidth, oneRowHeight));
879 jButtonSkuDel.setBounds(new java.awt.Rectangle(valueCenter + 5, rowEight, buttonWidth, oneRowHeight));
880 jButtonSkuDel.setLocation(new java.awt.Point(valueCenter + 5, rowEight));
881 jButtonSkuDel.setText("Delete");
882 jButtonSkuDel.setVisible(true);
883 jButtonSkuDel.addActionListener(new java.awt.event.ActionListener() {
884 public void actionPerformed(java.awt.event.ActionEvent e) {
885 if (jTableSkuInfo.isEditing()) {
886 jTableSkuInfo.getCellEditor().stopCellEditing();
887 }
888 if (jTableSkuInfo.getSelectedRow() < 1) {
889 return;
890 }
891 docConsole.setSaved(false);
892 ffc.removePlatformDefsSkuInfo(jTableSkuInfo.getSelectedRow());
893 skuInfoTableModel.removeRow(jTableSkuInfo.getSelectedRow());
894 }
895 });
896 }
897 return jButtonSkuDel;
898 }
899
900 /**
901 * This method initializes jScrollPane3
902 *
903 * @return javax.swing.JScrollPane
904 */
905 private JScrollPane getJScrollPaneSkuInfo() {
906 if (jScrollPaneSkuInfo == null) {
907 jScrollPaneSkuInfo = new JScrollPane();
908 jScrollPaneSkuInfo.setPreferredSize(new Dimension(tableWidth - 20, tableHeight - 20));
909 jScrollPaneSkuInfo.setBounds(new java.awt.Rectangle(valueColumn, rowNine, tableWidth - 5, tableHeight - 5));
910 jScrollPaneSkuInfo.setLocation(new java.awt.Point(valueColumn, rowNine));
911
912 jScrollPaneSkuInfo
913 .setBorder(javax.swing.BorderFactory
914 .createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
915
916 jScrollPaneSkuInfo.setViewportView(getJTableSkuInfo());
917 }
918 return jScrollPaneSkuInfo;
919 }
920
921 /**
922 * This method initializes jTable2
923 *
924 * @return javax.swing.JTable
925 */
926 private JTable getJTableSkuInfo() {
927 if (jTableSkuInfo == null) {
928 skuInfoTableModel = new SkuInfoTableModel();
929 skuInfoTableModel.addColumn("SKU ID");
930 skuInfoTableModel.addColumn("Name");
931 jTableSkuInfo = new JTable(skuInfoTableModel);
932 jTableSkuInfo.setToolTipText("<html>SKU ID 0 must always be defined as the default.<br>"
933 + "0 can mean either SKU disabled, or it can be the<br>"
934 + "default value if more than one SKU is defined, and the<br>"
935 + "platform is not jumpered to use one of the other SKU values.</html>");
936
937 jTableSkuInfo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
938
939 jTableSkuInfo.getModel().addTableModelListener(new TableModelListener() {
940 public void tableChanged(TableModelEvent arg0) {
941 // TODO Auto-generated method stub
942 int row = arg0.getFirstRow();
943 TableModel m = (TableModel) arg0.getSource();
944 if (arg0.getType() == TableModelEvent.UPDATE) {
945 //ToDo Data Validition check.
946 String id = m.getValueAt(row, 0) + "";
947 String name = m.getValueAt(row, 1) + "";
948 docConsole.setSaved(false);
949 ffc.updatePlatformDefsSkuInfo(row, id, name);
950 }
951 }
952 });
953 }
954 return jTableSkuInfo;
955 }
956
957 /**
958 * This method initializes jComboBox
959 *
960 * @return javax.swing.JComboBox
961 */
962 private JComboBox getJComboBoxInterDir() {
963 if (jComboBoxInterDir == null) {
964 jComboBoxInterDir = new JComboBox();
965 jComboBoxInterDir.setPreferredSize(new Dimension(75, oneRowHeight));
966 jComboBoxInterDir.setBounds(new java.awt.Rectangle(valueColumn + 30, rowEleven, 75, oneRowHeight));
967 jComboBoxInterDir.setLocation(new java.awt.Point(valueColumn + 30, rowEleven));
968 jComboBoxInterDir.addItem("UNIFIED");
969 jComboBoxInterDir.addItem("MODULE");
970 jComboBoxInterDir.setSelectedIndex(0);
971 jComboBoxInterDir.setToolTipText("<html>Select UNIFIED to generate intermediate directories under<br>"
972 + "under platform directory tree.<br>"
973 + "Select MODULE to generate intermediate directories under the<br>"
974 + "individual module directories.</html>");
975 jComboBoxInterDir.addItemListener(new java.awt.event.ItemListener() {
976 public void itemStateChanged(java.awt.event.ItemEvent e) {
977 if (docConsole != null) {
978 docConsole.setSaved(false);
979 }
980 ffc.setPlatformDefsInterDir(jComboBoxInterDir.getSelectedItem() + "");
981 }
982 });
983 }
984 return jComboBoxInterDir;
985 }
986
987 /**
988 * This method initializes jTextField
989 *
990 * @return javax.swing.JTextField Row Twelve
991 */
992 private JTextField getJTextFieldOutputDir() {
993 if (jTextFieldOutputDir == null) {
994 jTextFieldOutputDir = new JTextField();
995 jTextFieldOutputDir.setPreferredSize(new java.awt.Dimension(290, 20));
996 jTextFieldOutputDir.setBounds(new java.awt.Rectangle(valueColumn + 30, rowTwelve, valueWidth - 30,
997 oneRowHeight));
998 jTextFieldOutputDir.setLocation(new java.awt.Point(valueColumn + 30, rowTwelve));
999 jTextFieldOutputDir.setToolTipText("Select the name or URL for the output directory tree.");
1000 jTextFieldOutputDir.addFocusListener(new java.awt.event.FocusAdapter() {
1001 public void focusLost(java.awt.event.FocusEvent e) {
1002 docConsole.setSaved(false);
1003 ffc.setPlatformDefsOutputDir(jTextFieldOutputDir.getText());
1004 }
1005 });
1006 }
1007 return jTextFieldOutputDir;
1008 }
1009
1010 } // @jve:decl-index=0:visual-constraint="10,10"
1011
1012 class SkuInfoTableModel extends DefaultTableModel {
1013 private static final long serialVersionUID = 1L;
1014
1015 public boolean isCellEditable(int row, int column) {
1016 if (row == 0) {
1017 return false;
1018 }
1019 return true;
1020 }
1021 }
1022
1023 class TargetTableModel extends DefaultTableModel {
1024 private static final long serialVersionUID = 1L;
1025
1026 public boolean isCellEditable(int row, int column) {
1027 if (row < 2) {
1028 return false;
1029 }
1030 return true;
1031 }
1032 }