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