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