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