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