]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java
Refine the code for PCD tools.
[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.MODULE,
1855 false, vModule.get(indexJ)));
1856 } else {
1857 dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(),
1858 IDefaultMutableTreeNode.MODULE,
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.PACKAGE, 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.PLATFORM,
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.MODULE)));
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 // Select msa header node and show it in editor panel
2164 //
2165 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id,
2166 IDefaultMutableTreeNode.MSA_HEADER)));
2167 showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, openingModuleList.getOpeningModuleById(id));
2168 this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id);
2169 }
2170
2171 /**
2172 Open Module
2173
2174 @param path input file path
2175
2176 **/
2177 private void openModule(String path) {
2178 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
2179 try {
2180 msa = OpenFile.openMsaFile(path);
2181 } catch (IOException e) {
2182 Log.wrn("Open Module Surface Area " + path, e.getMessage());
2183 Log.err("Open Module Surface Area " + path, e.getMessage());
2184 return;
2185 } catch (XmlException e) {
2186 Log.wrn("Open Module Surface Area " + path, e.getMessage());
2187 Log.err("Open Module Surface Area " + path, e.getMessage());
2188 return;
2189 } catch (Exception e) {
2190 Log.wrn("Open Module Surface Area " + path, "Invalid file type");
2191 Log.err("Open Module Surface Area " + path, "Invalid file type");
2192 return;
2193 }
2194 Identification id = new Identification(msa.getMsaHeader().getModuleName(), msa.getMsaHeader().getGuidValue(),
2195 msa.getMsaHeader().getVersion(), path);
2196 //
2197 // Generate module id
2198 //
2199 PackageIdentification pid = wt.getPackageIdByModuleId(id);
2200 if (pid != null) {
2201 //
2202 // To judge if the module existed in vModuleList
2203 // If not, add it to vModuleList
2204 //
2205 boolean isFind = false;
2206 for (int index = 0; index < vModuleList.size(); index++) {
2207 if (vModuleList.elementAt(index).equals(id)) {
2208 isFind = true;
2209 break;
2210 }
2211 }
2212 if (!isFind) {
2213 ModuleIdentification mid = new ModuleIdentification(id, pid);
2214 vModuleList.addElement(mid);
2215 addModuleToTree(mid);
2216 }
2217 } else {
2218 //
2219 // The module is not in existing packages
2220 //
2221 Log.wrn("Open Module", "The module hasn't been added to any package of current workspace!");
2222 return;
2223 }
2224
2225 //
2226 // Make the node selected
2227 //
2228 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id,
2229 IDefaultMutableTreeNode.MODULE)));
2230 //
2231 // Update opening Module list information
2232 //
2233 if (!openingModuleList.existsModule(id)) {
2234 //
2235 // Insert sub node of module
2236 //
2237 insertModuleTreeNode(id);
2238 iTree.getSelectNode().setOpening(true);
2239
2240 //
2241 // Update opening module list
2242 //
2243 openingModuleList.insertToOpeningModuleList(id, msa);
2244 openingModuleList.setTreePathById(id, iTree.getSelectionPath());
2245 }
2246 //
2247 // Select msa header node and show it in editor panel
2248 //
2249 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id,
2250 IDefaultMutableTreeNode.MSA_HEADER)));
2251 showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, openingModuleList.getOpeningModuleById(id));
2252 this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id);
2253 }
2254
2255 /**
2256 Open Package
2257
2258 @param path input file path
2259
2260 **/
2261 private void openPackage(String path) {
2262 PackageSurfaceAreaDocument.PackageSurfaceArea spd = null;
2263 try {
2264 spd = OpenFile.openSpdFile(path);
2265 } catch (IOException 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 (XmlException e) {
2270 Log.wrn("Open Package Surface Area " + path, e.getMessage());
2271 Log.err("Open Package Surface Area " + path, e.getMessage());
2272 return;
2273 } catch (Exception e) {
2274 Log.wrn("Open Package Surface Area " + path, "Invalid file type");
2275 Log.err("Open Package Surface Area " + path, "Invalid file type");
2276 return;
2277 }
2278 Identification id = new Identification(spd.getSpdHeader().getPackageName(), spd.getSpdHeader().getGuidValue(),
2279 spd.getSpdHeader().getVersion(), path);
2280 //
2281 // To judge if the package existed in vPackageList
2282 // If not, add it to vPackageList
2283 //
2284 boolean isFind = false;
2285 for (int index = 0; index < vPackageList.size(); index++) {
2286 if (vPackageList.elementAt(index).equals(id)) {
2287 isFind = true;
2288 break;
2289 }
2290 }
2291 if (!isFind) {
2292 //
2293 // The module is not in existing packages
2294 //
2295 Log.wrn("Open Package", "The package hasn't been added to current workspace!");
2296 return;
2297 }
2298
2299 //
2300 // Make the node selected
2301 //
2302 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPackageDescription, id,
2303 IDefaultMutableTreeNode.PACKAGE)));
2304 //
2305 // Update opening package list information
2306 //
2307 if (!openingPackageList.existsPackage(id)) {
2308 //
2309 // Insert sub node of module
2310 //
2311 insertPackageTreeNode(id);
2312 iTree.getSelectNode().setOpening(true);
2313
2314 //
2315 // Update opening module list
2316 //
2317 openingPackageList.insertToOpeningPackageList(id, spd);
2318 openingPackageList.setTreePathById(id, iTree.getSelectionPath());
2319 }
2320 //
2321 // Show spd header in editor panel
2322 //
2323 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPackageDescription, id,
2324 IDefaultMutableTreeNode.SPD_HEADER)));
2325 showPackageElement(IDefaultMutableTreeNode.SPD_HEADER, openingPackageList.getOpeningPackageById(id));
2326 this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id);
2327 }
2328
2329 /**
2330 Open Package
2331
2332 @param path input file path
2333
2334 **/
2335 private void openPlatform(String path) {
2336 PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd = null;
2337 try {
2338 fpd = OpenFile.openFpdFile(path);
2339 } catch (IOException e) {
2340 Log.wrn("Open Platform Surface Area " + path, e.getMessage());
2341 Log.err("Open Platform Surface Area " + path, e.getMessage());
2342 return;
2343 } catch (XmlException e) {
2344 Log.wrn("Open Platform Surface Area " + path, e.getMessage());
2345 Log.err("Open Platform Surface Area " + path, e.getMessage());
2346 return;
2347 } catch (Exception e) {
2348 Log.wrn("Open Platform Surface Area " + path, "Invalid file type");
2349 Log.err("Open Platform Surface Area " + path, "Invalid file type");
2350 return;
2351 }
2352 Identification id = new Identification(fpd.getPlatformHeader().getPlatformName(), fpd.getPlatformHeader()
2353 .getGuidValue(),
2354 fpd.getPlatformHeader().getVersion(), path);
2355 //
2356 // To judge if the platform existed in vPlatformList
2357 // If not, add it to vPlatformList
2358 //
2359 boolean isFind = false;
2360 for (int index = 0; index < vPlatformList.size(); index++) {
2361 if (vPlatformList.elementAt(index).equals(id)) {
2362 isFind = true;
2363 break;
2364 }
2365 }
2366 if (!isFind) {
2367 //
2368 // The module is not in existing packages
2369 //
2370 Log.wrn("Open Platform", "The platform hasn't been added to current workspace!");
2371 return;
2372 }
2373
2374 //
2375 // Make the node selected
2376 //
2377 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPlatformDescription, id,
2378 IDefaultMutableTreeNode.PLATFORM)));
2379 //
2380 // Update opening package list information
2381 //
2382 if (!openingPlatformList.existsPlatform(id)) {
2383 //
2384 // Insert sub node of module
2385 //
2386 insertPlatformTreeNode(id);
2387 iTree.getSelectNode().setOpening(true);
2388
2389 //
2390 // Update opening module list
2391 //
2392 openingPlatformList.insertToOpeningPlatformList(id, fpd);
2393 openingPlatformList.setTreePathById(id, iTree.getSelectionPath());
2394 }
2395 //
2396 // Show fpd header in editor panel
2397 //
2398 iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPlatformDescription, id,
2399 IDefaultMutableTreeNode.FPD_PLATFORMHEADER)));
2400 showPlatformElement(IDefaultMutableTreeNode.FPD_PLATFORMHEADER, openingPlatformList.getOpeningPlatformById(id));
2401 this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id);
2402 }
2403
2404 /**
2405 Save module
2406
2407 **/
2408 private void saveModule(int index) {
2409 OpeningModuleType omt = openingModuleList.getOpeningModuleByIndex(index);
2410 if (omt.isNew()) {
2411 if (getNewFilePath(DataType.MODULE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) {
2412 return;
2413 }
2414 }
2415 try {
2416 SaveFile.saveMsaFile(omt.getId().getPath(), omt.getXmlMsa());
2417 openingModuleList.setNew(omt.getId(), false);
2418 openingModuleList.setModuleSaved(omt.getId(), true);
2419 } catch (Exception e) {
2420 Log.wrn("Save Module", e.getMessage());
2421 Log.err("Save Module", e.getMessage());
2422 }
2423 }
2424
2425 /**
2426 Save package
2427
2428 **/
2429 private void savePackage(int index) {
2430 OpeningPackageType opt = openingPackageList.getOpeningPackageByIndex(index);
2431 if (opt.isNew()) {
2432 if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) {
2433 return;
2434 }
2435 }
2436 try {
2437 SaveFile.saveSpdFile(opt.getId().getPath(), opt.getXmlSpd());
2438 openingPackageList.setNew(opt.getId(), false);
2439 openingPackageList.setPackageSaved(opt.getId(), true);
2440 } catch (Exception e) {
2441 Log.wrn("Save Package", e.getMessage());
2442 Log.err("Save Package", e.getMessage());
2443 }
2444 }
2445
2446 /**
2447 Save platform
2448
2449 **/
2450 private void savePlatform(int index) {
2451 OpeningPlatformType opt = openingPlatformList.getOpeningPlatformByIndex(index);
2452 if (opt.isNew()) {
2453 if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) {
2454 return;
2455 }
2456 }
2457 try {
2458 SaveFile.saveFpdFile(opt.getId().getPath(), opt.getXmlFpd());
2459 openingPlatformList.setNew(opt.getId(), false);
2460 openingPlatformList.setPlatformSaved(opt.getId(), true);
2461 } catch (Exception e) {
2462 Log.wrn("Save Package", e.getMessage());
2463 Log.err("Save Package", e.getMessage());
2464 }
2465 }
2466
2467 public void componentHidden(ComponentEvent arg0) {
2468 // TODO Auto-generated method stub
2469
2470 }
2471
2472 public void componentMoved(ComponentEvent arg0) {
2473 // TODO Auto-generated method stub
2474
2475 }
2476
2477 public void componentResized(ComponentEvent arg0) {
2478 this.jSplitPane.setSize(this.getWidth() - DataType.MAIN_FRAME_WIDTH_SPACING,
2479 this.getHeight() - DataType.MAIN_FRAME_HEIGHT_SPACING);
2480 this.jSplitPane.validate();
2481 resizeDesktopPanel();
2482 }
2483
2484 public void componentShown(ComponentEvent arg0) {
2485 // TODO Auto-generated method stub
2486
2487 }
2488
2489 /**
2490 Resize JDesktopPanel
2491
2492 */
2493 private void resizeDesktopPanel() {
2494 resizeDesktopPanel(this.jDesktopPaneModule);
2495 resizeDesktopPanel(this.jDesktopPanePackage);
2496 resizeDesktopPanel(this.jDesktopPanePlatform);
2497 }
2498
2499 /**
2500 Resize JDesktopPanel
2501
2502 */
2503 private void resizeDesktopPanel(JDesktopPane jdk) {
2504 JInternalFrame[] iif = jdk.getAllFrames();
2505 for (int index = 0; index < iif.length; index++) {
2506 iif[index].setSize(jdk.getWidth(), jdk.getHeight());
2507 }
2508 }
2509
2510 private void getCompontentsFromFrameworkDatabase() {
2511 this.vModuleList = wt.getAllModules();
2512 this.vPackageList = wt.getAllPackages();
2513 this.vPlatformList = wt.getAllPlatforms();
2514 }
2515
2516 private void insertModuleTreeNode(Identification id) {
2517 iTree.addNode(new IDefaultMutableTreeNode("Module Header", IDefaultMutableTreeNode.MSA_HEADER, true, id));
2518 iTree.addNode(new IDefaultMutableTreeNode("Module Definitions", IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS,
2519 true, id));
2520 iTree.addNode(new IDefaultMutableTreeNode("Library Class Definitions",
2521 IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id));
2522 iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id));
2523 iTree.addNode(new IDefaultMutableTreeNode("Package Dependencies",
2524 IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id));
2525 iTree.addNode(new IDefaultMutableTreeNode("Protocols", IDefaultMutableTreeNode.MSA_PROTOCOLS, true, id));
2526 iTree.addNode(new IDefaultMutableTreeNode("Events", IDefaultMutableTreeNode.MSA_EVENTS, true, id));
2527 iTree.addNode(new IDefaultMutableTreeNode("Hobs", IDefaultMutableTreeNode.MSA_HOBS, true, id));
2528 iTree.addNode(new IDefaultMutableTreeNode("Ppis", IDefaultMutableTreeNode.MSA_PPIS, true, id));
2529 iTree.addNode(new IDefaultMutableTreeNode("Variables", IDefaultMutableTreeNode.MSA_VARIABLES, true, id));
2530 iTree.addNode(new IDefaultMutableTreeNode("Boot Modes", IDefaultMutableTreeNode.MSA_BOOTMODES, true, id));
2531 iTree.addNode(new IDefaultMutableTreeNode("System Tables", IDefaultMutableTreeNode.MSA_SYSTEMTABLES, true, id));
2532 iTree.addNode(new IDefaultMutableTreeNode("Data Hubs", IDefaultMutableTreeNode.MSA_DATAHUBS, true, id));
2533 iTree.addNode(new IDefaultMutableTreeNode("Hii Packages", IDefaultMutableTreeNode.MSA_HIIPACKAGES, true, id));
2534 iTree.addNode(new IDefaultMutableTreeNode("Guids", IDefaultMutableTreeNode.MSA_GUIDS, true, id));
2535 iTree.addNode(new IDefaultMutableTreeNode("Externs", IDefaultMutableTreeNode.MSA_EXTERNS, true, id));
2536 iTree.addNode(new IDefaultMutableTreeNode("PcdCoded", IDefaultMutableTreeNode.MSA_PCDS, true, id));
2537 }
2538
2539 private void insertPackageTreeNode(Identification id) {
2540 iTree.addNode(new IDefaultMutableTreeNode("Package Header", IDefaultMutableTreeNode.SPD_HEADER, true, id));
2541 iTree.addNode(new IDefaultMutableTreeNode("Package Definitions",
2542 IDefaultMutableTreeNode.SPD_PACKAGEDEFINITIONS, true, id));
2543 iTree.addNode(new IDefaultMutableTreeNode("Library Class Declarations",
2544 IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id));
2545 iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id));
2546 iTree.addNode(new IDefaultMutableTreeNode("Package Includes", IDefaultMutableTreeNode.SPD_PACKAGEHEADERS, true,
2547 id));
2548 iTree.addNode(new IDefaultMutableTreeNode("Guid Declarations", IDefaultMutableTreeNode.SPD_GUIDDECLARATIONS,
2549 true, id));
2550 iTree.addNode(new IDefaultMutableTreeNode("Protocol Declarations",
2551 IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS, true, id));
2552 iTree.addNode(new IDefaultMutableTreeNode("Ppi Declarations", IDefaultMutableTreeNode.SPD_PPIDECLARATIONS,
2553 true, id));
2554 iTree.addNode(new IDefaultMutableTreeNode("Pcd Declarations", IDefaultMutableTreeNode.SPD_PCDDECLARATIONS,
2555 true, id));
2556 }
2557
2558 private void insertPlatformTreeNode(Identification id) {
2559 iTree.addNode(new IDefaultMutableTreeNode("Platform Header", IDefaultMutableTreeNode.FPD_PLATFORMHEADER, true,
2560 id));
2561 iTree.addNode(new IDefaultMutableTreeNode("Platform Definitions",
2562 IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS, true, id));
2563 iTree.addNode(new IDefaultMutableTreeNode("Flash", IDefaultMutableTreeNode.FPD_FLASH, true, id));
2564 iTree.addNode(new IDefaultMutableTreeNode("Framework Modules", IDefaultMutableTreeNode.FPD_FRAMEWORKMODULES,
2565 true, id));
2566 iTree.addNode(new IDefaultMutableTreeNode("Pcd Dynamic Build Declarations",
2567 IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS, true, id));
2568 iTree.addNode(new IDefaultMutableTreeNode("Build Options", IDefaultMutableTreeNode.FPD_BUILDOPTIONS, true, id));
2569 }
2570
2571 /**
2572 Operate when double click a tree node
2573
2574 **/
2575 private void doubleClickModuleTreeNode() {
2576 Identification id = null;
2577 int intCategory = -1;
2578 String path = null;
2579 boolean isOpen = false;
2580 try {
2581 id = iTree.getSelectNode().getId();
2582 intCategory = iTree.getSelectCategory();
2583 isOpen = iTree.getSelectNode().isOpening();
2584
2585 if (!isOpen) {
2586 //
2587 // If the node is not opened yet
2588 // Insert top level elements first
2589 //
2590 if (intCategory == IDefaultMutableTreeNode.MODULE) {
2591
2592 if (intCategory == IDefaultMutableTreeNode.MODULE) {
2593 path = iTree.getSelectNode().getId().getPath();
2594 }
2595 if (intCategory == IDefaultMutableTreeNode.PACKAGE) {
2596 path = iTree.getSelectNode().getId().getPath();
2597 }
2598 openModule(path);
2599 return;
2600 }
2601 if (intCategory == IDefaultMutableTreeNode.PACKAGE) {
2602 path = iTree.getSelectNode().getId().getPath();
2603 openPackage(path);
2604 return;
2605 }
2606 if (intCategory == IDefaultMutableTreeNode.PLATFORM) {
2607 path = iTree.getSelectNode().getId().getPath();
2608 openPlatform(path);
2609 return;
2610 }
2611 }
2612
2613 //
2614 // Show editor panel
2615 //
2616 if (intCategory >= IDefaultMutableTreeNode.MSA_HEADER && intCategory < IDefaultMutableTreeNode.SPD_HEADER) {
2617 showModuleElement(intCategory, openingModuleList.getOpeningModuleById(id));
2618 this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id);
2619 }
2620 if (intCategory >= IDefaultMutableTreeNode.SPD_HEADER
2621 && intCategory < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) {
2622 showPackageElement(intCategory, openingPackageList.getOpeningPackageById(id));
2623 this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id);
2624 }
2625 if (intCategory >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) {
2626 showPlatformElement(intCategory, openingPlatformList.getOpeningPlatformById(id));
2627 this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id);
2628 }
2629 } catch (RuntimeException e) {
2630 Log.log("double click category: " + intCategory);
2631 Log.log("double click id path: " + id);
2632 Log.log("double click exception: " + e.getMessage());
2633 }
2634 }
2635
2636 /**
2637 Show content of editor panel via selected element
2638
2639 @param elementType
2640 @param fpd
2641
2642 **/
2643 private void showPlatformElement(int elementType, OpeningPlatformType fpd) {
2644 this.cleanDesktopPanePlatform();
2645
2646 switch (elementType) {
2647 case IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS:
2648 FpdPlatformDefs frmFpdPlatformDefs = new FpdPlatformDefs(fpd);
2649 getJDesktopPanePlatform().add(frmFpdPlatformDefs, 1);
2650 break;
2651 case IDefaultMutableTreeNode.FPD_PLATFORMHEADER:
2652 FpdHeader frmFpdHeader = new FpdHeader(fpd);
2653 getJDesktopPanePlatform().add(frmFpdHeader, 1);
2654 break;
2655 case IDefaultMutableTreeNode.FPD_FLASH:
2656 FpdFlash frmFpdFlash = new FpdFlash(fpd);
2657 getJDesktopPanePlatform().add(frmFpdFlash, 1);
2658 break;
2659 case IDefaultMutableTreeNode.FPD_FRAMEWORKMODULES:
2660 FpdFrameworkModules frmFpdFrameworkModules = new FpdFrameworkModules(fpd);
2661 getJDesktopPanePlatform().add(frmFpdFrameworkModules, 1);
2662 break;
2663 case IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS:
2664 FpdDynamicPcdBuildDefinitions frmFpdDynamicPcdBuildDefinitions = new FpdDynamicPcdBuildDefinitions(fpd);
2665 getJDesktopPanePlatform().add(frmFpdDynamicPcdBuildDefinitions, 1);
2666 break;
2667 case IDefaultMutableTreeNode.FPD_BUILDOPTIONS:
2668 FpdBuildOptions frmFpdBuildOptions = new FpdBuildOptions(fpd);
2669 getJDesktopPanePlatform().add(frmFpdBuildOptions, 1);
2670 break;
2671 }
2672 this.jTabbedPaneEditor.setSelectedIndex(2);
2673 resizeDesktopPanel();
2674 }
2675
2676 /**
2677 Show content of editor panel via selected element
2678
2679 @param elementType
2680 @param spd
2681
2682 */
2683 private void showPackageElement(int elementType, OpeningPackageType spd) {
2684 this.cleanDesktopPanePackage();
2685 Tools.dirForNewSpd = spd.getId().getPath();
2686 switch (elementType) {
2687 case IDefaultMutableTreeNode.SPD_HEADER:
2688 SpdHeader frmSpdHeader = new SpdHeader(spd);
2689 getJDesktopPanePackage().add(frmSpdHeader, 1);
2690 break;
2691 case IDefaultMutableTreeNode.SPD_PACKAGEDEFINITIONS:
2692 SpdPackageDefinitions frmSpdPackageDefinitions = new SpdPackageDefinitions(spd);
2693 getJDesktopPanePackage().add(frmSpdPackageDefinitions, 1);
2694 break;
2695 case IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS:
2696 SpdLibClassDecls frmSlcd = new SpdLibClassDecls(spd);
2697 getJDesktopPanePackage().add(frmSlcd, 1);
2698 break;
2699 case IDefaultMutableTreeNode.SPD_MSAFILES:
2700 SpdMsaFiles frmSmf = new SpdMsaFiles(spd);
2701 getJDesktopPanePackage().add(frmSmf, 1);
2702 break;
2703 case IDefaultMutableTreeNode.SPD_PACKAGEHEADERS:
2704 SpdPackageHeaders frmSph = new SpdPackageHeaders(spd);
2705 getJDesktopPanePackage().add(frmSph, 1);
2706 break;
2707 case IDefaultMutableTreeNode.SPD_GUIDDECLARATIONS:
2708 SpdGuidDecls frmSgd = new SpdGuidDecls(spd);
2709 getJDesktopPanePackage().add(frmSgd, 1);
2710 break;
2711 case IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS:
2712 SpdProtocolDecls frmSprod = new SpdProtocolDecls(spd);
2713 getJDesktopPanePackage().add(frmSprod, 1);
2714 break;
2715 case IDefaultMutableTreeNode.SPD_PPIDECLARATIONS:
2716 SpdPpiDecls frmSppid = new SpdPpiDecls(spd);
2717 getJDesktopPanePackage().add(frmSppid, 1);
2718 break;
2719 case IDefaultMutableTreeNode.SPD_PCDDECLARATIONS:
2720 SpdPcdDefs frmSpcdd = new SpdPcdDefs(spd);
2721 getJDesktopPanePackage().add(frmSpcdd, 1);
2722 break;
2723 }
2724 this.jTabbedPaneEditor.setSelectedIndex(1);
2725 resizeDesktopPanel();
2726 }
2727
2728 /**
2729 Show content of editor panel via selected element
2730
2731 @param elementType
2732 @param msa
2733
2734 */
2735 private void showModuleElement(int elementType, OpeningModuleType msa) {
2736 this.cleanDesktopPaneModule();
2737 switch (elementType) {
2738 case IDefaultMutableTreeNode.MSA_HEADER:
2739 MsaHeader frmMsaHeader = new MsaHeader(msa);
2740 getJDesktopPaneModule().add(frmMsaHeader, 1);
2741 break;
2742 case IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS:
2743 ModuleDefinitions frmMd = new ModuleDefinitions(msa);
2744 getJDesktopPaneModule().add(frmMd, 1);
2745 break;
2746 case IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS:
2747 ModuleLibraryClassDefinitions frmMlcd = new ModuleLibraryClassDefinitions(msa);
2748 getJDesktopPaneModule().add(frmMlcd, 1);
2749 break;
2750 case IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES:
2751 ModulePackageDependencies frmMpd = new ModulePackageDependencies(msa);
2752 getJDesktopPaneModule().add(frmMpd, 1);
2753 break;
2754 case IDefaultMutableTreeNode.MSA_SOURCEFILES:
2755 ModuleSourceFiles frmMsf = new ModuleSourceFiles(msa);
2756 getJDesktopPaneModule().add(frmMsf, 1);
2757 break;
2758 case IDefaultMutableTreeNode.MSA_PROTOCOLS:
2759 ModuleProtocols frmMp = new ModuleProtocols(msa);
2760 getJDesktopPaneModule().add(frmMp, 1);
2761 break;
2762 case IDefaultMutableTreeNode.MSA_EVENTS:
2763 ModuleEvents frmMe = new ModuleEvents(msa);
2764 getJDesktopPaneModule().add(frmMe, 1);
2765 break;
2766 case IDefaultMutableTreeNode.MSA_HOBS:
2767 ModuleHobs frmMh = new ModuleHobs(msa);
2768 getJDesktopPaneModule().add(frmMh, 1);
2769 break;
2770 case IDefaultMutableTreeNode.MSA_PPIS:
2771 ModulePpis frmMpp = new ModulePpis(msa);
2772 getJDesktopPaneModule().add(frmMpp, 1);
2773 break;
2774 case IDefaultMutableTreeNode.MSA_VARIABLES:
2775 ModuleVariables frmMv = new ModuleVariables(msa);
2776 getJDesktopPaneModule().add(frmMv, 1);
2777 break;
2778 case IDefaultMutableTreeNode.MSA_BOOTMODES:
2779 ModuleBootModes frmMbm = new ModuleBootModes(msa);
2780 getJDesktopPaneModule().add(frmMbm, 1);
2781 break;
2782 case IDefaultMutableTreeNode.MSA_SYSTEMTABLES:
2783 ModuleSystemTables frmMst = new ModuleSystemTables(msa);
2784 getJDesktopPaneModule().add(frmMst, 1);
2785 break;
2786 case IDefaultMutableTreeNode.MSA_DATAHUBS:
2787 ModuleDataHubs frmMdh = new ModuleDataHubs(msa);
2788 getJDesktopPaneModule().add(frmMdh, 1);
2789 break;
2790 case IDefaultMutableTreeNode.MSA_HIIPACKAGES:
2791 ModuleHiiPackages frmMf = new ModuleHiiPackages(msa);
2792 getJDesktopPaneModule().add(frmMf, 1);
2793 break;
2794 case IDefaultMutableTreeNode.MSA_GUIDS:
2795 ModuleGuids frmGuid = new ModuleGuids(msa);
2796 getJDesktopPaneModule().add(frmGuid, 1);
2797 break;
2798 case IDefaultMutableTreeNode.MSA_EXTERNS:
2799 ModuleExterns frmMex = new ModuleExterns(msa);
2800 getJDesktopPaneModule().add(frmMex, 1);
2801 break;
2802 case IDefaultMutableTreeNode.MSA_PCDS:
2803 ModulePCDs frmPcd = new ModulePCDs(msa);
2804 getJDesktopPaneModule().add(frmPcd, 1);
2805 break;
2806 }
2807 this.jTabbedPaneEditor.setSelectedIndex(0);
2808 resizeDesktopPanel();
2809 }
2810
2811 //
2812 // Define operations of menu
2813 //
2814 /**
2815 New a file
2816
2817 **/
2818 private void fileNew() {
2819 int result = -1;
2820 //
2821 // Selece new file type
2822 //
2823 NewFileChooser nfc = new NewFileChooser(this, true);
2824 result = nfc.showDialog();
2825
2826 if (result == DataType.RETURN_TYPE_CANCEL) {
2827 nfc.dispose();
2828 return;
2829 } else if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
2830 //
2831 // To new a module
2832 //
2833 SelectModuleBelong smb = new SelectModuleBelong(this, true, result);
2834 result = smb.showDialog();
2835
2836 if (result == DataType.RETURN_TYPE_CANCEL) {
2837 nfc.dispose();
2838 smb.dispose();
2839 return;
2840 } else if (result == DataType.RETURN_TYPE_OK) {
2841 PackageSurfaceAreaDocument.PackageSurfaceArea psa = null;
2842 if (this.openingPackageList.existsPackage(smb.getMid().getPackageId())) {
2843 psa = openingPackageList.getPackageSurfaceAreaFromId(smb.getMid().getPackageId());
2844 }
2845 try {
2846 wt.addModuleToPackage(smb.getMid(), psa);
2847 } catch (IOException e) {
2848 Log.wrn("Upddate MsaFiles of Package", e.getMessage());
2849 Log.err("Upddate MsaFiles of Package", e.getMessage());
2850 return;
2851 } catch (XmlException e) {
2852 Log.wrn("Upddate MsaFiles of Package", e.getMessage());
2853 Log.err("Upddate MsaFiles of Package", e.getMessage());
2854 return;
2855 } catch (Exception e) {
2856 Log.wrn("Upddate MsaFiles of Package", e.getMessage());
2857 Log.err("Upddate MsaFiles of Package", e.getMessage());
2858 return;
2859 }
2860 this.openModule(smb.getMid().getPath(), smb.getMid());
2861 }
2862 } else if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
2863 //
2864 // To new a package
2865 //
2866 SelectModuleBelong smb = new SelectModuleBelong(this, true, result);
2867 result = smb.showDialog();
2868
2869 if (result == DataType.RETURN_TYPE_CANCEL) {
2870 nfc.dispose();
2871 smb.dispose();
2872 return;
2873 } else if (result == DataType.RETURN_TYPE_OK) {
2874 try {
2875 wt.addPackageToDatabase(smb.getPid());
2876 } catch (Exception e) {
2877 Log.err("addPackageToDatabase", e.getMessage());
2878 }
2879 vPackageList.addElement(smb.getPid());
2880
2881 //
2882 // Add to Module Description node
2883 //
2884 IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(),
2885 IDefaultMutableTreeNode.MODULE_PACKAGE,
2886 false, vPackageList.lastElement());
2887
2888 iTree.addNode(dmtnModuleDescription, node);
2889
2890 //
2891 // Add new SpdHeader node to the tree
2892 //
2893 node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(),
2894 IDefaultMutableTreeNode.SPD_HEADER, true, vPackageList.lastElement());
2895 iTree.addNode(dmtnPackageDescription, node);
2896
2897 this.openPackage(smb.getPid().getPath());
2898 }
2899 } else if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
2900 //
2901 // To new a platform
2902 //
2903 SelectModuleBelong smb = new SelectModuleBelong(this, true, result);
2904 result = smb.showDialog();
2905
2906 if (result == DataType.RETURN_TYPE_CANCEL) {
2907 nfc.dispose();
2908 smb.dispose();
2909 return;
2910 } else if (result == DataType.RETURN_TYPE_OK) {
2911 try {
2912 wt.addPlatformToDatabase(smb.getFid());
2913 } catch (Exception e) {
2914 Log.err("addPlatformToDatabase", e.getMessage());
2915 }
2916 vPlatformList.addElement(smb.getFid());
2917 //
2918 // Add new SpdHeader node to the tree
2919 //
2920 IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPlatformList.lastElement().getName(),
2921 IDefaultMutableTreeNode.FPD_PLATFORMHEADER,
2922 true, vPlatformList.lastElement());
2923 iTree.addNode(dmtnPlatformDescription, node);
2924 this.openPlatform(smb.getFid().getPath());
2925 }
2926 }
2927 }
2928
2929 /**
2930 Open a file
2931
2932 **/
2933 private void open() {
2934 JFileChooser fc = new JFileChooser(Workspace.getCurrentWorkspace());
2935 fc.setAcceptAllFileFilterUsed(false);
2936 IFileFilter iffM = new IFileFilter(DataType.MODULE_SURFACE_AREA_EXT);
2937 IFileFilter iffP = new IFileFilter(DataType.PACKAGE_SURFACE_AREA_EXT);
2938 IFileFilter iffF = new IFileFilter(DataType.PLATFORM_SURFACE_AREA_EXT);
2939 fc.addChoosableFileFilter(iffM);
2940 fc.addChoosableFileFilter(iffP);
2941 fc.addChoosableFileFilter(iffF);
2942 fc.setFileFilter(iffM);
2943
2944 int result = fc.showOpenDialog(new JPanel());
2945
2946 if (result == JFileChooser.APPROVE_OPTION) {
2947 String path = fc.getSelectedFile().getPath();
2948 String match = path.substring(path.length() - 4);
2949 if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.MODULE_SURFACE_AREA_EXT)) {
2950 openModule(path);
2951 } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PACKAGE_SURFACE_AREA_EXT)) {
2952 openPackage(path);
2953 } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PLATFORM_SURFACE_AREA_EXT)) {
2954 openPlatform(path);
2955 }
2956 }
2957 }
2958
2959 /**
2960 Close files
2961
2962 **/
2963 private void close() {
2964 switch (this.jTabbedPaneEditor.getSelectedIndex()) {
2965 //
2966 // Current is module
2967 //
2968 case 0:
2969 if (this.currentOpeningModuleIndex > -1) {
2970 if (!openingModuleList.getModuleSaved(currentOpeningModuleIndex)) {
2971 int result = showSaveDialog();
2972 if (result == JOptionPane.YES_OPTION) {
2973 this.saveAll();
2974 }
2975 if (result == JOptionPane.NO_OPTION) {
2976 // Do nothing
2977 }
2978 if (result == JOptionPane.CANCEL_OPTION) {
2979 return;
2980 }
2981 }
2982 iTree.removeNodeChildrenByPath(openingModuleList.getTreePathByIndex(currentOpeningModuleIndex));
2983 this.openingModuleList.removeFromOpeningModuleListByIndex(this.currentOpeningModuleIndex);
2984 this.cleanDesktopPaneModule();
2985 this.currentOpeningModuleIndex = -1;
2986 }
2987 break;
2988 //
2989 // Current is package
2990 //
2991 case 1:
2992 if (this.currentOpeningPackageIndex > -1) {
2993 if (!openingPackageList.getPackageSaved(currentOpeningPackageIndex)) {
2994 int result = showSaveDialog();
2995 if (result == JOptionPane.YES_OPTION) {
2996 this.saveAll();
2997 }
2998 if (result == JOptionPane.NO_OPTION) {
2999 // Do nothing
3000 }
3001 if (result == JOptionPane.CANCEL_OPTION) {
3002 return;
3003 }
3004 }
3005 iTree.removeNodeChildrenByPath(openingPackageList.getTreePathByIndex(currentOpeningPackageIndex));
3006 this.openingPackageList.removeFromOpeningPackageListByIndex(this.currentOpeningPackageIndex);
3007 this.cleanDesktopPanePackage();
3008 this.currentOpeningPackageIndex = -1;
3009 }
3010 break;
3011 //
3012 // Current is platform
3013 //
3014 case 2:
3015 if (this.currentOpeningPlatformIndex > -1) {
3016 if (!openingPlatformList.getPlatformSaved(currentOpeningPlatformIndex)) {
3017 int result = showSaveDialog();
3018 if (result == JOptionPane.YES_OPTION) {
3019 this.saveAll();
3020 }
3021 if (result == JOptionPane.NO_OPTION) {
3022 // Do nothing
3023 }
3024 if (result == JOptionPane.CANCEL_OPTION) {
3025 return;
3026 }
3027 }
3028 iTree.removeNodeChildrenByPath(openingPlatformList.getTreePathByIndex(currentOpeningPlatformIndex));
3029 this.openingPlatformList.removeFromOpeningPlatformListByIndex(this.currentOpeningPlatformIndex);
3030 this.cleanDesktopPanePlatform();
3031 this.currentOpeningPlatformIndex = -1;
3032 }
3033 break;
3034 }
3035 }
3036
3037 /**
3038 Close all opening files and clean all showing internal frame
3039
3040 **/
3041 private void closeAll() {
3042 int result = -1;
3043 if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) {
3044 result = showSaveDialog();
3045 }
3046 if (result == JOptionPane.YES_OPTION) {
3047 this.saveAll();
3048 }
3049 if (result == JOptionPane.NO_OPTION) {
3050 //
3051 // Do nothing
3052 //
3053 }
3054 if (result == JOptionPane.CANCEL_OPTION) {
3055 return;
3056 }
3057 this.cleanDesktopPane();
3058 this.getCompontentsFromFrameworkDatabase();
3059 openingModuleList.removeAllFromOpeningModuleList();
3060 openingPackageList.removeAllFromOpeningPackageList();
3061 openingPlatformList.removeAllFromOpeningPlatformList();
3062 this.makeEmptyTree();
3063 }
3064
3065 /**
3066 Save currentModule when press button OK
3067
3068 **/
3069 private void save() {
3070 switch (this.jTabbedPaneEditor.getSelectedIndex()) {
3071 case 0:
3072 if (this.currentOpeningModuleIndex > -1) {
3073 saveModule(this.currentOpeningModuleIndex);
3074 }
3075 break;
3076 case 1:
3077 if (this.currentOpeningPackageIndex > -1) {
3078 savePackage(this.currentOpeningPackageIndex);
3079 }
3080 break;
3081 case 2:
3082 if (this.currentOpeningPlatformIndex > -1) {
3083 savePlatform(this.currentOpeningPlatformIndex);
3084 }
3085 break;
3086 }
3087 }
3088
3089 private void saveAs() {
3090
3091 }
3092
3093 private void saveAll() {
3094 //
3095 // Save all modules
3096 //
3097 for (int index = 0; index < openingModuleList.size(); index++) {
3098 if (!openingModuleList.getModuleSaved(index)) {
3099 saveModule(index);
3100 }
3101 }
3102
3103 //
3104 // Save all packages
3105 //
3106 for (int index = 0; index < openingPackageList.size(); index++) {
3107 if (!openingPackageList.getPackageSaved(index)) {
3108 savePackage(index);
3109 }
3110 }
3111
3112 //
3113 // Save all platforms
3114 //
3115 for (int index = 0; index < openingPlatformList.size(); index++) {
3116 if (!openingPlatformList.getPlatformSaved(index)) {
3117 savePlatform(index);
3118 }
3119 }
3120 }
3121
3122 /**
3123 To save changed items before exit.
3124
3125 **/
3126 private void exit() {
3127 int result = -1;
3128 if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) {
3129 result = showSaveDialog();
3130 }
3131 if (result == JOptionPane.YES_OPTION) {
3132 this.saveAll();
3133 }
3134 if (result == JOptionPane.NO_OPTION) {
3135 // Do nothing
3136 }
3137 if (result == JOptionPane.CANCEL_OPTION) {
3138 return;
3139 }
3140 this.dispose();
3141 System.exit(0);
3142 }
3143
3144 /**
3145 Switch current workspace to others
3146
3147 **/
3148 private void changeWorkspace() {
3149 SwitchWorkspace sw = new SwitchWorkspace(this, true);
3150 int result = sw.showDialog();
3151 if (result == DataType.RETURN_TYPE_CANCEL) {
3152 return;
3153 } else if (result == DataType.RETURN_TYPE_OK) {
3154 //
3155 // Reinit whole window
3156 //
3157 closeAll();
3158 this.setTitle(DataType.PROJECT_NAME + " " + DataType.PROJECT_VERSION + " " + "- ["
3159 + Workspace.getCurrentWorkspace() + "]");
3160 }
3161 sw.dispose();
3162 }
3163
3164 /**
3165 To create a Far file from current workspace
3166
3167 **/
3168 private void createFar() {
3169 CreateStepOne cso = new CreateStepOne(this, true);
3170 int result = cso.showDialog();
3171 if (result == DataType.RETURN_TYPE_OK) {
3172 String strReturn = "Create Far Done!";
3173 JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION,
3174 JOptionPane.INFORMATION_MESSAGE);
3175 }
3176 cso.dispose();
3177 }
3178
3179 /**
3180 To install a Far file to current workspace
3181
3182 **/
3183 private void installFar() {
3184 InstallStepOne iso = new InstallStepOne(this, true);
3185 int result = iso.showDialog();
3186 if (result == DataType.RETURN_TYPE_OK) {
3187 String strReturn = "<html>Install 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 iso.dispose();
3193 }
3194
3195 /**
3196 To remove a Far's items from current workspace
3197
3198 **/
3199 private void removeFar() {
3200 DeleteStepOne dso = new DeleteStepOne(this, true);
3201 int result = dso.showDialog();
3202 if (result == DataType.RETURN_TYPE_OK) {
3203 String strReturn = "<html>Delete 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 dso.dispose();
3209 }
3210
3211 /**
3212 To update an existing Far file
3213
3214 **/
3215 private void updateFar() {
3216 UpdateStepOne uso = new UpdateStepOne(this, true);
3217 int result = uso.showDialog();
3218 if (result == DataType.RETURN_TYPE_OK) {
3219 String strReturn = "<html>Update Far Done! <br>The WORKSPACE will be refreshed!</html>";
3220 JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION,
3221 JOptionPane.INFORMATION_MESSAGE);
3222 this.closeAll();
3223 }
3224 uso.dispose();
3225 }
3226
3227 /**
3228 Show Tool Chain Configuration Dialog to setup Tool Chain
3229
3230 **/
3231 private void setupToolChainConfiguration() {
3232 ToolChainConfig tcc = ToolChainConfig.getInstance();
3233 tcc.showDialog();
3234 }
3235
3236 /**
3237 Clone selected item
3238
3239 **/
3240 private void cloneItem() {
3241 int mode = -1;
3242
3243 //
3244 // Check if there is any item can be cloned
3245 //
3246 if (iTree.getSelectionPath() == null) {
3247 Log.wrn("Clone", "Please select a target to clone!");
3248 return;
3249 }
3250 int category = iTree.getSelectCategory();
3251 Identification id = iTree.getSelectNode().getId();
3252 if (category == IDefaultMutableTreeNode.MODULE || category == IDefaultMutableTreeNode.PACKAGE
3253 || category == IDefaultMutableTreeNode.PLATFORM) {
3254 Log.wrn("Clone", "Please select a target to clone!");
3255 return;
3256 }
3257
3258 if (category == IDefaultMutableTreeNode.WORKSPACE) {
3259 mode = DataType.RETURN_TYPE_WORKSPACE;
3260 id = null;
3261 }
3262 if (category >= IDefaultMutableTreeNode.MSA_HEADER && category < IDefaultMutableTreeNode.SPD_HEADER) {
3263 mode = DataType.RETURN_TYPE_MODULE_SURFACE_AREA;
3264 }
3265 if (category >= IDefaultMutableTreeNode.SPD_HEADER && category < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) {
3266 mode = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA;
3267 }
3268 if (category >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) {
3269 mode = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;
3270 }
3271
3272 Clone c = new Clone(this, true, mode, id);
3273 int result = c.showDialog();
3274
3275 if (result == DataType.RETURN_TYPE_CANCEL) {
3276 c.dispose();
3277 }
3278 if (result == DataType.RETURN_TYPE_WORKSPACE) {
3279 Tools.showInformationMessage("Workspace Clone Finished");
3280 }
3281 if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
3282 Tools.showInformationMessage("Module Surface Area Clone Finished");
3283 vModuleList.addElement(c.getMid());
3284 addModuleToTree(c.getMid());
3285 }
3286 if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
3287 Tools.showInformationMessage("Package Surface Area Clone Finished");
3288 vPackageList.addElement(c.getPid());
3289 //
3290 // Add new SpdHeader node to the tree
3291 //
3292 IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(),
3293 IDefaultMutableTreeNode.SPD_HEADER, true,
3294 vPackageList.lastElement());
3295 iTree.addNode(dmtnPackageDescription, node);
3296 }
3297 if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
3298 Tools.showInformationMessage("Platform Surface Area Clone Finished");
3299 vPlatformList.addElement(c.getFid());
3300 //
3301 // Add new SpdHeader node to the tree
3302 //
3303 IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPlatformList.lastElement().getName(),
3304 IDefaultMutableTreeNode.FPD_PLATFORMHEADER,
3305 true, vPlatformList.lastElement());
3306 iTree.addNode(dmtnPlatformDescription, node);
3307 //this.openPlatform(c.getFid().getPath());
3308 }
3309 if (result == DataType.RETURN_TYPE_OK) {
3310
3311 }
3312 }
3313
3314 public void valueChanged(TreeSelectionEvent arg0) {
3315 // TODO Auto-generated method stub
3316
3317 }
3318
3319 public void menuCanceled(MenuEvent arg0) {
3320 // TODO Auto-generated method stub
3321
3322 }
3323
3324 public void menuDeselected(MenuEvent arg0) {
3325 // TODO Auto-generated method stub
3326
3327 }
3328
3329 public void menuSelected(MenuEvent arg0) {
3330 if (arg0.getSource() == jMenuFile) {
3331 //
3332 // Enable close/close all if some files are opened
3333 //
3334 jMenuItemFileClose.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend()
3335 || openingPlatformList.isOpend());
3336 jMenuItemFileCloseAll.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend()
3337 || openingPlatformList.isOpend());
3338
3339 //
3340 // Enable save/save all if some files are changed
3341 //
3342 jMenuItemFileSave.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved()
3343 || !openingPlatformList.isSaved());
3344 jMenuItemFileSaveAll.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved()
3345 || !openingPlatformList.isSaved());
3346 }
3347
3348 if (arg0.getSource() == jMenuTools) {
3349 //
3350 // Enable clone when select some items
3351 //
3352 if (iTree.getSelectionPath() == null) {
3353 jMenuItemToolsClone.setEnabled(false);
3354 } else {
3355 int category = iTree.getSelectCategory();
3356 if (category == IDefaultMutableTreeNode.MODULE || category == IDefaultMutableTreeNode.PACKAGE
3357 || category == IDefaultMutableTreeNode.PLATFORM
3358 || category == IDefaultMutableTreeNode.MODULE_PACKAGE
3359 || category == IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY
3360 || category == IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE) {
3361 jMenuItemToolsClone.setEnabled(false);
3362 } else {
3363 jMenuItemToolsClone.setEnabled(true);
3364 }
3365 }
3366 }
3367 }
3368 }