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