]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java
1. Add function "Refresh" in main UI
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / FrameworkWizardUI.java
1 /** @file
2
3 The main GUI for module editor.
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 package org.tianocore.frameworkwizard;
17
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ComponentEvent;
20 import java.awt.event.KeyEvent;
21 import java.awt.event.KeyListener;
22 import java.awt.event.MouseEvent;
23 import java.awt.event.MouseListener;
24 import java.awt.event.WindowEvent;
25 import java.io.IOException;
26 import java.util.Iterator;
27 import java.util.Set;
28 import java.util.Vector;
29
30 import javax.swing.JButton;
31 import javax.swing.JCheckBoxMenuItem;
32 import javax.swing.JDesktopPane;
33 import javax.swing.JFileChooser;
34 import javax.swing.JFrame;
35 import javax.swing.JInternalFrame;
36 import javax.swing.JMenu;
37 import javax.swing.JMenuBar;
38 import javax.swing.JMenuItem;
39 import javax.swing.JOptionPane;
40 import javax.swing.JPanel;
41 import javax.swing.JScrollPane;
42 import javax.swing.JSplitPane;
43 import javax.swing.JTabbedPane;
44 import javax.swing.event.MenuEvent;
45 import javax.swing.event.MenuListener;
46 import javax.swing.event.TreeSelectionEvent;
47 import javax.swing.event.TreeSelectionListener;
48 import javax.swing.tree.TreePath;
49
50 import org.apache.xmlbeans.XmlException;
51 import org.tianocore.PackageSurfaceAreaDocument;
52 import org.tianocore.frameworkwizard.common.DataType;
53 import org.tianocore.frameworkwizard.common.GlobalData;
54 import org.tianocore.frameworkwizard.common.IFileFilter;
55 import org.tianocore.frameworkwizard.common.Log;
56 import org.tianocore.frameworkwizard.common.SaveFile;
57 import org.tianocore.frameworkwizard.common.Tools;
58 import org.tianocore.frameworkwizard.common.Identifications.Identification;
59 import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
60 import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
61 import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
62 import org.tianocore.frameworkwizard.common.find.FindResult;
63 import org.tianocore.frameworkwizard.common.ui.IDefaultMutableTreeNode;
64 import org.tianocore.frameworkwizard.common.ui.IDesktopManager;
65 import org.tianocore.frameworkwizard.common.ui.IFrame;
66 import org.tianocore.frameworkwizard.common.ui.ITree;
67 import org.tianocore.frameworkwizard.far.createui.CreateStepOne;
68 import org.tianocore.frameworkwizard.far.deleteui.DeleteStepOne;
69 import org.tianocore.frameworkwizard.far.installui.InstallStepOne;
70 import org.tianocore.frameworkwizard.far.updateui.UpdateStepOne;
71 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
72 import org.tianocore.frameworkwizard.module.ui.ModuleBootModes;
73 import org.tianocore.frameworkwizard.module.ui.ModuleDataHubs;
74 import org.tianocore.frameworkwizard.module.ui.ModuleEvents;
75 import org.tianocore.frameworkwizard.module.ui.ModuleExterns;
76 import org.tianocore.frameworkwizard.module.ui.ModuleGuids;
77 import org.tianocore.frameworkwizard.module.ui.ModuleHiiPackages;
78 import org.tianocore.frameworkwizard.module.ui.ModuleHobs;
79 import org.tianocore.frameworkwizard.module.ui.ModuleLibraryClassDefinitions;
80 import org.tianocore.frameworkwizard.module.ui.ModulePCDs;
81 import org.tianocore.frameworkwizard.module.ui.ModulePackageDependencies;
82 import org.tianocore.frameworkwizard.module.ui.ModulePpis;
83 import org.tianocore.frameworkwizard.module.ui.ModuleProtocols;
84 import org.tianocore.frameworkwizard.module.ui.ModuleSourceFiles;
85 import org.tianocore.frameworkwizard.module.ui.ModuleSystemTables;
86 import org.tianocore.frameworkwizard.module.ui.ModuleVariables;
87 import org.tianocore.frameworkwizard.module.ui.MsaHeader;
88 import org.tianocore.frameworkwizard.packaging.PackageIdentification;
89 import org.tianocore.frameworkwizard.packaging.ui.SpdGuidDecls;
90 import org.tianocore.frameworkwizard.packaging.ui.SpdHeader;
91 import org.tianocore.frameworkwizard.packaging.ui.SpdLibClassDecls;
92 import org.tianocore.frameworkwizard.packaging.ui.SpdMsaFiles;
93 import org.tianocore.frameworkwizard.packaging.ui.SpdPackageHeaders;
94 import org.tianocore.frameworkwizard.packaging.ui.SpdPcdDefs;
95 import org.tianocore.frameworkwizard.packaging.ui.SpdPpiDecls;
96 import org.tianocore.frameworkwizard.packaging.ui.SpdProtocolDecls;
97 import org.tianocore.frameworkwizard.platform.PlatformIdentification;
98 import org.tianocore.frameworkwizard.platform.ui.FpdBuildOptions;
99 import org.tianocore.frameworkwizard.platform.ui.FpdDynamicPcdBuildDefinitions;
100 import org.tianocore.frameworkwizard.platform.ui.FpdFlash;
101 import org.tianocore.frameworkwizard.platform.ui.FpdFrameworkModules;
102 import org.tianocore.frameworkwizard.platform.ui.FpdHeader;
103 import org.tianocore.frameworkwizard.platform.ui.FpdPlatformDefs;
104 import org.tianocore.frameworkwizard.workspace.Workspace;
105 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
106 import org.tianocore.frameworkwizard.workspace.ui.SwitchWorkspace;
107 import org.tianocore.frameworkwizard.toolchain.Preferences;
108
109 /**
110 The class is used to show main GUI of FrameworkWizard
111 It extends IFrame implements MouseListener, TreeSelectionListener, ComponentListener and MenuListener
112
113 **/
114 public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListener, TreeSelectionListener,
115 MenuListener {
116 ///
117 /// Define class Serial Version UID
118 ///
119 private static final long serialVersionUID = -7103240960573031772L;
120
121 ///
122 /// Used to record current operation target
123 ///
124 private int currentOpeningModuleIndex = -1;
125
126 private int currentOpeningPackageIndex = -1;
127
128 private int currentOpeningPlatformIndex = -1;
129
130 ///
131 /// Used to generate tree structure
132 ///
133 private IDefaultMutableTreeNode dmtnRoot = null;
134
135 private IDefaultMutableTreeNode dmtnModuleDescription = null;
136
137 private IDefaultMutableTreeNode dmtnPackageDescription = null;
138
139 private IDefaultMutableTreeNode dmtnPlatformDescription = null;
140
141 ///
142 /// Used for UI
143 ///
144 private JPanel jContentPane = null;
145
146 private JMenuBar jMenuBar = null;
147
148 private JMenu jMenuFile = null;
149
150 private JMenuItem jMenuItemFileNew = null;
151
152 private JMenuItem jMenuItemFileRefresh = null;
153
154 private JMenuItem jMenuItemFileSaveAs = null;
155
156 private JMenuItem jMenuItemFileExit = null;
157
158 private JMenu jMenuEdit = null;
159
160 private JDesktopPane jDesktopPaneModule = null;
161
162 private JDesktopPane jDesktopPanePackage = null;
163
164 private JDesktopPane jDesktopPanePlatform = null;
165
166 private JTabbedPane jTabbedPaneTree = null;
167
168 private JTabbedPane jTabbedPaneEditor = null;
169
170 private IDesktopManager iDesktopManager = new IDesktopManager();
171
172 private JScrollPane jScrollPaneTree = null;
173
174 private ITree iTree = null;
175
176 private JMenu jMenuHelp = null;
177
178 private JMenuItem jMenuItemHelpAbout = null;
179
180 private JMenuItem jMenuItemEditDelete = null;
181
182 private WorkspaceTools wt = new WorkspaceTools();
183
184 private JMenuItem jMenuItemFileSave = null;
185
186 private JMenuItem jMenuItemFileClose = null;
187
188 private JMenu jMenuTools = null;
189
190 private JMenu jMenuWindow = null;
191
192 private JPanel jPanelOperation = null;
193
194 private JButton jButtonOk = null;
195
196 private JButton jButtonCancel = null;
197
198 private JMenuItem jMenuItemFileOpen = null;
199
200 private JMenuItem jMenuItemFileCloseAll = null;
201
202 private JMenuItem jMenuItemFileSaveAll = null;
203
204 private JMenuItem jMenuItemFilePageSetup = null;
205
206 private JMenuItem jMenuItemFilePrint = null;
207
208 private JMenuItem jMenuItemFileImport = null;
209
210 private JMenuItem jMenuItemFileProperties = null;
211
212 private JMenu jMenuFileRecentFiles = null;
213
214 private JSplitPane jSplitPane = null;
215
216 private JMenuItem jMenuItemEditUndo = null;
217
218 private JMenuItem jMenuItemEditRedo = null;
219
220 private JMenuItem jMenuItemEditCut = null;
221
222 private JMenuItem jMenuItemEditCopy = null;
223
224 private JMenuItem jMenuItemEditPaste = null;
225
226 private JMenuItem jMenuItemEditSelectAll = null;
227
228 private JMenuItem jMenuItemEditFindNext = null;
229
230 private JMenu jMenuView = null;
231
232 private JMenu jMenuViewToolbars = null;
233
234 private JCheckBoxMenuItem jCheckBoxMenuItemViewToolbarsFile = null;
235
236 private JCheckBoxMenuItem jCheckBoxMenuItemViewToolbarsEdit = null;
237
238 private JCheckBoxMenuItem jCheckBoxMenuItemViewToolbarsWindow = null;
239
240 private JMenuItem jMenuItemViewStandard = null;
241
242 private JMenuItem jMenuItemViewAdvanced = null;
243
244 private JMenu jMenuProject = null;
245
246 private JMenuItem jMenuItemProjectAdmin = null;
247
248 private JMenuItem jMenuItemProjectChangeWorkspace = null;
249
250 private JMenuItem jMenuItemToolsBuildPreferences = null;
251
252 // private JCheckBoxMenuItem jCheckBoxMenuItemProjectBuildTargetsDebug = null;
253
254 // private JCheckBoxMenuItem jCheckBoxMenuItemProjectBuildTargetsRelease = null;
255
256 private JMenuItem jMenuItemToolsToolChainConfiguration = null;
257
258 private JMenuItem jMenuItemToolsClone = null;
259
260 private JMenuItem jMenuItemToolsCodeScan = null;
261
262 private JMenuItem jMenuItemWindowDisplaySide = null;
263
264 private JMenuItem jMenuItemWindowDisplayTopBottom = null;
265
266 private JMenuItem jMenuItemViewXML = null;
267
268 private JMenuItem jMenuItemWindowTabView = null;
269
270 private JMenuItem jMenuItemWindowSource = null;
271
272 private JMenuItem jMenuItemWindowXML = null;
273
274 private JMenuItem jMenuItemWindowPreferences = null;
275
276 private JMenuItem jMenuItemHelpContents = null;
277
278 private JMenuItem jMenuItemHelpIndex = null;
279
280 private JMenuItem jMenuItemHelpSearch = null;
281
282 private JMenuItem jMenuItemProjectInstallFar = null;
283
284 private JMenuItem jMenuItemProjectUpdateFar = null;
285
286 private JMenuItem jMenuItemProjectRemoveFar = null;
287
288 private JMenuItem jMenuItemProjectCreateFar = null;
289
290 private JMenu jMenuEditFind = null;
291
292 private JMenuItem jMenuItemEditFindPcd = null;
293
294 private JMenuItem jMenuItemEditFindLibraryClass = null;
295
296 private JMenuItem jMenuItemEditFindPpi = null;
297
298 private JMenuItem jMenuItemEditFindProtocol = null;
299
300 private JMenuItem jMenuItemEditFindGuid = null;
301
302 private JMenuItem jMenuItemEditFindLibraryInstance = null;
303
304 ///
305 /// A static definition for this class itself
306 ///
307 private static FrameworkWizardUI fwui = null;
308
309 /**
310 If the class hasn't an instnace, new one.
311
312 @return FrameworkWizardUI The instance of this class
313
314 **/
315 public static FrameworkWizardUI getInstance() {
316 if (fwui == null) {
317 fwui = new FrameworkWizardUI();
318 }
319 return fwui;
320 }
321
322 /**
323 This method initializes jMenuBar
324
325 @return javax.swing.JMenuBar Main menu bar for the entire GUI
326
327 **/
328 private JMenuBar getjJMenuBar() {
329 if (jMenuBar == null) {
330 jMenuBar = new JMenuBar();
331 jMenuBar.setPreferredSize(new java.awt.Dimension(0, 18));
332 jMenuBar.add(getJMenuFile());
333 jMenuBar.add(getJMenuEdit());
334 jMenuBar.add(getJMenuView());
335 jMenuBar.add(getJMenuProject());
336 jMenuBar.add(getJMenuTools());
337 jMenuBar.add(getJMenuWindow());
338 jMenuBar.add(getJMenuHelp());
339 }
340 return jMenuBar;
341 }
342
343 /**
344 This method initializes jSplitPane
345
346 @return javax.swing.JSplitPane
347
348 **/
349 private JSplitPane getJSplitPane() {
350 if (jSplitPane == null) {
351 jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, getJTabbedPaneTree(), getJTabbedPaneEditor());
352 jSplitPane.setBounds(new java.awt.Rectangle(0, 1, DataType.MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_WIDTH,
353 DataType.MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_HEIGHT));
354 jSplitPane.addComponentListener(this);
355 }
356 return jSplitPane;
357 }
358
359 /**
360 This method initializes jTabbedPaneEditor
361
362 @return javax.swing.JTabbedPane
363
364 **/
365 private JTabbedPane getJTabbedPaneEditor() {
366 if (jTabbedPaneEditor == null) {
367 jTabbedPaneEditor = new JTabbedPane();
368 jTabbedPaneEditor.setBounds(new java.awt.Rectangle(DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_X,
369 DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_Y,
370 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH,
371 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT));
372 jTabbedPaneEditor
373 .setMinimumSize(new java.awt.Dimension(
374 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH,
375 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT));
376 jTabbedPaneEditor.addTab("Module", null, getJDesktopPaneModule(), null);
377 jTabbedPaneEditor.addTab("Package", null, getJDesktopPanePackage(), null);
378 jTabbedPaneEditor.addTab("Platform", null, getJDesktopPanePlatform(), null);
379 }
380 return jTabbedPaneEditor;
381 }
382
383 /**
384 This method initializes jTabbedPaneTree
385
386 @return javax.swing.JTabbedPane
387
388 **/
389 private JTabbedPane getJTabbedPaneTree() {
390 if (jTabbedPaneTree == null) {
391 jTabbedPaneTree = new JTabbedPane();
392 jTabbedPaneTree
393 .setPreferredSize(new java.awt.Dimension(
394 DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH,
395 DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT));
396 jTabbedPaneTree
397 .setMinimumSize(new java.awt.Dimension(DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH,
398 DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT));
399 jTabbedPaneTree.addTab("Workspace Explorer", null, getJScrollPaneTree(), null);
400 }
401 return jTabbedPaneTree;
402 }
403
404 /**
405 This method initializes jMenuFile
406
407 @return javax.swing.JMenu jMenuModule
408
409 **/
410 private JMenu getJMenuFile() {
411 if (jMenuFile == null) {
412 //
413 // Set jMenuFile's attributes
414 //
415 jMenuFile = new JMenu();
416 jMenuFile.setText("File");
417 jMenuFile.setMnemonic('F');
418 jMenuFile.addMenuListener(this);
419
420 //
421 // Add sub menu items
422 //
423 jMenuFile.add(getJMenuItemFileNew());
424 jMenuFile.add(getJMenuItemFileOpen());
425 jMenuFile.add(getJMenuItemFileClose());
426 jMenuFile.add(getJMenuItemFileCloseAll());
427 jMenuFile.addSeparator();
428
429 jMenuFile.add(getJMenuFileRecentFiles());
430 jMenuFile.add(getJMenuItemFileSave());
431 jMenuFile.add(getJMenuItemFileSaveAs());
432 jMenuFile.add(getJMenuItemFileSaveAll());
433 jMenuFile.addSeparator();
434
435 jMenuFile.add(getJMenuItemFileRefresh());
436 jMenuFile.addSeparator();
437
438 jMenuFile.add(getJMenuItemFilePageSetup());
439 jMenuFile.add(getJMenuItemFilePrint());
440 jMenuFile.add(getJMenuItemFileImport());
441 jMenuFile.add(getJMenuItemFileProperties());
442
443 jMenuFile.add(getJMenuItemFileExit());
444 }
445 return jMenuFile;
446 }
447
448 /**
449 This method initializes jMenuItemFileSaveAs
450
451 @return javax.swing.JMenuItem jMenuItemFileSaveAs
452
453 **/
454 private JMenuItem getJMenuItemFileSaveAs() {
455 if (jMenuItemFileSaveAs == null) {
456 jMenuItemFileSaveAs = new JMenuItem();
457 jMenuItemFileSaveAs.setText("Save As...");
458 jMenuItemFileSaveAs.setMnemonic('a');
459 jMenuItemFileSaveAs.addActionListener(this);
460 jMenuItemFileSaveAs.setEnabled(false);
461 jMenuItemFileSaveAs.setVisible(false);
462 }
463 return jMenuItemFileSaveAs;
464 }
465
466 /**
467 This method initializes jMenuItemFileRefresh
468
469 @return javax.swing.JMenuItem jMenuItemFileRefresh
470
471 **/
472 private JMenuItem getJMenuItemFileRefresh() {
473 if (jMenuItemFileRefresh == null) {
474 jMenuItemFileRefresh = new JMenuItem();
475 jMenuItemFileRefresh.setText("Refresh");
476 jMenuItemFileRefresh.setMnemonic('R');
477 jMenuItemFileRefresh.addActionListener(this);
478 jMenuItemFileRefresh.setVisible(true);
479 }
480 return jMenuItemFileRefresh;
481 }
482
483 /**
484 This method initializes jMenuItemModuleExit
485
486 @return javax.swing.JMenuItem jMenuItemModuleExit
487
488 **/
489 private JMenuItem getJMenuItemFileExit() {
490 if (jMenuItemFileExit == null) {
491 jMenuItemFileExit = new JMenuItem();
492 jMenuItemFileExit.setText("Exit");
493 jMenuItemFileExit.setMnemonic('x');
494 jMenuItemFileExit.addActionListener(this);
495 }
496 return jMenuItemFileExit;
497 }
498
499 /**
500 This method initializes jMenuEdit
501
502 @return javax.swing.JMenu jMenuEdit
503
504 **/
505 private JMenu getJMenuEdit() {
506 if (jMenuEdit == null) {
507 //
508 // Set jMenuEdit's attributes
509 //
510 jMenuEdit = new JMenu();
511 jMenuEdit.setText("Edit");
512 jMenuEdit.setMnemonic('E');
513 jMenuEdit.setVisible(true);
514
515 //
516 // Add sub menu items
517 //
518 jMenuEdit.add(getJMenuItemEditUndo());
519 jMenuEdit.add(getJMenuItemEditRedo());
520 //jMenuEdit.addSeparator();
521
522 jMenuEdit.add(getJMenuItemEditCut());
523 jMenuEdit.add(getJMenuItemEditCopy());
524 jMenuEdit.add(getJMenuItemEditPaste());
525 jMenuEdit.add(getJMenuItemEditDelete());
526 //jMenuEdit.addSeparator();
527
528 jMenuEdit.add(getJMenuItemEditSelectAll());
529 jMenuEdit.add(getJMenuEditFind());
530 jMenuEdit.add(getJMenuItemEditFindNext());
531 //jMenuEdit.addSeparator();
532 }
533 return jMenuEdit;
534 }
535
536 /**
537 This method initializes jDesktopPane
538
539 @return javax.swing.JDesktopPane jDesktopPane
540
541 **/
542 private JDesktopPane getJDesktopPaneModule() {
543 if (jDesktopPaneModule == null) {
544 jDesktopPaneModule = new JDesktopPane();
545 jDesktopPaneModule
546 .setBounds(new java.awt.Rectangle(DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_X,
547 DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_Y,
548 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH,
549 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT));
550 jDesktopPaneModule
551 .setMinimumSize(new java.awt.Dimension(
552 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH,
553 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT));
554 jDesktopPaneModule.setDesktopManager(iDesktopManager);
555 jDesktopPaneModule.addComponentListener(this);
556 }
557 return jDesktopPaneModule;
558 }
559
560 /**
561 This method initializes jDesktopPane
562
563 @return javax.swing.JDesktopPane jDesktopPane
564
565 **/
566 private JDesktopPane getJDesktopPanePackage() {
567 if (jDesktopPanePackage == null) {
568 jDesktopPanePackage = new JDesktopPane();
569 jDesktopPanePackage
570 .setBounds(new java.awt.Rectangle(DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_X,
571 DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_Y,
572 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH,
573 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT));
574 jDesktopPanePackage
575 .setMinimumSize(new java.awt.Dimension(
576 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH,
577 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT));
578 jDesktopPanePackage.setDesktopManager(iDesktopManager);
579 jDesktopPanePackage.addComponentListener(this);
580 }
581 return jDesktopPanePackage;
582 }
583
584 /**
585 This method initializes jDesktopPane
586
587 @return javax.swing.JDesktopPane jDesktopPane
588
589 **/
590 private JDesktopPane getJDesktopPanePlatform() {
591 if (jDesktopPanePlatform == null) {
592 jDesktopPanePlatform = new JDesktopPane();
593 jDesktopPanePlatform
594 .setBounds(new java.awt.Rectangle(
595 DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_X,
596 DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_Y,
597 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH,
598 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT));
599 jDesktopPanePlatform
600 .setMinimumSize(new java.awt.Dimension(
601 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH,
602 DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT));
603 jDesktopPanePlatform.setDesktopManager(iDesktopManager);
604 jDesktopPanePlatform.addComponentListener(this);
605 }
606 return jDesktopPanePlatform;
607 }
608
609 /**
610 This method initializes jScrollPaneTree
611
612 @return javax.swing.JScrollPane jScrollPaneTree
613
614 **/
615 private JScrollPane getJScrollPaneTree() {
616 if (jScrollPaneTree == null) {
617 jScrollPaneTree = new JScrollPane();
618 jScrollPaneTree
619 .setPreferredSize(new java.awt.Dimension(
620 DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH,
621 DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT));
622 jScrollPaneTree
623 .setMinimumSize(new java.awt.Dimension(
624 DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH / 2,
625 DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT));
626 jScrollPaneTree.setViewportView(getITree());
627 }
628 return jScrollPaneTree;
629 }
630
631 /**
632 This method initializes iTree
633
634 @return org.tianocore.packaging.common.ui.ITree iTree
635
636 **/
637 private ITree getITree() {
638 //
639 //Before open a real module, use an empty root node for the tree
640 //
641 makeEmptyTree();
642 return iTree;
643 }
644
645 /**
646 This method initializes jMenuHelp
647
648 @return javax.swing.JMenu jMenuHelp
649
650 **/
651 private JMenu getJMenuHelp() {
652 if (jMenuHelp == null) {
653 //
654 // Set jMenuHelp's attributes
655 //
656 jMenuHelp = new JMenu();
657 jMenuHelp.setText("Help");
658 jMenuHelp.setMnemonic('H');
659
660 //
661 // Add sub menu items
662 //
663 jMenuHelp.add(getJMenuItemHelpContents());
664 jMenuHelp.add(getJMenuItemHelpIndex());
665 jMenuHelp.add(getJMenuItemHelpSearch());
666
667 jMenuHelp.add(getJMenuItemHelpAbout());
668 }
669 return jMenuHelp;
670 }
671
672 /**
673 This method initializes jMenuItemHelpAbout
674
675 @return javax.swing.JMenuItem jMenuItemHelpAbout
676
677 **/
678 private JMenuItem getJMenuItemHelpAbout() {
679 if (jMenuItemHelpAbout == null) {
680 jMenuItemHelpAbout = new JMenuItem();
681 jMenuItemHelpAbout.setText("About...");
682 jMenuItemHelpAbout.setMnemonic('A');
683 jMenuItemHelpAbout.addActionListener(this);
684 }
685 return jMenuItemHelpAbout;
686 }
687
688 /**
689 This method initializes jMenuItemEditDelete
690
691 @return javax.swing.JMenuItem jMenuItemEditDelete
692
693 **/
694 private JMenuItem getJMenuItemEditDelete() {
695 if (jMenuItemEditDelete == null) {
696 jMenuItemEditDelete = new JMenuItem();
697 jMenuItemEditDelete.setText("Delete");
698 jMenuItemEditDelete.setMnemonic('D');
699 jMenuItemEditDelete.setVisible(false);
700 jMenuItemEditDelete.setEnabled(false);
701 jMenuItemEditDelete.addActionListener(this);
702 //
703 //Disabled first when no module is open
704 //
705 jMenuItemEditDelete.setEnabled(false);
706 }
707 return jMenuItemEditDelete;
708 }
709
710 /**
711 This method initializes jMenuFileNew
712
713 @return javax.swing.JMenuItem jMenuFileNew
714
715 **/
716 private JMenuItem getJMenuItemFileNew() {
717 if (jMenuItemFileNew == null) {
718 jMenuItemFileNew = new JMenuItem();
719 jMenuItemFileNew.setText("New...");
720 jMenuItemFileNew.setMnemonic('N');
721 jMenuItemFileNew.addActionListener(this);
722 }
723 return jMenuItemFileNew;
724 }
725
726 /**
727 This method initializes jMenuItemFileSave
728
729 @return javax.swing.JMenuItem jMenuItemModuleSave
730
731 **/
732 private JMenuItem getJMenuItemFileSave() {
733 if (jMenuItemFileSave == null) {
734 jMenuItemFileSave = new JMenuItem();
735 jMenuItemFileSave.setText("Save");
736 jMenuItemFileSave.setMnemonic('S');
737 jMenuItemFileSave.addActionListener(this);
738 jMenuItemFileSave.setEnabled(true);
739 }
740 return jMenuItemFileSave;
741 }
742
743 /**
744 This method initializes jMenuItemModuleClose
745
746 @return javax.swing.JMenuItem jMenuItemModuleClose
747
748 **/
749 private JMenuItem getJMenuItemFileClose() {
750 if (jMenuItemFileClose == null) {
751 jMenuItemFileClose = new JMenuItem();
752 jMenuItemFileClose.setText("Close");
753 jMenuItemFileClose.setMnemonic('C');
754 jMenuItemFileClose.setEnabled(true);
755 jMenuItemFileClose.addActionListener(this);
756 }
757 return jMenuItemFileClose;
758 }
759
760 /**
761 This method initializes jMenuTools
762 Reserved
763
764 @return javax.swing.JMenu jMenuTools
765
766 **/
767 private JMenu getJMenuTools() {
768 if (jMenuTools == null) {
769 //
770 // Set jMenuTools's attributes
771 //
772 jMenuTools = new JMenu();
773 jMenuTools.setText("Tools");
774 jMenuTools.setMnemonic('T');
775 jMenuTools.addMenuListener(this);
776
777 //
778 // Add sub menu items
779 //
780
781 jMenuTools.add(getJMenuItemToolsClone());
782 jMenuTools.add(getJMenuItemToolsCodeScan());
783 jMenuTools.addSeparator();
784
785 jMenuTools.add(getJMenuItemToolsToolChainConfiguration());
786 jMenuTools.add(getJMenuItemToolsBuildPreferences());
787 }
788 return jMenuTools;
789 }
790
791 /**
792 This method initializes jMenuWindow
793 Reserved
794
795 @return javax.swing.JMenu jMenuWindow
796
797 **/
798 private JMenu getJMenuWindow() {
799 if (jMenuWindow == null) {
800 //
801 // Set jMenuWindow's attribute
802 //
803 jMenuWindow = new JMenu();
804 jMenuWindow.setText("Window");
805 jMenuWindow.setMnemonic('W');
806 jMenuWindow.setVisible(false);
807
808 //
809 // Add sub menu items
810 //
811 jMenuWindow.add(getJMenuItemWindowDisplaySide());
812 jMenuWindow.add(getJMenuItemWindowDisplayTopBottom());
813 jMenuWindow.addSeparator();
814
815 jMenuWindow.add(getJMenuItemWindowTabView());
816 jMenuWindow.addSeparator();
817
818 jMenuWindow.add(getJMenuItemWindowSource());
819 jMenuWindow.add(getJMenuItemWindowXML());
820 jMenuWindow.addSeparator();
821
822 jMenuWindow.add(getJMenuItemWindowPreferences());
823 }
824 return jMenuWindow;
825 }
826
827 /**
828 This method initializes jPanelOperation
829 Reserved
830
831 @return javax.swing.JPanel jPanelOperation
832
833 **/
834 private JPanel getJPanelOperation() {
835 if (jPanelOperation == null) {
836 jPanelOperation = new JPanel();
837 jPanelOperation.setLayout(null);
838 jPanelOperation.setBounds(new java.awt.Rectangle(295, 520, 500, 25));
839 jPanelOperation.add(getJButtonOk(), null);
840 jPanelOperation.add(getJButtonCancel(), null);
841 jPanelOperation.setVisible(false);
842 }
843 return jPanelOperation;
844 }
845
846 /**
847 This method initializes jButtonOk
848 Reserved
849
850 @return javax.swing.JButton jButtonOk
851
852 **/
853 private JButton getJButtonOk() {
854 if (jButtonOk == null) {
855 jButtonOk = new JButton();
856 jButtonOk.setBounds(new java.awt.Rectangle(395, 2, 90, 20));
857 jButtonOk.setText("Ok");
858 jButtonOk.setEnabled(false);
859 jButtonOk.addActionListener(this);
860 }
861 return jButtonOk;
862 }
863
864 /**
865 This method initializes jButtonCancel
866 Reserved
867
868 @return javax.swing.JButton jButtonCancel
869
870 **/
871 private JButton getJButtonCancel() {
872 if (jButtonCancel == null) {
873 jButtonCancel = new JButton();
874 jButtonCancel.setBounds(new java.awt.Rectangle(395, 2, 90, 20));
875 jButtonCancel.setText("Cancel");
876 jButtonCancel.setEnabled(false);
877 jButtonCancel.addActionListener(this);
878 jButtonCancel.setVisible(false);
879 }
880 return jButtonCancel;
881 }
882
883 /**
884 This method initializes jMenuItemFileOpen
885
886 @return javax.swing.JMenuItem jMenuItemFileOpen
887
888 **/
889 private JMenuItem getJMenuItemFileOpen() {
890 if (jMenuItemFileOpen == null) {
891 jMenuItemFileOpen = new JMenuItem();
892 jMenuItemFileOpen.setText("Open...");
893 jMenuItemFileOpen.setMnemonic('O');
894 jMenuItemFileOpen.addActionListener(this);
895 }
896 return jMenuItemFileOpen;
897 }
898
899 /**
900 This method initializes jMenuItemFileCloseAll
901
902 @return javax.swing.JMenuItem jMenuItemFileOpen
903
904 **/
905 private JMenuItem getJMenuItemFileCloseAll() {
906 if (jMenuItemFileCloseAll == null) {
907 jMenuItemFileCloseAll = new JMenuItem();
908 jMenuItemFileCloseAll.setText("Close All");
909 jMenuItemFileCloseAll.setMnemonic('A');
910 jMenuItemFileCloseAll.setEnabled(true);
911 jMenuItemFileCloseAll.addActionListener(this);
912 }
913 return jMenuItemFileCloseAll;
914 }
915
916 /**
917 This method initializes jMenuItemFileSaveAll
918
919 @return javax.swing.JMenuItem jMenuItemFileSaveAll
920
921 **/
922 private JMenuItem getJMenuItemFileSaveAll() {
923 if (jMenuItemFileSaveAll == null) {
924 jMenuItemFileSaveAll = new JMenuItem();
925 jMenuItemFileSaveAll.setText("Save All");
926 jMenuItemFileSaveAll.setMnemonic('v');
927 jMenuItemFileSaveAll.setEnabled(true);
928 jMenuItemFileSaveAll.addActionListener(this);
929 }
930 return jMenuItemFileSaveAll;
931 }
932
933 /**
934 This method initializes jMenuItemFilePageSetup
935
936 @return javax.swing.JMenuItem
937
938 **/
939 private JMenuItem getJMenuItemFilePageSetup() {
940 if (jMenuItemFilePageSetup == null) {
941 jMenuItemFilePageSetup = new JMenuItem();
942 jMenuItemFilePageSetup.setText("Page Setup");
943 jMenuItemFilePageSetup.setMnemonic('u');
944 jMenuItemFilePageSetup.setEnabled(false);
945 jMenuItemFilePageSetup.addActionListener(this);
946 jMenuItemFilePageSetup.setVisible(false);
947 }
948 return jMenuItemFilePageSetup;
949 }
950
951 /**
952 This method initializes jMenuItemFilePrint
953
954 @return javax.swing.JMenuItem
955
956 **/
957 private JMenuItem getJMenuItemFilePrint() {
958 if (jMenuItemFilePrint == null) {
959 jMenuItemFilePrint = new JMenuItem();
960 jMenuItemFilePrint.setText("Print");
961 jMenuItemFilePrint.setMnemonic('P');
962 jMenuItemFilePrint.setEnabled(false);
963 jMenuItemFilePrint.addActionListener(this);
964 jMenuItemFilePrint.setVisible(false);
965 }
966 return jMenuItemFilePrint;
967 }
968
969 /**
970 This method initializes jMenuItemFileImport
971
972 @return javax.swing.JMenuItem
973
974 **/
975 private JMenuItem getJMenuItemFileImport() {
976 if (jMenuItemFileImport == null) {
977 jMenuItemFileImport = new JMenuItem();
978 jMenuItemFileImport.setText("Import");
979 jMenuItemFileImport.setMnemonic('I');
980 jMenuItemFileImport.setEnabled(false);
981 jMenuItemFileImport.addActionListener(this);
982 jMenuItemFileImport.setVisible(false);
983 }
984 return jMenuItemFileImport;
985 }
986
987 /**
988 This method initializes jMenuItemFileProperties
989
990 @return javax.swing.JMenuItem
991
992 **/
993 private JMenuItem getJMenuItemFileProperties() {
994 if (jMenuItemFileProperties == null) {
995 jMenuItemFileProperties = new JMenuItem();
996 jMenuItemFileProperties.setText("Properties");
997 jMenuItemFileProperties.setMnemonic('t');
998 jMenuItemFileProperties.setEnabled(false);
999 jMenuItemFileProperties.addActionListener(this);
1000 jMenuItemFileProperties.setVisible(false);
1001 }
1002 return jMenuItemFileProperties;
1003 }
1004
1005 /**
1006 This method initializes jMenuFileRecentFiles
1007
1008 @return javax.swing.JMenu
1009
1010 **/
1011 private JMenu getJMenuFileRecentFiles() {
1012 if (jMenuFileRecentFiles == null) {
1013 jMenuFileRecentFiles = new JMenu();
1014 jMenuFileRecentFiles.setText("Recent Files");
1015 jMenuFileRecentFiles.setMnemonic('F');
1016 jMenuFileRecentFiles.setEnabled(false);
1017 jMenuFileRecentFiles.addActionListener(this);
1018 jMenuFileRecentFiles.setVisible(false);
1019 }
1020 return jMenuFileRecentFiles;
1021 }
1022
1023 /**
1024 This method initializes jMenuItemEditUndo
1025
1026 @return javax.swing.JMenuItem
1027
1028 **/
1029 private JMenuItem getJMenuItemEditUndo() {
1030 if (jMenuItemEditUndo == null) {
1031 jMenuItemEditUndo = new JMenuItem();
1032 jMenuItemEditUndo.setText("Undo");
1033 jMenuItemEditUndo.setMnemonic('U');
1034 jMenuItemEditUndo.setEnabled(false);
1035 jMenuItemEditUndo.setVisible(false);
1036 jMenuItemEditUndo.addActionListener(this);
1037 }
1038 return jMenuItemEditUndo;
1039 }
1040
1041 /**
1042 This method initializes jMenuItemEditRedo
1043
1044 @return javax.swing.JMenuItem
1045
1046 **/
1047 private JMenuItem getJMenuItemEditRedo() {
1048 if (jMenuItemEditRedo == null) {
1049 jMenuItemEditRedo = new JMenuItem();
1050 jMenuItemEditRedo.setText("Redo");
1051 jMenuItemEditRedo.setMnemonic('R');
1052 jMenuItemEditRedo.setEnabled(false);
1053 jMenuItemEditRedo.setVisible(false);
1054 jMenuItemEditRedo.addActionListener(this);
1055 }
1056 return jMenuItemEditRedo;
1057 }
1058
1059 /**
1060 This method initializes jMenuItemEditCut
1061
1062 @return javax.swing.JMenuItem
1063
1064 **/
1065 private JMenuItem getJMenuItemEditCut() {
1066 if (jMenuItemEditCut == null) {
1067 jMenuItemEditCut = new JMenuItem();
1068 jMenuItemEditCut.setText("Cut");
1069 jMenuItemEditCut.setMnemonic('t');
1070 jMenuItemEditCut.setEnabled(false);
1071 jMenuItemEditCut.setVisible(false);
1072 jMenuItemEditCut.addActionListener(this);
1073 }
1074 return jMenuItemEditCut;
1075 }
1076
1077 /**
1078 This method initializes jMenuItemEditCopy
1079
1080 @return javax.swing.JMenuItem
1081
1082 **/
1083 private JMenuItem getJMenuItemEditCopy() {
1084 if (jMenuItemEditCopy == null) {
1085 jMenuItemEditCopy = new JMenuItem();
1086 jMenuItemEditCopy.setText("Copy");
1087 jMenuItemEditCopy.setMnemonic('C');
1088 jMenuItemEditCopy.setEnabled(false);
1089 jMenuItemEditCopy.setVisible(false);
1090 jMenuItemEditCopy.addActionListener(this);
1091 }
1092 return jMenuItemEditCopy;
1093 }
1094
1095 /**
1096 This method initializes jMenuItemEditPaste
1097
1098 return javax.swing.JMenuItem
1099
1100 **/
1101 private JMenuItem getJMenuItemEditPaste() {
1102 if (jMenuItemEditPaste == null) {
1103 jMenuItemEditPaste = new JMenuItem();
1104 jMenuItemEditPaste.setText("Paste");
1105 jMenuItemEditPaste.setMnemonic('P');
1106 jMenuItemEditPaste.setEnabled(false);
1107 jMenuItemEditPaste.setVisible(false);
1108 jMenuItemEditPaste.addActionListener(this);
1109 }
1110 return jMenuItemEditPaste;
1111 }
1112
1113 /**
1114 This method initializes jMenuItem
1115
1116 @return javax.swing.JMenuItem
1117
1118 **/
1119 private JMenuItem getJMenuItemEditSelectAll() {
1120 if (jMenuItemEditSelectAll == null) {
1121 jMenuItemEditSelectAll = new JMenuItem();
1122 jMenuItemEditSelectAll.setText("Select All");
1123 jMenuItemEditSelectAll.setMnemonic('A');
1124 jMenuItemEditSelectAll.setEnabled(false);
1125 jMenuItemEditSelectAll.setVisible(false);
1126 jMenuItemEditSelectAll.addActionListener(this);
1127 }
1128 return jMenuItemEditSelectAll;
1129 }
1130
1131 /**
1132 This method initializes jMenuItemEditFindNext
1133
1134 @return javax.swing.JMenuItem
1135
1136 **/
1137 private JMenuItem getJMenuItemEditFindNext() {
1138 if (jMenuItemEditFindNext == null) {
1139 jMenuItemEditFindNext = new JMenuItem();
1140 jMenuItemEditFindNext.setText("Find Next");
1141 jMenuItemEditFindNext.setMnemonic('n');
1142 jMenuItemEditFindNext.setEnabled(false);
1143 jMenuItemEditFindNext.setVisible(false);
1144 jMenuItemEditFindNext.addActionListener(this);
1145 }
1146 return jMenuItemEditFindNext;
1147 }
1148
1149 /**
1150 This method initializes jMenuView
1151
1152 @return javax.swing.JMenu
1153
1154 **/
1155 private JMenu getJMenuView() {
1156 if (jMenuView == null) {
1157 //
1158 // Set jMenuView's attributes
1159 //
1160 jMenuView = new JMenu();
1161 jMenuView.setText("View");
1162 jMenuView.setMnemonic('V');
1163 jMenuView.setVisible(false);
1164
1165 //
1166 // Add sub menu items
1167 //
1168 jMenuView.add(getJMenuViewToolbars());
1169 jMenuView.add(getJMenuItemViewAdvanced());
1170 jMenuView.add(getJMenuItemViewStandard());
1171 jMenuView.add(getJMenuItemViewXML());
1172 }
1173 return jMenuView;
1174 }
1175
1176 /**
1177 This method initializes jMenuViewToolbars
1178
1179 @return javax.swing.JMenu
1180
1181 **/
1182 private JMenu getJMenuViewToolbars() {
1183 if (jMenuViewToolbars == null) {
1184 jMenuViewToolbars = new JMenu();
1185 jMenuViewToolbars.setText("Toolbars");
1186 jMenuViewToolbars.setMnemonic('T');
1187
1188 jMenuViewToolbars.add(getJCheckBoxMenuItemViewToolbarsFile());
1189 jMenuViewToolbars.add(getJCheckBoxMenuItemViewToolbarsEdit());
1190 jMenuViewToolbars.add(getJCheckBoxMenuItemViewToolbarsWindow());
1191 }
1192 return jMenuViewToolbars;
1193 }
1194
1195 /**
1196 This method initializes jCheckBoxMenuItemViewToolbarsFile
1197
1198 @return javax.swing.JCheckBoxMenuItem
1199
1200 **/
1201 private JCheckBoxMenuItem getJCheckBoxMenuItemViewToolbarsFile() {
1202 if (jCheckBoxMenuItemViewToolbarsFile == null) {
1203 jCheckBoxMenuItemViewToolbarsFile = new JCheckBoxMenuItem();
1204 jCheckBoxMenuItemViewToolbarsFile.setText("File");
1205 jCheckBoxMenuItemViewToolbarsFile.setEnabled(false);
1206 jCheckBoxMenuItemViewToolbarsFile.addActionListener(this);
1207 }
1208 return jCheckBoxMenuItemViewToolbarsFile;
1209 }
1210
1211 /**
1212 This method initializes jCheckBoxMenuItemViewToolbarsEdit
1213
1214 @return javax.swing.JCheckBoxMenuItem
1215
1216 **/
1217 private JCheckBoxMenuItem getJCheckBoxMenuItemViewToolbarsEdit() {
1218 if (jCheckBoxMenuItemViewToolbarsEdit == null) {
1219 jCheckBoxMenuItemViewToolbarsEdit = new JCheckBoxMenuItem();
1220 jCheckBoxMenuItemViewToolbarsEdit.setText("Edit");
1221 jCheckBoxMenuItemViewToolbarsEdit.setEnabled(false);
1222 jCheckBoxMenuItemViewToolbarsEdit.addActionListener(this);
1223 }
1224 return jCheckBoxMenuItemViewToolbarsEdit;
1225 }
1226
1227 /**
1228 This method initializes jCheckBoxMenuItemViewToolbarsWindow
1229
1230 @return javax.swing.JCheckBoxMenuItem
1231
1232 **/
1233 private JCheckBoxMenuItem getJCheckBoxMenuItemViewToolbarsWindow() {
1234 if (jCheckBoxMenuItemViewToolbarsWindow == null) {
1235 jCheckBoxMenuItemViewToolbarsWindow = new JCheckBoxMenuItem();
1236 jCheckBoxMenuItemViewToolbarsWindow.setText("Window");
1237 jCheckBoxMenuItemViewToolbarsWindow.setEnabled(false);
1238 jCheckBoxMenuItemViewToolbarsWindow.addActionListener(this);
1239 }
1240 return jCheckBoxMenuItemViewToolbarsWindow;
1241 }
1242
1243 /**
1244 This method initializes jMenuItemStandard
1245
1246 @return javax.swing.JMenuItem
1247
1248 **/
1249 private JMenuItem getJMenuItemViewStandard() {
1250 if (jMenuItemViewStandard == null) {
1251 jMenuItemViewStandard = new JMenuItem();
1252 jMenuItemViewStandard.setText("Standard");
1253 jMenuItemViewStandard.setMnemonic('S');
1254 jMenuItemViewStandard.setEnabled(false);
1255 jMenuItemViewStandard.addActionListener(this);
1256 }
1257 return jMenuItemViewStandard;
1258 }
1259
1260 /**
1261 This method initializes jMenuItemAdvanced
1262
1263 @return javax.swing.JMenuItem
1264
1265 **/
1266 private JMenuItem getJMenuItemViewAdvanced() {
1267 if (jMenuItemViewAdvanced == null) {
1268 jMenuItemViewAdvanced = new JMenuItem();
1269 jMenuItemViewAdvanced.setText("Advanced");
1270 jMenuItemViewAdvanced.setMnemonic('A');
1271 jMenuItemViewAdvanced.setEnabled(false);
1272 jMenuItemViewAdvanced.addActionListener(this);
1273 }
1274 return jMenuItemViewAdvanced;
1275 }
1276
1277 /**
1278 This method initializes jMenuProject
1279
1280 @return javax.swing.JMenu
1281
1282 **/
1283 private JMenu getJMenuProject() {
1284 if (jMenuProject == null) {
1285 //
1286 // Set jMenuProject's attributes
1287 //
1288 jMenuProject = new JMenu();
1289 jMenuProject.setText("Project");
1290 jMenuProject.setMnemonic('P');
1291
1292 //
1293 // Add sub menu items
1294 //
1295 jMenuProject.add(getJMenuItemProjectAdmin());
1296
1297 jMenuProject.add(getJMenuItemProjectChangeWorkspace());
1298 jMenuProject.addSeparator();
1299
1300 jMenuProject.add(getJMenuItemProjectCreateFar());
1301 jMenuProject.add(getJMenuItemProjectInstallFar());
1302 jMenuProject.add(getJMenuItemProjectUpdateFar());
1303 jMenuProject.add(getJMenuItemProjectRemoveFar());
1304
1305 }
1306 return jMenuProject;
1307 }
1308
1309 /**
1310 This method initializes jMenuItemProjectAdmin
1311
1312 @return javax.swing.JMenuItem
1313
1314 **/
1315 private JMenuItem getJMenuItemProjectAdmin() {
1316 if (jMenuItemProjectAdmin == null) {
1317 jMenuItemProjectAdmin = new JMenuItem();
1318 jMenuItemProjectAdmin.setText("Admin...");
1319 jMenuItemProjectAdmin.setMnemonic('A');
1320 jMenuItemProjectAdmin.setEnabled(false);
1321 jMenuItemProjectAdmin.addActionListener(this);
1322 jMenuItemProjectAdmin.setVisible(false);
1323 }
1324 return jMenuItemProjectAdmin;
1325 }
1326
1327 /**
1328 This method initializes jMenuItemProjectChangeWorkspace
1329
1330 @return javax.swing.JMenuItem
1331
1332 **/
1333 private JMenuItem getJMenuItemProjectChangeWorkspace() {
1334 if (jMenuItemProjectChangeWorkspace == null) {
1335 jMenuItemProjectChangeWorkspace = new JMenuItem();
1336 jMenuItemProjectChangeWorkspace.setText("Change WORKSPACE...");
1337 jMenuItemProjectChangeWorkspace.setMnemonic('W');
1338 jMenuItemProjectChangeWorkspace.setEnabled(true);
1339 jMenuItemProjectChangeWorkspace.addActionListener(this);
1340 }
1341 return jMenuItemProjectChangeWorkspace;
1342 }
1343
1344 /**
1345 This method initializes jMenuProjectBuildPreferences
1346
1347 @return javax.swing.JMenu
1348
1349 **/
1350 private JMenuItem getJMenuItemToolsBuildPreferences() {
1351 if (jMenuItemToolsBuildPreferences == null) {
1352 jMenuItemToolsBuildPreferences = new JMenuItem();
1353 jMenuItemToolsBuildPreferences.setText("Build Preferences");
1354 jMenuItemToolsBuildPreferences.setMnemonic('P');
1355 jMenuItemToolsBuildPreferences.setEnabled(true);
1356 jMenuItemToolsBuildPreferences.addActionListener(this);
1357 }
1358 return jMenuItemToolsBuildPreferences;
1359 }
1360
1361 /**
1362 This method initializes jMenuItemToolsToolChainConfiguration
1363
1364 @return javax.swing.JMenuItem
1365
1366 **/
1367 private JMenuItem getJMenuItemToolsToolChainConfiguration() {
1368 if (jMenuItemToolsToolChainConfiguration == null) {
1369 jMenuItemToolsToolChainConfiguration = new JMenuItem();
1370 jMenuItemToolsToolChainConfiguration.setText("Tool Chain Configuration...");
1371 jMenuItemToolsToolChainConfiguration.setMnemonic('C');
1372 jMenuItemToolsToolChainConfiguration.addActionListener(this);
1373 }
1374 return jMenuItemToolsToolChainConfiguration;
1375 }
1376
1377 /**
1378 This method initializes jMenuItemToolsClone
1379
1380 @return javax.swing.JMenuItem
1381
1382 **/
1383 private JMenuItem getJMenuItemToolsClone() {
1384 if (jMenuItemToolsClone == null) {
1385 jMenuItemToolsClone = new JMenuItem();
1386 jMenuItemToolsClone.setText("Clone...");
1387 jMenuItemToolsClone.setMnemonic('l');
1388 jMenuItemToolsClone.setEnabled(true);
1389 jMenuItemToolsClone.addActionListener(this);
1390 }
1391 return jMenuItemToolsClone;
1392 }
1393
1394 /**
1395 This method initializes jMenuItemToolsCodeScan
1396
1397 @return javax.swing.JMenuItem
1398
1399 **/
1400 private JMenuItem getJMenuItemToolsCodeScan() {
1401 if (jMenuItemToolsCodeScan == null) {
1402 jMenuItemToolsCodeScan = new JMenuItem();
1403 jMenuItemToolsCodeScan.setText("Code Scan...");
1404 jMenuItemToolsCodeScan.setMnemonic('S');
1405 jMenuItemToolsCodeScan.setEnabled(false);
1406 jMenuItemToolsCodeScan.addActionListener(this);
1407 jMenuItemToolsCodeScan.setVisible(false);
1408 }
1409 return jMenuItemToolsCodeScan;
1410 }
1411
1412 /**
1413 This method initializes jMenuItemWindowSplitVertical
1414
1415 @return javax.swing.JMenuItem
1416
1417 **/
1418 private JMenuItem getJMenuItemWindowDisplaySide() {
1419 if (jMenuItemWindowDisplaySide == null) {
1420 jMenuItemWindowDisplaySide = new JMenuItem();
1421 jMenuItemWindowDisplaySide.setText("Display Side by Side");
1422 jMenuItemWindowDisplaySide.setMnemonic('S');
1423 jMenuItemWindowDisplaySide.setEnabled(false);
1424 jMenuItemWindowDisplaySide.addActionListener(this);
1425 }
1426 return jMenuItemWindowDisplaySide;
1427 }
1428
1429 /**
1430 This method initializes jMenuItemWindowSplitHorizontal
1431
1432 @return javax.swing.JMenuItem
1433
1434 **/
1435 private JMenuItem getJMenuItemWindowDisplayTopBottom() {
1436 if (jMenuItemWindowDisplayTopBottom == null) {
1437 jMenuItemWindowDisplayTopBottom = new JMenuItem();
1438 jMenuItemWindowDisplayTopBottom.setText("Display Top and Bottom");
1439 jMenuItemWindowDisplayTopBottom.setMnemonic('B');
1440 jMenuItemWindowDisplayTopBottom.setEnabled(false);
1441 jMenuItemWindowDisplayTopBottom.addActionListener(this);
1442 }
1443 return jMenuItemWindowDisplayTopBottom;
1444 }
1445
1446 /**
1447 This method initializes jMenuItemViewXML
1448
1449 @return javax.swing.JMenuItem
1450
1451 **/
1452 private JMenuItem getJMenuItemViewXML() {
1453 if (jMenuItemViewXML == null) {
1454 jMenuItemViewXML = new JMenuItem();
1455 jMenuItemViewXML.setText("XML");
1456 jMenuItemViewXML.setMnemonic('X');
1457 jMenuItemViewXML.setEnabled(false);
1458 jMenuItemViewXML.addActionListener(this);
1459 }
1460 return jMenuItemViewXML;
1461 }
1462
1463 /**
1464 This method initializes jMenuItemWindowTabView
1465
1466 @return javax.swing.JMenuItem
1467
1468 **/
1469 private JMenuItem getJMenuItemWindowTabView() {
1470 if (jMenuItemWindowTabView == null) {
1471 jMenuItemWindowTabView = new JMenuItem();
1472 jMenuItemWindowTabView.setText("Tab View");
1473 jMenuItemWindowTabView.setMnemonic('T');
1474 jMenuItemWindowTabView.setEnabled(false);
1475 jMenuItemWindowTabView.addActionListener(this);
1476 }
1477 return jMenuItemWindowTabView;
1478 }
1479
1480 /**
1481 This method initializes jMenuItemWindowSource
1482
1483 @return javax.swing.JMenuItem
1484
1485 **/
1486 private JMenuItem getJMenuItemWindowSource() {
1487 if (jMenuItemWindowSource == null) {
1488 jMenuItemWindowSource = new JMenuItem();
1489 jMenuItemWindowSource.setText("Source");
1490 jMenuItemWindowSource.setMnemonic('S');
1491 jMenuItemWindowSource.setEnabled(false);
1492 jMenuItemWindowSource.addActionListener(this);
1493 }
1494 return jMenuItemWindowSource;
1495 }
1496
1497 /**
1498 This method initializes jMenuItemWindowXML
1499
1500 @return javax.swing.JMenuItem
1501
1502 **/
1503 private JMenuItem getJMenuItemWindowXML() {
1504 if (jMenuItemWindowXML == null) {
1505 jMenuItemWindowXML = new JMenuItem();
1506 jMenuItemWindowXML.setText("XML");
1507 jMenuItemWindowXML.setMnemonic('X');
1508 jMenuItemWindowXML.setEnabled(false);
1509 jMenuItemWindowXML.addActionListener(this);
1510 }
1511 return jMenuItemWindowXML;
1512 }
1513
1514 /**
1515 This method initializes jMenuItemWindowPreferences
1516
1517 @return javax.swing.JMenuItem
1518
1519 **/
1520 private JMenuItem getJMenuItemWindowPreferences() {
1521 if (jMenuItemWindowPreferences == null) {
1522 jMenuItemWindowPreferences = new JMenuItem();
1523 jMenuItemWindowPreferences.setText("Preferences");
1524 jMenuItemWindowPreferences.setMnemonic('P');
1525 jMenuItemWindowPreferences.setEnabled(false);
1526 jMenuItemWindowPreferences.addActionListener(this);
1527 }
1528 return jMenuItemWindowPreferences;
1529 }
1530
1531 /**
1532 This method initializes jMenuItemHelpContents
1533
1534 @return javax.swing.JMenuItem
1535
1536 **/
1537 private JMenuItem getJMenuItemHelpContents() {
1538 if (jMenuItemHelpContents == null) {
1539 jMenuItemHelpContents = new JMenuItem();
1540 jMenuItemHelpContents.setText("Contents");
1541 jMenuItemHelpContents.setMnemonic('C');
1542 jMenuItemHelpContents.setEnabled(false);
1543 jMenuItemHelpContents.addActionListener(this);
1544 jMenuItemHelpContents.setVisible(false);
1545 }
1546 return jMenuItemHelpContents;
1547 }
1548
1549 /**
1550 This method initializes jMenuItemHelpIndex
1551
1552 @return javax.swing.JMenuItem
1553
1554 **/
1555 private JMenuItem getJMenuItemHelpIndex() {
1556 if (jMenuItemHelpIndex == null) {
1557 jMenuItemHelpIndex = new JMenuItem();
1558 jMenuItemHelpIndex.setText("Index");
1559 jMenuItemHelpIndex.setMnemonic('I');
1560 jMenuItemHelpIndex.setEnabled(false);
1561 jMenuItemHelpIndex.addActionListener(this);
1562 jMenuItemHelpIndex.setVisible(false);
1563 }
1564 return jMenuItemHelpIndex;
1565 }
1566
1567 /**
1568 This method initializes jMenuItemHelpSearch
1569
1570 @return javax.swing.JMenuItem
1571
1572 */
1573 private JMenuItem getJMenuItemHelpSearch() {
1574 if (jMenuItemHelpSearch == null) {
1575 jMenuItemHelpSearch = new JMenuItem();
1576 jMenuItemHelpSearch.setText("Search");
1577 jMenuItemHelpSearch.setMnemonic('S');
1578 jMenuItemHelpSearch.setEnabled(false);
1579 jMenuItemHelpSearch.addActionListener(this);
1580 jMenuItemHelpSearch.setVisible(false);
1581 }
1582 return jMenuItemHelpSearch;
1583 }
1584
1585 /**
1586 * This method initializes jMenuItemToolsInstallPackage
1587 *
1588 * @return javax.swing.JMenuItem
1589 */
1590 private JMenuItem getJMenuItemProjectInstallFar() {
1591 if (jMenuItemProjectInstallFar == null) {
1592 jMenuItemProjectInstallFar = new JMenuItem();
1593 jMenuItemProjectInstallFar.setText("Install FAR");
1594 jMenuItemProjectInstallFar.setMnemonic('I');
1595 jMenuItemProjectInstallFar.setEnabled(true);
1596 jMenuItemProjectInstallFar.addActionListener(this);
1597 }
1598 return jMenuItemProjectInstallFar;
1599 }
1600
1601 /**
1602 * This method initializes jMenuItemToolsUpdatePackage
1603 *
1604 * @return javax.swing.JMenuItem
1605 */
1606 private JMenuItem getJMenuItemProjectUpdateFar() {
1607 if (jMenuItemProjectUpdateFar == null) {
1608 jMenuItemProjectUpdateFar = new JMenuItem();
1609 jMenuItemProjectUpdateFar.setText("Update FAR");
1610 jMenuItemProjectUpdateFar.setMnemonic('U');
1611 jMenuItemProjectUpdateFar.setEnabled(true);
1612 jMenuItemProjectUpdateFar.addActionListener(this);
1613 jMenuItemProjectUpdateFar.setVisible(true);
1614 }
1615 return jMenuItemProjectUpdateFar;
1616 }
1617
1618 /**
1619 * This method initializes jMenuItemRemovePackage
1620 *
1621 * @return javax.swing.JMenuItem
1622 */
1623 private JMenuItem getJMenuItemProjectRemoveFar() {
1624 if (jMenuItemProjectRemoveFar == null) {
1625 jMenuItemProjectRemoveFar = new JMenuItem();
1626 jMenuItemProjectRemoveFar.setText("Remove FAR");
1627 jMenuItemProjectRemoveFar.setMnemonic('R');
1628 jMenuItemProjectRemoveFar.setEnabled(true);
1629 jMenuItemProjectRemoveFar.addActionListener(this);
1630 }
1631 return jMenuItemProjectRemoveFar;
1632 }
1633
1634 /**
1635 * This method initializes jMenuItemProjectCreateFar
1636 *
1637 * @return javax.swing.JMenuItem
1638 */
1639 private JMenuItem getJMenuItemProjectCreateFar() {
1640 if (jMenuItemProjectCreateFar == null) {
1641 jMenuItemProjectCreateFar = new JMenuItem();
1642 jMenuItemProjectCreateFar.setText("Create FAR");
1643 jMenuItemProjectCreateFar.setMnemonic('C');
1644 jMenuItemProjectCreateFar.addActionListener(this);
1645 }
1646 return jMenuItemProjectCreateFar;
1647 }
1648
1649 /**
1650 * This method initializes jMenuEditFind
1651 *
1652 * @return javax.swing.JMenu
1653 */
1654 private JMenu getJMenuEditFind() {
1655 if (jMenuEditFind == null) {
1656 jMenuEditFind = new JMenu();
1657 jMenuEditFind.setText("Find");
1658 jMenuEditFind.setMnemonic('F');
1659
1660 jMenuEditFind.add(getJMenuItemEditFindPpi());
1661 jMenuEditFind.add(getJMenuItemEditFindProtocol());
1662 jMenuEditFind.add(getJMenuItemEditFindGuid());
1663 jMenuEditFind.add(getJMenuItemEditFindPcd());
1664 jMenuEditFind.add(getJMenuItemEditFindLibraryClass());
1665 jMenuEditFind.add(getJMenuItemEditFindLibraryInstance());
1666 }
1667 return jMenuEditFind;
1668 }
1669
1670 /**
1671 * This method initializes jMenuItemEditFindPcd
1672 *
1673 * @return javax.swing.JMenuItem
1674 */
1675 private JMenuItem getJMenuItemEditFindPcd() {
1676 if (jMenuItemEditFindPcd == null) {
1677 jMenuItemEditFindPcd = new JMenuItem();
1678 jMenuItemEditFindPcd.setText("All PCD entries");
1679 jMenuItemEditFindPcd.setMnemonic('P');
1680 jMenuItemEditFindPcd.addActionListener(this);
1681 }
1682 return jMenuItemEditFindPcd;
1683 }
1684
1685 /**
1686 * This method initializes jMenuItemEditFindLibraryClass
1687 *
1688 * @return javax.swing.JMenuItem
1689 */
1690 private JMenuItem getJMenuItemEditFindLibraryClass() {
1691 if (jMenuItemEditFindLibraryClass == null) {
1692 jMenuItemEditFindLibraryClass = new JMenuItem();
1693 jMenuItemEditFindLibraryClass.setText("All Library Classes");
1694 jMenuItemEditFindLibraryClass.setMnemonic('C');
1695 jMenuItemEditFindLibraryClass.addActionListener(this);
1696 }
1697 return jMenuItemEditFindLibraryClass;
1698 }
1699
1700 /**
1701 * This method initializes jMenuItemEditFindPpi
1702 *
1703 * @return javax.swing.JMenuItem
1704 */
1705 private JMenuItem getJMenuItemEditFindPpi() {
1706 if (jMenuItemEditFindPpi == null) {
1707 jMenuItemEditFindPpi = new JMenuItem();
1708 jMenuItemEditFindPpi.setText("All PPIs");
1709 jMenuItemEditFindPpi.setMnemonic('I');
1710 jMenuItemEditFindPpi.addActionListener(this);
1711 }
1712 return jMenuItemEditFindPpi;
1713 }
1714
1715 /**
1716 * This method initializes jMenuItemEditFindProtocol
1717 *
1718 * @return javax.swing.JMenuItem
1719 */
1720 private JMenuItem getJMenuItemEditFindProtocol() {
1721 if (jMenuItemEditFindProtocol == null) {
1722 jMenuItemEditFindProtocol = new JMenuItem();
1723 jMenuItemEditFindProtocol.setText("All Protocols");
1724 jMenuItemEditFindProtocol.setMnemonic('r');
1725 jMenuItemEditFindProtocol.addActionListener(this);
1726 }
1727 return jMenuItemEditFindProtocol;
1728 }
1729
1730 /**
1731 * This method initializes jMenuItemEditFindGuid
1732 *
1733 * @return javax.swing.JMenuItem
1734 */
1735 private JMenuItem getJMenuItemEditFindGuid() {
1736 if (jMenuItemEditFindGuid == null) {
1737 jMenuItemEditFindGuid = new JMenuItem();
1738 jMenuItemEditFindGuid.setText("All GUIDs");
1739 jMenuItemEditFindGuid.setMnemonic('G');
1740 jMenuItemEditFindGuid.addActionListener(this);
1741 }
1742 return jMenuItemEditFindGuid;
1743 }
1744
1745 /**
1746 * This method initializes jMenuItemEditFindLibraryInstance
1747 *
1748 * @return javax.swing.JMenuItem
1749 */
1750 private JMenuItem getJMenuItemEditFindLibraryInstance() {
1751 if (jMenuItemEditFindLibraryInstance == null) {
1752 jMenuItemEditFindLibraryInstance = new JMenuItem();
1753 jMenuItemEditFindLibraryInstance.setText("All Library Instances");
1754 jMenuItemEditFindLibraryInstance.setMnemonic('n');
1755 jMenuItemEditFindLibraryInstance.addActionListener(this);
1756 jMenuItemEditFindLibraryInstance.setVisible(false);
1757 }
1758 return jMenuItemEditFindLibraryInstance;
1759 }
1760
1761 /* (non-Javadoc)
1762 * @see org.tianocore.packaging.common.ui.IFrame#main(java.lang.String[])
1763 *
1764 * Main class, start the GUI
1765 *
1766 */
1767 public static void main(String[] args) {
1768 FrameworkWizardUI module = FrameworkWizardUI.getInstance();
1769 module.setVisible(true);
1770 }
1771
1772 /**
1773 This is the default constructor
1774
1775 **/
1776 public FrameworkWizardUI() {
1777 super();
1778 init();
1779 }
1780
1781 /**
1782 This method initializes this
1783
1784
1785 **/
1786 private void init() {
1787 //
1788 // Show splash screen
1789 //
1790 SplashScreen ss = new SplashScreen();
1791 ss.setVisible(true);
1792
1793 //
1794 // Set current workspace and check
1795 // Check if exists WORKSPACE
1796 //
1797 //
1798 Workspace.setCurrentWorkspace(System.getenv("WORKSPACE"));
1799 if (!Workspace.checkCurrentWorkspace()) {
1800 JOptionPane.showConfirmDialog(null, "Workspace is not setup correctly. Please setup first.", "Warning",
1801 JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
1802 this.dispose();
1803 System.exit(0);
1804 }
1805
1806 //
1807 // Init Global Data
1808 //
1809 GlobalData.init();
1810
1811 //
1812 // Close splash screen
1813 //
1814 ss.dispose();
1815
1816 //
1817 // Init the frame
1818 //
1819 this.setSize(DataType.MAIN_FRAME_PREFERRED_SIZE_WIDTH, DataType.MAIN_FRAME_PREFERRED_SIZE_HEIGHT);
1820 this.setResizable(true);
1821 this.setJMenuBar(getjJMenuBar());
1822 this.setContentPane(getJContentPane());
1823 this.setTitle(DataType.PROJECT_NAME + " " + DataType.PROJECT_VERSION + " " + "- ["
1824 + Workspace.getCurrentWorkspace() + "]");
1825 this.setExitType(1);
1826
1827 //
1828 // max the window
1829 //
1830 this.setExtendedState(JFrame.MAXIMIZED_BOTH);
1831 }
1832
1833 /**
1834 This method initializes jContentPane
1835
1836 @return javax.swing.JPanel jContentPane
1837
1838 **/
1839 private JPanel getJContentPane() {
1840 if (jContentPane == null) {
1841 jContentPane = new JPanel();
1842 jContentPane.setLayout(null);
1843 jContentPane.add(getJPanelOperation(), null);
1844 jContentPane.add(getJSplitPane(), null);
1845 }
1846 return jContentPane;
1847 }
1848
1849 /* (non-Javadoc)
1850 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
1851 *
1852 * Override actionPerformed to listen all actions
1853 *
1854 */
1855 public void actionPerformed(ActionEvent arg0) {
1856 //
1857 // Operations of Menu
1858 //
1859 if (arg0.getSource() == this.jMenuItemFileNew) {
1860 this.fileNew();
1861 }
1862
1863 if (arg0.getSource() == this.jMenuItemFileOpen) {
1864 this.open();
1865 }
1866
1867 if (arg0.getSource() == this.jMenuItemFileClose) {
1868 this.close();
1869 }
1870
1871 if (arg0.getSource() == this.jMenuItemFileCloseAll) {
1872 this.closeAll();
1873 this.makeEmptyTree();
1874 }
1875
1876 if (arg0.getSource() == this.jMenuItemFileSave) {
1877 this.save();
1878 }
1879
1880 if (arg0.getSource() == this.jMenuItemFileSaveAs) {
1881 this.saveAs();
1882 }
1883
1884 if (arg0.getSource() == this.jMenuItemFileSaveAll) {
1885 this.saveAll();
1886 }
1887
1888 if (arg0.getSource() == this.jMenuItemFileRefresh) {
1889 this.closeAll();
1890 this.refresh();
1891 this.makeEmptyTree();
1892 }
1893
1894 if (arg0.getSource() == this.jMenuItemFileExit) {
1895 this.exit();
1896 }
1897
1898 if (arg0.getSource() == this.jMenuItemEditFindPpi) {
1899 this.findPpi();
1900 }
1901
1902 if (arg0.getSource() == this.jMenuItemEditFindProtocol) {
1903 this.findProtocol();
1904 }
1905
1906 if (arg0.getSource() == this.jMenuItemEditFindGuid) {
1907 this.findGuid();
1908 }
1909
1910 if (arg0.getSource() == this.jMenuItemEditFindPcd) {
1911 this.findPcd();
1912 }
1913
1914 if (arg0.getSource() == this.jMenuItemEditFindLibraryClass) {
1915 this.findLibraryClass();
1916 }
1917
1918 if (arg0.getSource() == this.jMenuItemEditFindLibraryInstance) {
1919 this.findLibraryInstance();
1920 }
1921
1922 if (arg0.getSource() == jMenuItemToolsBuildPreferences) {
1923 configBuildPreferences();
1924 }
1925
1926 if (arg0.getSource() == this.jMenuItemProjectChangeWorkspace) {
1927 this.changeWorkspace();
1928 }
1929
1930 if (arg0.getSource() == this.jMenuItemProjectCreateFar) {
1931 this.createFar();
1932 }
1933
1934 if (arg0.getSource() == this.jMenuItemProjectInstallFar) {
1935 this.installFar();
1936 }
1937
1938 if (arg0.getSource() == this.jMenuItemProjectRemoveFar) {
1939 this.removeFar();
1940 }
1941
1942 if (arg0.getSource() == this.jMenuItemProjectUpdateFar) {
1943 this.updateFar();
1944 }
1945
1946 if (arg0.getSource() == this.jMenuItemToolsClone) {
1947 this.cloneItem();
1948 }
1949
1950 if (arg0.getSource() == this.jMenuItemToolsToolChainConfiguration) {
1951 this.setupToolChainConfiguration();
1952 }
1953
1954 if (arg0.getSource() == this.jMenuItemHelpAbout) {
1955 About a = new About(this, true);
1956 int result = a.showDialog();
1957 if (result == DataType.RETURN_TYPE_OK) {
1958 a.dispose();
1959 }
1960 }
1961 }
1962
1963 /**
1964 Create an empty tree if no file is open
1965
1966 **/
1967 private void makeEmptyTree() {
1968 //
1969 // Make root
1970 //
1971 dmtnRoot = new IDefaultMutableTreeNode("WORKSPACE", IDefaultMutableTreeNode.WORKSPACE, false, null, null);
1972
1973 //
1974 // Make Module Description
1975 //
1976 dmtnModuleDescription = new IDefaultMutableTreeNode("Modules", IDefaultMutableTreeNode.MODULE_DESCRIPTION,
1977 false, null, dmtnRoot);
1978
1979 //
1980 // First add package
1981 //
1982 if (GlobalData.vPackageList.size() > 0) {
1983 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
1984 IDefaultMutableTreeNode dmtnModulePackage = null;
1985 IDefaultMutableTreeNode dmtnModulePackageLibrary = null;
1986 IDefaultMutableTreeNode dmtnModulePackageModule = null;
1987
1988 dmtnModulePackage = new IDefaultMutableTreeNode(GlobalData.vPackageList.elementAt(index).getName(),
1989 IDefaultMutableTreeNode.MODULE_PACKAGE, false,
1990 GlobalData.vPackageList.elementAt(index),
1991 this.dmtnModuleDescription);
1992 dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library",
1993 IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY,
1994 false, GlobalData.vPackageList.elementAt(index),
1995 this.dmtnModuleDescription);
1996 dmtnModulePackageModule = new IDefaultMutableTreeNode("Module",
1997 IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE,
1998 false, GlobalData.vPackageList.elementAt(index),
1999 this.dmtnModuleDescription);
2000 //
2001 // And then add each module in its package
2002 //
2003 Vector<ModuleIdentification> vModule = wt.getAllModules(GlobalData.vPackageList.elementAt(index));
2004 for (int indexJ = 0; indexJ < vModule.size(); indexJ++) {
2005 if (vModule.get(indexJ).isLibrary()) {
2006 dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(),
2007 IDefaultMutableTreeNode.MODULE, false,
2008 vModule.get(indexJ),
2009 this.dmtnModuleDescription));
2010 } else {
2011 dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(),
2012 IDefaultMutableTreeNode.MODULE, false,
2013 vModule.get(indexJ),
2014 this.dmtnModuleDescription));
2015 }
2016 }
2017 if (dmtnModulePackageModule.getChildCount() > 0) {
2018 dmtnModulePackage.add(dmtnModulePackageModule);
2019 }
2020 if (dmtnModulePackageLibrary.getChildCount() > 0) {
2021 dmtnModulePackage.add(dmtnModulePackageLibrary);
2022 }
2023
2024 dmtnModuleDescription.add(dmtnModulePackage);
2025 }
2026 }
2027
2028 //
2029 // Make Package Description
2030 //
2031 dmtnPackageDescription = new IDefaultMutableTreeNode("Packages", IDefaultMutableTreeNode.PACKAGE_DESCRIPTION,
2032 false, null, this.dmtnRoot);
2033 if (GlobalData.vPackageList.size() > 0) {
2034 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
2035 dmtnPackageDescription.add(new IDefaultMutableTreeNode(GlobalData.vPackageList.elementAt(index)
2036 .getName(),
2037 IDefaultMutableTreeNode.PACKAGE, false,
2038 GlobalData.vPackageList.elementAt(index),
2039 this.dmtnPackageDescription));
2040 }
2041 }
2042
2043 //
2044 // Make Platform Description
2045 //
2046 dmtnPlatformDescription = new IDefaultMutableTreeNode("Platforms",
2047 IDefaultMutableTreeNode.PLATFORM_DESCRIPTION, false,
2048 null, this.dmtnRoot);
2049 if (GlobalData.vPlatformList.size() > 0) {
2050 for (int index = 0; index < GlobalData.vPlatformList.size(); index++) {
2051 dmtnPlatformDescription.add(new IDefaultMutableTreeNode(GlobalData.vPlatformList.elementAt(index)
2052 .getName(),
2053 IDefaultMutableTreeNode.PLATFORM, false,
2054 GlobalData.vPlatformList.elementAt(index),
2055 this.dmtnPlatformDescription));
2056 }
2057 }
2058
2059 //
2060 // Add sub nodes to root node
2061 //
2062 dmtnRoot.add(dmtnModuleDescription);
2063 dmtnRoot.add(dmtnPackageDescription);
2064 dmtnRoot.add(dmtnPlatformDescription);
2065 iTree = new ITree(dmtnRoot);
2066 iTree.addMouseListener(this);
2067 iTree.addKeyListener(this);
2068 jScrollPaneTree.setViewportView(iTree);
2069 }
2070
2071 /* (non-Javadoc)
2072 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
2073 *
2074 * Override windowClosing to popup warning message to confirm quit
2075 *
2076 */
2077 public void windowClosing(WindowEvent arg0) {
2078 this.exit();
2079 }
2080
2081 /* (non-Javadoc)
2082 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
2083 *
2084 * Override mouseClicked to check if need display popup menu
2085 *
2086 */
2087 public void mouseClicked(MouseEvent arg0) {
2088 //
2089 // When double click
2090 //
2091 if (arg0.getClickCount() == 2) {
2092 doubleClickModuleTreeNode();
2093 }
2094 }
2095
2096 public void mouseEntered(MouseEvent arg0) {
2097 // TODO Auto-generated method stub
2098 }
2099
2100 public void mouseExited(MouseEvent arg0) {
2101 // TODO Auto-generated method stub
2102 }
2103
2104 public void mousePressed(MouseEvent arg0) {
2105 // TODO Auto-generated method stub
2106 }
2107
2108 public void mouseReleased(MouseEvent arg0) {
2109 // TODO Auto-generated method stub
2110 }
2111
2112 /**
2113 Remove all Internal Frame of Module Desktop Pane
2114
2115 **/
2116 private void cleanDesktopPaneModule() {
2117 if (jDesktopPaneModule != null) {
2118 JInternalFrame[] iif = this.jDesktopPaneModule.getAllFrames();
2119 for (int index = 0; index < iif.length; index++) {
2120 iif[index].dispose();
2121 }
2122 }
2123 }
2124
2125 /**
2126 Remove all Internal Frame of package Desktop Pane
2127
2128 **/
2129 private void cleanDesktopPanePackage() {
2130 if (jDesktopPanePlatform != null) {
2131 JInternalFrame[] iif = this.jDesktopPanePackage.getAllFrames();
2132 for (int index = 0; index < iif.length; index++) {
2133 iif[index].dispose();
2134 }
2135 }
2136 }
2137
2138 /**
2139 Remove all Internal Frame of platform Desktop Pane
2140
2141 **/
2142 private void cleanDesktopPanePlatform() {
2143 if (jDesktopPanePlatform != null) {
2144 JInternalFrame[] iif = this.jDesktopPanePlatform.getAllFrames();
2145 for (int index = 0; index < iif.length; index++) {
2146 iif[index].dispose();
2147 }
2148 }
2149 }
2150
2151 /**
2152 Remove all Internal Frame of all Desktop Panes
2153
2154 **/
2155 private void cleanDesktopPane() {
2156 cleanDesktopPaneModule();
2157 cleanDesktopPanePackage();
2158 cleanDesktopPanePlatform();
2159 }
2160
2161 /**
2162 Set file filter as input ext
2163
2164 @param ext
2165 @return
2166
2167 **/
2168 private int getNewFilePath(String ext) {
2169 JFileChooser fc = new JFileChooser(Workspace.getCurrentWorkspace());
2170 fc.setAcceptAllFileFilterUsed(false);
2171 fc.addChoosableFileFilter(new IFileFilter(ext));
2172 return fc.showSaveDialog(new JPanel());
2173 }
2174
2175 /**
2176 Add a module to tree
2177
2178 @param mid The module node to be added
2179
2180 **/
2181 private void addModuleToTree(ModuleIdentification mid) {
2182 //
2183 // Add new MsaHeader node to the tree
2184 //
2185 IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(mid.getName(), IDefaultMutableTreeNode.MODULE,
2186 false, mid, this.dmtnModuleDescription);
2187 //
2188 // First find the module belongs to which package
2189 //
2190 IDefaultMutableTreeNode packageNode = iTree.getNodeById(dmtnModuleDescription, mid.getPackageId(),
2191 IDefaultMutableTreeNode.MODULE_PACKAGE);
2192 //
2193 // To check if has module node or library node
2194 //
2195 IDefaultMutableTreeNode parentModuleNode = null;
2196 IDefaultMutableTreeNode parentLibraryNode = null;
2197 boolean hasModule = false;
2198 boolean hasLibrary = false;
2199 for (int index = 0; index < packageNode.getChildCount(); index++) {
2200 IDefaultMutableTreeNode iNode = (IDefaultMutableTreeNode) packageNode.getChildAt(index);
2201 if (iNode.getCategory() == IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY) {
2202 hasLibrary = true;
2203 parentLibraryNode = iNode;
2204 }
2205 if (iNode.getCategory() == IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE) {
2206 hasModule = true;
2207 parentModuleNode = iNode;
2208 }
2209 }
2210
2211 //
2212 // If is a module
2213 //
2214 if (!mid.isLibrary()) {
2215 //
2216 // Create parent node first if has no parent node
2217 //
2218 if (!hasModule) {
2219 parentModuleNode = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE,
2220 false, mid.getPackageId(), this.dmtnModuleDescription);
2221 iTree.addNode(packageNode, parentModuleNode);
2222 }
2223
2224 iTree.addNode(parentModuleNode, node);
2225 }
2226
2227 //
2228 // If is a Library
2229 //
2230 if (mid.isLibrary()) {
2231 //
2232 // Create parent node first if has no parent node
2233 //
2234 if (!hasLibrary) {
2235 parentLibraryNode = new IDefaultMutableTreeNode("Library",
2236 IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, false,
2237 mid.getPackageId(), this.dmtnModuleDescription);
2238 iTree.addNode(packageNode, parentLibraryNode);
2239 }
2240
2241 iTree.addNode(parentLibraryNode, node);
2242 }
2243 }
2244
2245 /**
2246 Open Module
2247
2248 @param path input file path
2249
2250 **/
2251 private void openModule(String path, IDefaultMutableTreeNode belongNode) {
2252 ModuleIdentification id = GlobalData.openingModuleList.getIdByPath(path);
2253 if (id == null) {
2254 //
2255 // The module is not in existing packages
2256 //
2257 Log.wrn("Open Module", "The module does not belong to any package in the current workspace!");
2258 return;
2259 }
2260
2261 //
2262 // Make the node selected
2263 //
2264 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(belongNode, id, IDefaultMutableTreeNode.MODULE)));
2265
2266 //
2267 // Update opening Module list information
2268 //
2269 if (!iTree.getSelectNode().isOpening()) {
2270 //
2271 // Insert sub node of module
2272 //
2273 insertModuleTreeNode(id, belongNode);
2274 iTree.getSelectNode().setOpening(true);
2275
2276 //
2277 // Update opening module list
2278 //
2279 GlobalData.openingModuleList.setModuleOpen(id, true);
2280 Set<TreePath> temp = GlobalData.openingModuleList.getTreePathById(id);
2281 temp.add(iTree.getSelectionPath());
2282 GlobalData.openingModuleList.setTreePathById(id, temp);
2283 }
2284 //
2285 // Select msa header node and show it in editor panel
2286 //
2287 iTree
2288 .setSelectionPath(iTree
2289 .getPathOfNode(iTree
2290 .getNodeById(belongNode, id, IDefaultMutableTreeNode.MSA_HEADER)));
2291 showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, GlobalData.openingModuleList.getOpeningModuleById(id));
2292 this.currentOpeningModuleIndex = GlobalData.openingModuleList.findIndexOfListById(id);
2293 }
2294
2295 /**
2296 Open Package
2297
2298 @param path input file path
2299
2300 **/
2301 private void openPackage(String path) {
2302 PackageIdentification id = GlobalData.openingPackageList.getIdByPath(path);
2303 if (id == null) {
2304 //
2305 // The package is not in current workspace
2306 //
2307 Log.wrn("Open Package", "The package has not been installed in the current workspace!");
2308 return;
2309 }
2310
2311 //
2312 // Make the node selected
2313 //
2314 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPackageDescription, id,
2315 IDefaultMutableTreeNode.PACKAGE)));
2316 //
2317 // Update opening package list information
2318 //
2319 if (!GlobalData.openingPackageList.getPackageOpen(id)) {
2320 //
2321 // Insert sub node of module
2322 //
2323 insertPackageTreeNode(id);
2324 iTree.getSelectNode().setOpening(true);
2325
2326 //
2327 // Update opening module list
2328 //
2329 GlobalData.openingPackageList.setPackageOpen(id, true);
2330 Set<TreePath> temp = GlobalData.openingPackageList.getTreePathById(id);
2331 temp.add(iTree.getSelectionPath());
2332 GlobalData.openingPackageList.setTreePathById(id, temp);
2333 }
2334 //
2335 // Show spd header in editor panel
2336 //
2337 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPackageDescription, id,
2338 IDefaultMutableTreeNode.SPD_HEADER)));
2339 showPackageElement(IDefaultMutableTreeNode.SPD_HEADER, GlobalData.openingPackageList.getOpeningPackageById(id));
2340 this.currentOpeningPackageIndex = GlobalData.openingPackageList.findIndexOfListById(id);
2341 }
2342
2343 /**
2344 Open Package
2345
2346 @param path input file path
2347
2348 **/
2349 private void openPlatform(String path) {
2350 PlatformIdentification id = GlobalData.openingPlatformList.getIdByPath(path);
2351 if (id == null) {
2352 //
2353 // The platform is not in current workspace
2354 //
2355 Log.wrn("Open Platform", "The platform has not been installed in the current workspace!");
2356 return;
2357 }
2358
2359 //
2360 // Make the node selected
2361 //
2362 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPlatformDescription, id,
2363 IDefaultMutableTreeNode.PLATFORM)));
2364 //
2365 // Update opening package list information
2366 //
2367 if (!GlobalData.openingPlatformList.getPlatformOpen(id)) {
2368 //
2369 // Insert sub node of module
2370 //
2371 insertPlatformTreeNode(id);
2372 iTree.getSelectNode().setOpening(true);
2373
2374 //
2375 // Update opening module list
2376 //
2377 GlobalData.openingPlatformList.setPlatformOpen(id, true);
2378 Set<TreePath> temp = GlobalData.openingPlatformList.getTreePathById(id);
2379 temp.add(iTree.getSelectionPath());
2380 GlobalData.openingPlatformList.setTreePathById(id, temp);
2381 }
2382 //
2383 // Show fpd header in editor panel
2384 //
2385 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPlatformDescription, id,
2386 IDefaultMutableTreeNode.FPD_PLATFORMHEADER)));
2387 showPlatformElement(IDefaultMutableTreeNode.FPD_PLATFORMHEADER,
2388 GlobalData.openingPlatformList.getOpeningPlatformById(id));
2389 this.currentOpeningPlatformIndex = GlobalData.openingPlatformList.findIndexOfListById(id);
2390 }
2391
2392 /**
2393 Save module
2394
2395 **/
2396 private void saveModule(int index) {
2397 OpeningModuleType omt = GlobalData.openingModuleList.getOpeningModuleByIndex(index);
2398 if (omt.isNew()) {
2399 if (getNewFilePath(DataType.MODULE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) {
2400 return;
2401 }
2402 }
2403 try {
2404 SaveFile.saveMsaFile(omt.getId().getPath(), omt.getXmlMsa());
2405 GlobalData.openingModuleList.setNew(omt.getId(), false);
2406 GlobalData.openingModuleList.setModuleSaved(omt.getId(), true);
2407 } catch (Exception e) {
2408 Log.wrn("Save Module", e.getMessage());
2409 Log.err("Save Module", e.getMessage());
2410 }
2411 }
2412
2413 /**
2414 Save package
2415
2416 **/
2417 private void savePackage(int index) {
2418 OpeningPackageType opt = GlobalData.openingPackageList.getOpeningPackageByIndex(index);
2419 if (opt.isNew()) {
2420 if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) {
2421 return;
2422 }
2423 }
2424 try {
2425 SaveFile.saveSpdFile(opt.getId().getPath(), opt.getXmlSpd());
2426 GlobalData.openingPackageList.setNew(opt.getId(), false);
2427 GlobalData.openingPackageList.setPackageSaved(opt.getId(), true);
2428 } catch (Exception e) {
2429 Log.wrn("Save Package", e.getMessage());
2430 Log.err("Save Package", e.getMessage());
2431 }
2432 }
2433
2434 /**
2435 Save platform
2436
2437 **/
2438 private void savePlatform(int index) {
2439 OpeningPlatformType opt = GlobalData.openingPlatformList.getOpeningPlatformByIndex(index);
2440 if (opt.isNew()) {
2441 if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) {
2442 return;
2443 }
2444 }
2445 try {
2446 SaveFile.saveFpdFile(opt.getId().getPath(), opt.getXmlFpd());
2447 GlobalData.openingPlatformList.setNew(opt.getId(), false);
2448 GlobalData.openingPlatformList.setPlatformSaved(opt.getId(), true);
2449 } catch (Exception e) {
2450 Log.wrn("Save Package", e.getMessage());
2451 Log.err("Save Package", e.getMessage());
2452 }
2453 }
2454
2455 public void componentResized(ComponentEvent arg0) {
2456 if (this.jSplitPane != null) {
2457 this.jSplitPane.setSize(this.getWidth() - DataType.MAIN_FRAME_WIDTH_SPACING,
2458 this.getHeight() - DataType.MAIN_FRAME_HEIGHT_SPACING);
2459 this.jSplitPane.validate();
2460 resizeDesktopPanel();
2461 }
2462 }
2463
2464 /**
2465 Resize JDesktopPanel
2466
2467 */
2468 private void resizeDesktopPanel() {
2469 resizeDesktopPanel(this.jDesktopPaneModule);
2470 resizeDesktopPanel(this.jDesktopPanePackage);
2471 resizeDesktopPanel(this.jDesktopPanePlatform);
2472 }
2473
2474 /**
2475 Resize JDesktopPanel
2476
2477 */
2478 private void resizeDesktopPanel(JDesktopPane jdk) {
2479 JInternalFrame[] iif = jdk.getAllFrames();
2480 for (int index = 0; index < iif.length; index++) {
2481 iif[index].setSize(jdk.getWidth(), jdk.getHeight());
2482 }
2483 }
2484
2485 private void insertModuleTreeNode(Identification id, IDefaultMutableTreeNode belongNode) {
2486 iTree.addNode(new IDefaultMutableTreeNode("Module Header", IDefaultMutableTreeNode.MSA_HEADER, true, id,
2487 belongNode));
2488 iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id,
2489 belongNode));
2490 iTree.addNode(new IDefaultMutableTreeNode("Library Class Definitions",
2491 IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id,
2492 belongNode));
2493 iTree
2494 .addNode(new IDefaultMutableTreeNode("Package Dependencies",
2495 IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id, belongNode));
2496 iTree.addNode(new IDefaultMutableTreeNode("Protocols", IDefaultMutableTreeNode.MSA_PROTOCOLS, true, id,
2497 belongNode));
2498 iTree.addNode(new IDefaultMutableTreeNode("Events", IDefaultMutableTreeNode.MSA_EVENTS, true, id, belongNode));
2499 iTree.addNode(new IDefaultMutableTreeNode("Hobs", IDefaultMutableTreeNode.MSA_HOBS, true, id, belongNode));
2500 iTree.addNode(new IDefaultMutableTreeNode("Ppis", IDefaultMutableTreeNode.MSA_PPIS, true, id, belongNode));
2501 iTree.addNode(new IDefaultMutableTreeNode("Variables", IDefaultMutableTreeNode.MSA_VARIABLES, true, id,
2502 belongNode));
2503 iTree.addNode(new IDefaultMutableTreeNode("Boot Modes", IDefaultMutableTreeNode.MSA_BOOTMODES, true, id,
2504 belongNode));
2505 iTree.addNode(new IDefaultMutableTreeNode("System Tables", IDefaultMutableTreeNode.MSA_SYSTEMTABLES, true, id,
2506 belongNode));
2507 iTree.addNode(new IDefaultMutableTreeNode("Data Hubs", IDefaultMutableTreeNode.MSA_DATAHUBS, true, id,
2508 belongNode));
2509 iTree.addNode(new IDefaultMutableTreeNode("Hii Packages", IDefaultMutableTreeNode.MSA_HIIPACKAGES, true, id,
2510 belongNode));
2511 iTree.addNode(new IDefaultMutableTreeNode("Guids", IDefaultMutableTreeNode.MSA_GUIDS, true, id, belongNode));
2512 iTree.addNode(new IDefaultMutableTreeNode("External Defintions", IDefaultMutableTreeNode.MSA_EXTERNS, true, id,
2513 belongNode));
2514 iTree.addNode(new IDefaultMutableTreeNode("Pcd Coded", IDefaultMutableTreeNode.MSA_PCDS, true, id, belongNode));
2515 }
2516
2517 private void insertPackageTreeNode(Identification id) {
2518 IDefaultMutableTreeNode idmtTemp = this.dmtnPackageDescription;
2519 iTree.addNode(new IDefaultMutableTreeNode("Package Header", IDefaultMutableTreeNode.SPD_HEADER, true, id,
2520 idmtTemp));
2521 iTree.addNode(new IDefaultMutableTreeNode("Library Class Declarations",
2522 IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id,
2523 idmtTemp));
2524 iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id,
2525 idmtTemp));
2526 iTree.addNode(new IDefaultMutableTreeNode("Package Includes", IDefaultMutableTreeNode.SPD_PACKAGEHEADERS, true,
2527 id, idmtTemp));
2528 iTree.addNode(new IDefaultMutableTreeNode("Guid Declarations", IDefaultMutableTreeNode.SPD_GUIDDECLARATIONS,
2529 true, id, idmtTemp));
2530 iTree
2531 .addNode(new IDefaultMutableTreeNode("Protocol Declarations",
2532 IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS, true, id, idmtTemp));
2533 iTree.addNode(new IDefaultMutableTreeNode("Ppi Declarations", IDefaultMutableTreeNode.SPD_PPIDECLARATIONS,
2534 true, id, idmtTemp));
2535 iTree.addNode(new IDefaultMutableTreeNode("Pcd Declarations", IDefaultMutableTreeNode.SPD_PCDDECLARATIONS,
2536 true, id, idmtTemp));
2537 //
2538 // Add modules in this package
2539 //
2540 IDefaultMutableTreeNode dmtnModulePackageLibrary = null;
2541 IDefaultMutableTreeNode dmtnModulePackageModule = null;
2542
2543 dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library",
2544 IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, false,
2545 id, idmtTemp);
2546 dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE,
2547 false, id, idmtTemp);
2548
2549 Vector<ModuleIdentification> vModule = wt.getAllModules(new PackageIdentification(id));
2550 for (int indexJ = 0; indexJ < vModule.size(); indexJ++) {
2551 if (vModule.get(indexJ).isLibrary()) {
2552 dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(),
2553 IDefaultMutableTreeNode.MODULE, false,
2554 vModule.get(indexJ), idmtTemp));
2555 } else {
2556 dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(),
2557 IDefaultMutableTreeNode.MODULE, false,
2558 vModule.get(indexJ), idmtTemp));
2559 }
2560 }
2561 if (dmtnModulePackageModule.getChildCount() > 0) {
2562 iTree.addNode(dmtnModulePackageModule);
2563 }
2564 if (dmtnModulePackageLibrary.getChildCount() > 0) {
2565 iTree.addNode(dmtnModulePackageLibrary);
2566 }
2567 }
2568
2569 private void insertPlatformTreeNode(Identification id) {
2570 IDefaultMutableTreeNode idmtTemp = this.dmtnPlatformDescription;
2571 iTree.addNode(new IDefaultMutableTreeNode("Platform Header", IDefaultMutableTreeNode.FPD_PLATFORMHEADER, true,
2572 id, idmtTemp));
2573 iTree.addNode(new IDefaultMutableTreeNode("Platform Definitions",
2574 IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS, true, id, idmtTemp));
2575 iTree.addNode(new IDefaultMutableTreeNode("Flash Information", IDefaultMutableTreeNode.FPD_FLASH, true, id,
2576 idmtTemp));
2577 iTree.addNode(new IDefaultMutableTreeNode("Framework Modules", IDefaultMutableTreeNode.FPD_FRAMEWORKMODULES,
2578 true, id, idmtTemp));
2579 iTree.addNode(new IDefaultMutableTreeNode("Dynamic PCD Build Declarations",
2580 IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS, true, id,
2581 idmtTemp));
2582 iTree.addNode(new IDefaultMutableTreeNode("Build Options", IDefaultMutableTreeNode.FPD_BUILDOPTIONS, true, id,
2583 idmtTemp));
2584
2585 //
2586 // Add modules in this platform
2587 //
2588 IDefaultMutableTreeNode dmtnModulePackageLibrary = null;
2589 IDefaultMutableTreeNode dmtnModulePackageModule = null;
2590
2591 dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library",
2592 IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, false,
2593 id, idmtTemp);
2594 dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE,
2595 false, id, idmtTemp);
2596
2597 Vector<ModuleIdentification> vModule = wt.getAllModules(new PlatformIdentification(id));
2598 for (int indexJ = 0; indexJ < vModule.size(); indexJ++) {
2599 if (vModule.get(indexJ).isLibrary()) {
2600 dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(),
2601 IDefaultMutableTreeNode.MODULE, false,
2602 vModule.get(indexJ), idmtTemp));
2603 } else {
2604 dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(),
2605 IDefaultMutableTreeNode.MODULE, false,
2606 vModule.get(indexJ), idmtTemp));
2607 }
2608 }
2609 if (dmtnModulePackageModule.getChildCount() > 0) {
2610 iTree.addNode(dmtnModulePackageModule);
2611 }
2612 if (dmtnModulePackageLibrary.getChildCount() > 0) {
2613 iTree.addNode(dmtnModulePackageLibrary);
2614 }
2615 }
2616
2617 /**
2618 Operate when double click a tree node
2619
2620 **/
2621 private void doubleClickModuleTreeNode() {
2622 Identification id = null;
2623 int intCategory = -1;
2624 String path = null;
2625 IDefaultMutableTreeNode belongNode = null;
2626
2627 try {
2628 id = iTree.getSelectNode().getId();
2629 intCategory = iTree.getSelectCategory();
2630 belongNode = iTree.getSelectNode().getBelongNode();
2631
2632 //
2633 // If id is null, return directly
2634 //
2635 if (id == null) {
2636 return;
2637 }
2638
2639 //
2640 // If the node is not opened yet
2641 // Insert top level elements first
2642 //
2643 if (intCategory == IDefaultMutableTreeNode.MODULE) {
2644 path = iTree.getSelectNode().getId().getPath();
2645 openModule(path, belongNode);
2646 return;
2647 }
2648 if (intCategory == IDefaultMutableTreeNode.PACKAGE) {
2649 path = iTree.getSelectNode().getId().getPath();
2650 openPackage(path);
2651 return;
2652 }
2653 if (intCategory == IDefaultMutableTreeNode.PLATFORM) {
2654 path = iTree.getSelectNode().getId().getPath();
2655 openPlatform(path);
2656 return;
2657 }
2658
2659 //
2660 // Show editor panel
2661 //
2662 if (intCategory >= IDefaultMutableTreeNode.MSA_HEADER && intCategory < IDefaultMutableTreeNode.SPD_HEADER) {
2663 showModuleElement(intCategory,
2664 GlobalData.openingModuleList.getOpeningModuleById(new ModuleIdentification(id)));
2665 this.currentOpeningModuleIndex = GlobalData.openingModuleList
2666 .findIndexOfListById(new ModuleIdentification(
2667 id));
2668 }
2669 if (intCategory >= IDefaultMutableTreeNode.SPD_HEADER
2670 && intCategory < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) {
2671 showPackageElement(intCategory,
2672 GlobalData.openingPackageList.getOpeningPackageById(new PackageIdentification(id)));
2673 this.currentOpeningPackageIndex = GlobalData.openingPackageList
2674 .findIndexOfListById(new PackageIdentification(
2675 id));
2676 }
2677 if (intCategory >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) {
2678 showPlatformElement(
2679 intCategory,
2680 GlobalData.openingPlatformList
2681 .getOpeningPlatformById(new PlatformIdentification(id)));
2682 this.currentOpeningPlatformIndex = GlobalData.openingPlatformList
2683 .findIndexOfListById(new PlatformIdentification(
2684 id));
2685 }
2686 } catch (Exception e) {
2687 Log.err("double click category: " + intCategory);
2688 Log.err("double click belong node: " + belongNode.toString());
2689 Log.err("double click id path: " + id);
2690 Log.err("double click exception: " + e.getMessage());
2691 }
2692 }
2693
2694 /**
2695 Show content of editor panel via selected element
2696
2697 @param elementType
2698 @param fpd
2699
2700 **/
2701 private void showPlatformElement(int elementType, OpeningPlatformType fpd) {
2702 this.cleanDesktopPanePlatform();
2703
2704 switch (elementType) {
2705 case IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS:
2706 FpdPlatformDefs frmFpdPlatformDefs = new FpdPlatformDefs(fpd);
2707 getJDesktopPanePlatform().add(frmFpdPlatformDefs, 1);
2708 break;
2709 case IDefaultMutableTreeNode.FPD_PLATFORMHEADER:
2710 FpdHeader frmFpdHeader = new FpdHeader(fpd);
2711 getJDesktopPanePlatform().add(frmFpdHeader, 1);
2712 break;
2713 case IDefaultMutableTreeNode.FPD_FLASH:
2714 FpdFlash frmFpdFlash = new FpdFlash(fpd);
2715 getJDesktopPanePlatform().add(frmFpdFlash, 1);
2716 break;
2717 case IDefaultMutableTreeNode.FPD_FRAMEWORKMODULES:
2718 FpdFrameworkModules frmFpdFrameworkModules = new FpdFrameworkModules(fpd);
2719 getJDesktopPanePlatform().add(frmFpdFrameworkModules, 1);
2720 break;
2721 case IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS:
2722 FpdDynamicPcdBuildDefinitions frmFpdDynamicPcdBuildDefinitions = new FpdDynamicPcdBuildDefinitions(fpd);
2723 getJDesktopPanePlatform().add(frmFpdDynamicPcdBuildDefinitions, 1);
2724 break;
2725 case IDefaultMutableTreeNode.FPD_BUILDOPTIONS:
2726 FpdBuildOptions frmFpdBuildOptions = new FpdBuildOptions(fpd);
2727 getJDesktopPanePlatform().add(frmFpdBuildOptions, 1);
2728 break;
2729 }
2730 this.jTabbedPaneEditor.setSelectedIndex(2);
2731 resizeDesktopPanel();
2732 }
2733
2734 /**
2735 Show content of editor panel via selected element
2736
2737 @param elementType
2738 @param spd
2739
2740 */
2741 private void showPackageElement(int elementType, OpeningPackageType spd) {
2742 this.cleanDesktopPanePackage();
2743 Tools.dirForNewSpd = spd.getId().getPath();
2744 switch (elementType) {
2745 case IDefaultMutableTreeNode.SPD_HEADER:
2746 SpdHeader frmSpdHeader = new SpdHeader(spd);
2747 getJDesktopPanePackage().add(frmSpdHeader, 1);
2748 break;
2749 case IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS:
2750 SpdLibClassDecls frmSlcd = new SpdLibClassDecls(spd);
2751 getJDesktopPanePackage().add(frmSlcd, 1);
2752 break;
2753 case IDefaultMutableTreeNode.SPD_MSAFILES:
2754 SpdMsaFiles frmSmf = new SpdMsaFiles(spd);
2755 getJDesktopPanePackage().add(frmSmf, 1);
2756 break;
2757 case IDefaultMutableTreeNode.SPD_PACKAGEHEADERS:
2758 SpdPackageHeaders frmSph = new SpdPackageHeaders(spd);
2759 getJDesktopPanePackage().add(frmSph, 1);
2760 break;
2761 case IDefaultMutableTreeNode.SPD_GUIDDECLARATIONS:
2762 SpdGuidDecls frmSgd = new SpdGuidDecls(spd);
2763 getJDesktopPanePackage().add(frmSgd, 1);
2764 break;
2765 case IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS:
2766 SpdProtocolDecls frmSprod = new SpdProtocolDecls(spd);
2767 getJDesktopPanePackage().add(frmSprod, 1);
2768 break;
2769 case IDefaultMutableTreeNode.SPD_PPIDECLARATIONS:
2770 SpdPpiDecls frmSppid = new SpdPpiDecls(spd);
2771 getJDesktopPanePackage().add(frmSppid, 1);
2772 break;
2773 case IDefaultMutableTreeNode.SPD_PCDDECLARATIONS:
2774 SpdPcdDefs frmSpcdd = new SpdPcdDefs(spd);
2775 getJDesktopPanePackage().add(frmSpcdd, 1);
2776 break;
2777 }
2778 this.jTabbedPaneEditor.setSelectedIndex(1);
2779 resizeDesktopPanel();
2780 }
2781
2782 /**
2783 Show content of editor panel via selected element
2784
2785 @param elementType
2786 @param msa
2787
2788 */
2789 private void showModuleElement(int elementType, OpeningModuleType msa) {
2790 this.cleanDesktopPaneModule();
2791 switch (elementType) {
2792 case IDefaultMutableTreeNode.MSA_HEADER:
2793 MsaHeader frmMsaHeader = new MsaHeader(msa);
2794 getJDesktopPaneModule().add(frmMsaHeader, 1);
2795 break;
2796 case IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS:
2797 ModuleLibraryClassDefinitions frmMlcd = new ModuleLibraryClassDefinitions(msa);
2798 getJDesktopPaneModule().add(frmMlcd, 1);
2799 break;
2800 case IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES:
2801 ModulePackageDependencies frmMpd = new ModulePackageDependencies(msa);
2802 getJDesktopPaneModule().add(frmMpd, 1);
2803 break;
2804 case IDefaultMutableTreeNode.MSA_SOURCEFILES:
2805 ModuleSourceFiles frmMsf = new ModuleSourceFiles(msa);
2806 getJDesktopPaneModule().add(frmMsf, 1);
2807 break;
2808 case IDefaultMutableTreeNode.MSA_PROTOCOLS:
2809 ModuleProtocols frmMp = new ModuleProtocols(msa);
2810 getJDesktopPaneModule().add(frmMp, 1);
2811 break;
2812 case IDefaultMutableTreeNode.MSA_EVENTS:
2813 ModuleEvents frmMe = new ModuleEvents(msa);
2814 getJDesktopPaneModule().add(frmMe, 1);
2815 break;
2816 case IDefaultMutableTreeNode.MSA_HOBS:
2817 ModuleHobs frmMh = new ModuleHobs(msa);
2818 getJDesktopPaneModule().add(frmMh, 1);
2819 break;
2820 case IDefaultMutableTreeNode.MSA_PPIS:
2821 ModulePpis frmMpp = new ModulePpis(msa);
2822 getJDesktopPaneModule().add(frmMpp, 1);
2823 break;
2824 case IDefaultMutableTreeNode.MSA_VARIABLES:
2825 ModuleVariables frmMv = new ModuleVariables(msa);
2826 getJDesktopPaneModule().add(frmMv, 1);
2827 break;
2828 case IDefaultMutableTreeNode.MSA_BOOTMODES:
2829 ModuleBootModes frmMbm = new ModuleBootModes(msa);
2830 getJDesktopPaneModule().add(frmMbm, 1);
2831 break;
2832 case IDefaultMutableTreeNode.MSA_SYSTEMTABLES:
2833 ModuleSystemTables frmMst = new ModuleSystemTables(msa);
2834 getJDesktopPaneModule().add(frmMst, 1);
2835 break;
2836 case IDefaultMutableTreeNode.MSA_DATAHUBS:
2837 ModuleDataHubs frmMdh = new ModuleDataHubs(msa);
2838 getJDesktopPaneModule().add(frmMdh, 1);
2839 break;
2840 case IDefaultMutableTreeNode.MSA_HIIPACKAGES:
2841 ModuleHiiPackages frmMf = new ModuleHiiPackages(msa);
2842 getJDesktopPaneModule().add(frmMf, 1);
2843 break;
2844 case IDefaultMutableTreeNode.MSA_GUIDS:
2845 ModuleGuids frmGuid = new ModuleGuids(msa);
2846 getJDesktopPaneModule().add(frmGuid, 1);
2847 break;
2848 case IDefaultMutableTreeNode.MSA_EXTERNS:
2849 ModuleExterns frmMex = new ModuleExterns(msa);
2850 getJDesktopPaneModule().add(frmMex, 1);
2851 break;
2852 case IDefaultMutableTreeNode.MSA_PCDS:
2853 ModulePCDs frmPcd = new ModulePCDs(msa);
2854 getJDesktopPaneModule().add(frmPcd, 1);
2855 break;
2856 }
2857 this.jTabbedPaneEditor.setSelectedIndex(0);
2858 resizeDesktopPanel();
2859 }
2860
2861 //
2862 // Define operations of menu
2863 //
2864 /**
2865 New a file
2866
2867 **/
2868 private void fileNew() {
2869 int result = -1;
2870 //
2871 // Selece new file type
2872 //
2873 NewFileChooser nfc = new NewFileChooser(this, true);
2874 result = nfc.showDialog();
2875
2876 if (result == DataType.RETURN_TYPE_CANCEL) {
2877 nfc.dispose();
2878 return;
2879 } else if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
2880 //
2881 // To new a module
2882 //
2883 SelectModuleBelong smb = new SelectModuleBelong(this, true, result);
2884 result = smb.showDialog();
2885
2886 if (result == DataType.RETURN_TYPE_CANCEL) {
2887 nfc.dispose();
2888 smb.dispose();
2889 return;
2890 } else if (result == DataType.RETURN_TYPE_OK) {
2891 ModuleIdentification mid = smb.getMid();
2892 if (mid != null) {
2893 //
2894 // Update package of workspace first
2895 //
2896 PackageSurfaceAreaDocument.PackageSurfaceArea psa = null;
2897 if (GlobalData.openingPackageList.existsPackage(mid.getPackageId())) {
2898 psa = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(mid.getPackageId());
2899 }
2900 try {
2901 wt.addModuleToPackage(mid, psa);
2902 } catch (IOException e) {
2903 Log.wrn("Update MsaFiles in Package", e.getMessage());
2904 Log.err("Update MsaFiles in Package", e.getMessage());
2905 return;
2906 } catch (XmlException e) {
2907 Log.wrn("Update MsaFiles in Package", e.getMessage());
2908 Log.err("Update MsaFiles in Package", e.getMessage());
2909 return;
2910 } catch (Exception e) {
2911 Log.wrn("Update MsaFiles in Package", e.getMessage());
2912 Log.err("Update MsaFiles in Package", e.getMessage());
2913 return;
2914 }
2915
2916 //
2917 // Update Global Data
2918 //
2919 GlobalData.openingModuleList.insertToOpeningModuleList(mid, smb.getMsa());
2920 GlobalData.vModuleList.addElement(mid);
2921
2922 //
2923 // Create new node on the tree
2924 //
2925 addModuleToTree(mid);
2926
2927 //
2928 // Open the node
2929 //
2930 this.openModule(mid.getPath(), this.dmtnModuleDescription);
2931 }
2932 }
2933 } else if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
2934 //
2935 // To new a package
2936 //
2937 SelectModuleBelong smb = new SelectModuleBelong(this, true, result);
2938 result = smb.showDialog();
2939
2940 if (result == DataType.RETURN_TYPE_CANCEL) {
2941 nfc.dispose();
2942 smb.dispose();
2943 return;
2944 } else if (result == DataType.RETURN_TYPE_OK) {
2945 PackageIdentification pid = smb.getPid();
2946 if (pid != null) {
2947 try {
2948 wt.addPackageToDatabase(smb.getPid());
2949 } catch (Exception e) {
2950 Log.err("addPackageToDatabase", e.getMessage());
2951 }
2952
2953 //
2954 // Update Global Data
2955 //
2956 GlobalData.openingPackageList.insertToOpeningPackageList(pid, smb.getSpd());
2957 GlobalData.vPackageList.addElement(pid);
2958
2959 //
2960 // Add to Module Description node
2961 //
2962 IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(pid.getName(),
2963 IDefaultMutableTreeNode.MODULE_PACKAGE,
2964 false, pid, this.dmtnModuleDescription);
2965
2966 iTree.addNode(dmtnModuleDescription, node);
2967
2968 //
2969 // Add new SpdHeader node to the tree
2970 //
2971 node = new IDefaultMutableTreeNode(pid.getName(), IDefaultMutableTreeNode.PACKAGE, true, pid,
2972 this.dmtnPackageDescription);
2973 iTree.addNode(dmtnPackageDescription, node);
2974
2975 this.openPackage(pid.getPath());
2976 }
2977 }
2978 } else if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
2979 //
2980 // To new a platform
2981 //
2982 SelectModuleBelong smb = new SelectModuleBelong(this, true, result);
2983 result = smb.showDialog();
2984
2985 if (result == DataType.RETURN_TYPE_CANCEL) {
2986 nfc.dispose();
2987 smb.dispose();
2988 return;
2989 } else if (result == DataType.RETURN_TYPE_OK) {
2990 PlatformIdentification fid = smb.getFid();
2991 if (fid != null) {
2992 try {
2993 wt.addPlatformToDatabase(fid);
2994 } catch (Exception e) {
2995 Log.err("addPlatformToDatabase", e.getMessage());
2996 }
2997
2998 //
2999 // Update global data
3000 //
3001 GlobalData.openingPlatformList.insertToOpeningPlatformList(fid, smb.getFpd());
3002 GlobalData.vPlatformList.addElement(fid);
3003 //
3004 // Add new SpdHeader node to the tree
3005 //
3006 IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(fid.getName(),
3007 IDefaultMutableTreeNode.PLATFORM, true,
3008 fid, this.dmtnPlatformDescription);
3009 iTree.addNode(dmtnPlatformDescription, node);
3010 this.openPlatform(fid.getPath());
3011 }
3012 }
3013 }
3014 }
3015
3016 /**
3017 Open a file
3018
3019 **/
3020 private void open() {
3021 JFileChooser fc = new JFileChooser(Workspace.getCurrentWorkspace());
3022 fc.setAcceptAllFileFilterUsed(false);
3023 IFileFilter iffM = new IFileFilter(DataType.MODULE_SURFACE_AREA_EXT);
3024 IFileFilter iffP = new IFileFilter(DataType.PACKAGE_SURFACE_AREA_EXT);
3025 IFileFilter iffF = new IFileFilter(DataType.PLATFORM_SURFACE_AREA_EXT);
3026 fc.addChoosableFileFilter(iffM);
3027 fc.addChoosableFileFilter(iffP);
3028 fc.addChoosableFileFilter(iffF);
3029 fc.setFileFilter(iffM);
3030
3031 int result = fc.showOpenDialog(new JPanel());
3032
3033 if (result == JFileChooser.APPROVE_OPTION) {
3034 String path = fc.getSelectedFile().getPath();
3035 String match = path.substring(path.length() - 4);
3036 if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.MODULE_SURFACE_AREA_EXT)) {
3037 openModule(path, this.dmtnModuleDescription);
3038 } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PACKAGE_SURFACE_AREA_EXT)) {
3039 openPackage(path);
3040 } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PLATFORM_SURFACE_AREA_EXT)) {
3041 openPlatform(path);
3042 }
3043 }
3044 }
3045
3046 /**
3047 Close files
3048
3049 **/
3050 private void close() {
3051 TreePath item = null;
3052 switch (this.jTabbedPaneEditor.getSelectedIndex()) {
3053 //
3054 // Current is module
3055 //
3056 case 0:
3057 if (this.currentOpeningModuleIndex > -1) {
3058 if (!GlobalData.openingModuleList.getModuleSaved(currentOpeningModuleIndex)) {
3059 int result = showSaveDialog();
3060 if (result == JOptionPane.YES_OPTION) {
3061 this.saveAll();
3062 }
3063 if (result == JOptionPane.NO_OPTION) {
3064 // Do nothing
3065 }
3066 if (result == JOptionPane.CANCEL_OPTION) {
3067 return;
3068 }
3069 }
3070
3071 //
3072 // Remove all tree paths for the module
3073 //
3074 Set<TreePath> openingTreePaths = GlobalData.openingModuleList
3075 .getTreePathByIndex(currentOpeningModuleIndex);
3076 Iterator<TreePath> openingTreePathsIter = openingTreePaths.iterator();
3077 while (openingTreePathsIter.hasNext()) {
3078 item = openingTreePathsIter.next();
3079 iTree.getNodeByPath(item).setOpening(false);
3080 iTree.removeNodeChildrenByPath(item);
3081 }
3082
3083 GlobalData.openingModuleList.setModuleOpen(this.currentOpeningModuleIndex, false);
3084 this.cleanDesktopPaneModule();
3085 this.currentOpeningModuleIndex = -1;
3086 }
3087 break;
3088 //
3089 // Current is package
3090 //
3091 case 1:
3092 if (this.currentOpeningPackageIndex > -1) {
3093 if (!GlobalData.openingPackageList.getPackageSaved(currentOpeningPackageIndex)) {
3094 int result = showSaveDialog();
3095 if (result == JOptionPane.YES_OPTION) {
3096 this.saveAll();
3097 }
3098 if (result == JOptionPane.NO_OPTION) {
3099 // Do nothing
3100 }
3101 if (result == JOptionPane.CANCEL_OPTION) {
3102 return;
3103 }
3104 }
3105
3106 //
3107 // Remove all tree paths for the module
3108 //
3109 Set<TreePath> openingTreePaths = GlobalData.openingPackageList
3110 .getTreePathByIndex(currentOpeningPackageIndex);
3111 Iterator<TreePath> openingTreePathsIter = openingTreePaths.iterator();
3112 while (openingTreePathsIter.hasNext()) {
3113 item = openingTreePathsIter.next();
3114 iTree.getNodeByPath(item).setOpening(false);
3115 iTree.removeNodeChildrenByPath(item);
3116 }
3117
3118 GlobalData.openingPackageList.setPackageOpen(this.currentOpeningPackageIndex, false);
3119 this.cleanDesktopPanePackage();
3120 this.currentOpeningPackageIndex = -1;
3121 }
3122 break;
3123 //
3124 // Current is platform
3125 //
3126 case 2:
3127 if (this.currentOpeningPlatformIndex > -1) {
3128 if (!GlobalData.openingPlatformList.getPlatformSaved(currentOpeningPlatformIndex)) {
3129 int result = showSaveDialog();
3130 if (result == JOptionPane.YES_OPTION) {
3131 this.saveAll();
3132 }
3133 if (result == JOptionPane.NO_OPTION) {
3134 // Do nothing
3135 }
3136 if (result == JOptionPane.CANCEL_OPTION) {
3137 return;
3138 }
3139 }
3140
3141 //
3142 // Remove all tree paths for the module
3143 //
3144 Set<TreePath> openingTreePaths = GlobalData.openingPlatformList
3145 .getTreePathByIndex(currentOpeningPlatformIndex);
3146 Iterator<TreePath> openingTreePathsIter = openingTreePaths.iterator();
3147 while (openingTreePathsIter.hasNext()) {
3148 item = openingTreePathsIter.next();
3149 iTree.getNodeByPath(item).setOpening(false);
3150 iTree.removeNodeChildrenByPath(item);
3151 }
3152
3153 GlobalData.openingPlatformList.setPlatformOpen(this.currentOpeningPlatformIndex, false);
3154 this.cleanDesktopPanePlatform();
3155 this.currentOpeningPlatformIndex = -1;
3156 }
3157 break;
3158 }
3159 }
3160
3161 /**
3162 Close all opening files and clean all showing internal frame
3163
3164 **/
3165 private void closeAll() {
3166 int result = -1;
3167 if (!GlobalData.openingModuleList.isSaved() || !GlobalData.openingPackageList.isSaved()
3168 || !GlobalData.openingPlatformList.isSaved()) {
3169 result = showSaveDialog();
3170 }
3171 if (result == JOptionPane.YES_OPTION) {
3172 this.saveAll();
3173 }
3174 if (result == JOptionPane.NO_OPTION) {
3175 //
3176 // Do nothing
3177 //
3178 }
3179 if (result == JOptionPane.CANCEL_OPTION) {
3180 return;
3181 }
3182 this.cleanDesktopPane();
3183 GlobalData.openingModuleList.closeAll();
3184 GlobalData.openingPackageList.closeAll();
3185 GlobalData.openingPlatformList.closeAll();
3186 }
3187
3188 /**
3189 Refresh all global data from disk to memory
3190
3191 **/
3192 private void refresh() {
3193 GlobalData.init();
3194 }
3195
3196 /**
3197 Save currentModule when press button OK
3198
3199 **/
3200 private void save() {
3201 switch (this.jTabbedPaneEditor.getSelectedIndex()) {
3202 case 0:
3203 if (this.currentOpeningModuleIndex > -1) {
3204 saveModule(this.currentOpeningModuleIndex);
3205 }
3206 break;
3207 case 1:
3208 if (this.currentOpeningPackageIndex > -1) {
3209 savePackage(this.currentOpeningPackageIndex);
3210 }
3211 break;
3212 case 2:
3213 if (this.currentOpeningPlatformIndex > -1) {
3214 savePlatform(this.currentOpeningPlatformIndex);
3215 }
3216 break;
3217 }
3218 }
3219
3220 private void saveAs() {
3221
3222 }
3223
3224 private void saveAll() {
3225 //
3226 // Save all modules
3227 //
3228 for (int index = 0; index < GlobalData.openingModuleList.size(); index++) {
3229 if (!GlobalData.openingModuleList.getModuleSaved(index)) {
3230 saveModule(index);
3231 }
3232 }
3233
3234 //
3235 // Save all packages
3236 //
3237 for (int index = 0; index < GlobalData.openingPackageList.size(); index++) {
3238 if (!GlobalData.openingPackageList.getPackageSaved(index)) {
3239 savePackage(index);
3240 }
3241 }
3242
3243 //
3244 // Save all platforms
3245 //
3246 for (int index = 0; index < GlobalData.openingPlatformList.size(); index++) {
3247 if (!GlobalData.openingPlatformList.getPlatformSaved(index)) {
3248 savePlatform(index);
3249 }
3250 }
3251 }
3252
3253 /**
3254 To save changed items before exit.
3255
3256 **/
3257 private void exit() {
3258 int result = -1;
3259 if (!GlobalData.openingModuleList.isSaved() || !GlobalData.openingPackageList.isSaved()
3260 || !GlobalData.openingPlatformList.isSaved()) {
3261 result = showSaveDialog();
3262 }
3263 if (result == JOptionPane.YES_OPTION) {
3264 this.saveAll();
3265 }
3266 if (result == JOptionPane.NO_OPTION) {
3267 // Do nothing
3268 }
3269 if (result == JOptionPane.CANCEL_OPTION) {
3270 return;
3271 }
3272 this.dispose();
3273 System.exit(0);
3274 }
3275
3276 /**
3277 To find all defined PPIs in workspace
3278
3279 **/
3280 private void findPpi() {
3281 FindResult fr = FindResult.getInstance("PPI");
3282 fr.setVisible(true);
3283 }
3284
3285 /**
3286 To find all defined PROTOCOLs in workspace
3287
3288 **/
3289 private void findProtocol() {
3290 FindResult fr = FindResult.getInstance("PROTOCOL");
3291 fr.setVisible(true);
3292 }
3293
3294 /**
3295 To find all defined PROTOCOLs in workspace
3296
3297 **/
3298 private void findGuid() {
3299 FindResult fr = FindResult.getInstance("GUID");
3300 fr.setVisible(true);
3301 }
3302
3303 /**
3304 To find all defined PROTOCOLs in workspace
3305
3306 **/
3307 private void findPcd() {
3308 FindResult fr = FindResult.getInstance("PCD");
3309 fr.setVisible(true);
3310 }
3311
3312 /**
3313 To find all defined Library Classes in workspace
3314
3315 **/
3316 private void findLibraryClass() {
3317 FindResult fr = FindResult.getInstance("LIBRARY_CLASS");
3318 fr.setVisible(true);
3319 }
3320
3321 /**
3322 To find all defined Library Instances in workspace
3323
3324 **/
3325 private void findLibraryInstance() {
3326 FindResult fr = FindResult.getInstance("LIBRARY_INSTANCE");
3327 fr.setVisible(true);
3328 }
3329
3330 /**
3331 Switch current workspace to others
3332
3333 **/
3334 private void changeWorkspace() {
3335 SwitchWorkspace sw = new SwitchWorkspace(this, true);
3336 int result = sw.showDialog();
3337 if (result == DataType.RETURN_TYPE_CANCEL) {
3338 return;
3339 } else if (result == DataType.RETURN_TYPE_OK) {
3340 //
3341 // Reinit whole window
3342 //
3343 this.closeAll();
3344 this.setTitle(DataType.PROJECT_NAME + " " + DataType.PROJECT_VERSION + " " + "- ["
3345 + Workspace.getCurrentWorkspace() + "]");
3346 //
3347 // Refrash the tree
3348 //
3349 this.refresh();
3350 }
3351 sw.dispose();
3352 }
3353
3354 /**
3355 To create a Far file from current workspace
3356
3357 **/
3358 private void createFar() {
3359 CreateStepOne cso = new CreateStepOne(this, true);
3360 int result = cso.showDialog();
3361 if (result == DataType.RETURN_TYPE_OK) {
3362 String strReturn = "Far Creation Completed!";
3363 JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION,
3364 JOptionPane.INFORMATION_MESSAGE);
3365 }
3366 cso.dispose();
3367 }
3368
3369 /**
3370 To install a Far file to current workspace
3371
3372 **/
3373 private void installFar() {
3374 InstallStepOne iso = new InstallStepOne(this, true);
3375 int result = iso.showDialog();
3376 if (result == DataType.RETURN_TYPE_OK) {
3377 String strReturn = "<html>Far Installalation completed!<br>Refreshing the WORKSPACE!</html>";
3378 JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION,
3379 JOptionPane.INFORMATION_MESSAGE);
3380 this.closeAll();
3381 this.refresh();
3382 this.makeEmptyTree();
3383 }
3384 iso.dispose();
3385 }
3386
3387 /**
3388 To remove a Far's items from current workspace
3389
3390 **/
3391 private void removeFar() {
3392 DeleteStepOne dso = new DeleteStepOne(this, true);
3393 int result = dso.showDialog();
3394 if (result == DataType.RETURN_TYPE_OK) {
3395 String strReturn = "<html>Far Deletion completed!<br>Refreshing the WORKSPACE!</html>";
3396 JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION,
3397 JOptionPane.INFORMATION_MESSAGE);
3398 this.closeAll();
3399 this.refresh();
3400 this.makeEmptyTree();
3401 }
3402 dso.dispose();
3403 }
3404
3405 /**
3406 To update an existing Far file
3407
3408 **/
3409 private void updateFar() {
3410 UpdateStepOne uso = new UpdateStepOne(this, true);
3411 int result = uso.showDialog();
3412 if (result == DataType.RETURN_TYPE_OK) {
3413 String strReturn = "<html>Far Update completed!<br>Refreshing the WORKSPACE!</html>";
3414 JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION,
3415 JOptionPane.INFORMATION_MESSAGE);
3416 this.closeAll();
3417 this.refresh();
3418 this.makeEmptyTree();
3419 }
3420 uso.dispose();
3421 }
3422
3423 /**
3424 Show Tool Chain Configuration Dialog to setup Tool Chain
3425
3426 **/
3427 private void setupToolChainConfiguration() {
3428 ToolChainConfig tcc = ToolChainConfig.getInstance();
3429 tcc.showDialog();
3430 }
3431
3432 private void configBuildPreferences() {
3433 Preferences bt = Preferences.getInstance();
3434 bt.showDialog();
3435 }
3436
3437 /**
3438 Clone selected item
3439
3440 **/
3441 private void cloneItem() {
3442 int mode = -1;
3443
3444 //
3445 // Check if there is any item can be cloned
3446 //
3447 if (iTree.getSelectionPath() == null) {
3448 Log.wrn("Clone", "Please select a target to clone!");
3449 return;
3450 }
3451 int category = iTree.getSelectCategory();
3452 Identification id = iTree.getSelectNode().getId();
3453
3454 if (category == IDefaultMutableTreeNode.WORKSPACE) {
3455 mode = DataType.RETURN_TYPE_WORKSPACE;
3456 id = null;
3457 }
3458 if ((category == IDefaultMutableTreeNode.MODULE)
3459 || (category >= IDefaultMutableTreeNode.MSA_HEADER && category < IDefaultMutableTreeNode.SPD_HEADER)) {
3460 mode = DataType.RETURN_TYPE_MODULE_SURFACE_AREA;
3461 }
3462 if ((category == IDefaultMutableTreeNode.PACKAGE)
3463 || (category >= IDefaultMutableTreeNode.SPD_HEADER && category < IDefaultMutableTreeNode.FPD_PLATFORMHEADER)) {
3464 mode = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA;
3465 }
3466 if ((category == IDefaultMutableTreeNode.PLATFORM) || (category >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER)) {
3467 mode = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;
3468 }
3469
3470 Clone c = new Clone(this, true, mode, id);
3471 int result = c.showDialog();
3472
3473 if (result == DataType.RETURN_TYPE_CANCEL) {
3474 c.dispose();
3475 }
3476 if (result == DataType.RETURN_TYPE_WORKSPACE) {
3477 Tools.showInformationMessage("Workspace Clone Completed!");
3478 }
3479 if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
3480 Tools.showInformationMessage("Module Clone Completed!");
3481 addModuleToTree(c.getMid());
3482 }
3483 if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
3484 Tools.showInformationMessage("Package Clone Completed!");
3485 //
3486 // Add new SpdHeader node to the tree
3487 //
3488 IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(GlobalData.vPackageList.lastElement().getName(),
3489 IDefaultMutableTreeNode.PACKAGE, false,
3490 GlobalData.vPackageList.lastElement(),
3491 this.dmtnPackageDescription);
3492 iTree.addNode(this.dmtnPackageDescription, node);
3493 }
3494 if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
3495 Tools.showInformationMessage("Platform Surface Area Clone Finished");
3496 //
3497 // Add new SpdHeader node to the tree
3498 //
3499 IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(
3500 GlobalData.vPlatformList.lastElement().getName(),
3501 IDefaultMutableTreeNode.PLATFORM, false,
3502 GlobalData.vPlatformList.lastElement(),
3503 this.dmtnPlatformDescription);
3504 iTree.addNode(this.dmtnPlatformDescription, node);
3505 }
3506 if (result == DataType.RETURN_TYPE_OK) {
3507
3508 }
3509 }
3510
3511 public void valueChanged(TreeSelectionEvent arg0) {
3512 // TODO Auto-generated method stub
3513
3514 }
3515
3516 public void menuCanceled(MenuEvent arg0) {
3517 // TODO Auto-generated method stub
3518
3519 }
3520
3521 public void menuDeselected(MenuEvent arg0) {
3522 // TODO Auto-generated method stub
3523
3524 }
3525
3526 public void menuSelected(MenuEvent arg0) {
3527 if (arg0.getSource() == jMenuFile) {
3528 //
3529 // Enable close/close all if some files are opened
3530 //
3531 jMenuItemFileClose.setEnabled(GlobalData.openingModuleList.isOpen()
3532 || GlobalData.openingPackageList.isOpen()
3533 || GlobalData.openingPlatformList.isOpen());
3534 jMenuItemFileCloseAll.setEnabled(GlobalData.openingModuleList.isOpen()
3535 || GlobalData.openingPackageList.isOpen()
3536 || GlobalData.openingPlatformList.isOpen());
3537
3538 //
3539 // Enable save/save all if some files are changed
3540 //
3541 jMenuItemFileSave.setEnabled(!GlobalData.openingModuleList.isSaved()
3542 || !GlobalData.openingPackageList.isSaved()
3543 || !GlobalData.openingPlatformList.isSaved());
3544 jMenuItemFileSaveAll.setEnabled(!GlobalData.openingModuleList.isSaved()
3545 || !GlobalData.openingPackageList.isSaved()
3546 || !GlobalData.openingPlatformList.isSaved());
3547 }
3548
3549 if (arg0.getSource() == jMenuTools) {
3550 //
3551 // Enable clone when select some items
3552 //
3553 if (iTree.getSelectionPath() == null) {
3554 jMenuItemToolsClone.setEnabled(false);
3555 } else {
3556 int category = iTree.getSelectCategory();
3557 if (category == IDefaultMutableTreeNode.MODULE_DESCRIPTION
3558 || category == IDefaultMutableTreeNode.PACKAGE_DESCRIPTION
3559 || category == IDefaultMutableTreeNode.PLATFORM_DESCRIPTION
3560 || category == IDefaultMutableTreeNode.MODULE_PACKAGE
3561 || category == IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY
3562 || category == IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE) {
3563 jMenuItemToolsClone.setEnabled(false);
3564 } else {
3565 jMenuItemToolsClone.setEnabled(true);
3566 }
3567 }
3568 }
3569 }
3570
3571 public void keyTyped(KeyEvent arg0) {
3572 // TODO Auto-generated method stub
3573
3574 }
3575
3576 public void keyPressed(KeyEvent arg0) {
3577 // TODO Auto-generated method stub
3578
3579 }
3580
3581 public void keyReleased(KeyEvent arg0) {
3582 if (arg0.getSource() == this.iTree) {
3583 if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
3584 this.doubleClickModuleTreeNode();
3585 }
3586 }
3587 }
3588 }