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