X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2FFrameworkWizardUI.java;h=5efa81b25d2a1c2552161f353e8ae17dc1922b15;hp=68a6bc5660550d56fbb749d2bfce0507408b60bf;hb=0e8d8bc75d4b513716d22e3e6d57a9a811f48091;hpb=535329b5c1782a324f072793abd6dc81e54ad007 diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java index 68a6bc5660..5efa81b25d 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java @@ -17,11 +17,17 @@ package org.tianocore.frameworkwizard; import java.awt.event.ActionEvent; import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.WindowEvent; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; import java.io.IOException; +import java.util.Iterator; +import java.util.Set; import java.util.Vector; import javax.swing.JButton; @@ -42,24 +48,21 @@ import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.TreePath; import org.apache.xmlbeans.XmlException; -import org.tianocore.ModuleSurfaceAreaDocument; import org.tianocore.PackageSurfaceAreaDocument; -import org.tianocore.PlatformSurfaceAreaDocument; import org.tianocore.frameworkwizard.common.DataType; +import org.tianocore.frameworkwizard.common.GlobalData; import org.tianocore.frameworkwizard.common.IFileFilter; import org.tianocore.frameworkwizard.common.Log; -import org.tianocore.frameworkwizard.common.OpenFile; import org.tianocore.frameworkwizard.common.SaveFile; import org.tianocore.frameworkwizard.common.Tools; import org.tianocore.frameworkwizard.common.Identifications.Identification; -import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleList; import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType; -import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageList; import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType; -import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformList; import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType; +import org.tianocore.frameworkwizard.common.find.FindResult; import org.tianocore.frameworkwizard.common.ui.IDefaultMutableTreeNode; import org.tianocore.frameworkwizard.common.ui.IDesktopManager; import org.tianocore.frameworkwizard.common.ui.IFrame; @@ -71,7 +74,6 @@ import org.tianocore.frameworkwizard.far.updateui.UpdateStepOne; import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; import org.tianocore.frameworkwizard.module.ui.ModuleBootModes; import org.tianocore.frameworkwizard.module.ui.ModuleDataHubs; -import org.tianocore.frameworkwizard.module.ui.ModuleDefinitions; import org.tianocore.frameworkwizard.module.ui.ModuleEvents; import org.tianocore.frameworkwizard.module.ui.ModuleExterns; import org.tianocore.frameworkwizard.module.ui.ModuleGuids; @@ -91,7 +93,6 @@ import org.tianocore.frameworkwizard.packaging.ui.SpdGuidDecls; import org.tianocore.frameworkwizard.packaging.ui.SpdHeader; import org.tianocore.frameworkwizard.packaging.ui.SpdLibClassDecls; import org.tianocore.frameworkwizard.packaging.ui.SpdMsaFiles; -import org.tianocore.frameworkwizard.packaging.ui.SpdPackageDefinitions; import org.tianocore.frameworkwizard.packaging.ui.SpdPackageHeaders; import org.tianocore.frameworkwizard.packaging.ui.SpdPcdDefs; import org.tianocore.frameworkwizard.packaging.ui.SpdPpiDecls; @@ -106,13 +107,14 @@ import org.tianocore.frameworkwizard.platform.ui.FpdPlatformDefs; import org.tianocore.frameworkwizard.workspace.Workspace; import org.tianocore.frameworkwizard.workspace.WorkspaceTools; import org.tianocore.frameworkwizard.workspace.ui.SwitchWorkspace; +import org.tianocore.frameworkwizard.toolchain.Preferences; /** The class is used to show main GUI of FrameworkWizard It extends IFrame implements MouseListener, TreeSelectionListener, ComponentListener and MenuListener **/ -public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSelectionListener, ComponentListener, +public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListener, TreeSelectionListener, MenuListener { /// /// Define class Serial Version UID @@ -120,20 +122,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele private static final long serialVersionUID = -7103240960573031772L; /// - /// Used to save information of all files + /// Used to record current operation target /// - private Vector vModuleList = new Vector(); - - private Vector vPackageList = new Vector(); - - private Vector vPlatformList = new Vector(); - - private OpeningModuleList openingModuleList = new OpeningModuleList(); - - private OpeningPackageList openingPackageList = new OpeningPackageList(); - - private OpeningPlatformList openingPlatformList = new OpeningPlatformList(); - private int currentOpeningModuleIndex = -1; private int currentOpeningPackageIndex = -1; @@ -162,6 +152,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele private JMenuItem jMenuItemFileNew = null; + private JMenuItem jMenuItemFileRefresh = null; + private JMenuItem jMenuItemFileSaveAs = null; private JMenuItem jMenuItemFileExit = null; @@ -236,8 +228,6 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele private JMenuItem jMenuItemEditSelectAll = null; - private JMenuItem jMenuItemEditFind = null; - private JMenuItem jMenuItemEditFindNext = null; private JMenu jMenuView = null; @@ -260,11 +250,11 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele private JMenuItem jMenuItemProjectChangeWorkspace = null; - private JMenu jMenuProjectBuildTargets = null; + private JMenuItem jMenuItemToolsBuildPreferences = null; - private JCheckBoxMenuItem jCheckBoxMenuItemProjectBuildTargetsDebug = null; + // private JCheckBoxMenuItem jCheckBoxMenuItemProjectBuildTargetsDebug = null; - private JCheckBoxMenuItem jCheckBoxMenuItemProjectBuildTargetsRelease = null; + // private JCheckBoxMenuItem jCheckBoxMenuItemProjectBuildTargetsRelease = null; private JMenuItem jMenuItemToolsToolChainConfiguration = null; @@ -300,11 +290,27 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele private JMenuItem jMenuItemProjectCreateFar = null; + private JMenu jMenuEditFind = null; + + private JMenuItem jMenuItemEditFindPcd = null; + + private JMenuItem jMenuItemEditFindLibraryClass = null; + + private JMenuItem jMenuItemEditFindPpi = null; + + private JMenuItem jMenuItemEditFindProtocol = null; + + private JMenuItem jMenuItemEditFindGuid = null; + + private JMenuItem jMenuItemEditFindLibraryInstance = null; + /// /// A static definition for this class itself /// private static FrameworkWizardUI fwui = null; + private JMenuItem jMenuItemToolsGenerateGuidsXref = null; + /** If the class hasn't an instnace, new one. @@ -431,6 +437,9 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuFile.add(getJMenuItemFileSaveAll()); jMenuFile.addSeparator(); + jMenuFile.add(getJMenuItemFileRefresh()); + jMenuFile.addSeparator(); + jMenuFile.add(getJMenuItemFilePageSetup()); jMenuFile.add(getJMenuItemFilePrint()); jMenuFile.add(getJMenuItemFileImport()); @@ -459,6 +468,23 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return jMenuItemFileSaveAs; } + /** + This method initializes jMenuItemFileRefresh + + @return javax.swing.JMenuItem jMenuItemFileRefresh + + **/ + private JMenuItem getJMenuItemFileRefresh() { + if (jMenuItemFileRefresh == null) { + jMenuItemFileRefresh = new JMenuItem(); + jMenuItemFileRefresh.setText("Refresh"); + jMenuItemFileRefresh.setMnemonic('R'); + jMenuItemFileRefresh.addActionListener(this); + jMenuItemFileRefresh.setVisible(true); + } + return jMenuItemFileRefresh; + } + /** This method initializes jMenuItemModuleExit @@ -489,25 +515,25 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuEdit = new JMenu(); jMenuEdit.setText("Edit"); jMenuEdit.setMnemonic('E'); - jMenuEdit.setVisible(false); + jMenuEdit.setVisible(true); // // Add sub menu items // jMenuEdit.add(getJMenuItemEditUndo()); jMenuEdit.add(getJMenuItemEditRedo()); - jMenuEdit.addSeparator(); + //jMenuEdit.addSeparator(); jMenuEdit.add(getJMenuItemEditCut()); jMenuEdit.add(getJMenuItemEditCopy()); jMenuEdit.add(getJMenuItemEditPaste()); jMenuEdit.add(getJMenuItemEditDelete()); - jMenuEdit.addSeparator(); + //jMenuEdit.addSeparator(); jMenuEdit.add(getJMenuItemEditSelectAll()); - jMenuEdit.add(getJMenuItemEditFind()); + jMenuEdit.add(getJMenuEditFind()); jMenuEdit.add(getJMenuItemEditFindNext()); - jMenuEdit.addSeparator(); + //jMenuEdit.addSeparator(); } return jMenuEdit; } @@ -634,6 +660,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // jMenuHelp = new JMenu(); jMenuHelp.setText("Help"); + jMenuHelp.setMnemonic('H'); // // Add sub menu items @@ -657,6 +684,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele if (jMenuItemHelpAbout == null) { jMenuItemHelpAbout = new JMenuItem(); jMenuItemHelpAbout.setText("About..."); + jMenuItemHelpAbout.setMnemonic('A'); jMenuItemHelpAbout.addActionListener(this); } return jMenuItemHelpAbout; @@ -673,6 +701,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuItemEditDelete = new JMenuItem(); jMenuItemEditDelete.setText("Delete"); jMenuItemEditDelete.setMnemonic('D'); + jMenuItemEditDelete.setVisible(false); + jMenuItemEditDelete.setEnabled(false); jMenuItemEditDelete.addActionListener(this); // //Disabled first when no module is open @@ -752,11 +782,16 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Add sub menu items // - jMenuTools.add(getJMenuItemToolsToolChainConfiguration()); - jMenuTools.addSeparator(); jMenuTools.add(getJMenuItemToolsClone()); jMenuTools.add(getJMenuItemToolsCodeScan()); + jMenuTools.addSeparator(); + + jMenuTools.add(getJMenuItemToolsToolChainConfiguration()); + jMenuTools.add(getJMenuItemToolsBuildPreferences()); + jMenuTools.addSeparator(); + + jMenuTools.add(getJMenuItemToolsGenerateGuidsXref()); } return jMenuTools; } @@ -879,6 +914,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele if (jMenuItemFileCloseAll == null) { jMenuItemFileCloseAll = new JMenuItem(); jMenuItemFileCloseAll.setText("Close All"); + jMenuItemFileCloseAll.setMnemonic('A'); jMenuItemFileCloseAll.setEnabled(true); jMenuItemFileCloseAll.addActionListener(this); } @@ -1004,6 +1040,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuItemEditUndo.setText("Undo"); jMenuItemEditUndo.setMnemonic('U'); jMenuItemEditUndo.setEnabled(false); + jMenuItemEditUndo.setVisible(false); jMenuItemEditUndo.addActionListener(this); } return jMenuItemEditUndo; @@ -1021,6 +1058,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuItemEditRedo.setText("Redo"); jMenuItemEditRedo.setMnemonic('R'); jMenuItemEditRedo.setEnabled(false); + jMenuItemEditRedo.setVisible(false); jMenuItemEditRedo.addActionListener(this); } return jMenuItemEditRedo; @@ -1038,6 +1076,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuItemEditCut.setText("Cut"); jMenuItemEditCut.setMnemonic('t'); jMenuItemEditCut.setEnabled(false); + jMenuItemEditCut.setVisible(false); jMenuItemEditCut.addActionListener(this); } return jMenuItemEditCut; @@ -1055,6 +1094,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuItemEditCopy.setText("Copy"); jMenuItemEditCopy.setMnemonic('C'); jMenuItemEditCopy.setEnabled(false); + jMenuItemEditCopy.setVisible(false); jMenuItemEditCopy.addActionListener(this); } return jMenuItemEditCopy; @@ -1072,6 +1112,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuItemEditPaste.setText("Paste"); jMenuItemEditPaste.setMnemonic('P'); jMenuItemEditPaste.setEnabled(false); + jMenuItemEditPaste.setVisible(false); jMenuItemEditPaste.addActionListener(this); } return jMenuItemEditPaste; @@ -1089,28 +1130,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuItemEditSelectAll.setText("Select All"); jMenuItemEditSelectAll.setMnemonic('A'); jMenuItemEditSelectAll.setEnabled(false); + jMenuItemEditSelectAll.setVisible(false); jMenuItemEditSelectAll.addActionListener(this); } return jMenuItemEditSelectAll; } - /** - This method initializes jMenuItemEditFind - - @return javax.swing.JMenuItem - - **/ - private JMenuItem getJMenuItemEditFind() { - if (jMenuItemEditFind == null) { - jMenuItemEditFind = new JMenuItem(); - jMenuItemEditFind.setText("Find"); - jMenuItemEditFind.setMnemonic('F'); - jMenuItemEditFind.setEnabled(false); - jMenuItemEditFind.addActionListener(this); - } - return jMenuItemEditFind; - } - /** This method initializes jMenuItemEditFindNext @@ -1123,6 +1148,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuItemEditFindNext.setText("Find Next"); jMenuItemEditFindNext.setMnemonic('n'); jMenuItemEditFindNext.setEnabled(false); + jMenuItemEditFindNext.setVisible(false); jMenuItemEditFindNext.addActionListener(this); } return jMenuItemEditFindNext; @@ -1284,7 +1310,6 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuProject.add(getJMenuItemProjectUpdateFar()); jMenuProject.add(getJMenuItemProjectRemoveFar()); - jMenuProject.add(getJMenuProjectBuildTargets()); } return jMenuProject; } @@ -1325,52 +1350,20 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } /** - This method initializes jMenuProjectBuildTargets + This method initializes jMenuProjectBuildPreferences @return javax.swing.JMenu **/ - private JMenu getJMenuProjectBuildTargets() { - if (jMenuProjectBuildTargets == null) { - jMenuProjectBuildTargets = new JMenu(); - jMenuProjectBuildTargets.setText("Build Targets"); - jMenuProjectBuildTargets.setMnemonic('T'); - jMenuProjectBuildTargets.setVisible(false); - - jMenuProjectBuildTargets.add(getJCheckBoxMenuItemProjectBuildTargetsDebug()); - jMenuProjectBuildTargets.add(getJCheckBoxMenuItemProjectBuildTargetsRelease()); - } - return jMenuProjectBuildTargets; - } - - /** - This method initializes jCheckBoxMenuItemProjectBuildTargetsDebug - - @return javax.swing.JCheckBoxMenuItem - - **/ - private JCheckBoxMenuItem getJCheckBoxMenuItemProjectBuildTargetsDebug() { - if (jCheckBoxMenuItemProjectBuildTargetsDebug == null) { - jCheckBoxMenuItemProjectBuildTargetsDebug = new JCheckBoxMenuItem(); - jCheckBoxMenuItemProjectBuildTargetsDebug.setText("Debug"); - jCheckBoxMenuItemProjectBuildTargetsDebug.setEnabled(false); + private JMenuItem getJMenuItemToolsBuildPreferences() { + if (jMenuItemToolsBuildPreferences == null) { + jMenuItemToolsBuildPreferences = new JMenuItem(); + jMenuItemToolsBuildPreferences.setText("Build Preferences"); + jMenuItemToolsBuildPreferences.setMnemonic('P'); + jMenuItemToolsBuildPreferences.setEnabled(true); + jMenuItemToolsBuildPreferences.addActionListener(this); } - return jCheckBoxMenuItemProjectBuildTargetsDebug; - } - - /** - This method initializes jCheckBoxMenuItemProjectBuildTargetsRelease - - @return javax.swing.JCheckBoxMenuItem - - **/ - private JCheckBoxMenuItem getJCheckBoxMenuItemProjectBuildTargetsRelease() { - if (jCheckBoxMenuItemProjectBuildTargetsRelease == null) { - jCheckBoxMenuItemProjectBuildTargetsRelease = new JCheckBoxMenuItem(); - jCheckBoxMenuItemProjectBuildTargetsRelease.setText("Release"); - jCheckBoxMenuItemProjectBuildTargetsRelease.setEnabled(false); - } - return jCheckBoxMenuItemProjectBuildTargetsRelease; + return jMenuItemToolsBuildPreferences; } /** @@ -1661,6 +1654,133 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return jMenuItemProjectCreateFar; } + /** + * This method initializes jMenuEditFind + * + * @return javax.swing.JMenu + */ + private JMenu getJMenuEditFind() { + if (jMenuEditFind == null) { + jMenuEditFind = new JMenu(); + jMenuEditFind.setText("Find"); + jMenuEditFind.setMnemonic('F'); + + jMenuEditFind.add(getJMenuItemEditFindPpi()); + jMenuEditFind.add(getJMenuItemEditFindProtocol()); + jMenuEditFind.add(getJMenuItemEditFindGuid()); + jMenuEditFind.add(getJMenuItemEditFindPcd()); + jMenuEditFind.add(getJMenuItemEditFindLibraryClass()); + jMenuEditFind.add(getJMenuItemEditFindLibraryInstance()); + } + return jMenuEditFind; + } + + /** + * This method initializes jMenuItemEditFindPcd + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditFindPcd() { + if (jMenuItemEditFindPcd == null) { + jMenuItemEditFindPcd = new JMenuItem(); + jMenuItemEditFindPcd.setText("All PCD entries"); + jMenuItemEditFindPcd.setMnemonic('P'); + jMenuItemEditFindPcd.addActionListener(this); + } + return jMenuItemEditFindPcd; + } + + /** + * This method initializes jMenuItemEditFindLibraryClass + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditFindLibraryClass() { + if (jMenuItemEditFindLibraryClass == null) { + jMenuItemEditFindLibraryClass = new JMenuItem(); + jMenuItemEditFindLibraryClass.setText("All Library Classes"); + jMenuItemEditFindLibraryClass.setMnemonic('C'); + jMenuItemEditFindLibraryClass.addActionListener(this); + } + return jMenuItemEditFindLibraryClass; + } + + /** + * This method initializes jMenuItemEditFindPpi + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditFindPpi() { + if (jMenuItemEditFindPpi == null) { + jMenuItemEditFindPpi = new JMenuItem(); + jMenuItemEditFindPpi.setText("All PPIs"); + jMenuItemEditFindPpi.setMnemonic('I'); + jMenuItemEditFindPpi.addActionListener(this); + } + return jMenuItemEditFindPpi; + } + + /** + * This method initializes jMenuItemEditFindProtocol + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditFindProtocol() { + if (jMenuItemEditFindProtocol == null) { + jMenuItemEditFindProtocol = new JMenuItem(); + jMenuItemEditFindProtocol.setText("All Protocols"); + jMenuItemEditFindProtocol.setMnemonic('r'); + jMenuItemEditFindProtocol.addActionListener(this); + } + return jMenuItemEditFindProtocol; + } + + /** + * This method initializes jMenuItemEditFindGuid + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditFindGuid() { + if (jMenuItemEditFindGuid == null) { + jMenuItemEditFindGuid = new JMenuItem(); + jMenuItemEditFindGuid.setText("All GUIDs"); + jMenuItemEditFindGuid.setMnemonic('G'); + jMenuItemEditFindGuid.addActionListener(this); + } + return jMenuItemEditFindGuid; + } + + /** + * This method initializes jMenuItemEditFindLibraryInstance + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditFindLibraryInstance() { + if (jMenuItemEditFindLibraryInstance == null) { + jMenuItemEditFindLibraryInstance = new JMenuItem(); + jMenuItemEditFindLibraryInstance.setText("All Library Instances"); + jMenuItemEditFindLibraryInstance.setMnemonic('n'); + jMenuItemEditFindLibraryInstance.addActionListener(this); + jMenuItemEditFindLibraryInstance.setVisible(false); + } + return jMenuItemEditFindLibraryInstance; + } + + /** + * This method initializes jMenuItemProjectGenerateGuidsXref + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemToolsGenerateGuidsXref() { + if (jMenuItemToolsGenerateGuidsXref == null) { + jMenuItemToolsGenerateGuidsXref = new JMenuItem(); + jMenuItemToolsGenerateGuidsXref.setText("Generate guids.xref"); + jMenuItemToolsGenerateGuidsXref.setMnemonic('G'); + jMenuItemToolsGenerateGuidsXref.addActionListener(this); + } + return jMenuItemToolsGenerateGuidsXref; + } + /* (non-Javadoc) * @see org.tianocore.packaging.common.ui.IFrame#main(java.lang.String[]) * @@ -1687,6 +1807,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void init() { + // + // Show splash screen + // + SplashScreen ss = new SplashScreen(); + ss.setVisible(true); + // // Set current workspace and check // Check if exists WORKSPACE @@ -1700,11 +1826,22 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele System.exit(0); } + // + // Init Global Data + // + GlobalData.init(); + + // + // Close splash screen + // + ss.dispose(); + + // + // Init the frame + // this.setSize(DataType.MAIN_FRAME_PREFERRED_SIZE_WIDTH, DataType.MAIN_FRAME_PREFERRED_SIZE_HEIGHT); this.setResizable(true); this.setJMenuBar(getjJMenuBar()); - this.addComponentListener(this); - this.getCompontentsFromFrameworkDatabase(); this.setContentPane(getJContentPane()); this.setTitle(DataType.PROJECT_NAME + " " + DataType.PROJECT_VERSION + " " + "- [" + Workspace.getCurrentWorkspace() + "]"); @@ -1742,67 +1879,106 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Operations of Menu // - if (arg0.getSource() == jMenuItemFileNew) { + if (arg0.getSource() == this.jMenuItemFileNew) { this.fileNew(); } - if (arg0.getSource() == jMenuItemFileOpen) { + if (arg0.getSource() == this.jMenuItemFileOpen) { this.open(); } - if (arg0.getSource() == jMenuItemFileClose) { + if (arg0.getSource() == this.jMenuItemFileClose) { this.close(); } - if (arg0.getSource() == jMenuItemFileCloseAll) { + if (arg0.getSource() == this.jMenuItemFileCloseAll) { this.closeAll(); + this.makeEmptyTree(); } - if (arg0.getSource() == jMenuItemFileSave) { + if (arg0.getSource() == this.jMenuItemFileSave) { this.save(); } - if (arg0.getSource() == jMenuItemFileSaveAs) { + if (arg0.getSource() == this.jMenuItemFileSaveAs) { this.saveAs(); } - if (arg0.getSource() == jMenuItemFileSaveAll) { + if (arg0.getSource() == this.jMenuItemFileSaveAll) { this.saveAll(); } - if (arg0.getSource() == jMenuItemFileExit) { + if (arg0.getSource() == this.jMenuItemFileRefresh) { + this.closeAll(); + this.refresh(); + this.makeEmptyTree(); + } + + if (arg0.getSource() == this.jMenuItemFileExit) { this.exit(); } - if (arg0.getSource() == jMenuItemProjectChangeWorkspace) { - changeWorkspace(); + if (arg0.getSource() == this.jMenuItemEditFindPpi) { + this.findPpi(); + } + + if (arg0.getSource() == this.jMenuItemEditFindProtocol) { + this.findProtocol(); + } + + if (arg0.getSource() == this.jMenuItemEditFindGuid) { + this.findGuid(); + } + + if (arg0.getSource() == this.jMenuItemEditFindPcd) { + this.findPcd(); + } + + if (arg0.getSource() == this.jMenuItemEditFindLibraryClass) { + this.findLibraryClass(); + } + + if (arg0.getSource() == this.jMenuItemEditFindLibraryInstance) { + this.findLibraryInstance(); + } + + if (arg0.getSource() == jMenuItemToolsBuildPreferences) { + configBuildPreferences(); } - if (arg0.getSource() == jMenuItemProjectCreateFar) { - createFar(); + if (arg0.getSource() == this.jMenuItemProjectChangeWorkspace) { + this.changeWorkspace(); } - if (arg0.getSource() == jMenuItemProjectInstallFar) { - installFar(); + if (arg0.getSource() == this.jMenuItemProjectCreateFar) { + this.createFar(); } - if (arg0.getSource() == jMenuItemProjectRemoveFar) { - removeFar(); + if (arg0.getSource() == this.jMenuItemProjectInstallFar) { + this.installFar(); } - if (arg0.getSource() == jMenuItemProjectUpdateFar) { - updateFar(); + if (arg0.getSource() == this.jMenuItemProjectRemoveFar) { + this.removeFar(); } - if (arg0.getSource() == jMenuItemToolsClone) { - cloneItem(); + if (arg0.getSource() == this.jMenuItemProjectUpdateFar) { + this.updateFar(); } - if (arg0.getSource() == jMenuItemToolsToolChainConfiguration) { - setupToolChainConfiguration(); + if (arg0.getSource() == this.jMenuItemToolsClone) { + this.cloneItem(); } - if (arg0.getSource() == jMenuItemHelpAbout) { + if (arg0.getSource() == this.jMenuItemToolsToolChainConfiguration) { + this.setupToolChainConfiguration(); + } + + if (arg0.getSource() == this.jMenuItemToolsGenerateGuidsXref) { + this.generateGuidsXref(); + } + + if (arg0.getSource() == this.jMenuItemHelpAbout) { About a = new About(this, true); int result = a.showDialog(); if (result == DataType.RETURN_TYPE_OK) { @@ -1819,44 +1995,50 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Make root // - dmtnRoot = new IDefaultMutableTreeNode("WORKSPACE", IDefaultMutableTreeNode.WORKSPACE, -1); + dmtnRoot = new IDefaultMutableTreeNode("WORKSPACE", IDefaultMutableTreeNode.WORKSPACE, false, null, null); // // Make Module Description // - dmtnModuleDescription = new IDefaultMutableTreeNode("ModuleDescription", IDefaultMutableTreeNode.MODULE, -1); + dmtnModuleDescription = new IDefaultMutableTreeNode("Modules", IDefaultMutableTreeNode.MODULE_DESCRIPTION, + false, null, dmtnRoot); // // First add package // - if (this.vPackageList.size() > 0) { - for (int index = 0; index < this.vPackageList.size(); index++) { + if (GlobalData.vPackageList.size() > 0) { + for (int index = 0; index < GlobalData.vPackageList.size(); index++) { IDefaultMutableTreeNode dmtnModulePackage = null; IDefaultMutableTreeNode dmtnModulePackageLibrary = null; IDefaultMutableTreeNode dmtnModulePackageModule = null; - dmtnModulePackage = new IDefaultMutableTreeNode(this.vPackageList.elementAt(index).getName(), + dmtnModulePackage = new IDefaultMutableTreeNode(GlobalData.vPackageList.elementAt(index).getName(), IDefaultMutableTreeNode.MODULE_PACKAGE, false, - this.vPackageList.elementAt(index)); + GlobalData.vPackageList.elementAt(index), + this.dmtnModuleDescription); dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library", IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, - false, this.vPackageList.elementAt(index)); + false, GlobalData.vPackageList.elementAt(index), + this.dmtnModuleDescription); dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, - false, this.vPackageList.elementAt(index)); + false, GlobalData.vPackageList.elementAt(index), + this.dmtnModuleDescription); // // And then add each module in its package // - Vector vModule = wt.getAllModules(this.vPackageList.elementAt(index)); + Vector vModule = wt.getAllModules(GlobalData.vPackageList.elementAt(index)); for (int indexJ = 0; indexJ < vModule.size(); indexJ++) { if (vModule.get(indexJ).isLibrary()) { dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), - IDefaultMutableTreeNode.MODULE, - false, vModule.get(indexJ))); + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), + this.dmtnModuleDescription)); } else { dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), - IDefaultMutableTreeNode.MODULE, - false, vModule.get(indexJ))); + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), + this.dmtnModuleDescription)); } } if (dmtnModulePackageModule.getChildCount() > 0) { @@ -1873,25 +2055,31 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Make Package Description // - dmtnPackageDescription = new IDefaultMutableTreeNode("PackageDescription", IDefaultMutableTreeNode.PACKAGE, -1); - if (this.vPackageList.size() > 0) { - for (int index = 0; index < this.vPackageList.size(); index++) { - dmtnPackageDescription.add(new IDefaultMutableTreeNode(this.vPackageList.elementAt(index).getName(), + dmtnPackageDescription = new IDefaultMutableTreeNode("Packages", IDefaultMutableTreeNode.PACKAGE_DESCRIPTION, + false, null, this.dmtnRoot); + if (GlobalData.vPackageList.size() > 0) { + for (int index = 0; index < GlobalData.vPackageList.size(); index++) { + dmtnPackageDescription.add(new IDefaultMutableTreeNode(GlobalData.vPackageList.elementAt(index) + .getName(), IDefaultMutableTreeNode.PACKAGE, false, - this.vPackageList.elementAt(index))); + GlobalData.vPackageList.elementAt(index), + this.dmtnPackageDescription)); } } // // Make Platform Description // - dmtnPlatformDescription = new IDefaultMutableTreeNode("PlatformDescription", IDefaultMutableTreeNode.PLATFORM, - -1); - if (this.vPlatformList.size() > 0) { - for (int index = 0; index < this.vPlatformList.size(); index++) { - dmtnPlatformDescription.add(new IDefaultMutableTreeNode(this.vPlatformList.elementAt(index).getName(), - IDefaultMutableTreeNode.PLATFORM, - false, this.vPlatformList.elementAt(index))); + dmtnPlatformDescription = new IDefaultMutableTreeNode("Platforms", + IDefaultMutableTreeNode.PLATFORM_DESCRIPTION, false, + null, this.dmtnRoot); + if (GlobalData.vPlatformList.size() > 0) { + for (int index = 0; index < GlobalData.vPlatformList.size(); index++) { + dmtnPlatformDescription.add(new IDefaultMutableTreeNode(GlobalData.vPlatformList.elementAt(index) + .getName(), + IDefaultMutableTreeNode.PLATFORM, false, + GlobalData.vPlatformList.elementAt(index), + this.dmtnPlatformDescription)); } } @@ -1903,6 +2091,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele dmtnRoot.add(dmtnPlatformDescription); iTree = new ITree(dmtnRoot); iTree.addMouseListener(this); + iTree.addKeyListener(this); jScrollPaneTree.setViewportView(iTree); } @@ -1923,10 +2112,6 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele * */ public void mouseClicked(MouseEvent arg0) { - if (arg0.getButton() == MouseEvent.BUTTON1) { - } - if (arg0.getButton() == MouseEvent.BUTTON3) { - } // // When double click // @@ -2024,8 +2209,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Add new MsaHeader node to the tree // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(mid.getName(), IDefaultMutableTreeNode.MSA_HEADER, - true, mid); + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(mid.getName(), IDefaultMutableTreeNode.MODULE, + false, mid, this.dmtnModuleDescription); // // First find the module belongs to which package // @@ -2059,7 +2244,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // if (!hasModule) { parentModuleNode = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, - false, mid.getPackageId()); + false, mid.getPackageId(), this.dmtnModuleDescription); iTree.addNode(packageNode, parentModuleNode); } @@ -2076,7 +2261,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele if (!hasLibrary) { parentLibraryNode = new IDefaultMutableTreeNode("Library", IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, false, - mid.getPackageId()); + mid.getPackageId(), this.dmtnModuleDescription); iTree.addNode(packageNode, parentLibraryNode); } @@ -2090,166 +2275,48 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele @param path input file path **/ - private void openModule(String path, ModuleIdentification moduleId) { - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; - try { - msa = OpenFile.openMsaFile(path); - } catch (IOException e) { - Log.wrn("Open Module Surface Area " + path, e.getMessage()); - Log.err("Open Module Surface Area " + path, e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Open Module Surface Area " + path, e.getMessage()); - Log.err("Open Module Surface Area " + path, e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Open Module Surface Area " + path, "Invalid file type"); - Log.err("Open Module Surface Area " + path, "Invalid file type"); - return; - } - Identification id = new Identification(msa.getMsaHeader().getModuleName(), msa.getMsaHeader().getGuidValue(), - msa.getMsaHeader().getVersion(), path); - // - // Generate module id - // - PackageIdentification pid = wt.getPackageIdByModuleId(id); - if (pid != null) { - // - // To judge if the module existed in vModuleList - // If not, add it to vModuleList - // - boolean isFind = false; - for (int index = 0; index < vModuleList.size(); index++) { - if (vModuleList.elementAt(index).equals(id)) { - isFind = true; - break; - } - } - if (!isFind) { - ModuleIdentification mid = new ModuleIdentification(id, pid, moduleId.isLibrary()); - vModuleList.addElement(mid); - addModuleToTree(mid); - } - } else { + private void openModule(String path, IDefaultMutableTreeNode belongNode) { + ModuleIdentification id = GlobalData.openingModuleList.getIdByPath(path); + if (id == null) { // // The module is not in existing packages // - Log.err("The module hasn't been added to any package of current workspace!"); + Log.wrn("Open Module", "The module does not belong to any package in the current workspace!"); return; } // // Make the node selected // - iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, - IDefaultMutableTreeNode.MODULE))); - // - // Update opening Module list information - // - if (!openingModuleList.existsModule(id)) { - // - // Insert sub node of module - // - insertModuleTreeNode(id); - iTree.getSelectNode().setOpening(true); - - // - // Update opening module list - // - openingModuleList.insertToOpeningModuleList(id, msa); - openingModuleList.setTreePathById(id, iTree.getSelectionPath()); - } - // - // Select msa header node and show it in editor panel - // - iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, - IDefaultMutableTreeNode.MSA_HEADER))); - showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, openingModuleList.getOpeningModuleById(id)); - this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); - } - - /** - Open Module - - @param path input file path - - **/ - private void openModule(String path) { - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; - try { - msa = OpenFile.openMsaFile(path); - } catch (IOException e) { - Log.wrn("Open Module Surface Area " + path, e.getMessage()); - Log.err("Open Module Surface Area " + path, e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Open Module Surface Area " + path, e.getMessage()); - Log.err("Open Module Surface Area " + path, e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Open Module Surface Area " + path, "Invalid file type"); - Log.err("Open Module Surface Area " + path, "Invalid file type"); - return; - } - Identification id = new Identification(msa.getMsaHeader().getModuleName(), msa.getMsaHeader().getGuidValue(), - msa.getMsaHeader().getVersion(), path); - // - // Generate module id - // - PackageIdentification pid = wt.getPackageIdByModuleId(id); - if (pid != null) { - // - // To judge if the module existed in vModuleList - // If not, add it to vModuleList - // - boolean isFind = false; - for (int index = 0; index < vModuleList.size(); index++) { - if (vModuleList.elementAt(index).equals(id)) { - isFind = true; - break; - } - } - if (!isFind) { - ModuleIdentification mid = new ModuleIdentification(id, pid); - vModuleList.addElement(mid); - addModuleToTree(mid); - } - } else { - // - // The module is not in existing packages - // - Log.wrn("Open Module", "The module hasn't been added to any package of current workspace!"); - return; - } + iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(belongNode, id, IDefaultMutableTreeNode.MODULE))); - // - // Make the node selected - // - iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, - IDefaultMutableTreeNode.MODULE))); // // Update opening Module list information // - if (!openingModuleList.existsModule(id)) { + if (!iTree.getSelectNode().isOpening()) { // // Insert sub node of module // - insertModuleTreeNode(id); + insertModuleTreeNode(id, belongNode); iTree.getSelectNode().setOpening(true); // // Update opening module list // - openingModuleList.insertToOpeningModuleList(id, msa); - openingModuleList.setTreePathById(id, iTree.getSelectionPath()); + GlobalData.openingModuleList.setModuleOpen(id, true); + Set temp = GlobalData.openingModuleList.getTreePathById(id); + temp.add(iTree.getSelectionPath()); + GlobalData.openingModuleList.setTreePathById(id, temp); } // // Select msa header node and show it in editor panel // - iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, - IDefaultMutableTreeNode.MSA_HEADER))); - showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, openingModuleList.getOpeningModuleById(id)); - this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); + iTree + .setSelectionPath(iTree + .getPathOfNode(iTree + .getNodeById(belongNode, id, IDefaultMutableTreeNode.MSA_HEADER))); + showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, GlobalData.openingModuleList.getOpeningModuleById(id)); + this.currentOpeningModuleIndex = GlobalData.openingModuleList.findIndexOfListById(id); } /** @@ -2259,40 +2326,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void openPackage(String path) { - PackageSurfaceAreaDocument.PackageSurfaceArea spd = null; - try { - spd = OpenFile.openSpdFile(path); - } catch (IOException e) { - Log.wrn("Open Package Surface Area " + path, e.getMessage()); - Log.err("Open Package Surface Area " + path, e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Open Package Surface Area " + path, e.getMessage()); - Log.err("Open Package Surface Area " + path, e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Open Package Surface Area " + path, "Invalid file type"); - Log.err("Open Package Surface Area " + path, "Invalid file type"); - return; - } - Identification id = new Identification(spd.getSpdHeader().getPackageName(), spd.getSpdHeader().getGuidValue(), - spd.getSpdHeader().getVersion(), path); - // - // To judge if the package existed in vPackageList - // If not, add it to vPackageList - // - boolean isFind = false; - for (int index = 0; index < vPackageList.size(); index++) { - if (vPackageList.elementAt(index).equals(id)) { - isFind = true; - break; - } - } - if (!isFind) { + PackageIdentification id = GlobalData.openingPackageList.getIdByPath(path); + if (id == null) { // - // The module is not in existing packages + // The package is not in current workspace // - Log.wrn("Open Package", "The package hasn't been added to current workspace!"); + Log.wrn("Open Package", "The package has not been installed in the current workspace!"); return; } @@ -2304,7 +2343,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening package list information // - if (!openingPackageList.existsPackage(id)) { + if (!GlobalData.openingPackageList.getPackageOpen(id)) { // // Insert sub node of module // @@ -2314,16 +2353,18 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening module list // - openingPackageList.insertToOpeningPackageList(id, spd); - openingPackageList.setTreePathById(id, iTree.getSelectionPath()); + GlobalData.openingPackageList.setPackageOpen(id, true); + Set temp = GlobalData.openingPackageList.getTreePathById(id); + temp.add(iTree.getSelectionPath()); + GlobalData.openingPackageList.setTreePathById(id, temp); } // // Show spd header in editor panel // iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPackageDescription, id, IDefaultMutableTreeNode.SPD_HEADER))); - showPackageElement(IDefaultMutableTreeNode.SPD_HEADER, openingPackageList.getOpeningPackageById(id)); - this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id); + showPackageElement(IDefaultMutableTreeNode.SPD_HEADER, GlobalData.openingPackageList.getOpeningPackageById(id)); + this.currentOpeningPackageIndex = GlobalData.openingPackageList.findIndexOfListById(id); } /** @@ -2333,41 +2374,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void openPlatform(String path) { - PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd = null; - try { - fpd = OpenFile.openFpdFile(path); - } catch (IOException e) { - Log.wrn("Open Platform Surface Area " + path, e.getMessage()); - Log.err("Open Platform Surface Area " + path, e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Open Platform Surface Area " + path, e.getMessage()); - Log.err("Open Platform Surface Area " + path, e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Open Platform Surface Area " + path, "Invalid file type"); - Log.err("Open Platform Surface Area " + path, "Invalid file type"); - return; - } - Identification id = new Identification(fpd.getPlatformHeader().getPlatformName(), fpd.getPlatformHeader() - .getGuidValue(), - fpd.getPlatformHeader().getVersion(), path); - // - // To judge if the platform existed in vPlatformList - // If not, add it to vPlatformList - // - boolean isFind = false; - for (int index = 0; index < vPlatformList.size(); index++) { - if (vPlatformList.elementAt(index).equals(id)) { - isFind = true; - break; - } - } - if (!isFind) { + PlatformIdentification id = GlobalData.openingPlatformList.getIdByPath(path); + if (id == null) { // - // The module is not in existing packages + // The platform is not in current workspace // - Log.wrn("Open Platform", "The platform hasn't been added to current workspace!"); + Log.wrn("Open Platform", "The platform has not been installed in the current workspace!"); return; } @@ -2379,7 +2391,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening package list information // - if (!openingPlatformList.existsPlatform(id)) { + if (!GlobalData.openingPlatformList.getPlatformOpen(id)) { // // Insert sub node of module // @@ -2389,16 +2401,19 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening module list // - openingPlatformList.insertToOpeningPlatformList(id, fpd); - openingPlatformList.setTreePathById(id, iTree.getSelectionPath()); + GlobalData.openingPlatformList.setPlatformOpen(id, true); + Set temp = GlobalData.openingPlatformList.getTreePathById(id); + temp.add(iTree.getSelectionPath()); + GlobalData.openingPlatformList.setTreePathById(id, temp); } // // Show fpd header in editor panel // iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPlatformDescription, id, IDefaultMutableTreeNode.FPD_PLATFORMHEADER))); - showPlatformElement(IDefaultMutableTreeNode.FPD_PLATFORMHEADER, openingPlatformList.getOpeningPlatformById(id)); - this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id); + showPlatformElement(IDefaultMutableTreeNode.FPD_PLATFORMHEADER, + GlobalData.openingPlatformList.getOpeningPlatformById(id)); + this.currentOpeningPlatformIndex = GlobalData.openingPlatformList.findIndexOfListById(id); } /** @@ -2406,7 +2421,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void saveModule(int index) { - OpeningModuleType omt = openingModuleList.getOpeningModuleByIndex(index); + OpeningModuleType omt = GlobalData.openingModuleList.getOpeningModuleByIndex(index); if (omt.isNew()) { if (getNewFilePath(DataType.MODULE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { return; @@ -2414,8 +2429,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } try { SaveFile.saveMsaFile(omt.getId().getPath(), omt.getXmlMsa()); - openingModuleList.setNew(omt.getId(), false); - openingModuleList.setModuleSaved(omt.getId(), true); + GlobalData.openingModuleList.setNew(omt.getId(), false); + GlobalData.openingModuleList.setModuleSaved(omt.getId(), true); } catch (Exception e) { Log.wrn("Save Module", e.getMessage()); Log.err("Save Module", e.getMessage()); @@ -2427,7 +2442,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void savePackage(int index) { - OpeningPackageType opt = openingPackageList.getOpeningPackageByIndex(index); + OpeningPackageType opt = GlobalData.openingPackageList.getOpeningPackageByIndex(index); if (opt.isNew()) { if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { return; @@ -2435,8 +2450,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } try { SaveFile.saveSpdFile(opt.getId().getPath(), opt.getXmlSpd()); - openingPackageList.setNew(opt.getId(), false); - openingPackageList.setPackageSaved(opt.getId(), true); + GlobalData.openingPackageList.setNew(opt.getId(), false); + GlobalData.openingPackageList.setPackageSaved(opt.getId(), true); } catch (Exception e) { Log.wrn("Save Package", e.getMessage()); Log.err("Save Package", e.getMessage()); @@ -2448,7 +2463,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void savePlatform(int index) { - OpeningPlatformType opt = openingPlatformList.getOpeningPlatformByIndex(index); + OpeningPlatformType opt = GlobalData.openingPlatformList.getOpeningPlatformByIndex(index); if (opt.isNew()) { if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { return; @@ -2456,34 +2471,21 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } try { SaveFile.saveFpdFile(opt.getId().getPath(), opt.getXmlFpd()); - openingPlatformList.setNew(opt.getId(), false); - openingPlatformList.setPlatformSaved(opt.getId(), true); + GlobalData.openingPlatformList.setNew(opt.getId(), false); + GlobalData.openingPlatformList.setPlatformSaved(opt.getId(), true); } catch (Exception e) { Log.wrn("Save Package", e.getMessage()); Log.err("Save Package", e.getMessage()); } } - public void componentHidden(ComponentEvent arg0) { - // TODO Auto-generated method stub - - } - - public void componentMoved(ComponentEvent arg0) { - // TODO Auto-generated method stub - - } - public void componentResized(ComponentEvent arg0) { - this.jSplitPane.setSize(this.getWidth() - DataType.MAIN_FRAME_WIDTH_SPACING, - this.getHeight() - DataType.MAIN_FRAME_HEIGHT_SPACING); - this.jSplitPane.validate(); - resizeDesktopPanel(); - } - - public void componentShown(ComponentEvent arg0) { - // TODO Auto-generated method stub - + if (this.jSplitPane != null) { + this.jSplitPane.setSize(this.getWidth() - DataType.MAIN_FRAME_WIDTH_SPACING, + this.getHeight() - DataType.MAIN_FRAME_HEIGHT_SPACING); + this.jSplitPane.validate(); + resizeDesktopPanel(); + } } /** @@ -2507,65 +2509,136 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } } - private void getCompontentsFromFrameworkDatabase() { - this.vModuleList = wt.getAllModules(); - this.vPackageList = wt.getAllPackages(); - this.vPlatformList = wt.getAllPlatforms(); - } - - private void insertModuleTreeNode(Identification id) { - iTree.addNode(new IDefaultMutableTreeNode("Module Header", IDefaultMutableTreeNode.MSA_HEADER, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Module Definitions", IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS, - true, id)); + private void insertModuleTreeNode(Identification id, IDefaultMutableTreeNode belongNode) { + iTree.addNode(new IDefaultMutableTreeNode("Module Header", IDefaultMutableTreeNode.MSA_HEADER, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id, + belongNode)); iTree.addNode(new IDefaultMutableTreeNode("Library Class Definitions", - IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Package Dependencies", - IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Protocols", IDefaultMutableTreeNode.MSA_PROTOCOLS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Events", IDefaultMutableTreeNode.MSA_EVENTS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Hobs", IDefaultMutableTreeNode.MSA_HOBS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Ppis", IDefaultMutableTreeNode.MSA_PPIS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Variables", IDefaultMutableTreeNode.MSA_VARIABLES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Boot Modes", IDefaultMutableTreeNode.MSA_BOOTMODES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("System Tables", IDefaultMutableTreeNode.MSA_SYSTEMTABLES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Data Hubs", IDefaultMutableTreeNode.MSA_DATAHUBS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Hii Packages", IDefaultMutableTreeNode.MSA_HIIPACKAGES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Guids", IDefaultMutableTreeNode.MSA_GUIDS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Externs", IDefaultMutableTreeNode.MSA_EXTERNS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("PcdCoded", IDefaultMutableTreeNode.MSA_PCDS, true, id)); + IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id, + belongNode)); + iTree + .addNode(new IDefaultMutableTreeNode("Package Dependencies", + IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Protocols", IDefaultMutableTreeNode.MSA_PROTOCOLS, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Events", IDefaultMutableTreeNode.MSA_EVENTS, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Hobs", IDefaultMutableTreeNode.MSA_HOBS, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Ppis", IDefaultMutableTreeNode.MSA_PPIS, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Variables", IDefaultMutableTreeNode.MSA_VARIABLES, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Boot Modes", IDefaultMutableTreeNode.MSA_BOOTMODES, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("System Tables", IDefaultMutableTreeNode.MSA_SYSTEMTABLES, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Data Hubs", IDefaultMutableTreeNode.MSA_DATAHUBS, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Hii Packages", IDefaultMutableTreeNode.MSA_HIIPACKAGES, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Guids", IDefaultMutableTreeNode.MSA_GUIDS, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("External Defintions", IDefaultMutableTreeNode.MSA_EXTERNS, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Pcd Coded", IDefaultMutableTreeNode.MSA_PCDS, true, id, belongNode)); } private void insertPackageTreeNode(Identification id) { - iTree.addNode(new IDefaultMutableTreeNode("Package Header", IDefaultMutableTreeNode.SPD_HEADER, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Package Definitions", - IDefaultMutableTreeNode.SPD_PACKAGEDEFINITIONS, true, id)); + IDefaultMutableTreeNode idmtTemp = this.dmtnPackageDescription; + iTree.addNode(new IDefaultMutableTreeNode("Package Header", IDefaultMutableTreeNode.SPD_HEADER, true, id, + idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Library Class Declarations", - IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id)); + IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id, + idmtTemp)); + iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id, + idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Package Includes", IDefaultMutableTreeNode.SPD_PACKAGEHEADERS, true, - id)); + id, idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Guid Declarations", IDefaultMutableTreeNode.SPD_GUIDDECLARATIONS, - true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Protocol Declarations", - IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS, true, id)); + true, id, idmtTemp)); + iTree + .addNode(new IDefaultMutableTreeNode("Protocol Declarations", + IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS, true, id, idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Ppi Declarations", IDefaultMutableTreeNode.SPD_PPIDECLARATIONS, - true, id)); + true, id, idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Pcd Declarations", IDefaultMutableTreeNode.SPD_PCDDECLARATIONS, - true, id)); + true, id, idmtTemp)); + // + // Add modules in this package + // + IDefaultMutableTreeNode dmtnModulePackageLibrary = null; + IDefaultMutableTreeNode dmtnModulePackageModule = null; + + dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library", + IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, false, + id, idmtTemp); + dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, + false, id, idmtTemp); + + Vector vModule = wt.getAllModules(new PackageIdentification(id)); + for (int indexJ = 0; indexJ < vModule.size(); indexJ++) { + if (vModule.get(indexJ).isLibrary()) { + dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), idmtTemp)); + } else { + dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), idmtTemp)); + } + } + if (dmtnModulePackageModule.getChildCount() > 0) { + iTree.addNode(dmtnModulePackageModule); + } + if (dmtnModulePackageLibrary.getChildCount() > 0) { + iTree.addNode(dmtnModulePackageLibrary); + } } private void insertPlatformTreeNode(Identification id) { + IDefaultMutableTreeNode idmtTemp = this.dmtnPlatformDescription; iTree.addNode(new IDefaultMutableTreeNode("Platform Header", IDefaultMutableTreeNode.FPD_PLATFORMHEADER, true, - id)); + id, idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Platform Definitions", - IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Flash", IDefaultMutableTreeNode.FPD_FLASH, true, id)); + IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS, true, id, idmtTemp)); + iTree.addNode(new IDefaultMutableTreeNode("Flash Information", IDefaultMutableTreeNode.FPD_FLASH, true, id, + idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Framework Modules", IDefaultMutableTreeNode.FPD_FRAMEWORKMODULES, - true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Pcd Dynamic Build Declarations", - IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Build Options", IDefaultMutableTreeNode.FPD_BUILDOPTIONS, true, id)); + true, id, idmtTemp)); + iTree.addNode(new IDefaultMutableTreeNode("Dynamic PCD Build Declarations", + IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS, true, id, + idmtTemp)); + iTree.addNode(new IDefaultMutableTreeNode("Build Options", IDefaultMutableTreeNode.FPD_BUILDOPTIONS, true, id, + idmtTemp)); + + // + // Add modules in this platform + // + IDefaultMutableTreeNode dmtnModulePackageLibrary = null; + IDefaultMutableTreeNode dmtnModulePackageModule = null; + + dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library", + IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, false, + id, idmtTemp); + dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, + false, id, idmtTemp); + + Vector vModule = wt.getAllModules(new PlatformIdentification(id)); + for (int indexJ = 0; indexJ < vModule.size(); indexJ++) { + if (vModule.get(indexJ).isLibrary()) { + dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), idmtTemp)); + } else { + dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), idmtTemp)); + } + } + if (dmtnModulePackageModule.getChildCount() > 0) { + iTree.addNode(dmtnModulePackageModule); + } + if (dmtnModulePackageLibrary.getChildCount() > 0) { + iTree.addNode(dmtnModulePackageLibrary); + } } /** @@ -2576,60 +2649,78 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele Identification id = null; int intCategory = -1; String path = null; - boolean isOpen = false; + IDefaultMutableTreeNode belongNode = null; + try { - id = iTree.getSelectNode().getId(); + // + // Get selected tree node + // + if (iTree.getSelectNode() != null) { + id = iTree.getSelectNode().getId(); + } + + // + // If id is null, return directly + // + if (id == null) { + return; + } + intCategory = iTree.getSelectCategory(); - isOpen = iTree.getSelectNode().isOpening(); - - if (!isOpen) { - // - // If the node is not opened yet - // Insert top level elements first - // - if (intCategory == IDefaultMutableTreeNode.MODULE) { + belongNode = iTree.getSelectNode().getBelongNode(); - if (intCategory == IDefaultMutableTreeNode.MODULE) { - path = iTree.getSelectNode().getId().getPath(); - } - if (intCategory == IDefaultMutableTreeNode.PACKAGE) { - path = iTree.getSelectNode().getId().getPath(); - } - openModule(path); - return; - } - if (intCategory == IDefaultMutableTreeNode.PACKAGE) { - path = iTree.getSelectNode().getId().getPath(); - openPackage(path); - return; - } - if (intCategory == IDefaultMutableTreeNode.PLATFORM) { - path = iTree.getSelectNode().getId().getPath(); - openPlatform(path); - return; - } + // + // If the node is not opened yet + // Insert top level elements first + // + if (intCategory == IDefaultMutableTreeNode.MODULE) { + path = iTree.getSelectNode().getId().getPath(); + openModule(path, belongNode); + return; + } + if (intCategory == IDefaultMutableTreeNode.PACKAGE) { + path = iTree.getSelectNode().getId().getPath(); + openPackage(path); + return; + } + if (intCategory == IDefaultMutableTreeNode.PLATFORM) { + path = iTree.getSelectNode().getId().getPath(); + openPlatform(path); + return; } - + // // Show editor panel // if (intCategory >= IDefaultMutableTreeNode.MSA_HEADER && intCategory < IDefaultMutableTreeNode.SPD_HEADER) { - showModuleElement(intCategory, openingModuleList.getOpeningModuleById(id)); - this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); + showModuleElement(intCategory, + GlobalData.openingModuleList.getOpeningModuleById(new ModuleIdentification(id))); + this.currentOpeningModuleIndex = GlobalData.openingModuleList + .findIndexOfListById(new ModuleIdentification( + id)); } if (intCategory >= IDefaultMutableTreeNode.SPD_HEADER && intCategory < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { - showPackageElement(intCategory, openingPackageList.getOpeningPackageById(id)); - this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id); + showPackageElement(intCategory, + GlobalData.openingPackageList.getOpeningPackageById(new PackageIdentification(id))); + this.currentOpeningPackageIndex = GlobalData.openingPackageList + .findIndexOfListById(new PackageIdentification( + id)); } if (intCategory >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { - showPlatformElement(intCategory, openingPlatformList.getOpeningPlatformById(id)); - this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id); + showPlatformElement( + intCategory, + GlobalData.openingPlatformList + .getOpeningPlatformById(new PlatformIdentification(id))); + this.currentOpeningPlatformIndex = GlobalData.openingPlatformList + .findIndexOfListById(new PlatformIdentification( + id)); } - } catch (RuntimeException e) { - Log.log("double click category: " + intCategory); - Log.log("double click id path: " + id); - Log.log("double click exception: " + e.getMessage()); + } catch (Exception e) { + Log.err("double click category: " + intCategory); + Log.err("double click belong node: " + belongNode.toString()); + Log.err("double click id path: " + id); + Log.err("double click exception: " + e.getMessage()); } } @@ -2688,10 +2779,6 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele SpdHeader frmSpdHeader = new SpdHeader(spd); getJDesktopPanePackage().add(frmSpdHeader, 1); break; - case IDefaultMutableTreeNode.SPD_PACKAGEDEFINITIONS: - SpdPackageDefinitions frmSpdPackageDefinitions = new SpdPackageDefinitions(spd); - getJDesktopPanePackage().add(frmSpdPackageDefinitions, 1); - break; case IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS: SpdLibClassDecls frmSlcd = new SpdLibClassDecls(spd); getJDesktopPanePackage().add(frmSlcd, 1); @@ -2739,10 +2826,6 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele MsaHeader frmMsaHeader = new MsaHeader(msa); getJDesktopPaneModule().add(frmMsaHeader, 1); break; - case IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS: - ModuleDefinitions frmMd = new ModuleDefinitions(msa); - getJDesktopPaneModule().add(frmMd, 1); - break; case IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS: ModuleLibraryClassDefinitions frmMlcd = new ModuleLibraryClassDefinitions(msa); getJDesktopPaneModule().add(frmMlcd, 1); @@ -2838,26 +2921,47 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele smb.dispose(); return; } else if (result == DataType.RETURN_TYPE_OK) { - PackageSurfaceAreaDocument.PackageSurfaceArea psa = null; - if (this.openingPackageList.existsPackage(smb.getMid().getPackageId())) { - psa = openingPackageList.getPackageSurfaceAreaFromId(smb.getMid().getPackageId()); - } - try { - wt.addModuleToPackage(smb.getMid(), psa); - } catch (IOException e) { - Log.wrn("Upddate MsaFiles of Package", e.getMessage()); - Log.err("Upddate MsaFiles of Package", e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Upddate MsaFiles of Package", e.getMessage()); - Log.err("Upddate MsaFiles of Package", e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Upddate MsaFiles of Package", e.getMessage()); - Log.err("Upddate MsaFiles of Package", e.getMessage()); - return; + ModuleIdentification mid = smb.getMid(); + if (mid != null) { + // + // Update package of workspace first + // + PackageSurfaceAreaDocument.PackageSurfaceArea psa = null; + if (GlobalData.openingPackageList.existsPackage(mid.getPackageId())) { + psa = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(mid.getPackageId()); + } + try { + wt.addModuleToPackage(mid, psa); + } catch (IOException e) { + Log.wrn("Update MsaFiles in Package", e.getMessage()); + Log.err("Update MsaFiles in Package", e.getMessage()); + return; + } catch (XmlException e) { + Log.wrn("Update MsaFiles in Package", e.getMessage()); + Log.err("Update MsaFiles in Package", e.getMessage()); + return; + } catch (Exception e) { + Log.wrn("Update MsaFiles in Package", e.getMessage()); + Log.err("Update MsaFiles in Package", e.getMessage()); + return; + } + + // + // Update Global Data + // + GlobalData.openingModuleList.insertToOpeningModuleList(mid, smb.getMsa()); + GlobalData.vModuleList.addElement(mid); + + // + // Create new node on the tree + // + addModuleToTree(mid); + + // + // Open the node + // + this.openModule(mid.getPath(), this.dmtnModuleDescription); } - this.openModule(smb.getMid().getPath(), smb.getMid()); } } else if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { // @@ -2871,30 +2975,38 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele smb.dispose(); return; } else if (result == DataType.RETURN_TYPE_OK) { - try { - wt.addPackageToDatabase(smb.getPid()); - } catch (Exception e) { - Log.err("addPackageToDatabase", e.getMessage()); - } - vPackageList.addElement(smb.getPid()); - - // - // Add to Module Description node - // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(), - IDefaultMutableTreeNode.MODULE_PACKAGE, - false, vPackageList.lastElement()); - - iTree.addNode(dmtnModuleDescription, node); - - // - // Add new SpdHeader node to the tree - // - node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(), - IDefaultMutableTreeNode.SPD_HEADER, true, vPackageList.lastElement()); - iTree.addNode(dmtnPackageDescription, node); + PackageIdentification pid = smb.getPid(); + if (pid != null) { + try { + wt.addPackageToDatabase(smb.getPid()); + } catch (Exception e) { + Log.err("addPackageToDatabase", e.getMessage()); + } - this.openPackage(smb.getPid().getPath()); + // + // Update Global Data + // + GlobalData.openingPackageList.insertToOpeningPackageList(pid, smb.getSpd()); + GlobalData.vPackageList.addElement(pid); + + // + // Add to Module Description node + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(pid.getName(), + IDefaultMutableTreeNode.MODULE_PACKAGE, + false, pid, this.dmtnModuleDescription); + + iTree.addNode(dmtnModuleDescription, node); + + // + // Add new SpdHeader node to the tree + // + node = new IDefaultMutableTreeNode(pid.getName(), IDefaultMutableTreeNode.PACKAGE, true, pid, + this.dmtnPackageDescription); + iTree.addNode(dmtnPackageDescription, node); + + this.openPackage(pid.getPath()); + } } } else if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { // @@ -2908,20 +3020,28 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele smb.dispose(); return; } else if (result == DataType.RETURN_TYPE_OK) { - try { - wt.addPlatformToDatabase(smb.getFid()); - } catch (Exception e) { - Log.err("addPlatformToDatabase", e.getMessage()); + PlatformIdentification fid = smb.getFid(); + if (fid != null) { + try { + wt.addPlatformToDatabase(fid); + } catch (Exception e) { + Log.err("addPlatformToDatabase", e.getMessage()); + } + + // + // Update global data + // + GlobalData.openingPlatformList.insertToOpeningPlatformList(fid, smb.getFpd()); + GlobalData.vPlatformList.addElement(fid); + // + // Add new SpdHeader node to the tree + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(fid.getName(), + IDefaultMutableTreeNode.PLATFORM, true, + fid, this.dmtnPlatformDescription); + iTree.addNode(dmtnPlatformDescription, node); + this.openPlatform(fid.getPath()); } - vPlatformList.addElement(smb.getFid()); - // - // Add new SpdHeader node to the tree - // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPlatformList.lastElement().getName(), - IDefaultMutableTreeNode.FPD_PLATFORMHEADER, - true, vPlatformList.lastElement()); - iTree.addNode(dmtnPlatformDescription, node); - this.openPlatform(smb.getFid().getPath()); } } } @@ -2947,7 +3067,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele String path = fc.getSelectedFile().getPath(); String match = path.substring(path.length() - 4); if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.MODULE_SURFACE_AREA_EXT)) { - openModule(path); + openModule(path, this.dmtnModuleDescription); } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PACKAGE_SURFACE_AREA_EXT)) { openPackage(path); } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PLATFORM_SURFACE_AREA_EXT)) { @@ -2961,13 +3081,14 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void close() { + TreePath item = null; switch (this.jTabbedPaneEditor.getSelectedIndex()) { // // Current is module // case 0: if (this.currentOpeningModuleIndex > -1) { - if (!openingModuleList.getModuleSaved(currentOpeningModuleIndex)) { + if (!GlobalData.openingModuleList.getModuleSaved(currentOpeningModuleIndex)) { int result = showSaveDialog(); if (result == JOptionPane.YES_OPTION) { this.saveAll(); @@ -2979,18 +3100,30 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return; } } - iTree.removeNodeChildrenByPath(openingModuleList.getTreePathByIndex(currentOpeningModuleIndex)); - this.openingModuleList.removeFromOpeningModuleListByIndex(this.currentOpeningModuleIndex); + + // + // Remove all tree paths for the module + // + Set openingTreePaths = GlobalData.openingModuleList + .getTreePathByIndex(currentOpeningModuleIndex); + Iterator openingTreePathsIter = openingTreePaths.iterator(); + while (openingTreePathsIter.hasNext()) { + item = openingTreePathsIter.next(); + iTree.getNodeByPath(item).setOpening(false); + iTree.removeNodeChildrenByPath(item); + } + + GlobalData.openingModuleList.setModuleOpen(this.currentOpeningModuleIndex, false); this.cleanDesktopPaneModule(); this.currentOpeningModuleIndex = -1; } break; // // Current is package - // + // case 1: if (this.currentOpeningPackageIndex > -1) { - if (!openingPackageList.getPackageSaved(currentOpeningPackageIndex)) { + if (!GlobalData.openingPackageList.getPackageSaved(currentOpeningPackageIndex)) { int result = showSaveDialog(); if (result == JOptionPane.YES_OPTION) { this.saveAll(); @@ -3002,8 +3135,20 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return; } } - iTree.removeNodeChildrenByPath(openingPackageList.getTreePathByIndex(currentOpeningPackageIndex)); - this.openingPackageList.removeFromOpeningPackageListByIndex(this.currentOpeningPackageIndex); + + // + // Remove all tree paths for the module + // + Set openingTreePaths = GlobalData.openingPackageList + .getTreePathByIndex(currentOpeningPackageIndex); + Iterator openingTreePathsIter = openingTreePaths.iterator(); + while (openingTreePathsIter.hasNext()) { + item = openingTreePathsIter.next(); + iTree.getNodeByPath(item).setOpening(false); + iTree.removeNodeChildrenByPath(item); + } + + GlobalData.openingPackageList.setPackageOpen(this.currentOpeningPackageIndex, false); this.cleanDesktopPanePackage(); this.currentOpeningPackageIndex = -1; } @@ -3013,7 +3158,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // case 2: if (this.currentOpeningPlatformIndex > -1) { - if (!openingPlatformList.getPlatformSaved(currentOpeningPlatformIndex)) { + if (!GlobalData.openingPlatformList.getPlatformSaved(currentOpeningPlatformIndex)) { int result = showSaveDialog(); if (result == JOptionPane.YES_OPTION) { this.saveAll(); @@ -3025,8 +3170,20 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return; } } - iTree.removeNodeChildrenByPath(openingPlatformList.getTreePathByIndex(currentOpeningPlatformIndex)); - this.openingPlatformList.removeFromOpeningPlatformListByIndex(this.currentOpeningPlatformIndex); + + // + // Remove all tree paths for the module + // + Set openingTreePaths = GlobalData.openingPlatformList + .getTreePathByIndex(currentOpeningPlatformIndex); + Iterator openingTreePathsIter = openingTreePaths.iterator(); + while (openingTreePathsIter.hasNext()) { + item = openingTreePathsIter.next(); + iTree.getNodeByPath(item).setOpening(false); + iTree.removeNodeChildrenByPath(item); + } + + GlobalData.openingPlatformList.setPlatformOpen(this.currentOpeningPlatformIndex, false); this.cleanDesktopPanePlatform(); this.currentOpeningPlatformIndex = -1; } @@ -3040,7 +3197,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void closeAll() { int result = -1; - if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) { + if (!GlobalData.openingModuleList.isSaved() || !GlobalData.openingPackageList.isSaved() + || !GlobalData.openingPlatformList.isSaved()) { result = showSaveDialog(); } if (result == JOptionPane.YES_OPTION) { @@ -3055,11 +3213,17 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return; } this.cleanDesktopPane(); - this.getCompontentsFromFrameworkDatabase(); - openingModuleList.removeAllFromOpeningModuleList(); - openingPackageList.removeAllFromOpeningPackageList(); - openingPlatformList.removeAllFromOpeningPlatformList(); - this.makeEmptyTree(); + GlobalData.openingModuleList.closeAll(); + GlobalData.openingPackageList.closeAll(); + GlobalData.openingPlatformList.closeAll(); + } + + /** + Refresh all global data from disk to memory + + **/ + private void refresh() { + GlobalData.init(); } /** @@ -3094,8 +3258,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Save all modules // - for (int index = 0; index < openingModuleList.size(); index++) { - if (!openingModuleList.getModuleSaved(index)) { + for (int index = 0; index < GlobalData.openingModuleList.size(); index++) { + if (!GlobalData.openingModuleList.getModuleSaved(index)) { saveModule(index); } } @@ -3103,8 +3267,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Save all packages // - for (int index = 0; index < openingPackageList.size(); index++) { - if (!openingPackageList.getPackageSaved(index)) { + for (int index = 0; index < GlobalData.openingPackageList.size(); index++) { + if (!GlobalData.openingPackageList.getPackageSaved(index)) { savePackage(index); } } @@ -3112,8 +3276,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Save all platforms // - for (int index = 0; index < openingPlatformList.size(); index++) { - if (!openingPlatformList.getPlatformSaved(index)) { + for (int index = 0; index < GlobalData.openingPlatformList.size(); index++) { + if (!GlobalData.openingPlatformList.getPlatformSaved(index)) { savePlatform(index); } } @@ -3125,7 +3289,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void exit() { int result = -1; - if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) { + if (!GlobalData.openingModuleList.isSaved() || !GlobalData.openingPackageList.isSaved() + || !GlobalData.openingPlatformList.isSaved()) { result = showSaveDialog(); } if (result == JOptionPane.YES_OPTION) { @@ -3141,6 +3306,60 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele System.exit(0); } + /** + To find all defined PPIs in workspace + + **/ + private void findPpi() { + FindResult fr = FindResult.getInstance("PPI"); + fr.setVisible(true); + } + + /** + To find all defined PROTOCOLs in workspace + + **/ + private void findProtocol() { + FindResult fr = FindResult.getInstance("PROTOCOL"); + fr.setVisible(true); + } + + /** + To find all defined PROTOCOLs in workspace + + **/ + private void findGuid() { + FindResult fr = FindResult.getInstance("GUID"); + fr.setVisible(true); + } + + /** + To find all defined PROTOCOLs in workspace + + **/ + private void findPcd() { + FindResult fr = FindResult.getInstance("PCD"); + fr.setVisible(true); + } + + /** + To find all defined Library Classes in workspace + + **/ + private void findLibraryClass() { + FindResult fr = FindResult.getInstance("LIBRARY_CLASS"); + fr.setVisible(true); + } + + /** + To find all defined Library Instances in workspace + + **/ + private void findLibraryInstance() { + FindResult fr = FindResult.getInstance("LIBRARY_INSTANCE"); + fr.setVisible(true); + } + /** Switch current workspace to others @@ -3154,9 +3373,13 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Reinit whole window // - closeAll(); + this.closeAll(); this.setTitle(DataType.PROJECT_NAME + " " + DataType.PROJECT_VERSION + " " + "- [" + Workspace.getCurrentWorkspace() + "]"); + // + // Refrash the tree + // + this.refresh(); } sw.dispose(); } @@ -3169,7 +3392,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele CreateStepOne cso = new CreateStepOne(this, true); int result = cso.showDialog(); if (result == DataType.RETURN_TYPE_OK) { - String strReturn = "Create Far Done!"; + String strReturn = "Far Creation Completed!"; JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); } @@ -3184,10 +3407,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele InstallStepOne iso = new InstallStepOne(this, true); int result = iso.showDialog(); if (result == DataType.RETURN_TYPE_OK) { - String strReturn = "Install Far Done!
The WORKSPACE will be refreshed!"; + String strReturn = "Far Installalation completed!
Refreshing the WORKSPACE!"; JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); this.closeAll(); + this.refresh(); + this.makeEmptyTree(); } iso.dispose(); } @@ -3200,10 +3425,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele DeleteStepOne dso = new DeleteStepOne(this, true); int result = dso.showDialog(); if (result == DataType.RETURN_TYPE_OK) { - String strReturn = "Delete Far Done!
The WORKSPACE will be refreshed!"; + String strReturn = "Far Deletion completed!
Refreshing the WORKSPACE!"; JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); this.closeAll(); + this.refresh(); + this.makeEmptyTree(); } dso.dispose(); } @@ -3216,10 +3443,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele UpdateStepOne uso = new UpdateStepOne(this, true); int result = uso.showDialog(); if (result == DataType.RETURN_TYPE_OK) { - String strReturn = "Update Far Done!
The WORKSPACE will be refreshed!"; + String strReturn = "Far Update completed!
Refreshing the WORKSPACE!"; JOptionPane.showConfirmDialog(null, strReturn, "Done", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); this.closeAll(); + this.refresh(); + this.makeEmptyTree(); } uso.dispose(); } @@ -3233,6 +3462,11 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele tcc.showDialog(); } + private void configBuildPreferences() { + Preferences bt = Preferences.getInstance(); + bt.showDialog(); + } + /** Clone selected item @@ -3249,23 +3483,20 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } int category = iTree.getSelectCategory(); Identification id = iTree.getSelectNode().getId(); - if (category == IDefaultMutableTreeNode.MODULE || category == IDefaultMutableTreeNode.PACKAGE - || category == IDefaultMutableTreeNode.PLATFORM) { - Log.wrn("Clone", "Please select a target to clone!"); - return; - } if (category == IDefaultMutableTreeNode.WORKSPACE) { mode = DataType.RETURN_TYPE_WORKSPACE; id = null; } - if (category >= IDefaultMutableTreeNode.MSA_HEADER && category < IDefaultMutableTreeNode.SPD_HEADER) { + if ((category == IDefaultMutableTreeNode.MODULE) + || (category >= IDefaultMutableTreeNode.MSA_HEADER && category < IDefaultMutableTreeNode.SPD_HEADER)) { mode = DataType.RETURN_TYPE_MODULE_SURFACE_AREA; } - if (category >= IDefaultMutableTreeNode.SPD_HEADER && category < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { + if ((category == IDefaultMutableTreeNode.PACKAGE) + || (category >= IDefaultMutableTreeNode.SPD_HEADER && category < IDefaultMutableTreeNode.FPD_PLATFORMHEADER)) { mode = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA; } - if (category >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { + if ((category == IDefaultMutableTreeNode.PLATFORM) || (category >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER)) { mode = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA; } @@ -3276,35 +3507,34 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele c.dispose(); } if (result == DataType.RETURN_TYPE_WORKSPACE) { - Tools.showInformationMessage("Workspace Clone Finished"); + Tools.showInformationMessage("Workspace Clone Completed!"); } if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) { - Tools.showInformationMessage("Module Surface Area Clone Finished"); - vModuleList.addElement(c.getMid()); + Tools.showInformationMessage("Module Clone Completed!"); addModuleToTree(c.getMid()); } if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { - Tools.showInformationMessage("Package Surface Area Clone Finished"); - vPackageList.addElement(c.getPid()); + Tools.showInformationMessage("Package Clone Completed!"); // // Add new SpdHeader node to the tree // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(), - IDefaultMutableTreeNode.SPD_HEADER, true, - vPackageList.lastElement()); - iTree.addNode(dmtnPackageDescription, node); + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(GlobalData.vPackageList.lastElement().getName(), + IDefaultMutableTreeNode.PACKAGE, false, + GlobalData.vPackageList.lastElement(), + this.dmtnPackageDescription); + iTree.addNode(this.dmtnPackageDescription, node); } if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { Tools.showInformationMessage("Platform Surface Area Clone Finished"); - vPlatformList.addElement(c.getFid()); // // Add new SpdHeader node to the tree // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPlatformList.lastElement().getName(), - IDefaultMutableTreeNode.FPD_PLATFORMHEADER, - true, vPlatformList.lastElement()); - iTree.addNode(dmtnPlatformDescription, node); - //this.openPlatform(c.getFid().getPath()); + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode( + GlobalData.vPlatformList.lastElement().getName(), + IDefaultMutableTreeNode.PLATFORM, false, + GlobalData.vPlatformList.lastElement(), + this.dmtnPlatformDescription); + iTree.addNode(this.dmtnPlatformDescription, node); } if (result == DataType.RETURN_TYPE_OK) { @@ -3331,18 +3561,22 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Enable close/close all if some files are opened // - jMenuItemFileClose.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend() - || openingPlatformList.isOpend()); - jMenuItemFileCloseAll.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend() - || openingPlatformList.isOpend()); + jMenuItemFileClose.setEnabled(GlobalData.openingModuleList.isOpen() + || GlobalData.openingPackageList.isOpen() + || GlobalData.openingPlatformList.isOpen()); + jMenuItemFileCloseAll.setEnabled(GlobalData.openingModuleList.isOpen() + || GlobalData.openingPackageList.isOpen() + || GlobalData.openingPlatformList.isOpen()); // // Enable save/save all if some files are changed // - jMenuItemFileSave.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved() - || !openingPlatformList.isSaved()); - jMenuItemFileSaveAll.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved() - || !openingPlatformList.isSaved()); + jMenuItemFileSave.setEnabled(!GlobalData.openingModuleList.isSaved() + || !GlobalData.openingPackageList.isSaved() + || !GlobalData.openingPlatformList.isSaved()); + jMenuItemFileSaveAll.setEnabled(!GlobalData.openingModuleList.isSaved() + || !GlobalData.openingPackageList.isSaved() + || !GlobalData.openingPlatformList.isSaved()); } if (arg0.getSource() == jMenuTools) { @@ -3353,8 +3587,9 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele jMenuItemToolsClone.setEnabled(false); } else { int category = iTree.getSelectCategory(); - if (category == IDefaultMutableTreeNode.MODULE || category == IDefaultMutableTreeNode.PACKAGE - || category == IDefaultMutableTreeNode.PLATFORM + if (category == IDefaultMutableTreeNode.MODULE_DESCRIPTION + || category == IDefaultMutableTreeNode.PACKAGE_DESCRIPTION + || category == IDefaultMutableTreeNode.PLATFORM_DESCRIPTION || category == IDefaultMutableTreeNode.MODULE_PACKAGE || category == IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY || category == IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE) { @@ -3365,4 +3600,79 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } } } + + public void keyTyped(KeyEvent arg0) { + // TODO Auto-generated method stub + + } + + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + + } + + public void keyReleased(KeyEvent arg0) { + if (arg0.getSource() == this.iTree) { + if (arg0.getKeyCode() == KeyEvent.VK_ENTER) { + this.doubleClickModuleTreeNode(); + } + } + } + + /** + Search whole workspace and find all module's name and guid, and save them to a file + + **/ + private void generateGuidsXref() { + // + // Init File Chooser + // + JFileChooser fc = new JFileChooser(); + fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace())); + fc.setSelectedFile(new File(Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + + DataType.GUIDS_XREF_FILE_NAME)); + fc.setMultiSelectionEnabled(false); + + // + // Get guids xref and save to file + // + int result = fc.showSaveDialog(new JPanel()); + if (result == JFileChooser.APPROVE_OPTION) { + Vector v = wt.getAllModuleGuidXref(); + if (v.size() < 1) { + Log.wrn("No guids found!!!"); + return; + } + File f = fc.getSelectedFile(); + if (!f.exists()) { + try { + f.createNewFile(); + } catch (IOException e) { + Log.wrn("Fail to create file", e.getMessage()); + Log.err("Fail to create file when generating guids.xref", e.getMessage()); + } + } + FileWriter fw = null; + BufferedWriter bw = null; + try { + fw = new FileWriter(f); + bw = new BufferedWriter(fw); + for (int index = 0; index < v.size(); index++) { + bw.write(v.get(index)); + bw.newLine(); + } + bw.flush(); + fw.flush(); + bw.close(); + fw.close(); + } catch (IOException e) { + Log.wrn("Fail to write file", e.getMessage()); + Log.err("Fail to write file when generating guids.xref", e.getMessage()); + return; + } + + JOptionPane.showConfirmDialog(null, "File is created", "Generate guids.xref", JOptionPane.DEFAULT_OPTION, + JOptionPane.INFORMATION_MESSAGE); + } + } }