diff options
author | hche10x <hche10x@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-07-12 07:46:39 +0000 |
---|---|---|
committer | hche10x <hche10x@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-07-12 07:46:39 +0000 |
commit | 06a19ceec7b8b78f4698073ce4054b26dc4a74bd (patch) | |
tree | 07888d2d67d55904a7c2de561d7816c2127ae6cb | |
parent | 8958113b3a4688530fd9fe3825664c66ff3e62c0 (diff) | |
download | edk2-platforms-06a19ceec7b8b78f4698073ce4054b26dc4a74bd.tar.xz |
Use table and popup window to add/edit all elements of module instead of original drop down list.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@894 6f19259b-4bc3-4df7-8a09-765794883524
48 files changed, 9367 insertions, 7676 deletions
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java index f32ff6ed65..ba50465c6b 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java @@ -17,7 +17,7 @@ package org.tianocore.frameworkwizard.common; /**
The class is used to define all used final variables
-**/
+ **/
public class DataType {
/**
@@ -28,168 +28,200 @@ public class DataType { public static void main(String[] args) {
}
-
+
//
// Define all return types
//
public static final int RETURN_TYPE_OK = 1;
-
+
public static final int RETURN_TYPE_CANCEL = 2;
-
+
public static final int RETURN_TYPE_NEXT = 3;
-
+
public static final int RETURN_TYPE_BACK = 4;
-
+
public static final int RETURN_TYPE_MODULE_SURFACE_AREA = 11;
-
+
public static final int RETURN_TYPE_PACKAGE_SURFACE_AREA = 12;
-
+
public static final int RETURN_TYPE_PLATFORM_SURFACE_AREA = 13;
-
+
public static final int RETURN_TYPE_BUILD_XML = 14;
-
+
public static final int RETURN_TYPE_WORKSPACE = 15;
-
+
public static final int RETURN_TYPE_TEXT = 16;
-
-
+
//
// Define all used final variables
//
public static final String DOS_LINE_SEPARATOR = "\r\n";
public static final String UNIX_LINE_SEPARATOR = "\n";
-
+
public static final String EMPTY_SELECT_ITEM = "----";
-
+
public static final String DOS_FILE_SEPARATOR = "\\";
-
+
public static final String UNIX_FILE_SEPARATOR = "/";
-
+
//
// Define xml files ext
//
public static final String COPY_OF = "Copy of ";
-
+
public static final String FILE_EXT_SEPARATOR = ".";
-
+
public static final String WORKSPACE = "Workspace";
-
+
public static final String MODULE_SURFACE_AREA = "Module Surface Area Description";
-
+
public static final String MODULE_SURFACE_AREA_EXT = "msa";
-
- public static final String MODULE_SURFACE_AREA_EXT_DESCRIPTION = MODULE_SURFACE_AREA + " (*." + MODULE_SURFACE_AREA_EXT + ")";
-
+
+ public static final String MODULE_SURFACE_AREA_EXT_DESCRIPTION = MODULE_SURFACE_AREA + " (*."
+ + MODULE_SURFACE_AREA_EXT + ")";
+
public static final String PACKAGE_SURFACE_AREA = "Package Surface Area Description";
-
+
public static final String PACKAGE_SURFACE_AREA_EXT = "spd";
-
- public static final String PACKAGE_SURFACE_AREA_EXT_DESCRIPTION = PACKAGE_SURFACE_AREA + " (*." + PACKAGE_SURFACE_AREA_EXT + ")";
-
+
+ public static final String PACKAGE_SURFACE_AREA_EXT_DESCRIPTION = PACKAGE_SURFACE_AREA + " (*."
+ + PACKAGE_SURFACE_AREA_EXT + ")";
+
public static final String PLATFORM_SURFACE_AREA = "Platform Surface Area Description";
-
+
public static final String PLATFORM_SURFACE_AREA_EXT = "fpd";
-
- public static final String PLATFORM_SURFACE_AREA_EXT_DESCRIPTION = PLATFORM_SURFACE_AREA + " (*." + PLATFORM_SURFACE_AREA_EXT + ")";
-
+
+ public static final String PLATFORM_SURFACE_AREA_EXT_DESCRIPTION = PLATFORM_SURFACE_AREA + " (*."
+ + PLATFORM_SURFACE_AREA_EXT + ")";
+
public static final String ANT_BUILD_FILE = "ANT Build File";
-
+
public static final String ANT_BUILD_FILE_EXT = "xml";
-
+
public static final String ANT_BUILD_FILE_EXT_DESCRIPTION = ANT_BUILD_FILE + " (*." + ANT_BUILD_FILE_EXT + ")";
-
+
public static final String TEXT_FILE = "Text File";
-
+
public static final String TEXT_FILE_EXT = "txt";
-
+
public static final String TEXT_FILE_EXT_DESCRIPTION = TEXT_FILE + " (*." + TEXT_FILE_EXT + ")";
-
+
//
// Define file separator for current OS
//
public static String FILE_SEPARATOR = System.getProperty("file.separator");
-
+
//
// Defien all used frame, container component's sizes
//
public static final int MAIN_FRAME_PREFERRED_SIZE_WIDTH = 800;
+
public static final int MAIN_FRAME_PREFERRED_SIZE_HEIGHT = 600;
+
public static final int MAIN_FRAME_MAX_SIZE_WIDTH = 1920;
+
public static final int MAIN_FRAME_MAX_SIZE_HEIGHT = 1200;
-
+
public static final int MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_WIDTH = 790;
+
public static final int MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_HEIGHT = 545;
-
- public static final int MAIN_FRAME_WIDTH_SPACING = MAIN_FRAME_PREFERRED_SIZE_WIDTH - MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_WIDTH;
- public static final int MAIN_FRAME_HEIGHT_SPACING = MAIN_FRAME_PREFERRED_SIZE_HEIGHT - MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_HEIGHT;
-
+
+ public static final int MAIN_FRAME_WIDTH_SPACING = MAIN_FRAME_PREFERRED_SIZE_WIDTH
+ - MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_WIDTH;
+
+ public static final int MAIN_FRAME_HEIGHT_SPACING = MAIN_FRAME_PREFERRED_SIZE_HEIGHT
+ - MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_HEIGHT;
+
public static final int MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH = 273;
+
public static final int MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT = 545;
-
+
public static final int MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH = 515;
+
public static final int MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT = 545;
+
public static final int MAIN_FRAME_EDITOR_PANEL_LOCATION_X = 260;
+
public static final int MAIN_FRAME_EDITOR_PANEL_LOCATION_Y = 1;
-
+
public static final int SPACE_TO_RIGHT_FOR_GENERATE_BUTTON = 10;
+
public static final int SPACE_TO_RIGHT_FOR_OK_BUTTON = 10;
+
public static final int SPACE_TO_RIGHT_FOR_ADD_BUTTON = 180;
+
public static final int SPACE_TO_RIGHT_FOR_REMOVE_BUTTON = 95;
+
public static final int SPACE_TO_RIGHT_FOR_UPDATE_BUTTON = 10;
- public static final int SPACE_TO_RIGHT_FOR_PROTOCOL_NOTIFY = 25;
+ public static final int SPACE_TO_BOTTOM_FOR_ADD_BUTTON = 30;
+
+ public static final int SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON = 30;
+
+ public static final int SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON = 30;
+
+ public static final int SPACE_TO_RIGHT_FOR_PROTOCOL_NOTIFY = 25;
+
public static final int LEFT_WIDTH = 160;
+
public static final int LEFT_HEIGHT = 20;
-
+
public static final int RIGHT_WIDTH = 320;
+
public static final int RIGHT_HEIGHT = 20;
-
+
public static final int RIGHT_MULTIPLE_HEIGHT = 4 * RIGHT_HEIGHT;
-
+
public static final int BUTTON_GEN_WIDTH = 65;
+
public static final int BUTTON_GEN_HEIGHT = 20;
-
+
public static final int BUTTON_BROWSE_WIDTH = 65;
+
public static final int BUTTON_BROWSE_HEIGHT = 20;
-
+
public static final int BUTTON_ADD_WIDTH = 80;
+
public static final int BUTTON_ADD_HEIGHT = 20;
-
+
public static final int BUTTON_UPDATE_WIDTH = 80;
+
public static final int BUTTON_UPDATE_HEIGHT = 20;
-
+
public static final int BUTTON_REMOVE_WIDTH = 80;
+
public static final int BUTTON_REMOVE_HEIGHT = 20;
-
+
public static final int SCROLLBAR_WIDTH = 18;
+
public static final int SCROLLBAR_HEIGHT = 18;
-
+
//
// Common Help Text
// First defined here
// Will be replaced by resource file later
//
public static final String SUP_ARCH_LIST_HELP_TEXT = "Deselecting a checkbox will restrict this module for use with the selected architectures, based on the list of items that are checked. If all boxes are checked, then the module will support all current AND FUTURE architectures";
-
+
//
// Project name and version
//
public static final String PROJECT_NAME = "Framework Wizard";
-
+
public static final String PROJECT_VERSION = "1.0";
-
+
//
// Sort Type
//
public static final int SORT_TYPE_ASCENDING = 1;
-
+
public static final int SORT_TYPE_DESCENDING = 2;
-
+
//
// Module Type
//
public static final String MODULE_TYPE_LIBRARY = "Library";
-
+
public static final String MODULE_TYPE_MODULE = "Module";
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java index 2fc8b0268b..bb4212a459 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java @@ -20,6 +20,8 @@ public class EnumerationData { //
// Static data
//
+ public final static String EXTERNS_PCD_IS_DRIVER = "Pcd Is Driver";
+
public final static String EXTERNS_SPECIFICATION = "Specification";
public final static String EXTERNS_MODULE_ENTRY_POINT = "ModuleEntryPoint";
@@ -647,6 +649,9 @@ public class EnumerationData { private void initExternTypes() {
vExternTypes.removeAllElements();
+
+ vExternTypes.addElement(EnumerationData.EXTERNS_PCD_IS_DRIVER);
+
vExternTypes.addElement(EnumerationData.EXTERNS_SPECIFICATION);
vExternTypes.addElement(EnumerationData.EXTERNS_MODULE_ENTRY_POINT);
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ArchCheckBox.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ArchCheckBox.java new file mode 100644 index 0000000000..e564ab5eff --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ArchCheckBox.java @@ -0,0 +1,246 @@ +/** @file
+
+ The file is used to provid 6 kinds of arch in one jpanel
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.frameworkwizard.common.ui;
+
+import java.util.Vector;
+
+import javax.swing.JPanel;
+import javax.swing.JCheckBox;
+
+public class ArchCheckBox extends JPanel {
+
+ ///
+ ///
+ ///
+ private static final long serialVersionUID = 4792669775676953990L;
+
+ private JCheckBox jCheckBoxIa32 = null;
+
+ private JCheckBox jCheckBoxX64 = null;
+
+ private JCheckBox jCheckBoxIpf = null;
+
+ private JCheckBox jCheckBoxEbc = null;
+
+ private JCheckBox jCheckBoxArm = null;
+
+ private JCheckBox jCheckBoxPpc = null;
+
+ /**
+ * This method initializes jCheckBoxIa32
+ *
+ * @return javax.swing.JCheckBox
+ */
+ private JCheckBox getJCheckBoxIa32() {
+ if (jCheckBoxIa32 == null) {
+ jCheckBoxIa32 = new JCheckBox();
+ jCheckBoxIa32.setBounds(new java.awt.Rectangle(0, 0, 50, 20));
+ jCheckBoxIa32.setText("IA32");
+ }
+ return jCheckBoxIa32;
+ }
+
+ /**
+ * This method initializes jCheckBoxX64
+ *
+ * @return javax.swing.JCheckBox
+ */
+ private JCheckBox getJCheckBoxX64() {
+ if (jCheckBoxX64 == null) {
+ jCheckBoxX64 = new JCheckBox();
+ jCheckBoxX64.setBounds(new java.awt.Rectangle(50, 0, 50, 20));
+ jCheckBoxX64.setText("X64");
+ }
+ return jCheckBoxX64;
+ }
+
+ /**
+ * This method initializes jCheckBoxIpf
+ *
+ * @return javax.swing.JCheckBox
+ */
+ private JCheckBox getJCheckBoxIpf() {
+ if (jCheckBoxIpf == null) {
+ jCheckBoxIpf = new JCheckBox();
+ jCheckBoxIpf.setBounds(new java.awt.Rectangle(100, 0, 50, 20));
+ jCheckBoxIpf.setText("IPF");
+ }
+ return jCheckBoxIpf;
+ }
+
+ /**
+ * This method initializes jCheckBoxEbc
+ *
+ * @return javax.swing.JCheckBox
+ */
+ private JCheckBox getJCheckBoxEbc() {
+ if (jCheckBoxEbc == null) {
+ jCheckBoxEbc = new JCheckBox();
+ jCheckBoxEbc.setBounds(new java.awt.Rectangle(150, 0, 50, 20));
+ jCheckBoxEbc.setText("EBC");
+ }
+ return jCheckBoxEbc;
+ }
+
+ /**
+ * This method initializes jCheckBoxArm
+ *
+ * @return javax.swing.JCheckBox
+ */
+ private JCheckBox getJCheckBoxArm() {
+ if (jCheckBoxArm == null) {
+ jCheckBoxArm = new JCheckBox();
+ jCheckBoxArm.setBounds(new java.awt.Rectangle(200, 0, 55, 20));
+ jCheckBoxArm.setText("ARM");
+ }
+ return jCheckBoxArm;
+ }
+
+ /**
+ * This method initializes jCheckBoxPrc
+ *
+ * @return javax.swing.JCheckBox
+ */
+ private JCheckBox getJCheckBoxPpc() {
+ if (jCheckBoxPpc == null) {
+ jCheckBoxPpc = new JCheckBox();
+ jCheckBoxPpc.setBounds(new java.awt.Rectangle(255, 0, 50, 20));
+ jCheckBoxPpc.setText("PPC");
+ }
+ return jCheckBoxPpc;
+ }
+
+ /**
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * This is the default constructor
+ */
+ public ArchCheckBox() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setSize(320, 20);
+ this.setLayout(null);
+ this.add(getJCheckBoxIa32(), null);
+ this.add(getJCheckBoxX64(), null);
+ this.add(getJCheckBoxIpf(), null);
+ this.add(getJCheckBoxEbc(), null);
+ this.add(getJCheckBoxArm(), null);
+ this.add(getJCheckBoxPpc(), null);
+ }
+
+ public Vector<String> getSelectedItemsVector() {
+ Vector<String> v = new Vector<String>();
+ if (this.jCheckBoxIa32.isSelected()) {
+ v.addElement(jCheckBoxIa32.getText());
+ }
+ if (this.jCheckBoxX64.isSelected()) {
+ v.addElement(jCheckBoxX64.getText());
+ }
+ if (this.jCheckBoxIpf.isSelected()) {
+ v.addElement(jCheckBoxIpf.getText());
+ }
+ if (this.jCheckBoxEbc.isSelected()) {
+ v.addElement(jCheckBoxEbc.getText());
+ }
+ if (this.jCheckBoxArm.isSelected()) {
+ v.addElement(jCheckBoxArm.getText());
+ }
+ if (this.jCheckBoxPpc.isSelected()) {
+ v.addElement(jCheckBoxPpc.getText());
+ }
+ return v;
+ }
+
+ public String getSelectedItemsString() {
+ String s = "";
+ if (this.jCheckBoxIa32.isSelected()) {
+ s = s + jCheckBoxIa32.getText() + " ";
+ }
+ if (this.jCheckBoxX64.isSelected()) {
+ s = s + jCheckBoxX64.getText() + " ";
+ }
+ if (this.jCheckBoxIpf.isSelected()) {
+ s = s + jCheckBoxIpf.getText() + " ";
+ }
+ if (this.jCheckBoxEbc.isSelected()) {
+ s = s + jCheckBoxEbc.getText() + " ";
+ }
+ if (this.jCheckBoxArm.isSelected()) {
+ s = s + jCheckBoxArm.getText() + " ";
+ }
+ if (this.jCheckBoxPpc.isSelected()) {
+ s = s + jCheckBoxPpc.getText() + " ";
+ }
+ return s.trim();
+ }
+
+ public void setAllItmesSelected(boolean isSelected) {
+ this.jCheckBoxIa32.setSelected(isSelected);
+ this.jCheckBoxX64.setSelected(isSelected);
+ this.jCheckBoxIpf.setSelected(isSelected);
+ this.jCheckBoxEbc.setSelected(isSelected);
+ this.jCheckBoxArm.setSelected(isSelected);
+ this.jCheckBoxPpc.setSelected(isSelected);
+ }
+
+ public void setSelectedItems(Vector<String> v) {
+ setAllItmesSelected(false);
+ if (v != null) {
+ for (int index = 0; index < v.size(); index++) {
+ if (v.get(index).equals(this.jCheckBoxIa32.getText())) {
+ this.jCheckBoxIa32.setSelected(true);
+ continue;
+ }
+ if (v.get(index).equals(this.jCheckBoxIpf.getText())) {
+ this.jCheckBoxIpf.setSelected(true);
+ continue;
+ }
+ if (v.get(index).equals(this.jCheckBoxX64.getText())) {
+ this.jCheckBoxX64.setSelected(true);
+ continue;
+ }
+ if (v.get(index).equals(this.jCheckBoxEbc.getText())) {
+ this.jCheckBoxEbc.setSelected(true);
+ continue;
+ }
+ if (v.get(index).equals(this.jCheckBoxArm.getText())) {
+ this.jCheckBoxArm.setSelected(true);
+ continue;
+ }
+ if (v.get(index).equals(this.jCheckBoxPpc.getText())) {
+ this.jCheckBoxPpc.setSelected(true);
+ continue;
+ }
+ }
+ }
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/BootModes/BootModesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/BootModes/BootModesVector.java index 71255787b1..82928060bc 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/BootModes/BootModesVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/BootModes/BootModesVector.java @@ -50,7 +50,7 @@ public class BootModesVector { vBootModes.addElement(arg0);
}
- public void updateBootModes(BootModesIdentification arg0, int arg1) {
+ public void setBootModes(BootModesIdentification arg0, int arg1) {
vBootModes.setElementAt(arg0, arg1);
}
@@ -86,5 +86,11 @@ public class BootModesVector { public int size() {
return this.vBootModes.size();
}
-
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getBootModes(index).getName());
+ v.addElement(getBootModes(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/DataHubs/DataHubsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/DataHubs/DataHubsVector.java index b7899bdd7d..7405342c74 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/DataHubs/DataHubsVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/DataHubs/DataHubsVector.java @@ -50,7 +50,7 @@ public class DataHubsVector { vDataHubs.addElement(arg0);
}
- public void updateDataHubs(DataHubsIdentification arg0, int arg1) {
+ public void setDataHubs(DataHubsIdentification arg0, int arg1) {
vDataHubs.setElementAt(arg0, arg1);
}
@@ -86,5 +86,11 @@ public class DataHubsVector { public int size() {
return this.vDataHubs.size();
}
-
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getDataHubs(index).getName());
+ v.addElement(getDataHubs(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Events/EventsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Events/EventsVector.java index bafd98ab09..f64e184aa3 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Events/EventsVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Events/EventsVector.java @@ -50,7 +50,7 @@ public class EventsVector { vEvents.addElement(arg0);
}
- public void updateEvents(EventsIdentification arg0, int arg1) {
+ public void setEvents(EventsIdentification arg0, int arg1) {
vEvents.setElementAt(arg0, arg1);
}
@@ -86,5 +86,12 @@ public class EventsVector { public int size() {
return this.vEvents.size();
}
-
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getEvents(index).getName());
+ v.addElement(getEvents(index).getType());
+ v.addElement(getEvents(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Externs/ExternsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Externs/ExternsVector.java index ee5a031b49..93b2507f42 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Externs/ExternsVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Externs/ExternsVector.java @@ -16,6 +16,8 @@ package org.tianocore.frameworkwizard.module.Identifications.Externs; import java.util.Vector;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+
public class ExternsVector {
private Vector<ExternsIdentification> vExterns = new Vector<ExternsIdentification>();
@@ -47,10 +49,24 @@ public class ExternsVector { }
public void addExterns(ExternsIdentification arg0) {
- vExterns.addElement(arg0);
+ boolean isExistPcd = false;
+ if (arg0.getType().equals(EnumerationData.EXTERNS_PCD_IS_DRIVER)) {
+ for (int index = 0; index < size(); index++) {
+ if (getExterns(index).getType().equals(EnumerationData.EXTERNS_PCD_IS_DRIVER)) {
+ setExterns(arg0, index);
+ isExistPcd = true;
+ break;
+ }
+ }
+ if (!isExistPcd) {
+ vExterns.addElement(arg0);
+ }
+ } else {
+ vExterns.addElement(arg0);
+ }
}
- public void updateExterns(ExternsIdentification arg0, int arg1) {
+ public void setExterns(ExternsIdentification arg0, int arg1) {
vExterns.setElementAt(arg0, arg1);
}
@@ -87,4 +103,10 @@ public class ExternsVector { return this.vExterns.size();
}
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getExterns(index).getName());
+ v.addElement(getExterns(index).getType());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Guids/GuidsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Guids/GuidsVector.java index 01694cc5a8..6d415c3162 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Guids/GuidsVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Guids/GuidsVector.java @@ -50,7 +50,7 @@ public class GuidsVector { vGuids.addElement(arg0);
}
- public void updateGuids(GuidsIdentification arg0, int arg1) {
+ public void setGuids(GuidsIdentification arg0, int arg1) {
vGuids.setElementAt(arg0, arg1);
}
@@ -86,5 +86,12 @@ public class GuidsVector { public int size() {
return this.vGuids.size();
}
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getGuids(index).getName());
+ v.addElement(getGuids(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/HiiPackages/HiiPackagesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/HiiPackages/HiiPackagesVector.java index 161f6a4a28..f946c0c7e3 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/HiiPackages/HiiPackagesVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/HiiPackages/HiiPackagesVector.java @@ -50,7 +50,7 @@ public class HiiPackagesVector { vHiiPackages.addElement(arg0);
}
- public void updateHiiPackages(HiiPackagesIdentification arg0, int arg1) {
+ public void setHiiPackages(HiiPackagesIdentification arg0, int arg1) {
vHiiPackages.setElementAt(arg0, arg1);
}
@@ -86,5 +86,11 @@ public class HiiPackagesVector { public int size() {
return this.vHiiPackages.size();
}
-
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getHiiPackages(index).getName());
+ v.addElement(getHiiPackages(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Hobs/HobsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Hobs/HobsVector.java index fbbf529494..550cb0aca1 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Hobs/HobsVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Hobs/HobsVector.java @@ -50,7 +50,7 @@ public class HobsVector { vHobs.addElement(arg0);
}
- public void updateHobs(HobsIdentification arg0, int arg1) {
+ public void setHobs(HobsIdentification arg0, int arg1) {
vHobs.setElementAt(arg0, arg1);
}
@@ -86,5 +86,12 @@ public class HobsVector { public int size() {
return this.vHobs.size();
}
-
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getHobs(index).getName());
+ v.addElement(getHobs(index).getType());
+ v.addElement(getHobs(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/LibraryClass/LibraryClassVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/LibraryClass/LibraryClassVector.java index efb146e1e7..d5e22f980b 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/LibraryClass/LibraryClassVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/LibraryClass/LibraryClassVector.java @@ -50,7 +50,7 @@ public class LibraryClassVector { vLibraryClass.addElement(lib);
}
- public void updateLibraryClass(LibraryClassIdentification lib, int index) {
+ public void setLibraryClass(LibraryClassIdentification lib, int index) {
vLibraryClass.setElementAt(lib, index);
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PackageDependencies/PackageDependenciesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PackageDependencies/PackageDependenciesVector.java index 386a803628..7661453c4f 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PackageDependencies/PackageDependenciesVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PackageDependencies/PackageDependenciesVector.java @@ -50,7 +50,7 @@ public class PackageDependenciesVector { vPackageDependencies.addElement(arg0);
}
- public void updatePackageDependencies(PackageDependenciesIdentification arg0, int arg1) {
+ public void setPackageDependencies(PackageDependenciesIdentification arg0, int arg1) {
vPackageDependencies.setElementAt(arg0, arg1);
}
@@ -86,5 +86,12 @@ public class PackageDependenciesVector { public int size() {
return this.vPackageDependencies.size();
}
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getPackageDependencies(index).getName());
+ v.addElement(getPackageDependencies(index).getVersion());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PcdCoded/PcdCodedVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PcdCoded/PcdCodedVector.java index 023290db77..7d8529f4e2 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PcdCoded/PcdCodedVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PcdCoded/PcdCodedVector.java @@ -50,7 +50,7 @@ public class PcdCodedVector { vPcdCoded.addElement(arg0);
}
- public void updatePcdCoded(PcdCodedIdentification arg0, int arg1) {
+ public void setPcdCoded(PcdCodedIdentification arg0, int arg1) {
vPcdCoded.setElementAt(arg0, arg1);
}
@@ -87,4 +87,11 @@ public class PcdCodedVector { return this.vPcdCoded.size();
}
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getPcdCoded(index).getName());
+ v.addElement(getPcdCoded(index).getType());
+ v.addElement(getPcdCoded(index).getValue());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Ppis/PpisVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Ppis/PpisVector.java index b1d3457701..5baa0a0af6 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Ppis/PpisVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Ppis/PpisVector.java @@ -50,7 +50,7 @@ public class PpisVector { vPpis.addElement(arg0);
}
- public void updatePpis(PpisIdentification arg0, int arg1) {
+ public void setPpis(PpisIdentification arg0, int arg1) {
vPpis.setElementAt(arg0, arg1);
}
@@ -86,5 +86,13 @@ public class PpisVector { public int size() {
return this.vPpis.size();
}
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getPpis(index).getName());
+ v.addElement(getPpis(index).getType());
+ v.addElement(getPpis(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Protocols/ProtocolsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Protocols/ProtocolsVector.java index b9667049f6..7f09670d5a 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Protocols/ProtocolsVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Protocols/ProtocolsVector.java @@ -50,7 +50,7 @@ public class ProtocolsVector { vProtocols.addElement(arg0);
}
- public void updateProtocols(ProtocolsIdentification arg0, int arg1) {
+ public void setProtocols(ProtocolsIdentification arg0, int arg1) {
vProtocols.setElementAt(arg0, arg1);
}
@@ -86,5 +86,12 @@ public class ProtocolsVector { public int size() {
return this.vProtocols.size();
}
-
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getProtocols(index).getName());
+ v.addElement(getProtocols(index).getType());
+ v.addElement(getProtocols(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesVector.java index 8dccb74627..3e6e98dac3 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesVector.java @@ -50,7 +50,7 @@ public class SourceFilesVector { vSourceFiles.addElement(sfi);
}
- public void updateSourceFiles(SourceFilesIdentification sfi, int index) {
+ public void setSourceFiles(SourceFilesIdentification sfi, int index) {
vSourceFiles.setElementAt(sfi, index);
}
@@ -86,4 +86,10 @@ public class SourceFilesVector { public int size() {
return this.vSourceFiles.size();
}
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getSourceFiles(index).getFilename());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SystemTables/SystemTablesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SystemTables/SystemTablesVector.java index 8babcd725f..fb875acfd5 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SystemTables/SystemTablesVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SystemTables/SystemTablesVector.java @@ -50,7 +50,7 @@ public class SystemTablesVector { vSystemTables.addElement(arg0);
}
- public void updateSystemTables(SystemTablesIdentification arg0, int arg1) {
+ public void setSystemTables(SystemTablesIdentification arg0, int arg1) {
vSystemTables.setElementAt(arg0, arg1);
}
@@ -86,5 +86,11 @@ public class SystemTablesVector { public int size() {
return this.vSystemTables.size();
}
-
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getSystemTables(index).getName());
+ v.addElement(getSystemTables(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Variables/VariablesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Variables/VariablesVector.java index 946545729f..6949eff7c3 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Variables/VariablesVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/Variables/VariablesVector.java @@ -50,7 +50,7 @@ public class VariablesVector { vVariables.addElement(arg0);
}
- public void updateVariables(VariablesIdentification arg0, int arg1) {
+ public void setVariables(VariablesIdentification arg0, int arg1) {
vVariables.setElementAt(arg0, arg1);
}
@@ -86,5 +86,12 @@ public class VariablesVector { public int size() {
return this.vVariables.size();
}
-
+
+ public Vector<String> toStringVector(int index) {
+ Vector<String> v = new Vector<String>();
+ v.addElement(getVariables(index).getName());
+ v.addElement(getVariables(index).getGuid());
+ v.addElement(getVariables(index).getUsage());
+ return v;
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleBootModes.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleBootModes.java index 978214645e..51fa6f8196 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleBootModes.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleBootModes.java @@ -15,18 +15,18 @@ package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.BootModeNames;
import org.tianocore.BootModeUsage;
@@ -35,16 +35,15 @@ import org.tianocore.BootModesDocument.BootModes; import org.tianocore.BootModesDocument.BootModes.BootMode;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.BootModes.BootModesIdentification;
import org.tianocore.frameworkwizard.module.Identifications.BootModes.BootModesVector;
+import org.tianocore.frameworkwizard.module.ui.dialog.BootModesDlg;
/**
The class is used to create, update BootModes of MSA/MBD file
@@ -65,28 +64,6 @@ public class ModuleBootModes extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelBootModeName = null;
-
- private JComboBox jComboBoxBootModeName = null;
-
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelArch = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -95,21 +72,13 @@ public class ModuleBootModes extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
+ private JScrollPane jScrollPaneTable = null;
- private JScrollPane jScrollPaneArch = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -120,68 +89,9 @@ public class ModuleBootModes extends IInternalFrame { private BootModesVector vid = new BootModesVector();
- private EnumerationData ed = new EnumerationData();
-
- /**
- This method initializes jComboBoxBootModeName
-
- @return javax.swing.JComboBox jComboBoxBootModeName
-
- **/
- private JComboBox getJComboBoxBootModeName() {
- if (jComboBoxBootModeName == null) {
- jComboBoxBootModeName = new JComboBox();
- jComboBoxBootModeName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jComboBoxBootModeName.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxBootModeName;
- }
-
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
-
- /**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
- }
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -228,28 +138,13 @@ public class ModuleBootModes extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -263,117 +158,91 @@ public class ModuleBootModes extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
+ This method initializes jScrollPaneTable
+
+ @return javax.swing.JScrollPane
+ **/
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jTextAreaList;
+ return jScrollPaneTable;
}
/**
- This method initializes iCheckBoxListArch
-
- @return ICheckBoxList
+ This method initializes jTable
+
+ @return javax.swing.JTable
**/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Name");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return iCheckBoxListArch;
+ return jTable;
}
- /**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
+ public static void main(String[] args) {
+ }
+ /**
+ This method initializes this
+
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
- }
- return jScrollPaneArch;
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Boot Modes");
}
-
+
/**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
-
- **/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldHelpText;
- }
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inBootModes
- public static void main(String[] args) {
+ **/
+ private void init(BootModes inBootModes) {
+ init();
+ this.bootModes = inBootModes;
+
+ if (this.bootModes != null) {
+ if (this.bootModes.getBootModeList().size() > 0) {
+ for (int index = 0; index < this.bootModes.getBootModeList().size(); index++) {
+ String arg0 = null;
+ if (bootModes.getBootModeList().get(index).getBootModeName() != null) {
+ arg0 = bootModes.getBootModeList().get(index).getBootModeName().toString();
+ }
+ String arg1 = null;
+ if (bootModes.getBootModeList().get(index).getUsage() != null) {
+ arg1 = bootModes.getBootModeList().get(index).getUsage().toString();
+ }
+
+ String arg2 = bootModes.getBootModeList().get(index).getFeatureFlag();
+ Vector<String> arg3 = Tools.convertListToVector(bootModes.getBootModeList().get(index)
+ .getSupArchList());
+ String arg4 = bootModes.getBootModeList().get(index).getHelpText();
+
+ id = new BootModesIdentification(arg0, arg1, arg2, arg3, arg4);
+ vid.addBootModes(id);
+ }
+ }
+ }
+ showTable();
}
-
- /**
- This method initializes this
-
- **/
- private void init() {
- this.setSize(500, 515);
- this.setContentPane(getJScrollPane());
- this.setTitle("Boot Modes");
- initFrame();
- this.setViewMode(false);
- }
-
- /**
- This method initializes this
- Fill values to all fields if these values are not empty
-
- @param inPackageDependencies
-
- **/
- private void init(BootModes inBootModes) {
- init();
- this.bootModes = inBootModes;
-
- if (this.bootModes != null) {
- if (this.bootModes.getBootModeList().size() > 0) {
- for (int index = 0; index < this.bootModes.getBootModeList().size(); index++) {
- String arg0 = null;
- if (bootModes.getBootModeList().get(index).getBootModeName() != null) {
- arg0 = bootModes.getBootModeList().get(index).getBootModeName().toString();
- }
- String arg1 = null;
- if (bootModes.getBootModeList().get(index).getUsage() != null) {
- arg1 = bootModes.getBootModeList().get(index).getUsage().toString();
- }
-
- String arg2 = bootModes.getBootModeList().get(index).getFeatureFlag();
- Vector<String> arg3 = Tools.convertListToVector(bootModes.getBootModeList().get(index).getSupArchList());
- String arg4 = bootModes.getBootModeList().get(index).getHelpText();
-
- id = new BootModesIdentification(arg0, arg1, arg2, arg3, arg4);
- vid.addBootModes(id);
- }
- }
- }
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getBootModesName());
- reloadListArea();
- }
/**
This is the default constructor
@@ -398,20 +267,6 @@ public class ModuleBootModes extends IInternalFrame { init(msa.getBootModes());
this.setVisible(true);
}
-
-
- /**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jComboBoxBootModeName.setEnabled(!isView);
- this.jComboBoxUsage.setEnabled(!isView);
- }
- }
/**
This method initializes jContentPane
@@ -421,62 +276,62 @@ public class ModuleBootModes extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelArch.setText("Arch");
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelBootModeName = new JLabel();
- jLabelBootModeName.setText("Boot Mode Name");
- jLabelBootModeName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
- jLabelHelpText.setText("Help Text");
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
-
- jContentPane.add(jLabelBootModeName, null);
- jContentPane.add(getJComboBoxBootModeName(), null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(getJComboBoxUsage(), null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 10));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setLocation(new java.awt.Point(0, 35));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(jLabelArch, null);
-
- jContentPane.add(getJComboBoxList(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
+
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+ private void showEdit(int index) {
+ BootModesDlg dlg = new BootModesDlg(vid.getBootModes(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addBootModes(dlg.getId());
+ } else {
+ this.vid.setBootModes(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+
+ /**
+ Clear all table rows
+
+ **/
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
+
/**
- This method initializes BootModeName groups and Usage type
+ Read content of vector and put then into table
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxBootModeName, ed.getVBootModeNames());
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
-
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -487,45 +342,27 @@ public class ModuleBootModes extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
+ }
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeBootModes(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -551,7 +388,8 @@ public class ModuleBootModes extends IInternalFrame { if (!isEmpty(vid.getBootModes(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getBootModes(index).getFeatureFlag());
}
- if (vid.getBootModes(index).getSupArchList() != null && vid.getBootModes(index).getSupArchList().size() > 0) {
+ if (vid.getBootModes(index).getSupArchList() != null
+ && vid.getBootModes(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getBootModes(index).getSupArchList());
}
if (!isEmpty(vid.getBootModes(index).getHelp())) {
@@ -570,6 +408,36 @@ public class ModuleBootModes extends IInternalFrame { }
/* (non-Javadoc)
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
+ */
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
+ return;
+ }
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
+ return;
+ } else {
+ selectedRow = lsm.getMinSelectionIndex();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
@@ -580,180 +448,12 @@ public class ModuleBootModes extends IInternalFrame { int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
- resizeComponentWidth(jComboBoxBootModeName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
-
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- }
-
- private BootModesIdentification getCurrentBootModes() {
- String arg0 = this.jComboBoxBootModeName.getSelectedItem().toString();
-
- String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg2 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg4 = this.jTextFieldHelpText.getText();
- id = new BootModesIdentification(arg0, arg1, arg2, arg3, arg4);
- return id;
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addBootModes(getCurrentBootModes());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeBootModes(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateBootModes(getCurrentBootModes(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getBootModes(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jComboBoxBootModeName.setSelectedItem(vid.getBootModes(intSelectedItemId).getName());
- this.jComboBoxUsage.setSelectedItem(vid.getBootModes(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getBootModes(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getBootModes(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getBootModes(intSelectedItemId).getSupArchList());
-
- } else {
- }
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getBootModes(index).getName() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
- *
- */
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDataHubs.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDataHubs.java index cf342d24c4..753b7e8eab 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDataHubs.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDataHubs.java @@ -15,18 +15,18 @@ package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.DataHubUsage;
import org.tianocore.DataHubsDocument;
@@ -34,16 +34,15 @@ import org.tianocore.DataHubsDocument.DataHubs; import org.tianocore.DataHubsDocument.DataHubs.DataHubRecord;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.DataHubs.DataHubsIdentification;
import org.tianocore.frameworkwizard.module.Identifications.DataHubs.DataHubsVector;
+import org.tianocore.frameworkwizard.module.ui.dialog.DataHubsDlg;
/**
The class is used to create, update DataHub of MSA/MBD file
@@ -64,28 +63,6 @@ public class ModuleDataHubs extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private JLabel jLabelDataHubRecord = null;
-
- private JTextField jTextFieldDataHubRecord = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelArch = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -94,21 +71,13 @@ public class ModuleDataHubs extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
+ private JScrollPane jScrollPaneTable = null;
- private JScrollPane jScrollPaneArch = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -119,69 +88,9 @@ public class ModuleDataHubs extends IInternalFrame { private DataHubsVector vid = new DataHubsVector();
- private EnumerationData ed = new EnumerationData();
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
-
- /**
- This method initializes jTextFieldDataHubRecord
-
- @return javax.swing.JTextField jTextFieldDataHubRecord
-
- **/
- private JTextField getJTextFieldDataHubRecord() {
- if (jTextFieldDataHubRecord == null) {
- jTextFieldDataHubRecord = new JTextField();
- jTextFieldDataHubRecord.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jTextFieldDataHubRecord.setPreferredSize(new java.awt.Dimension(320, 20));
- jTextFieldDataHubRecord.setToolTipText("Enter the C Name of the Data Hub Record");
- }
- return jTextFieldDataHubRecord;
- }
-
- /**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -228,28 +137,13 @@ public class ModuleDataHubs extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -263,62 +157,41 @@ public class ModuleDataHubs extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
- }
- return jTextAreaList;
- }
-
- /**
- This method initializes iCheckBoxListArch
-
- @return ICheckBoxList
- **/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
- }
- return iCheckBoxListArch;
- }
-
- /**
- This method initializes jScrollPaneArch
-
+ This method initializes jScrollPaneTable
+
@return javax.swing.JScrollPane
-
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jScrollPaneArch;
+ return jScrollPaneTable;
}
/**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
+ This method initializes jTable
+ @return javax.swing.JTable
**/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Data Hub C_Name");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jTextFieldHelpText;
+ return jTable;
}
public static void main(String[] args) {
@@ -333,8 +206,6 @@ public class ModuleDataHubs extends IInternalFrame { this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Data Hubs");
- initFrame();
- this.setViewMode(false);
}
/**
@@ -354,24 +225,20 @@ public class ModuleDataHubs extends IInternalFrame { String arg0 = dataHubs.getDataHubRecordList().get(index).getDataHubCName();
String arg1 = null;
if (dataHubs.getDataHubRecordList().get(index).getUsage() != null) {
- arg1 = dataHubs.getDataHubRecordList().get(index).getUsage().toString();
+ arg1 = dataHubs.getDataHubRecordList().get(index).getUsage().toString();
}
-
+
String arg2 = dataHubs.getDataHubRecordList().get(index).getFeatureFlag();
Vector<String> arg3 = Tools.convertListToVector(dataHubs.getDataHubRecordList().get(index)
.getSupArchList());
String arg4 = dataHubs.getDataHubRecordList().get(index).getHelpText();
-
+
id = new DataHubsIdentification(arg0, arg1, arg2, arg3, arg4);
vid.addDataHubs(id);
}
}
}
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getDataHubsName());
- reloadListArea();
+ showTable();
}
/**
@@ -399,19 +266,6 @@ public class ModuleDataHubs extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jTextFieldDataHubRecord.setEnabled(!isView);
- this.jComboBoxUsage.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -419,62 +273,62 @@ public class ModuleDataHubs extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelDataHubRecord = new JLabel();
- jLabelDataHubRecord.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelDataHubRecord.setText("Data Hub Record");
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelArch.setText("Arch");
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
- jLabelHelpText.setText("Help Text");
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
-
- jContentPane.add(jLabelDataHubRecord, null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(jLabelArch, null);
-
- jContentPane.add(getJTextFieldDataHubRecord(), null);
- jContentPane.add(getJComboBoxUsage(), null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
-
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 10));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setLocation(new java.awt.Point(0, 35));
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
-
- jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+ private void showEdit(int index) {
+ DataHubsDlg dlg = new DataHubsDlg(vid.getDataHubs(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addDataHubs(dlg.getId());
+ } else {
+ this.vid.setDataHubs(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+
/**
- This method initializes Usage type
+ Clear all table rows
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVDataHubUsage());
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
+
+ /**
+ Read content of vector and put then into table
+
+ **/
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -485,60 +339,27 @@ public class ModuleDataHubs extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
- }
- }
-
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check DataHubRecord
- //
- if (isEmpty(this.jTextFieldDataHubRecord.getText())) {
- Log.err("Data Hub Record couldn't be empty");
- return false;
+ showEdit(selectedRow);
}
- if (!isEmpty(this.jTextFieldDataHubRecord.getText())) {
- if (!DataValidation.isC_NameType(this.jTextFieldDataHubRecord.getText())) {
- Log.err("Incorrect data type for Data Hub Record");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeDataHubs(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -584,190 +405,52 @@ public class ModuleDataHubs extends IInternalFrame { }
/* (non-Javadoc)
- * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
- *
- * Override componentResized to resize all components when frame's size is changed
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
*/
- public void componentResized(ComponentEvent arg0) {
- int intCurrentWidth = this.getJContentPane().getWidth();
- int intCurrentHeight = this.getJContentPane().getHeight();
- int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
- int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
-
- resizeComponentWidth(jTextFieldDataHubRecord, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
-
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- }
-
- private DataHubsIdentification getCurrentDataHubs() {
- String arg0 = this.jTextFieldDataHubRecord.getText();
- String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg2 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg4 = this.jTextFieldHelpText.getText();
-
- id = new DataHubsIdentification(arg0, arg1, arg2, arg3, arg4);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addDataHubs(getCurrentDataHubs());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
return;
}
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeDataHubs(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateDataHubs(getCurrentDataHubs(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getDataHubs(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jTextFieldDataHubRecord.setText(vid.getDataHubs(intSelectedItemId).getName());
- this.jComboBoxUsage.setSelectedItem(vid.getDataHubs(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getDataHubs(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getDataHubs(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getDataHubs(intSelectedItemId).getSupArchList());
-
} else {
+ selectedRow = lsm.getMinSelectionIndex();
}
-
- reloadListArea();
}
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getDataHubs(index).getName() + DataType.UNIX_LINE_SEPARATOR;
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
}
- this.jTextAreaList.setText(strListItem);
}
/* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
+ * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
+ * Override componentResized to resize all components when frame's size is changed
*/
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
+ public void componentResized(ComponentEvent arg0) {
+ int intCurrentWidth = this.getJContentPane().getWidth();
+ int intCurrentHeight = this.getJContentPane().getHeight();
+ int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
+ int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
+
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleEvents.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleEvents.java index 26c8a62c36..676b7acc4e 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleEvents.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleEvents.java @@ -14,18 +14,18 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.EventsDocument;
import org.tianocore.ProtocolNotifyUsage;
@@ -35,17 +35,16 @@ import org.tianocore.EventsDocument.Events.CreateEvents; import org.tianocore.EventsDocument.Events.SignalEvents;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.Events.EventsIdentification;
import org.tianocore.frameworkwizard.module.Identifications.Events.EventsVector;
-import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+import org.tianocore.frameworkwizard.module.ui.dialog.EventsDlg;
/**
The class is used to create, update Event of MSA/MBD file
@@ -66,26 +65,6 @@ public class ModuleEvents extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelEventType = null;
-
- private JLabel jLabelC_Name = null;
-
- private JComboBox jComboBoxGuidC_Name = null;
-
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private JComboBox jComboBoxEventsType = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -94,27 +73,13 @@ public class ModuleEvents extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
+ private JScrollPane jScrollPaneTable = null;
- private JLabel jLabelArch = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
-
- private JScrollPane jScrollPaneArch = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -126,71 +91,10 @@ public class ModuleEvents extends IInternalFrame { private EventsVector vid = new EventsVector();
private EnumerationData ed = new EnumerationData();
-
- private WorkspaceTools wt = new WorkspaceTools();
- /**
- This method initializes jTextFieldC_Name
-
- @return javax.swing.JTextField jTextFieldC_Name
-
- **/
- private JComboBox getJComboBoxGuidC_Name() {
- if (jComboBoxGuidC_Name == null) {
- jComboBoxGuidC_Name = new JComboBox();
- jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
- jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Event");
- }
- return jComboBoxGuidC_Name;
- }
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
-
- /**
- * This method initializes jComboBoxEventsType
- *
- * @return javax.swing.JComboBox
- */
- private JComboBox getJComboBoxEventsType() {
- if (jComboBoxEventsType == null) {
- jComboBoxEventsType = new JComboBox();
- jComboBoxEventsType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jComboBoxEventsType.setPreferredSize(new java.awt.Dimension(320, 20));
- jComboBoxEventsType.setToolTipText("Select Create event if the Module has an event that is waiting to be signaled. Select Signal if the Module will signal all events in an event group. Signal Event The events are named by GUID.");
- }
- return jComboBoxEventsType;
- }
-
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -237,28 +141,13 @@ public class ModuleEvents extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -272,151 +161,111 @@ public class ModuleEvents extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
+ This method initializes jScrollPaneTable
+
+ @return javax.swing.JScrollPane
+ **/
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jTextAreaList;
+ return jScrollPaneTable;
}
/**
- This method initializes iCheckBoxListArch
+ This method initializes jTable
- @return ICheckBoxList
+ @return javax.swing.JTable
**/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Guid C_Name");
+ model.addColumn("Type");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return iCheckBoxListArch;
+ return jTable;
+ }
+
+ public static void main(String[] args) {
+
}
/**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
+ This method initializes this
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
- }
- return jScrollPaneArch;
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Events");
}
/**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160,110,320,20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320,20));
- }
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
-
- **/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldHelpText;
- }
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inPackageDependencies
- public static void main(String[] args) {
+ **/
+ private void init(Events inEvents) {
+ init();
+ this.events = inEvents;
+
+ if (this.events != null) {
+ if (this.events.getCreateEvents() != null) {
+ if (this.events.getCreateEvents().getEventTypesList().size() > 0) {
+ for (int index = 0; index < this.events.getCreateEvents().getEventTypesList().size(); index++) {
+ String arg0 = events.getCreateEvents().getEventTypesList().get(index).getEventGuidCName();
+ String arg1 = ed.getVEventType().get(0);
+ String arg2 = null;
+ if (events.getCreateEvents().getEventTypesList().get(index).getUsage() != null) {
+ arg2 = events.getCreateEvents().getEventTypesList().get(index).getUsage().toString();
+ }
+
+ String arg3 = events.getCreateEvents().getEventTypesList().get(index).getFeatureFlag();
+ Vector<String> arg4 = Tools.convertListToVector(events.getCreateEvents().getEventTypesList()
+ .get(index).getSupArchList());
+ String arg5 = events.getCreateEvents().getEventTypesList().get(index).getHelpText();
+ id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ vid.addEvents(id);
+ }
+ }
+ }
+ if (this.events.getSignalEvents() != null) {
+ if (this.events.getSignalEvents().getEventTypesList().size() > 0) {
+ for (int index = 0; index < this.events.getSignalEvents().getEventTypesList().size(); index++) {
+ String arg0 = events.getSignalEvents().getEventTypesList().get(index).getEventGuidCName();
+ String arg1 = ed.getVEventType().get(1);
+ String arg2 = null;
+ if (events.getSignalEvents().getEventTypesList().get(index).getUsage() != null) {
+ arg2 = events.getSignalEvents().getEventTypesList().get(index).getUsage().toString();
+ }
+ String arg3 = events.getSignalEvents().getEventTypesList().get(index).getFeatureFlag();
+ Vector<String> arg4 = Tools.convertListToVector(events.getSignalEvents().getEventTypesList()
+ .get(index).getSupArchList());
+ String arg5 = events.getSignalEvents().getEventTypesList().get(index).getHelpText();
+ id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ vid.addEvents(id);
+ }
+ }
+ }
+ }
+ showTable();
}
-
- /**
- This method initializes this
-
- **/
- private void init() {
- this.setSize(500, 515);
- this.setContentPane(getJScrollPane());
- this.setTitle("Events");
- initFrame();
- this.setViewMode(false);
- }
-
- /**
- This method initializes this
- Fill values to all fields if these values are not empty
-
- @param inPackageDependencies
-
- **/
- private void init(Events inEvents) {
- init();
- this.events = inEvents;
-
- if (this.events != null) {
- if (this.events.getCreateEvents() != null) {
- if (this.events.getCreateEvents().getEventTypesList().size() > 0) {
- for (int index = 0; index < this.events.getCreateEvents().getEventTypesList().size(); index++) {
- String arg0 = events.getCreateEvents().getEventTypesList().get(index).getEventGuidCName();
- String arg1 = ed.getVEventType().get(0);
- String arg2 = null;
- if (events.getCreateEvents().getEventTypesList().get(index).getUsage() != null) {
- arg2 = events.getCreateEvents().getEventTypesList().get(index).getUsage().toString();
- }
-
- String arg3 = events.getCreateEvents().getEventTypesList().get(index).getFeatureFlag();
- Vector<String> arg4 = Tools.convertListToVector(events.getCreateEvents().getEventTypesList().get(index)
- .getSupArchList());
- String arg5 = events.getCreateEvents().getEventTypesList().get(index).getHelpText();
- id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- vid.addEvents(id);
- }
- }
- }
- if (this.events.getSignalEvents() != null) {
- if (this.events.getSignalEvents().getEventTypesList().size() > 0) {
- for (int index = 0; index < this.events.getSignalEvents().getEventTypesList().size(); index++) {
- String arg0 = events.getSignalEvents().getEventTypesList().get(index).getEventGuidCName();
- String arg1 = ed.getVEventType().get(1);
- String arg2 = null;
- if (events.getSignalEvents().getEventTypesList().get(index).getUsage() != null) {
- arg2 = events.getSignalEvents().getEventTypesList().get(index).getUsage().toString();
- }
-
- String arg3 = events.getSignalEvents().getEventTypesList().get(index).getFeatureFlag();
- Vector<String> arg4 = Tools.convertListToVector(events.getSignalEvents().getEventTypesList().get(index)
- .getSupArchList());
- String arg5 = events.getSignalEvents().getEventTypesList().get(index).getHelpText();
- id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- vid.addEvents(id);
- }
- }
- }
- }
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getEventsName());
- reloadListArea();
- }
/**
This is the default constructor
@@ -443,19 +292,6 @@ public class ModuleEvents extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jComboBoxGuidC_Name.setEnabled(!isView);
- this.jComboBoxUsage.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -463,68 +299,62 @@ public class ModuleEvents extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15,110,140,20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
- jLabelArch.setText("Arch");
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
- jLabelC_Name = new JLabel();
- jLabelC_Name.setText("Guid C_Name");
- jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelEventType = new JLabel();
- jLabelEventType.setText("Event Type");
- jLabelEventType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
- jLabelHelpText.setText("Help Text");
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
- jContentPane.add(jLabelEventType, null);
- jContentPane.add(jLabelC_Name, null);
- jContentPane.add(getJComboBoxGuidC_Name(), null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(getJComboBoxUsage(), null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
- jContentPane.add(getJComboBoxEventsType(), null);
-
- jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+
+ private void showEdit(int index) {
+ EventsDlg dlg = new EventsDlg(vid.getEvents(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addEvents(dlg.getId());
+ } else {
+ this.vid.setEvents(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
/**
- This method initializes events groups and usage type
+ Clear all table rows
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxEventsType, ed.getVEventType());
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVEventUsage());
- Tools.generateComboBoxByVector(jComboBoxGuidC_Name, wt.getAllGuidDeclarationsFromWorkspace());
-
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
+
+ /**
+ Read content of vector and put then into table
+
+ **/
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -535,60 +365,27 @@ public class ModuleEvents extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check Name
- //
- if (isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
- Log.err("Event Name couldn't be empty");
- return false;
- }
-
- if (!isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
- if (!DataValidation.isC_NameType(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
- Log.err("Incorrect data type for Event Name");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeEvents(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -604,7 +401,7 @@ public class ModuleEvents extends IInternalFrame { this.events = Events.Factory.newInstance();
CreateEvents ce = CreateEvents.Factory.newInstance();
SignalEvents se = SignalEvents.Factory.newInstance();
-
+
if (count > 0) {
for (int index = 0; index < count; index++) {
if (vid.getEvents(index).getType().equals(ed.getVEventType().get(0))) {
@@ -628,7 +425,7 @@ public class ModuleEvents extends IInternalFrame { ce.addNewEventTypes();
ce.setEventTypesArray(ce.getEventTypesList().size() - 1, e);
}
- if (vid.getEvents(index).getType().equals("Protocol Notify")) {
+ if (vid.getEvents(index).getType().equals(ed.getVEventType().get(1))) {
SignalEvents.EventTypes e = SignalEvents.EventTypes.Factory.newInstance();
if (!isEmpty(vid.getEvents(index).getName())) {
e.setEventGuidCName(vid.getEvents(index).getName());
@@ -668,191 +465,52 @@ public class ModuleEvents extends IInternalFrame { }
/* (non-Javadoc)
- * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
- *
- * Override componentResized to resize all components when frame's size is changed
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
*/
- public void componentResized(ComponentEvent arg0) {
- int intCurrentWidth = this.getJContentPane().getWidth();
- int intCurrentHeight = this.getJContentPane().getHeight();
- int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
- int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
-
- resizeComponentWidth(jComboBoxEventsType, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxGuidC_Name, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- }
-
- private EventsIdentification getCurrentEvents() {
- String arg0 = this.jComboBoxGuidC_Name.getSelectedItem().toString();
- String arg1 = this.jComboBoxEventsType.getSelectedItem().toString();
- String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg3 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg5 = this.jTextFieldHelpText.getText();
- id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addEvents(getCurrentEvents());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
return;
}
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeEvents(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateEvents(getCurrentEvents(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getEvents(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jComboBoxGuidC_Name.setSelectedItem(vid.getEvents(intSelectedItemId).getName());
- this.jComboBoxEventsType.setSelectedItem(vid.getEvents(intSelectedItemId).getType());
- this.jComboBoxUsage.setSelectedItem(vid.getEvents(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getEvents(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getEvents(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getEvents(intSelectedItemId).getSupArchList());
-
} else {
+ selectedRow = lsm.getMinSelectionIndex();
}
-
- reloadListArea();
}
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getEvents(index).getName() + DataType.UNIX_LINE_SEPARATOR;
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
}
- this.jTextAreaList.setText(strListItem);
}
/* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
+ * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
+ * Override componentResized to resize all components when frame's size is changed
*/
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
+ public void componentResized(ComponentEvent arg0) {
+ int intCurrentWidth = this.getJContentPane().getWidth();
+ int intCurrentHeight = this.getJContentPane().getHeight();
+ int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
+ int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
+
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleExterns.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleExterns.java index cfabd0aeb7..99a24302cd 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleExterns.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleExterns.java @@ -14,19 +14,19 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.ExternsDocument;
import org.tianocore.PcdDriverTypes;
@@ -34,15 +34,16 @@ import org.tianocore.ExternsDocument.Externs; import org.tianocore.ExternsDocument.Externs.Extern;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.Externs.ExternsIdentification;
import org.tianocore.frameworkwizard.module.Identifications.Externs.ExternsVector;
+import org.tianocore.frameworkwizard.module.ui.dialog.ExternsDlg;
/**
The class is used to create, update DataHub of MSA/MBD file
@@ -63,14 +64,6 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { //
private JPanel jContentPane = null;
- private JLabel jLabelName = null;
-
- private JComboBox jComboBoxType = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -79,31 +72,13 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private JLabel jLabelPcdIsDriver = null;
-
- private JComboBox jComboBoxPcdIsDriver = null;
-
- private JLabel jLabelC_Name = null;
-
- private JTextField jTextFieldC_Name = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JLabel jLabelArch = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
+ private JScrollPane jScrollPaneTable = null;
- private JScrollPane jScrollPaneArch = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -114,39 +89,9 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { private ExternsVector vid = new ExternsVector();
- private EnumerationData ed = new EnumerationData();
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxType
-
- @return javax.swing.JComboBox jComboBoxType
-
- **/
- private JComboBox getJComboBoxType() {
- if (jComboBoxType == null) {
- jComboBoxType = new JComboBox();
- jComboBoxType.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxType.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxType;
- }
-
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -193,28 +138,13 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -228,92 +158,41 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
- }
- return jTextAreaList;
- }
-
- /**
- * This method initializes jComboBoxPcdIsDriver
- *
- * @return javax.swing.JComboBox
- */
- private JComboBox getJComboBoxPcdIsDriver() {
- if (jComboBoxPcdIsDriver == null) {
- jComboBoxPcdIsDriver = new JComboBox();
- jComboBoxPcdIsDriver.setLocation(new java.awt.Point(160, 10));
- jComboBoxPcdIsDriver.setPreferredSize(new java.awt.Dimension(320, 20));
- jComboBoxPcdIsDriver.setSize(new java.awt.Dimension(320, 20));
- jComboBoxPcdIsDriver.addItemListener(this);
- }
- return jComboBoxPcdIsDriver;
- }
-
- /**
- This method initializes jTextFieldC_Name
-
- @return javax.swing.JTextField
+ This method initializes jScrollPaneTable
+ @return javax.swing.JScrollPane
**/
- private JTextField getJTextFieldC_Name() {
- if (jTextFieldC_Name == null) {
- jTextFieldC_Name = new JTextField();
- jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jTextFieldC_Name.setPreferredSize(new java.awt.Dimension(320,20));
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jTextFieldC_Name;
+ return jScrollPaneTable;
}
/**
- This method initializes jTextFieldFeatureFlag
-
- @return javax.swing.JTextField
+ This method initializes jTable
+ @return javax.swing.JTable
**/
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Name");
+ model.addColumn("Type");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes iCheckBoxListArch
-
- @return ICheckBoxList
- **/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
- }
- return iCheckBoxListArch;
- }
-
- /**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
-
- **/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
- }
- return jScrollPaneArch;
+ return jTable;
}
public static void main(String[] args) {
@@ -328,7 +207,6 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Externs");
- initFrame();
}
/**
@@ -347,9 +225,13 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { // Get PcdIsDriver
//
if (this.externs.getPcdIsDriver() != null) {
- this.jComboBoxPcdIsDriver.setSelectedItem(this.externs.getPcdIsDriver().toString());
+ String arg0 = this.externs.getPcdIsDriver().toString();
+ String arg1 = EnumerationData.EXTERNS_PCD_IS_DRIVER;
+
+ id = new ExternsIdentification(arg0, arg1, null, null);
+ vid.addExterns(id);
}
-
+
//
// Get specification
//
@@ -423,11 +305,7 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { }
}
}
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getExternsName());
- reloadListArea();
+ showTable();
}
/**
@@ -462,54 +340,62 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelC_Name = new JLabel();
- jLabelC_Name.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
- jLabelC_Name.setText("Value");
- jLabelPcdIsDriver = new JLabel();
- jLabelPcdIsDriver.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelPcdIsDriver.setText("Pcd Is Driver");
- jLabelName = new JLabel();
- jLabelName.setText("Choose Type");
- jLabelName.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelArch.setText("Arch");
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
-
- jContentPane.add(jLabelName, null);
- jContentPane.add(getJComboBoxType(), null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(getJScrollPaneArch(), null);
-
- jContentPane.add(getJComboBoxList(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
+
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(jLabelPcdIsDriver, null);
- jContentPane.add(getJComboBoxPcdIsDriver(), null);
- jContentPane.add(jLabelC_Name, null);
- jContentPane.add(getJTextFieldC_Name(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+ private void showEdit(int index) {
+ ExternsDlg dlg = new ExternsDlg(vid.getExterns(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addExterns(dlg.getId());
+ } else {
+ this.vid.setExterns(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+
+ /**
+ Clear all table rows
+
+ **/
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
+
/**
- This method initializes Usage type and Externs type
+ Read content of vector and put then into table
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(this.jComboBoxType, ed.getVExternTypes());
- Tools.generateComboBoxByVector(this.jComboBoxPcdIsDriver, ed.getVPcdDriverTypes());
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -520,67 +406,27 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check CName
- //
- if (isEmpty(this.jTextFieldC_Name.getText())) {
- Log.err("Value couldn't be empty");
- return false;
- }
-
- if (!isEmpty(this.jTextFieldC_Name.getText())) {
- if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_SPECIFICATION)) {
- if (!DataValidation.isSentence(this.jTextFieldC_Name.getText())) {
- Log.err("Incorrect data type for Specification");
- return false;
- }
- } else {
- if (!DataValidation.isC_NameType(this.jTextFieldC_Name.getText())) {
- Log.err("Incorrect data type for C_Name");
- return false;
- }
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeExterns(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -594,17 +440,25 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { int count = this.vid.size();
this.externs = Externs.Factory.newInstance();
- //
- // Save PcdIsDriver first
- //
- if (!this.jComboBoxPcdIsDriver.getSelectedItem().toString().equals(DataType.EMPTY_SELECT_ITEM)) {
- externs.setPcdIsDriver(PcdDriverTypes.Enum.forString(this.jComboBoxPcdIsDriver.getSelectedItem()
- .toString()));
- }
+ // //
+ // // Save PcdIsDriver first
+ // //
+ // if (!this.jComboBoxPcdIsDriver.getSelectedItem().toString().equals(DataType.EMPTY_SELECT_ITEM)) {
+ // externs.setPcdIsDriver(PcdDriverTypes.Enum.forString(this.jComboBoxPcdIsDriver.getSelectedItem()
+ // .toString()));
+ // }
if (count > 0) {
for (int index = 0; index < count; index++) {
//
+ // Save Pcd Is Driver
+ //
+ if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_PCD_IS_DRIVER)) {
+ externs.setPcdIsDriver(PcdDriverTypes.Enum.forString(vid.getExterns(index).getName()));
+ continue;
+ }
+
+ //
// Save specfication
//
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_SPECIFICATION)) {
@@ -697,198 +551,52 @@ public class ModuleExterns extends IInternalFrame implements ItemListener { }
/* (non-Javadoc)
- * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
- *
- * Override componentResized to resize all components when frame's size is changed
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
*/
- public void componentResized(ComponentEvent arg0) {
- int intCurrentWidth = this.getJContentPane().getWidth();
- int intCurrentHeight = this.getJContentPane().getHeight();
- int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
- int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
-
- resizeComponentWidth(this.jComboBoxPcdIsDriver, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jComboBoxType, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldC_Name, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
-
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- }
-
- private ExternsIdentification getCurrentExterns() {
- String arg0 = this.jTextFieldC_Name.getText();
- String arg1 = this.jComboBoxType.getSelectedItem().toString();
-
- String arg2 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
-
- id = new ExternsIdentification(arg0, arg1, arg2, arg3);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addExterns(getCurrentExterns());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
return;
}
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeExterns(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateExterns(getCurrentExterns(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getExterns(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jTextFieldC_Name.setText(vid.getExterns(intSelectedItemId).getName());
- this.jComboBoxType.setSelectedItem(vid.getExterns(intSelectedItemId).getType());
-
- jTextFieldFeatureFlag.setText(vid.getExterns(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getExterns(intSelectedItemId).getSupArchList());
-
} else {
+ selectedRow = lsm.getMinSelectionIndex();
}
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getExterns(index).getName() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
}
/* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*
- * Reflesh the frame when selected item changed
- *
*/
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- if (arg0.getSource() == this.jComboBoxPcdIsDriver && arg0.getStateChange() == ItemEvent.SELECTED && externs != null) {
- String s = this.jComboBoxPcdIsDriver.getSelectedItem().toString();
- if (s.equals(DataType.EMPTY_SELECT_ITEM)) {
- this.externs.setPcdIsDriver(null);
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
} else {
- this.externs.setPcdIsDriver(PcdDriverTypes.Enum.forString(s));
+ showEdit(selectedRow);
}
- this.msa.setExterns(externs);
- this.omt.setSaved(false);
}
}
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
+ *
+ * Override componentResized to resize all components when frame's size is changed
+ */
+ public void componentResized(ComponentEvent arg0) {
+ int intCurrentWidth = this.getJContentPane().getWidth();
+ int intCurrentHeight = this.getJContentPane().getHeight();
+ int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
+ int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
+
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleGuids.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleGuids.java index 35ac3f5278..6c0c4114db 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleGuids.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleGuids.java @@ -14,18 +14,18 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.GuidUsage;
import org.tianocore.GuidsDocument;
@@ -33,24 +33,20 @@ import org.tianocore.GuidsDocument.Guids; import org.tianocore.GuidsDocument.Guids.GuidCNames;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.Guids.GuidsIdentification;
import org.tianocore.frameworkwizard.module.Identifications.Guids.GuidsVector;
-import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+import org.tianocore.frameworkwizard.module.ui.dialog.GuidsDlg;
/**
The class is used to create, update Guids of MSA/MBD file
It extends IInternalFrame
-
-
**/
public class ModuleGuids extends IInternalFrame {
@@ -64,28 +60,6 @@ public class ModuleGuids extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelC_Name = null;
-
- private JComboBox jComboBoxCName = null;
-
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelArch = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -94,21 +68,13 @@ public class ModuleGuids extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
-
- private JScrollPane jScrollPaneArch = null;
+ private JScrollPane jScrollPaneTable = null;
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -119,71 +85,9 @@ public class ModuleGuids extends IInternalFrame { private GuidsVector vid = new GuidsVector();
- private EnumerationData ed = new EnumerationData();
-
- private WorkspaceTools wt = new WorkspaceTools();
-
- /**
- This method initializes jTextFieldC_Name
-
- @return javax.swing.JTextField jTextFieldC_Name
-
- **/
- private JComboBox getJComboBoxCName() {
- if (jComboBoxCName == null) {
- jComboBoxCName = new JComboBox();
- jComboBoxCName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxCName;
- }
-
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
+ private IDefaultTableModel model = null;
- /**
- This method initializes jTextFieldFeatureFlag
-
- @return javax.swing.JTextField
-
- **/
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -230,28 +134,13 @@ public class ModuleGuids extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -265,62 +154,41 @@ public class ModuleGuids extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
- }
- return jTextAreaList;
- }
-
- /**
- This method initializes iCheckBoxListArch
-
- @return ICheckBoxList
- **/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
- }
- return iCheckBoxListArch;
- }
-
- /**
- This method initializes jScrollPaneArch
-
+ This method initializes jScrollPaneTable
+
@return javax.swing.JScrollPane
-
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jScrollPaneArch;
+ return jScrollPaneTable;
}
/**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
+ This method initializes jTable
+ @return javax.swing.JTable
**/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Guid C_Name");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jTextFieldHelpText;
+ return jTable;
}
public static void main(String[] args) {
@@ -335,8 +203,6 @@ public class ModuleGuids extends IInternalFrame { this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Guids");
- initFrame();
- this.setViewMode(false);
}
/**
@@ -356,7 +222,7 @@ public class ModuleGuids extends IInternalFrame { String arg0 = guids.getGuidCNamesList().get(index).getGuidCName();
String arg1 = null;
if (guids.getGuidCNamesList().get(index).getUsage() != null) {
- arg1 = guids.getGuidCNamesList().get(index).getUsage().toString();
+ arg1 = guids.getGuidCNamesList().get(index).getUsage().toString();
}
String arg2 = guids.getGuidCNamesList().get(index).getFeatureFlag();
@@ -369,11 +235,7 @@ public class ModuleGuids extends IInternalFrame { }
}
}
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getGuidsName());
- reloadListArea();
+ showTable();
}
/**
@@ -401,18 +263,6 @@ public class ModuleGuids extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jComboBoxUsage.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -420,65 +270,62 @@ public class ModuleGuids extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelC_Name = new JLabel();
- jLabelC_Name.setText("C_Name");
- jLabelC_Name.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelArch.setText("Arch");
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
- jLabelHelpText.setText("Help Text");
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
-
- jContentPane.add(jLabelC_Name, null);
- jContentPane.add(getJComboBoxCName(), null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(getJComboBoxUsage(), null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 10));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setLocation(new java.awt.Point(0, 35));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
-
- jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
+ }
+ return jContentPane;
+ }
- initFrame();
+ private void showEdit(int index) {
+ GuidsDlg dlg = new GuidsDlg(vid.getGuids(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addGuids(dlg.getId());
+ } else {
+ this.vid.setGuids(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+ /**
+ Clear all table rows
+
+ **/
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
}
- return jContentPane;
}
/**
- This method initializes Usage type
+ Read content of vector and put then into table
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllGuidDeclarationsFromWorkspace());
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVGuidUsage());
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -489,55 +336,27 @@ public class ModuleGuids extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check Name
- //
- if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
- if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
- Log.err("Incorrect data type for Guid Name");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeGuids(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -582,190 +401,52 @@ public class ModuleGuids extends IInternalFrame { }
/* (non-Javadoc)
- * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
- *
- * Override componentResized to resize all components when frame's size is changed
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
*/
- public void componentResized(ComponentEvent arg0) {
- int intCurrentWidth = this.getJContentPane().getWidth();
- int intCurrentHeight = this.getJContentPane().getHeight();
- int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
- int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
-
- resizeComponentWidth(jComboBoxCName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
-
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- }
-
- private GuidsIdentification getCurrentGuids() {
- String arg0 = this.jComboBoxCName.getSelectedItem().toString();
- String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg2 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg4 = this.jTextFieldHelpText.getText();
-
- id = new GuidsIdentification(arg0, arg1, arg2, arg3, arg4);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addGuids(getCurrentGuids());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
return;
}
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeGuids(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateGuids(getCurrentGuids(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getGuids(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jComboBoxCName.setSelectedItem(vid.getGuids(intSelectedItemId).getName());
- this.jComboBoxUsage.setSelectedItem(vid.getGuids(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getGuids(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getGuids(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getGuids(intSelectedItemId).getSupArchList());
-
} else {
+ selectedRow = lsm.getMinSelectionIndex();
}
-
- reloadListArea();
}
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getGuids(index).getName() + DataType.UNIX_LINE_SEPARATOR;
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
}
- this.jTextAreaList.setText(strListItem);
}
/* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
+ * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
+ * Override componentResized to resize all components when frame's size is changed
*/
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
+ public void componentResized(ComponentEvent arg0) {
+ int intCurrentWidth = this.getJContentPane().getWidth();
+ int intCurrentHeight = this.getJContentPane().getHeight();
+ int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
+ int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
+
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHiiPackages.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHiiPackages.java index aefeba500f..884879e177 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHiiPackages.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHiiPackages.java @@ -14,18 +14,18 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.HiiPackageUsage;
import org.tianocore.HiiPackagesDocument;
@@ -33,22 +33,19 @@ import org.tianocore.HiiPackagesDocument.HiiPackages; import org.tianocore.HiiPackagesDocument.HiiPackages.HiiPackage;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.HiiPackages.HiiPackagesIdentification;
import org.tianocore.frameworkwizard.module.Identifications.HiiPackages.HiiPackagesVector;
+import org.tianocore.frameworkwizard.module.ui.dialog.HiiPackagesDlg;
/**
The class is used to create, update Formset of MSA/MBD file
It extends IInternalFrame
-
-
**/
public class ModuleHiiPackages extends IInternalFrame {
@@ -63,28 +60,6 @@ public class ModuleHiiPackages extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelName = null;
-
- private JTextField jTextFieldName = null;
-
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelArch = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -93,21 +68,13 @@ public class ModuleHiiPackages extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
-
- private JScrollPane jScrollPaneArch = null;
+ private JScrollPane jScrollPaneTable = null;
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -118,69 +85,9 @@ public class ModuleHiiPackages extends IInternalFrame { private HiiPackagesVector vid = new HiiPackagesVector();
- private EnumerationData ed = new EnumerationData();
-
- /**
- This method initializes jTextFieldName
-
- @return javax.swing.JTextField jTextFieldName
-
- **/
- private JTextField getJTextFieldName() {
- if (jTextFieldName == null) {
- jTextFieldName = new JTextField();
- jTextFieldName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jTextFieldName.setPreferredSize(new java.awt.Dimension(320, 20));
- jTextFieldName.setToolTipText("Enter the C Name of the HII Package");
- }
- return jTextFieldName;
- }
-
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
+ private IDefaultTableModel model = null;
- /**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -227,28 +134,13 @@ public class ModuleHiiPackages extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -262,62 +154,41 @@ public class ModuleHiiPackages extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
- }
- return jTextAreaList;
- }
-
- /**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
+ This method initializes jScrollPaneTable
+ @return javax.swing.JScrollPane
**/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldHelpText;
- }
-
- /**
- This method initializes iCheckBoxListArch
-
- @return ICheckBoxList
- **/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return iCheckBoxListArch;
+ return jScrollPaneTable;
}
/**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
-
+ This method initializes jTable
+
+ @return javax.swing.JTable
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Hii Package C_Name");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jScrollPaneArch;
+ return jTable;
}
public static void main(String[] args) {
@@ -332,8 +203,6 @@ public class ModuleHiiPackages extends IInternalFrame { this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Hii Packages");
- initFrame();
- this.setViewMode(false);
}
/**
@@ -353,24 +222,20 @@ public class ModuleHiiPackages extends IInternalFrame { String arg0 = hiiPackages.getHiiPackageList().get(index).getHiiCName();
String arg1 = null;
if (hiiPackages.getHiiPackageList().get(index).getUsage() != null) {
- arg1 = hiiPackages.getHiiPackageList().get(index).getUsage().toString();
+ arg1 = hiiPackages.getHiiPackageList().get(index).getUsage().toString();
}
String arg2 = hiiPackages.getHiiPackageList().get(index).getFeatureFlag();
Vector<String> arg3 = Tools.convertListToVector(hiiPackages.getHiiPackageList().get(index)
.getSupArchList());
String arg4 = hiiPackages.getHiiPackageList().get(index).getHelpText();
-
+
id = new HiiPackagesIdentification(arg0, arg1, arg2, arg3, arg4);
vid.addHiiPackages(id);
}
}
}
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getHiiPackagesName());
- reloadListArea();
+ showTable();
}
/**
@@ -401,19 +266,6 @@ public class ModuleHiiPackages extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jTextFieldName.setEnabled(!isView);
- this.jComboBoxUsage.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -421,62 +273,62 @@ public class ModuleHiiPackages extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelName = new JLabel();
- jLabelName.setText("Name");
- jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelArch.setText("Arch");
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
- jLabelHelpText.setText("Help Text");
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
-
- jContentPane.add(jLabelName, null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(getJTextFieldName(), null);
- jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
-
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 10));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setLocation(new java.awt.Point(0, 35));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
-
- jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+ private void showEdit(int index) {
+ HiiPackagesDlg dlg = new HiiPackagesDlg(vid.getHiiPackages(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addHiiPackages(dlg.getId());
+ } else {
+ this.vid.setHiiPackages(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+
/**
- This method initializes Usage type
+ Clear all table rows
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVHiiPackageUsage());
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
+
+ /**
+ Read content of vector and put then into table
+
+ **/
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -487,60 +339,27 @@ public class ModuleHiiPackages extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check Hii Package Name
- //
- if (isEmpty(this.jTextFieldName.getText())) {
- Log.err("Hii Package Name Record couldn't be empty");
- return false;
- }
-
- if (!isEmpty(this.jTextFieldName.getText())) {
- if (!DataValidation.isC_NameType(this.jTextFieldName.getText())) {
- Log.err("Incorrect data type for Hii Package Name");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeHiiPackages(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -586,190 +405,52 @@ public class ModuleHiiPackages extends IInternalFrame { }
/* (non-Javadoc)
- * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
- *
- * Override componentResized to resize all components when frame's size is changed
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
*/
- public void componentResized(ComponentEvent arg0) {
- int intCurrentWidth = this.getJContentPane().getWidth();
- int intCurrentHeight = this.getJContentPane().getHeight();
- int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
- int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
-
- resizeComponentWidth(jTextFieldName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
-
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- }
-
- private HiiPackagesIdentification getCurrentHiiPackages() {
- String arg0 = this.jTextFieldName.getText();
- String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg2 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg4 = this.jTextFieldHelpText.getText();
-
- id = new HiiPackagesIdentification(arg0, arg1, arg2, arg3, arg4);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addHiiPackages(getCurrentHiiPackages());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
return;
}
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeHiiPackages(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateHiiPackages(getCurrentHiiPackages(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getHiiPackages(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jTextFieldName.setText(vid.getHiiPackages(intSelectedItemId).getName());
- this.jComboBoxUsage.setSelectedItem(vid.getHiiPackages(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getHiiPackages(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getHiiPackages(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getHiiPackages(intSelectedItemId).getSupArchList());
-
} else {
+ selectedRow = lsm.getMinSelectionIndex();
}
-
- reloadListArea();
}
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getHiiPackages(index).getName() + DataType.UNIX_LINE_SEPARATOR;
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
}
- this.jTextAreaList.setText(strListItem);
}
/* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
+ * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
+ * Override componentResized to resize all components when frame's size is changed
*/
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
+ public void componentResized(ComponentEvent arg0) {
+ int intCurrentWidth = this.getJContentPane().getWidth();
+ int intCurrentHeight = this.getJContentPane().getHeight();
+ int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
+ int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
+
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHobs.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHobs.java index 7bbf1190b7..8b11f081d8 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHobs.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHobs.java @@ -14,18 +14,18 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.HobTypes;
import org.tianocore.HobUsage;
@@ -33,17 +33,15 @@ import org.tianocore.HobsDocument; import org.tianocore.HobsDocument.Hobs;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.Hobs.HobsIdentification;
import org.tianocore.frameworkwizard.module.Identifications.Hobs.HobsVector;
-import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+import org.tianocore.frameworkwizard.module.ui.dialog.HobsDlg;
/**
The class is used to create, update Hob of MSA/MBD file
@@ -64,26 +62,6 @@ public class ModuleHobs extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabel = null;
-
- private JComboBox jComboBoxGuidC_Name = null;
-
- private JLabel jLabelUsage = null;
-
- private JLabel jLabelHobType = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private JComboBox jComboBoxHobType = null;
-
- private StarLabel jStarLabel1 = null;
-
- private JLabel jLabelArch = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -92,25 +70,13 @@ public class ModuleHobs extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
+ private JScrollPane jScrollPaneTable = null;
- private ICheckBoxList iCheckBoxListArch = null;
-
- private JScrollPane jScrollPaneArch = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -121,72 +87,9 @@ public class ModuleHobs extends IInternalFrame { private HobsVector vid = new HobsVector();
- private EnumerationData ed = new EnumerationData();
-
- private WorkspaceTools wt = new WorkspaceTools();
-
- /**
- This method initializes jTextField
-
- @return javax.swing.JTextField jTextFieldC_Name
-
- **/
- private JComboBox getJComboBoxGuidC_Name() {
- if (jComboBoxGuidC_Name == null) {
- jComboBoxGuidC_Name = new JComboBox();
- jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
- jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Hob");
- }
- return jComboBoxGuidC_Name;
- }
-
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
-
- /**
- This method initializes jComboBoxHobType
-
- @return javax.swing.JComboBox jComboBoxHobType
-
- **/
- private JComboBox getJComboBoxHobType() {
- if (jComboBoxHobType == null) {
- jComboBoxHobType = new JComboBox();
- jComboBoxHobType.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxHobType.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxHobType;
- }
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -233,28 +136,13 @@ public class ModuleHobs extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -268,77 +156,43 @@ public class ModuleHobs extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
- }
- return jTextAreaList;
- }
-
- /**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes iCheckBoxListArch
-
- @return ICheckBoxList
+ This method initializes jScrollPaneTable
+
+ @return javax.swing.JScrollPane
**/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return iCheckBoxListArch;
+ return jScrollPaneTable;
}
/**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
-
+ This method initializes jTable
+
+ @return javax.swing.JTable
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Guid C_Name");
+ model.addColumn("Type");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jScrollPaneArch;
+ return jTable;
}
-
- /**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
-
- **/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldHelpText;
- }
public static void main(String[] args) {
@@ -352,8 +206,6 @@ public class ModuleHobs extends IInternalFrame { this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Hobs");
- initFrame();
- this.setViewMode(false);
}
/**
@@ -373,13 +225,13 @@ public class ModuleHobs extends IInternalFrame { String arg0 = hobs.getHobTypesList().get(index).getHobGuidCName();
String arg1 = null;
if (hobs.getHobTypesList().get(index).getHobType() != null) {
- arg1 = hobs.getHobTypesList().get(index).getHobType().toString();
+ arg1 = hobs.getHobTypesList().get(index).getHobType().toString();
}
String arg2 = null;
if (hobs.getHobTypesList().get(index).getUsage() != null) {
- arg2 = hobs.getHobTypesList().get(index).getUsage().toString();
+ arg2 = hobs.getHobTypesList().get(index).getUsage().toString();
}
-
+
String arg3 = hobs.getHobTypesList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(hobs.getHobTypesList().get(index).getSupArchList());
String arg5 = hobs.getHobTypesList().get(index).getHelpText();
@@ -388,11 +240,7 @@ public class ModuleHobs extends IInternalFrame { }
}
}
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getHobsName());
- reloadListArea();
+ showTable();
}
/**
@@ -420,20 +268,6 @@ public class ModuleHobs extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jComboBoxGuidC_Name.setEnabled(!isView);
- this.jComboBoxUsage.setEnabled(!isView);
- this.jComboBoxHobType.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -441,65 +275,63 @@ public class ModuleHobs extends IInternalFrame { **/
public JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
- jLabelArch.setText("Arch");
- jLabelHobType = new JLabel();
- jLabelHobType.setText("Hob Type");
- jLabelHobType.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
- jLabel = new JLabel();
- jLabel.setText("C_Name");
- jLabel.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
- jLabelHelpText.setText("Help Text");
-
+
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));
-
- jContentPane.add(jLabel, null);
- jContentPane.add(getJComboBoxGuidC_Name(), null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(jLabelHobType, null);
- jContentPane.add(getJComboBoxUsage(), null);
- jContentPane.add(getJComboBoxHobType(), null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 10));
- jContentPane.add(jStarLabel1, null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
- jContentPane.add(jLabelArch, null);
-
- jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+ private void showEdit(int index) {
+ HobsDlg dlg = new HobsDlg(vid.getHobs(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addHobs(dlg.getId());
+ } else {
+ this.vid.setHobs(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+
/**
- This method initializes Usage type and Hob type
+ Clear all table rows
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVHobUsage());
- Tools.generateComboBoxByVector(jComboBoxHobType, ed.getVHobType());
- Tools.generateComboBoxByVector(jComboBoxGuidC_Name, wt.getAllGuidDeclarationsFromWorkspace());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ /**
+ Read content of vector and put then into table
+
+ **/
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -510,60 +342,27 @@ public class ModuleHobs extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check Name
- //
- if (isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
- Log.err("Hob Name couldn't be empty");
- return false;
- }
-
- if (!isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
- if (!DataValidation.isC_NameType(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
- Log.err("Incorrect data type for Hob Name");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeHobs(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -609,6 +408,36 @@ public class ModuleHobs extends IInternalFrame { }
/* (non-Javadoc)
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
+ */
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
+ return;
+ }
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
+ return;
+ } else {
+ selectedRow = lsm.getMinSelectionIndex();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
@@ -619,182 +448,12 @@ public class ModuleHobs extends IInternalFrame { int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
- resizeComponentWidth(jComboBoxGuidC_Name, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxHobType, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
-
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- }
-
- private HobsIdentification getCurrentHobs() {
- String arg0 = this.jComboBoxGuidC_Name.getSelectedItem().toString();
- String arg1 = this.jComboBoxHobType.getSelectedItem().toString();
- String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg3 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg5 = this.jTextFieldHelpText.getText();
- id = new HobsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- return id;
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addHobs(getCurrentHobs());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeHobs(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateHobs(getCurrentHobs(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getHobs(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jComboBoxGuidC_Name.setSelectedItem(vid.getHobs(intSelectedItemId).getName());
- this.jComboBoxHobType.setSelectedItem(vid.getHobs(intSelectedItemId).getType());
- this.jComboBoxUsage.setSelectedItem(vid.getHobs(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getHobs(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getHobs(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getHobs(intSelectedItemId).getSupArchList());
-
- } else {
- }
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getHobs(index).getName() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
- *
- */
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleLibraryClassDefinitions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleLibraryClassDefinitions.java index a815c8549b..5104651700 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleLibraryClassDefinitions.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleLibraryClassDefinitions.java @@ -17,16 +17,15 @@ package org.tianocore.frameworkwizard.module.ui; import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.LibraryClassDefinitionsDocument;
import org.tianocore.LibraryUsage;
@@ -34,17 +33,15 @@ import org.tianocore.ModuleSurfaceAreaDocument; import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;
import org.tianocore.LibraryClassDocument.LibraryClass;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassIdentification;
import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassVector;
-import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+import org.tianocore.frameworkwizard.module.ui.dialog.LibraryClassDefsDlg;
/**
The class is used to create, update Library Class Definition of MSA/MBD file
@@ -63,61 +60,17 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { //
private JPanel jContentPane = null;
- private JComboBox jComboBoxLibraryClassName = null;
-
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
- private JLabel jLabelLibraryClassName = null;
-
- private JScrollPane jScrollPaneList = null;
-
private JScrollPane jScrollPane = null;
- private JTextArea jTextAreaList = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
-
- private JScrollPane jScrollPaneArch = null;
-
- private JLabel jLabelRecommendedInstanceVersion = null;
-
- private JTextField jTextFieldRecommendedInstanceVersion = null;
-
- private JLabel jLabelRecommendedInstanceGuid = null;
-
- private JTextField jTextFieldRecommendedInstanceGuid = null;
-
- private JButton jButtonGenerateGuid = null;
-
- private JLabel jLabelFeatureFlag = null;
+ private JScrollPane jScrollPaneTable = null;
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelArch = null;
-
- private JLabel jLabelModuleList = null;
-
- private JScrollPane jScrollPaneModuleList = null;
-
- private ICheckBoxList iCheckBoxListModule = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not for UI
@@ -128,65 +81,11 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { private LibraryClassVector vLibraryClass = new LibraryClassVector();
- private EnumerationData ed = new EnumerationData();
-
- private Vector<String> vLib = new Vector<String>();
-
- private int intSelectedItemId = 0;
-
- private WorkspaceTools wt = new WorkspaceTools();
-
- private LibraryClassIdentification lcid = null;
-
private OpeningModuleType omt = null;
- /**
- This method initializes jComboBoxSelect
-
- @return javax.swing.JComboBox jComboBoxSelect
-
- **/
- private JComboBox getJComboBoxLibraryClassName() {
- if (jComboBoxLibraryClassName == null) {
- jComboBoxLibraryClassName = new JComboBox();
- jComboBoxLibraryClassName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jComboBoxLibraryClassName.setPreferredSize(new Dimension(320, 20));
- jComboBoxLibraryClassName.setEnabled(true);
- }
- return jComboBoxLibraryClassName;
- }
-
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxUsage.setPreferredSize(new Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 330, 210, 20));
- jComboBoxList.setPreferredSize(new Dimension(210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -232,7 +131,7 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { if (jButtonUpdate == null) {
jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 330, 80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.setPreferredSize(new Dimension(80, 20));
jButtonUpdate.addActionListener(this);
}
@@ -240,21 +139,6 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { }
/**
- This method initializes jScrollPane
-
- @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 355, 465, 100));
- jScrollPaneList.setPreferredSize(new Dimension(465, 260));
- jScrollPaneList.setViewportView(getJTextAreaList());
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -268,147 +152,41 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { }
/**
- * This method initializes jTextAreaList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
- }
- return jTextAreaList;
- }
-
- /**
- * This method initializes jTextFieldRecommendedInstanceVersion
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldRecommendedInstanceVersion() {
- if (jTextFieldRecommendedInstanceVersion == null) {
- jTextFieldRecommendedInstanceVersion = new JTextField();
- jTextFieldRecommendedInstanceVersion.setPreferredSize(new java.awt.Dimension(260, 20));
- jTextFieldRecommendedInstanceVersion.setSize(new java.awt.Dimension(260, 20));
- jTextFieldRecommendedInstanceVersion.setLocation(new java.awt.Point(220, 85));
- }
- return jTextFieldRecommendedInstanceVersion;
- }
-
- /**
- * This method initializes jTextFieldRecommendedInstanceGuid
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldRecommendedInstanceGuid() {
- if (jTextFieldRecommendedInstanceGuid == null) {
- jTextFieldRecommendedInstanceGuid = new JTextField();
- jTextFieldRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(220, 110, 190, 20));
- jTextFieldRecommendedInstanceGuid.setPreferredSize(new java.awt.Dimension(190, 20));
- }
- return jTextFieldRecommendedInstanceGuid;
- }
-
- /**
- * This method initializes jButtonGenerateGuid
- *
- * @return javax.swing.JButton
- */
- private JButton getJButtonGenerateGuid() {
- if (jButtonGenerateGuid == null) {
- jButtonGenerateGuid = new JButton();
- jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 110, 65, 20));
- jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));
- jButtonGenerateGuid.setText("GEN");
- jButtonGenerateGuid.addActionListener(this);
- }
- return jButtonGenerateGuid;
- }
-
- /**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes iCheckBoxListArch
+ This method initializes jScrollPaneTable
- @return ICheckBoxList
+ @return javax.swing.JScrollPane
**/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return iCheckBoxListArch;
+ return jScrollPaneTable;
}
/**
- This method initializes iCheckBoxListArch
+ This method initializes jTable
- @return ICheckBoxList
+ @return javax.swing.JTable
**/
- private ICheckBoxList getICheckBoxListSupModuleList() {
- if (iCheckBoxListModule == null) {
- iCheckBoxListModule = new ICheckBoxList();
- }
- return iCheckBoxListModule;
- }
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
- /**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
-
- **/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 160, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
- }
- return jScrollPaneArch;
- }
-
- /**
- This method initializes jScrollPaneModuleList
-
- @return javax.swing.JScrollPane
-
- **/
- private JScrollPane getJScrollPaneModuleList() {
- if (jScrollPaneModuleList == null) {
- jScrollPaneModuleList = new JScrollPane();
- jScrollPaneModuleList.setBounds(new java.awt.Rectangle(160, 245, 320, 80));
- jScrollPaneModuleList.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneModuleList.setViewportView(getICheckBoxListSupModuleList());
- }
- return jScrollPaneModuleList;
- }
+ model.addColumn("Library Class Name");
+ model.addColumn("Usage");
- /**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
-
- **/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jTextFieldHelpText;
+ return jTable;
}
public static void main(String[] args) {
@@ -435,39 +213,10 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
- initLibraryClass();
init(msa.getLibraryClassDefinitions());
this.setVisible(true);
}
- // private void initLibraryClass(MsaHeaderDocument.MsaHeader msaHeader) {
- // Enum e = msaHeader.getModuleType();
- // if (e == ModuleTypeDef.BASE) {
- // vLib = ed.getVLibClassDefBase();
- // } else if (e == ModuleTypeDef.PEI_CORE) {
- // vLib = ed.getVLibClassDefPei();
- // } else if (e == ModuleTypeDef.PEIM) {
- // vLib = ed.getVLibClassDefPeim();
- // } else if (e == ModuleTypeDef.DXE_CORE) {
- // vLib = ed.getVLibClassDefDxeCore();
- // } else if (e == ModuleTypeDef.DXE_DRIVER) {
- // vLib = ed.getVLibClassDefDxeDriver();
- // } else if (e == ModuleTypeDef.DXE_SMM_DRIVER) {
- // vLib = ed.getVLibClassDefDxeSmmDriver();
- // } else if (e == ModuleTypeDef.UEFI_DRIVER) {
- // vLib = ed.getVLibClassDefUefiDriver();
- // } else {
- // //vLib = ed.getVLibClassDef();
- // }
- // }
-
- /**
-
- **/
- private void initLibraryClass() {
- vLib = wt.getAllLibraryClassDefinitionsFromWorkspace();
- }
-
/**
This method initializes this
Fill values to all fields if these values are not empty
@@ -484,7 +233,7 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { String name = lcd.getLibraryClassList().get(index).getKeyword();
String usage = null;
if (lcd.getLibraryClassList().get(index).getUsage() != null) {
- usage = lcd.getLibraryClassList().get(index).getUsage().toString();
+ usage = lcd.getLibraryClassList().get(index).getUsage().toString();
}
String version = lcd.getLibraryClassList().get(index).getRecommendedInstanceVersion();
String guid = lcd.getLibraryClassList().get(index).getRecommendedInstanceGuid();
@@ -503,8 +252,7 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { //
// Update the list
//
- Tools.generateComboBoxByVector(jComboBoxList, vLibraryClass.getLibraryClassName());
- reloadListArea();
+ showTable();
}
/**
@@ -515,21 +263,6 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { this.setContentPane(getJScrollPane());
this.setTitle("Library Class Definitions");
this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));
- initFrame();
- this.setViewMode(false);
- }
-
- /**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jComboBoxLibraryClassName.setEnabled(!isView);
- this.jComboBoxUsage.setEnabled(!isView);
- }
}
/**
@@ -540,160 +273,19 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
- jLabelHelpText.setText("Help Text");
- jLabelModuleList = new JLabel();
- jLabelModuleList.setBounds(new java.awt.Rectangle(15, 245, 140, 20));
- jLabelModuleList.setText("Sup Module List");
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
- jLabelArch.setText("Sup Arch List");
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelRecommendedInstanceGuid = new JLabel();
- jLabelRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(15, 110, 200, 20));
- jLabelRecommendedInstanceGuid.setText("Recommended Instance Guid");
- jLabelRecommendedInstanceVersion = new JLabel();
- jLabelRecommendedInstanceVersion.setBounds(new java.awt.Rectangle(15, 85, 200, 20));
- jLabelRecommendedInstanceVersion.setText("Recommended Instance Version");
- jLabelLibraryClassName = new JLabel();
- jLabelLibraryClassName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelLibraryClassName.setText("Library Class Name");
- jLabelUsage = new JLabel();
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelUsage.setText("Usage");
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 465));
-
- jContentPane.add(getJComboBoxLibraryClassName(), null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(getJComboBoxUsage(), null);
- jContentPane.add(jLabelLibraryClassName, null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(getJComboBoxList(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
+
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(jLabelRecommendedInstanceVersion, null);
- jContentPane.add(getJTextFieldRecommendedInstanceVersion(), null);
- jContentPane.add(jLabelRecommendedInstanceGuid, null);
- jContentPane.add(getJTextFieldRecommendedInstanceGuid(), null);
- jContentPane.add(getJButtonGenerateGuid(), null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(getJScrollPaneArch(), null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 10));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setLocation(new java.awt.Point(0, 35));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
- jContentPane.add(jLabelModuleList, null);
- jContentPane.add(getJScrollPaneModuleList(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
/**
- This method initializes all existing libraries and usage types
-
- **/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxLibraryClassName, vLib);
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVLibraryUsage());
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
- this.iCheckBoxListModule.setAllItems(ed.getVFrameworkModuleTypes());
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- *
- * Override actionPerformed to listen all actions
- *
- */
- public void actionPerformed(ActionEvent arg0) {
- if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
- }
- if (arg0.getSource() == jButtonUpdate) {
- updateForList();
- }
- if (arg0.getSource() == jButtonGenerateGuid) {
- this.jTextFieldRecommendedInstanceGuid.setText(Tools.generateUuidString());
- }
- }
-
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check LibraryClass
- //
- if (this.jComboBoxLibraryClassName.getSelectedItem() == null) {
- Log.err("No Library Class can be added");
- return false;
- }
- if (!DataValidation.isLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString())) {
- Log.err("Incorrect data type for Library Class");
- return false;
- }
-
- //
- // Check RecommendedInstanceVersion
- //
- if (!isEmpty(this.jTextFieldRecommendedInstanceVersion.getText())) {
- if (!DataValidation.isRecommendedInstanceVersion(this.jTextFieldRecommendedInstanceVersion.getText())) {
- Log.err("Incorrect data type for Recommended Instance Version");
- return false;
- }
- }
-
- //
- // Check RecommendedInstanceGuid
- //
- if (!isEmpty(this.jTextFieldRecommendedInstanceGuid.getText())) {
- if (!DataValidation.isGuid(this.jTextFieldRecommendedInstanceGuid.getText())) {
- Log.err("Incorrect data type for Recommended Instance Guid");
- return false;
- }
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
- }
- }
-
- if (this.vLibraryClass.findLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString()) > -1) {
- Log.err("The Library Class has been added already!");
- return false;
- }
- return true;
- }
-
- /**
Save all components of Mbd Header
if exists mbdHeader, set the value directly
if not exists mbdHeader, new an instance first
@@ -746,175 +338,111 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { }
}
- private LibraryClassIdentification getCurrentLibraryClass() {
- String name = this.jComboBoxLibraryClassName.getSelectedItem().toString();
- String usage = this.jComboBoxUsage.getSelectedItem().toString();
- String version = this.jTextFieldRecommendedInstanceVersion.getText();
- String guid = this.jTextFieldRecommendedInstanceGuid.getText();
- String featureFlag = this.jTextFieldFeatureFlag.getText();
- Vector<String> arch = this.iCheckBoxListArch.getAllCheckedItemsString();
- Vector<String> module = this.iCheckBoxListModule.getAllCheckedItemsString();
- String help = this.jTextFieldHelpText.getText();
- lcid = new LibraryClassIdentification(name, usage, version, guid, arch, featureFlag, module, help);
- return lcid;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vLibraryClass.size();
-
- vLibraryClass.addLibraryClass(getCurrentLibraryClass());
-
- jComboBoxList.addItem(lcid.getLibraryClassName());
- jComboBoxList.setSelectedItem(lcid.getLibraryClassName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vLibraryClass.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
+ private void showEdit(int index) {
+ LibraryClassDefsDlg mcdd = new LibraryClassDefsDlg(vLibraryClass.getLibraryClass(index), new IFrame());
+ int result = mcdd.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vLibraryClass.addLibraryClass(mcdd.getLcid());
+ } else {
+ this.vLibraryClass.setLibraryClass(mcdd.getLcid(), index);
+ }
+ this.showTable();
+ this.save();
+ mcdd.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ mcdd.dispose();
+ }
}
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vLibraryClass.size() < 1) {
- return;
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonAdd) {
+ showEdit(-1);
+ }
+ if (arg0.getSource() == jButtonUpdate) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
+ return;
+ }
+ showEdit(selectedRow);
}
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vLibraryClass.removeLibraryClass(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
+ }
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vLibraryClass.removeLibraryClass(selectedRow);
+ selectedRow = -1;
+ this.save();
+ }
+ }
}
/**
- Update current item of Vector
+ Clear all table rows
**/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vLibraryClass.size() < 1) {
- return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vLibraryClass.updateLibraryClass(getCurrentLibraryClass(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vLibraryClass.size(); index++) {
- jComboBoxList.addItem(vLibraryClass.getLibraryClass(index).getLibraryClassName());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
}
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
}
/**
- Refresh all fields' values of selected item of Vector
+ Read content of vector and put then into table
**/
- private void reloadFromList() {
+ private void showTable() {
+ clearAll();
+
if (vLibraryClass.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jComboBoxLibraryClassName.setSelectedItem(vLibraryClass.getLibraryClass(intSelectedItemId)
- .getLibraryClassName());
- this.jComboBoxUsage.setSelectedItem(vLibraryClass.getLibraryClass(intSelectedItemId).getUsage());
- this.jTextFieldRecommendedInstanceVersion.setText(vLibraryClass.getLibraryClass(intSelectedItemId)
- .getRecommendedInstanceVersion());
- this.jTextFieldRecommendedInstanceGuid.setText(vLibraryClass.getLibraryClass(intSelectedItemId)
- .getRecommendedInstanceGuid());
- this.jTextFieldFeatureFlag.setText(vLibraryClass.getLibraryClass(intSelectedItemId).getFeatureFlag());
- this.iCheckBoxListArch.setAllItemsUnchecked();
- this.iCheckBoxListArch.initCheckedItem(true, vLibraryClass.getLibraryClass(intSelectedItemId)
- .getSupArchList());
- this.iCheckBoxListModule.setAllItemsUnchecked();
- this.iCheckBoxListModule.initCheckedItem(true, vLibraryClass.getLibraryClass(intSelectedItemId)
- .getSupModuleList());
- this.jTextFieldHelpText.setText(vLibraryClass.getLibraryClass(intSelectedItemId).getHelp());
- } else {
+ for (int index = 0; index < vLibraryClass.size(); index++) {
+ model.addRow(vLibraryClass.toStringVector(index));
+ }
}
-
- reloadListArea();
+ this.jTable.repaint();
+ this.jTable.updateUI();
+ //this.jScrollPane.setViewportView(this.jTable);
}
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vLibraryClass.size(); index++) {
- strListItem = strListItem + vLibraryClass.getLibraryClass(index).getLibraryClassName()
- + DataType.UNIX_LINE_SEPARATOR;
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
+ */
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
+ return;
+ }
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
+ return;
+ } else {
+ selectedRow = lsm.getMinSelectionIndex();
}
- this.jTextAreaList.setText(strListItem);
}
/* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*
- * Reflesh the frame when selected item changed
- *
*/
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
}
}
@@ -929,24 +457,12 @@ public class ModuleLibraryClassDefinitions extends IInternalFrame { int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
- resizeComponentWidth(this.jComboBoxLibraryClassName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldRecommendedInstanceVersion, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldRecommendedInstanceGuid, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jScrollPaneModuleList, intCurrentWidth, intPreferredWidth);
-
- relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,
- DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
-
- resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
- relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,
- DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,
- DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePCDs.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePCDs.java index d87fca0d82..492b305c72 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePCDs.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePCDs.java @@ -14,18 +14,18 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.PcdCodedDocument;
import org.tianocore.PcdItemTypes;
@@ -33,17 +33,15 @@ import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.PcdCodedDocument.PcdCoded;
import org.tianocore.PcdCodedDocument.PcdCoded.PcdEntry;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdCodedIdentification;
import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdCodedVector;
-import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+import org.tianocore.frameworkwizard.module.ui.dialog.PCDsDlg;
/**
The class is used to create, update PCD of MSA/MBD file
@@ -64,32 +62,6 @@ public class ModulePCDs extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelItemType = null;
-
- private JLabel jLabelC_Name = null;
-
- private JComboBox jComboBoxItemType = null;
-
- private JComboBox jComboBoxCName = null;
-
- private JLabel jLabelDefaultValue = null;
-
- private JTextField jTextFieldDefaultValue = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private StarLabel jStarLabel3 = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -98,27 +70,13 @@ public class ModulePCDs extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private JLabel jLabelTokenSpaceGuid = null;
-
- private JTextField jTextFieldTokenSpaceGuid = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelArch = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
+ private JScrollPane jScrollPaneTable = null;
- private JScrollPane jScrollPaneArch = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -129,85 +87,9 @@ public class ModulePCDs extends IInternalFrame { private PcdCodedVector vid = new PcdCodedVector();
- private EnumerationData ed = new EnumerationData();
-
- private WorkspaceTools wt = new WorkspaceTools();
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxItemType
-
- @return javax.swing.JComboBox jComboBoxItemType
-
- **/
- private JComboBox getJComboBoxItemType() {
- if (jComboBoxItemType == null) {
- jComboBoxItemType = new JComboBox();
- jComboBoxItemType.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxItemType.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxItemType;
- }
-
- /**
- This method initializes jTextFieldC_Name
-
- @return javax.swing.JTextField jTextFieldC_Name
-
- **/
- private JComboBox getJComboBoxCName() {
- if (jComboBoxCName == null) {
- jComboBoxCName = new JComboBox();
- jComboBoxCName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxCName;
- }
-
- /**
- This method initializes jTextFieldDefaultValue
-
- @return javax.swing.JTextField jTextFieldDefaultValue
-
- **/
- private JTextField getJTextFieldDefaultValue() {
- if (jTextFieldDefaultValue == null) {
- jTextFieldDefaultValue = new JTextField();
- jTextFieldDefaultValue.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldDefaultValue.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldDefaultValue;
- }
-
- /**
- * This method initializes jTextFieldHelpText
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldHelpText;
- }
-
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 245, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -254,28 +136,13 @@ public class ModulePCDs extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 245, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 270, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -289,134 +156,94 @@ public class ModulePCDs extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
+ This method initializes jScrollPaneTable
+
+ @return javax.swing.JScrollPane
+ **/
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jTextAreaList;
+ return jScrollPaneTable;
}
/**
- * This method initializes jTextFieldTokenSpaceGuid
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldTokenSpaceGuid() {
- if (jTextFieldTokenSpaceGuid == null) {
- jTextFieldTokenSpaceGuid = new JTextField();
- jTextFieldTokenSpaceGuid.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jTextFieldTokenSpaceGuid.setPreferredSize(new java.awt.Dimension(320, 20));
+ This method initializes jTable
+
+ @return javax.swing.JTable
+ **/
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Name");
+ model.addColumn("Type");
+ model.addColumn("Value");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jTextFieldTokenSpaceGuid;
+ return jTable;
}
- /**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
+ public static void main(String[] args) {
+
}
/**
- This method initializes iCheckBoxListArch
-
- @return ICheckBoxList
+ This method initializes this
+
**/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
- }
- return iCheckBoxListArch;
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Pcd Coded");
}
/**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inPackageDependencies
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 160, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
- }
- return jScrollPaneArch;
- }
-
- public static void main(String[] args) {
+ private void init(PcdCoded inPcdCodeds) {
+ init();
+ this.pcds = inPcdCodeds;
+
+ if (this.pcds != null) {
+ if (this.pcds.getPcdEntryList().size() > 0) {
+ for (int index = 0; index < this.pcds.getPcdEntryList().size(); index++) {
+ String arg0 = pcds.getPcdEntryList().get(index).getCName();
+ String arg1 = pcds.getPcdEntryList().get(index).getTokenSpaceGuidCName();
+
+ String arg2 = pcds.getPcdEntryList().get(index).getFeatureFlag();
+ Vector<String> arg3 = Tools.convertListToVector(pcds.getPcdEntryList().get(index).getSupArchList());
+
+ String arg4 = pcds.getPcdEntryList().get(index).getDefaultValue();
+ String arg5 = pcds.getPcdEntryList().get(index).getHelpText();
+ String arg6 = null;
+ if (pcds.getPcdEntryList().get(index).getPcdItemType() != null) {
+ arg6 = pcds.getPcdEntryList().get(index).getPcdItemType().toString();
+ }
+ id = new PcdCodedIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+ vid.addPcdCoded(id);
+ }
+ }
+ }
+ showTable();
}
/**
- This method initializes this
-
- **/
- private void init() {
- this.setSize(500, 515);
- this.setContentPane(getJScrollPane());
- this.setTitle("Pcd Coded");
- initFrame();
- this.setViewMode(false);
- }
-
- /**
- This method initializes this
- Fill values to all fields if these values are not empty
-
- @param inPackageDependencies
-
- **/
- private void init(PcdCoded inPcdCodeds) {
- init();
- this.pcds = inPcdCodeds;
-
- if (this.pcds != null) {
- if (this.pcds.getPcdEntryList().size() > 0) {
- for (int index = 0; index < this.pcds.getPcdEntryList().size(); index++) {
- String arg0 = pcds.getPcdEntryList().get(index).getCName();
- String arg1 = pcds.getPcdEntryList().get(index).getTokenSpaceGuidCName();
-
-
- String arg2 = pcds.getPcdEntryList().get(index).getFeatureFlag();
- Vector<String> arg3 = Tools.convertListToVector(pcds.getPcdEntryList().get(index).getSupArchList());
-
- String arg4 = pcds.getPcdEntryList().get(index).getDefaultValue();
- String arg5 = pcds.getPcdEntryList().get(index).getHelpText();
- String arg6 = null;
- if (pcds.getPcdEntryList().get(index).getPcdItemType() != null) {
- arg6 = pcds.getPcdEntryList().get(index).getPcdItemType().toString();
- }
-
- id = new PcdCodedIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
- vid.addPcdCoded(id);
- }
- }
- }
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getPcdCodedName());
- reloadListArea();
- }
-
- /**
This is the default constructor
**/
@@ -441,19 +268,6 @@ public class ModulePCDs extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jTextFieldDefaultValue.setEnabled(!isView);
- this.jComboBoxItemType.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -461,73 +275,62 @@ public class ModulePCDs extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
- jLabelArch.setText("Sup Arch List");
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelTokenSpaceGuid = new JLabel();
- jLabelTokenSpaceGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
- jLabelTokenSpaceGuid.setText("Token Space C_Name");
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(15, 110, 137, 19));
- jLabelHelpText.setText("Help Text");
- jLabelC_Name = new JLabel();
- jLabelC_Name.setText("C_Name");
- jLabelC_Name.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelDefaultValue = new JLabel();
- jLabelDefaultValue.setText("Default Value");
- jLabelDefaultValue.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
- jLabelItemType = new JLabel();
- jLabelItemType.setText("Item Type");
- jLabelItemType.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 520));
-
- jContentPane.add(jLabelItemType, null);
- jContentPane.add(jLabelC_Name, null);
- jContentPane.add(getJComboBoxCName(), null);
- jContentPane.add(jLabelDefaultValue, null);
- jContentPane.add(getJTextFieldDefaultValue(), null);
- jContentPane.add(getJComboBoxItemType(), null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 10));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setLocation(new java.awt.Point(0, 35));
- jStarLabel3 = new StarLabel();
- jStarLabel3.setLocation(new java.awt.Point(0, 110));
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
- jContentPane.add(jStarLabel3, null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
-
- jContentPane.add(getJComboBoxList(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
+
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(jLabelTokenSpaceGuid, null);
- jContentPane.add(getJTextFieldTokenSpaceGuid(), null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(getJScrollPaneArch(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+ private void showEdit(int index) {
+ PCDsDlg dlg = new PCDsDlg(vid.getPcdCoded(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addPcdCoded(dlg.getId());
+ } else {
+ this.vid.setPcdCoded(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+
/**
- This method initializes Usage type, Item type and Datum type
+ Clear all table rows
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllPcdDeclarationsFromWorkspace());
- Tools.generateComboBoxByVector(jComboBoxItemType, ed.getVPcdItemTypes());
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
+
+ /**
+ Read content of vector and put then into table
+
+ **/
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -538,83 +341,27 @@ public class ModulePCDs extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check C_Name
- //
- if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
- if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
- Log.err("Incorrect data type for C_Name");
- return false;
- }
- }
-
- //
- // Check TokenSpaceGuid
- //
- if (!isEmpty(this.jTextFieldTokenSpaceGuid.getText())) {
- if (!DataValidation.isC_NameType(this.jTextFieldTokenSpaceGuid.getText())) {
- Log.err("Incorrect data type for Token Space C_Name");
- return false;
- }
- }
-
- //
- // Check DefaultValue
- //
- if (!isEmpty(this.jTextFieldDefaultValue.getText())) {
- if (!DataValidation.isDefaultValueType(this.jTextFieldDefaultValue.getText())) {
- Log.err("Incorrect data type for Default Value");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check HelpText
- //
- if (isEmpty(this.jTextFieldHelpText.getText())) {
- Log.err("Help Text couldn't be empty");
- return false;
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removePcdCoded(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -640,7 +387,8 @@ public class ModulePCDs extends IInternalFrame { if (!isEmpty(vid.getPcdCoded(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getPcdCoded(index).getFeatureFlag());
}
- if (vid.getPcdCoded(index).getSupArchList() != null && vid.getPcdCoded(index).getSupArchList().size() > 0) {
+ if (vid.getPcdCoded(index).getSupArchList() != null
+ && vid.getPcdCoded(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getPcdCoded(index).getSupArchList());
}
if (!isEmpty(vid.getPcdCoded(index).getValue())) {
@@ -665,6 +413,36 @@ public class ModulePCDs extends IInternalFrame { }
/* (non-Javadoc)
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
+ */
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
+ return;
+ }
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
+ return;
+ } else {
+ selectedRow = lsm.getMinSelectionIndex();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
@@ -675,188 +453,12 @@ public class ModulePCDs extends IInternalFrame { int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
- resizeComponentWidth(jComboBoxCName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldTokenSpaceGuid, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxItemType, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldDefaultValue, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
-
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
-
- private PcdCodedIdentification getCurrentPcdCoded() {
- String arg0 = this.jComboBoxCName.getSelectedItem().toString();
- String arg1 = this.jTextFieldTokenSpaceGuid.getText();
-
-
- String arg2 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
-
- String arg4 = this.jTextFieldDefaultValue.getText();
- String arg5 = this.jTextFieldHelpText.getText();
- String arg6 = this.jComboBoxItemType.getSelectedItem().toString();
- id = new PcdCodedIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addPcdCoded(getCurrentPcdCoded());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removePcdCoded(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updatePcdCoded(getCurrentPcdCoded(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getPcdCoded(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jComboBoxCName.setSelectedItem(vid.getPcdCoded(intSelectedItemId).getName());
- this.jTextFieldTokenSpaceGuid.setText(vid.getPcdCoded(intSelectedItemId).getGuid());
-
- this.jTextFieldDefaultValue.setText(vid.getPcdCoded(intSelectedItemId).getValue());
- this.jTextFieldHelpText.setText(vid.getPcdCoded(intSelectedItemId).getHelp());
- this.jComboBoxItemType.setSelectedItem(vid.getPcdCoded(intSelectedItemId).getType());
-
- jTextFieldFeatureFlag.setText(vid.getPcdCoded(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getPcdCoded(intSelectedItemId).getSupArchList());
-
- } else {
- }
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getPcdCoded(index).getName() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
- *
- */
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePackageDependencies.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePackageDependencies.java index 3ff3d4ad6d..661f71f728 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePackageDependencies.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePackageDependencies.java @@ -14,35 +14,32 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
-import org.tianocore.PackageDependenciesDocument;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.PackageDependenciesDocument.PackageDependencies;
import org.tianocore.PackageDependenciesDocument.PackageDependencies.Package;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.PackageDependencies.PackageDependenciesIdentification;
import org.tianocore.frameworkwizard.module.Identifications.PackageDependencies.PackageDependenciesVector;
+import org.tianocore.frameworkwizard.module.ui.dialog.PackageDepDlg;
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
@@ -53,7 +50,7 @@ import org.tianocore.frameworkwizard.workspace.WorkspaceTools; **/
-public class ModulePackageDependencies extends IInternalFrame implements ItemListener {
+public class ModulePackageDependencies extends IInternalFrame {
///
/// Define class Serial Version UID
@@ -65,30 +62,6 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis //
private JPanel jContentPane = null;
- private JLabel jLabelPackageName = null;
-
- private StarLabel jStarLabel1 = null;
-
- private JComboBox jComboBoxPackageName = null;
-
- private JLabel jLabelPackageGuid = null;
-
- private JTextField jTextFieldPackageGuid = null;
-
- private JButton jButtonGenerateGuid = null;
-
- private JLabel jLabelPackageVersion = null;
-
- private JTextField jTextFieldPackageVersion = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -97,127 +70,30 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
+ private JScrollPane jScrollPaneTable = null;
- private JLabel jLabelArch = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
-
- private JScrollPane jScrollPaneArch = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
- private PackageDependenciesIdentification id = null;
+ private PackageDependencies pd = null;
- private PackageDependenciesVector vid = new PackageDependenciesVector();
+ private PackageDependenciesIdentification pdid = null;
- private PackageDependenciesDocument.PackageDependencies packageDependencies = null;
+ private PackageDependenciesVector vid = new PackageDependenciesVector();
private WorkspaceTools wt = new WorkspaceTools();
private Vector<PackageIdentification> vPackage = wt.getAllPackages();
- /**
- * This method initializes jComboBoxPackageName
- *
- * @return javax.swing.JComboBox
- */
- private JComboBox getJComboBoxPackageName() {
- if (jComboBoxPackageName == null) {
- jComboBoxPackageName = new JComboBox();
- jComboBoxPackageName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jComboBoxPackageName.setPreferredSize(new java.awt.Dimension(320, 20));
- jComboBoxPackageName.setToolTipText("If your Module requires a package list that here.");
- jComboBoxPackageName.addItemListener(this);
- }
- return jComboBoxPackageName;
- }
-
- /**
- * This method initializes jTextFieldPackageGuid
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldPackageGuid() {
- if (jTextFieldPackageGuid == null) {
- jTextFieldPackageGuid = new JTextField();
- jTextFieldPackageGuid.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jTextFieldPackageGuid.setPreferredSize(new java.awt.Dimension(320, 20));
- jTextFieldPackageGuid.setEditable(false);
- }
- return jTextFieldPackageGuid;
- }
-
- /**
- * This method initializes jButtonGenerateGuid
- *
- * @return javax.swing.JButton
- */
- private JButton getJButtonGenerateGuid() {
- if (jButtonGenerateGuid == null) {
- jButtonGenerateGuid = new JButton();
- jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 35, 65, 20));
- jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));
- jButtonGenerateGuid.setText("GEN");
- jButtonGenerateGuid.addActionListener(this);
- jButtonGenerateGuid.setVisible(false);
- }
- return jButtonGenerateGuid;
- }
-
- /**
- * This method initializes jTextFieldPackageVersion
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldPackageVersion() {
- if (jTextFieldPackageVersion == null) {
- jTextFieldPackageVersion = new JTextField();
- jTextFieldPackageVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jTextFieldPackageVersion.setPreferredSize(new java.awt.Dimension(320, 20));
- jTextFieldPackageVersion
- .setToolTipText("If this module depends on a specific version of a package, enter the package version here. If the module can use the latest version that does not break backward compatibility, leave this field blank");
- }
- return jTextFieldPackageVersion;
- }
+ private IDefaultTableModel model = null;
- /**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -228,7 +104,7 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis private JButton getJButtonAdd() {
if (jButtonAdd == null) {
jButtonAdd = new JButton();
- jButtonAdd.setBounds(new java.awt.Rectangle(230, 195, 80, 20));
+ jButtonAdd.setBounds(new java.awt.Rectangle(230, 445, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
@@ -245,7 +121,7 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis private JButton getJButtonRemove() {
if (jButtonRemove == null) {
jButtonRemove = new JButton();
- jButtonRemove.setBounds(new java.awt.Rectangle(400, 195, 80, 20));
+ jButtonRemove.setBounds(new java.awt.Rectangle(400, 445, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
@@ -262,30 +138,15 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis private JButton getJButtonUpdate() {
if (jButtonUpdate == null) {
jButtonUpdate = new JButton();
- jButtonUpdate.setBounds(new java.awt.Rectangle(315, 195, 80, 20));
+ jButtonUpdate.setBounds(new java.awt.Rectangle(315, 445, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -299,50 +160,69 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
+ This method initializes jScrollPaneTable
+
+ @return javax.swing.JScrollPane
+ **/
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jTextAreaList;
+ return jScrollPaneTable;
}
/**
- This method initializes iCheckBoxListArch
+ This method initializes jTable
- @return ICheckBoxList
+ @return javax.swing.JTable
**/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Packge Name");
+ model.addColumn("Package Version");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return iCheckBoxListArch;
+ return jTable;
+ }
+
+ public static void main(String[] args) {
+
}
/**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
+ This is the default constructor
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
- }
- return jScrollPaneArch;
+ public ModulePackageDependencies() {
+ super();
+ init();
+ this.setVisible(true);
}
- public static void main(String[] args) {
-
+ /**
+ This is the override edit constructor
+
+ @param
+
+ **/
+ public ModulePackageDependencies(OpeningModuleType inOmt) {
+ super();
+ this.omt = inOmt;
+ this.msa = omt.getXmlMsa();
+ init(msa.getPackageDependencies());
+ this.setVisible(true);
}
/**
@@ -352,9 +232,7 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
- this.setTitle("Includes");
- initFrame();
- this.setViewMode(false);
+ this.setTitle("Package Dependencies");
}
/**
@@ -366,14 +244,14 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis **/
private void init(PackageDependencies inPackageDependencies) {
init();
- this.packageDependencies = inPackageDependencies;
+ this.pd = inPackageDependencies;
- if (this.packageDependencies != null) {
- if (this.packageDependencies.getPackageList().size() > 0) {
- for (int index = 0; index < this.packageDependencies.getPackageList().size(); index++) {
+ if (this.pd != null) {
+ if (this.pd.getPackageList().size() > 0) {
+ for (int index = 0; index < this.pd.getPackageList().size(); index++) {
String arg0 = "";
- String arg1 = packageDependencies.getPackageList().get(index).getPackageVersion();
- String arg2 = packageDependencies.getPackageList().get(index).getPackageGuid();
+ String arg1 = pd.getPackageList().get(index).getPackageVersion();
+ String arg2 = pd.getPackageList().get(index).getPackageGuid();
//
// If no guid, skip current item
//
@@ -385,56 +263,14 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis arg0 = vPackage.get(indexJ).getName();
}
}
- String arg3 = packageDependencies.getPackageList().get(index).getFeatureFlag();
- Vector<String> arg4 = Tools.convertListToVector(packageDependencies.getPackageList().get(index)
- .getSupArchList());
- id = new PackageDependenciesIdentification(arg0, arg1, arg2, arg3, arg4);
- vid.addPackageDependencies(id);
+ String arg3 = pd.getPackageList().get(index).getFeatureFlag();
+ Vector<String> arg4 = Tools.convertListToVector(pd.getPackageList().get(index).getSupArchList());
+ pdid = new PackageDependenciesIdentification(arg0, arg1, arg2, arg3, arg4);
+ vid.addPackageDependencies(pdid);
}
}
}
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getPackageDependenciesName());
- reloadListArea();
- }
-
- /**
- This is the default constructor
-
- **/
- public ModulePackageDependencies() {
- super();
- init();
- this.setVisible(true);
- }
-
- /**
- This is the override constructor
-
- **/
- public ModulePackageDependencies(OpeningModuleType inOmt) {
- super();
- this.omt = inOmt;
- this.msa = omt.getXmlMsa();
- init(msa.getPackageDependencies());
- this.setVisible(true);
- }
-
- /**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jComboBoxPackageName.setEnabled(!isView);
- this.jButtonAdd.setEnabled(!isView);
- this.jButtonUpdate.setEnabled(!isView);
- this.jButtonRemove.setEnabled(!isView);
- }
+ showTable();
}
/**
@@ -445,146 +281,96 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelArch.setText("Sup Arch List");
- jLabelPackageVersion = new JLabel();
- jLabelPackageVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
- jLabelPackageVersion.setText("Package Version");
- jLabelPackageGuid = new JLabel();
- jLabelPackageGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelPackageGuid.setText("Package Guid");
- jLabelPackageName = new JLabel();
- jLabelPackageName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelPackageName.setText("Package Name");
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 470));
-
- jContentPane.add(jLabelPackageName, null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 35));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(getJComboBoxPackageName(), null);
- jContentPane.add(jLabelPackageGuid, null);
- jContentPane.add(getJTextFieldPackageGuid(), null);
- jContentPane.add(getJButtonGenerateGuid(), null);
- jContentPane.add(jLabelPackageVersion, null);
- jContentPane.add(getJTextFieldPackageVersion(), null);
-
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
-
- jContentPane.add(getJComboBoxList(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
+
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(getJScrollPaneArch(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
- /* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- *
- * Override actionPerformed to listen all actions
- *
- */
- public void actionPerformed(ActionEvent arg0) {
- if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
+ private void showEdit(int index) {
+ PackageDepDlg pdd = new PackageDepDlg(vid.getPackageDependencies(index), new IFrame());
+ int result = pdd.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addPackageDependencies(pdd.getPdid());
+ } else {
+ this.vid.setPackageDependencies(pdd.getPdid(), index);
}
- addToList();
+ this.showTable();
+ this.save();
+ pdd.dispose();
}
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
- }
- if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
- return;
- }
- updateForList();
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ pdd.dispose();
}
}
/**
- This method initializes Usage type, Package type and Arch type
+ Clear all table rows
**/
- private void initFrame() {
- EnumerationData ed = new EnumerationData();
-
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
-
- for (int index = 0; index < vPackage.size(); index++) {
- jComboBoxPackageName.addItem(vPackage.elementAt(index).getName());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
}
- //jComboBoxPackageName.addItemListener(this);
}
/**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
+ Read content of vector and put then into table
**/
- public boolean check() {
- return true;
- }
+ private void showTable() {
+ clearAll();
- /**
- Data validation for all fields before add current item to Vector
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check PackageGuid
- //
- if (!isEmpty(this.jTextFieldPackageGuid.getText())) {
- if (!DataValidation.isGuid(this.jTextFieldPackageGuid.getText())) {
- Log.err("Incorrect data type for Package Guid");
- return false;
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
}
}
-
- //
- // Check PackageVersion
- //
- if (!isEmpty(this.jTextFieldPackageVersion.getText())) {
- if (!DataValidation.isVersion(this.jTextFieldPackageVersion.getText())) {
- Log.err("Incorrect data type for Package Version");
- return false;
+ this.jTable.repaint();
+ this.jTable.updateUI();
+ //this.jScrollPane.setViewportView(this.jTable);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonAdd) {
+ showEdit(-1);
+ }
+ if (arg0.getSource() == jButtonUpdate) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
+ return;
}
+ showEdit(selectedRow);
}
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
+ }
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removePackageDependencies(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
+
/**
Save all components of Includes
if exists includes, set the value directly
@@ -598,7 +384,7 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis //
int count = this.vid.size();
- this.packageDependencies = PackageDependencies.Factory.newInstance();
+ this.pd = PackageDependencies.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
Package p = Package.Factory.newInstance();
@@ -617,11 +403,11 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis p.setSupArchList(vid.getPackageDependencies(index).getSupArchList());
}
- this.packageDependencies.addNewPackage();
- this.packageDependencies.setPackageArray(index, p);
+ this.pd.addNewPackage();
+ this.pd.setPackageArray(index, p);
}
}
- this.msa.setPackageDependencies(packageDependencies);
+ this.msa.setPackageDependencies(pd);
this.omt.setSaved(false);
} catch (Exception e) {
e.printStackTrace();
@@ -630,198 +416,52 @@ public class ModulePackageDependencies extends IInternalFrame implements ItemLis }
/* (non-Javadoc)
- * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
- *
- * Override componentResized to resize all components when frame's size is changed
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
*/
- public void componentResized(ComponentEvent arg0) {
- int intCurrentWidth = this.getJContentPane().getWidth();
- int intCurrentHeight = this.getJContentPane().getHeight();
- int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
- int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
-
- resizeComponentWidth(this.jComboBoxPackageName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldPackageGuid, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldPackageVersion, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,
- DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
- }
-
- private PackageDependenciesIdentification getCurrentPackageDependencies() {
- String arg0 = this.jComboBoxPackageName.getSelectedItem().toString();
- String arg1 = this.jTextFieldPackageVersion.getText();
- String arg2 = this.jTextFieldPackageGuid.getText();
-
- String arg3 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
- id = new PackageDependenciesIdentification(arg0, arg1, arg2, arg3, arg4);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addPackageDependencies(getCurrentPackageDependencies());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
return;
}
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removePackageDependencies(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updatePackageDependencies(getCurrentPackageDependencies(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getPackageDependencies(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jComboBoxPackageName.setSelectedItem(vid.getPackageDependencies(intSelectedItemId).getName());
- this.jTextFieldPackageVersion.setText(vid.getPackageDependencies(intSelectedItemId).getVersion());
- this.jTextFieldPackageGuid.setText(vid.getPackageDependencies(intSelectedItemId).getGuid());
-
- jTextFieldFeatureFlag.setText(vid.getPackageDependencies(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getPackageDependencies(intSelectedItemId).getSupArchList());
-
} else {
+ selectedRow = lsm.getMinSelectionIndex();
}
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getPackageDependencies(index).getName() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
}
/* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*
- * Reflesh the frame when selected item changed
- *
*/
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- if (arg0.getSource() == this.jComboBoxPackageName && arg0.getStateChange() == ItemEvent.SELECTED) {
- for (int index = 0; index < vPackage.size(); index++) {
- if (this.jComboBoxPackageName.getSelectedItem().toString().equals(vPackage.get(index).getName())) {
- this.jTextFieldPackageGuid.setText(vPackage.get(index).getGuid());
- }
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
}
}
}
+ /* (non-Javadoc)
+ * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
+ *
+ * Override componentResized to resize all components when frame's size is changed
+ */
+ public void componentResized(ComponentEvent arg0) {
+ int intCurrentWidth = this.getJContentPane().getWidth();
+ int intCurrentHeight = this.getJContentPane().getHeight();
+ int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
+ int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
+
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePpis.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePpis.java index c0e17aa4b4..aef4addfd6 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePpis.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePpis.java @@ -14,18 +14,18 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.PPIsDocument;
import org.tianocore.PpiNotifyUsage;
@@ -35,17 +35,16 @@ import org.tianocore.PPIsDocument.PPIs; import org.tianocore.PPIsDocument.PPIs.Ppi;
import org.tianocore.PPIsDocument.PPIs.PpiNotify;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisIdentification;
import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisVector;
-import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+import org.tianocore.frameworkwizard.module.ui.dialog.PpisDlg;
/**
The class is used to create, update Ppi of MSA/MBD file
@@ -64,32 +63,6 @@ public class ModulePpis extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelC_Name = null;
-
- private JComboBox jComboBoxCName = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private JLabel jLabelPpiType = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private JComboBox jComboBoxPpiType = null;
-
- private JLabel jLabelArch = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -98,20 +71,13 @@ public class ModulePpis extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
+ private JScrollPane jScrollPaneTable = null;
- private JScrollPane jScrollPaneArch = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
@@ -123,86 +89,11 @@ public class ModulePpis extends IInternalFrame { private PpisVector vid = new PpisVector();
- private WorkspaceTools wt = new WorkspaceTools();
-
private EnumerationData ed = new EnumerationData();
- /**
- This method initializes jTextFieldC_Name
-
- @return javax.swing.JTextField jTextFieldC_Name
-
- **/
- private JComboBox getJComboBoxCName() {
- if (jComboBoxCName == null) {
- jComboBoxCName = new JComboBox();
- jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxCName;
- }
-
- /**
- This method initializes jTextFieldFeatureFlag
-
- @return javax.swing.JTextField jTextFieldFeatureFlag
-
- **/
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes jComboBox
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBox() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
-
- /**
- * This method initializes jComboBoxPpiType
- *
- * @return javax.swing.JComboBox
- */
- private JComboBox getJComboBoxPpiType() {
- if (jComboBoxPpiType == null) {
- jComboBoxPpiType = new JComboBox();
- jComboBoxPpiType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jComboBoxPpiType.setPreferredSize(new java.awt.Dimension(320, 20));
- jComboBoxPpiType.addItemListener(this);
- }
- return jComboBoxPpiType;
- }
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -249,28 +140,13 @@ public class ModulePpis extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -284,135 +160,108 @@ public class ModulePpis extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
+ This method initializes jScrollPaneTable
+
+ @return javax.swing.JScrollPane
+ **/
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jTextAreaList;
+ return jScrollPaneTable;
}
/**
- This method initializes iCheckBoxListArch
+ This method initializes jTable
- @return ICheckBoxList
+ @return javax.swing.JTable
**/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Guid C_Name");
+ model.addColumn("Type");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return iCheckBoxListArch;
+ return jTable;
+ }
+
+ public static void main(String[] args) {
+
}
/**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
+ This method initializes this
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
- }
- return jScrollPaneArch;
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Ppis");
}
-
+
/**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
-
- **/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldHelpText;
- }
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inPackageDependencies
- public static void main(String[] args) {
+ **/
+ private void init(PPIs inPpis) {
+ init();
+ this.ppis = inPpis;
+
+ if (this.ppis != null) {
+ if (this.ppis.getPpiList().size() > 0) {
+ for (int index = 0; index < this.ppis.getPpiList().size(); index++) {
+ String arg0 = ppis.getPpiList().get(index).getPpiCName();
+ String arg1 = ed.getVPpiType().get(0);
+ String arg2 = null;
+ if (ppis.getPpiList().get(index).getUsage() != null) {
+ arg2 = ppis.getPpiList().get(index).getUsage().toString();
+ }
+
+ String arg3 = ppis.getPpiList().get(index).getFeatureFlag();
+ Vector<String> arg4 = Tools.convertListToVector(ppis.getPpiList().get(index).getSupArchList());
+ String arg5 = ppis.getPpiList().get(index).getHelpText();
+
+ id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ vid.addPpis(id);
+ }
+ }
+ if (this.ppis.getPpiNotifyList().size() > 0) {
+ for (int index = 0; index < this.ppis.getPpiNotifyList().size(); index++) {
+ String arg0 = ppis.getPpiNotifyList().get(index).getPpiNotifyCName();
+ String arg1 = ed.getVPpiType().get(1);
+ String arg2 = null;
+ if (ppis.getPpiNotifyList().get(index).getUsage() != null) {
+ arg2 = ppis.getPpiNotifyList().get(index).getUsage().toString();
+ }
+
+ String arg3 = ppis.getPpiNotifyList().get(index).getFeatureFlag();
+ Vector<String> arg4 = Tools
+ .convertListToVector(ppis.getPpiNotifyList().get(index).getSupArchList());
+ String arg5 = ppis.getPpiNotifyList().get(index).getHelpText();
+ id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ vid.addPpis(id);
+ }
+ }
+ }
+ showTable();
}
-
- /**
- This method initializes this
-
- **/
- private void init() {
- this.setSize(500, 515);
- this.setContentPane(getJScrollPane());
- this.setTitle("Ppis");
- initFrame();
- this.setViewMode(false);
- }
-
- /**
- This method initializes this
- Fill values to all fields if these values are not empty
-
- @param inPackageDependencies
-
- **/
- private void init(PPIs inPpis) {
- init();
- this.ppis = inPpis;
-
- if (this.ppis != null) {
- if (this.ppis.getPpiList().size() > 0) {
- for (int index = 0; index < this.ppis.getPpiList().size(); index++) {
- String arg0 = ppis.getPpiList().get(index).getPpiCName();
- String arg1 = ed.getVPpiType().get(0);
- String arg2 = null;
- if (ppis.getPpiList().get(index).getUsage() != null) {
- arg2 = ppis.getPpiList().get(index).getUsage().toString();
- }
-
- String arg3 = ppis.getPpiList().get(index).getFeatureFlag();
- Vector<String> arg4 = Tools.convertListToVector(ppis.getPpiList().get(index)
- .getSupArchList());
- String arg5 = ppis.getPpiList().get(index).getHelpText();
-
- id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- vid.addPpis(id);
- }
- }
- if (this.ppis.getPpiNotifyList().size() > 0) {
- for (int index = 0; index < this.ppis.getPpiNotifyList().size(); index++) {
- String arg0 = ppis.getPpiNotifyList().get(index).getPpiNotifyCName();
- String arg1 = ed.getVPpiType().get(1);
- String arg2 = null;
- if (ppis.getPpiNotifyList().get(index).getUsage() != null) {
- arg2 = ppis.getPpiNotifyList().get(index).getUsage().toString();
- }
-
- String arg3 = ppis.getPpiNotifyList().get(index).getFeatureFlag();
- Vector<String> arg4 = Tools.convertListToVector(ppis.getPpiNotifyList().get(index)
- .getSupArchList());
- String arg5 = ppis.getPpiNotifyList().get(index).getHelpText();
-
- id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- vid.addPpis(id);
- }
- }
- }
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getPpisName());
- reloadListArea();
- }
/**
This is the default constructor
@@ -439,20 +288,6 @@ public class ModulePpis extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jComboBoxCName.setEnabled(!isView);
- this.jComboBoxUsage.setEnabled(!isView);
- this.jTextFieldFeatureFlag.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -460,70 +295,62 @@ public class ModulePpis extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
- jLabelArch.setText("Arch");
- jLabelPpiType = new JLabel();
- jLabelPpiType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelPpiType.setText("Ppi Type");
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelC_Name = new JLabel();
- jLabelC_Name.setText("C_Name Type");
- jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
- jLabelHelpText.setText("Help Text");
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));
-
- jContentPane.add(jLabelC_Name, null);
- jContentPane.add(getJComboBoxCName(), null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(getJComboBox(), null);
- jContentPane.add(getJComboBoxPpiType(), null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(jLabelPpiType, null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
-
- jContentPane.add(getJComboBoxList(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
+
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+ private void showEdit(int index) {
+ PpisDlg dlg = new PpisDlg(vid.getPpis(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addPpis(dlg.getId());
+ } else {
+ this.vid.setPpis(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+
+ /**
+ Clear all table rows
+
+ **/
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
+
/**
- This method initializes Usage type
+ Read content of vector and put then into table
**/
- private void initFrame() {
- EnumerationData ed = new EnumerationData();
-
- Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllPpiDeclarationsFromWorkspace());
- Tools.generateComboBoxByVector(jComboBoxPpiType, ed.getVPpiType());
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
-
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -534,55 +361,27 @@ public class ModulePpis extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check Name
- //
- if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
- if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
- Log.err("Incorrect data type for Ppi/PpiNotify Name");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removePpis(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -652,6 +451,36 @@ public class ModulePpis extends IInternalFrame { }
/* (non-Javadoc)
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
+ */
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
+ return;
+ }
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
+ return;
+ } else {
+ selectedRow = lsm.getMinSelectionIndex();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
@@ -662,189 +491,12 @@ public class ModulePpis extends IInternalFrame { int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
- resizeComponentWidth(jComboBoxPpiType, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxCName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
-
- private PpisIdentification getCurrentPpis() {
- String arg0 = this.jComboBoxCName.getSelectedItem().toString();
- String arg1 = this.jComboBoxPpiType.getSelectedItem().toString();
- String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg3 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg5 = this.jTextFieldHelpText.getText();
-
- id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addPpis(getCurrentPpis());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removePpis(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updatePpis(getCurrentPpis(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getPpis(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jComboBoxCName.setSelectedItem(vid.getPpis(intSelectedItemId).getName());
- this.jComboBoxPpiType.setSelectedItem(vid.getPpis(intSelectedItemId).getType());
- this.jComboBoxUsage.setSelectedItem(vid.getPpis(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getPpis(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getPpis(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getPpis(intSelectedItemId).getSupArchList());
-
- } else {
- }
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getPpis(index).getName() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
- *
- */
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- if (arg0.getSource() == this.jComboBoxPpiType && arg0.getStateChange() == ItemEvent.SELECTED) {
- if (this.jComboBoxPpiType.getSelectedItem().toString().equals(ed.getVPpiType().get(0))) {
- Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVPpiUsage());
- } else {
- Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVPpiNotifyUsage());
- }
- }
- }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleProtocols.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleProtocols.java index 6c09aa1909..ed55f3ce73 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleProtocols.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleProtocols.java @@ -15,18 +15,18 @@ package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.ProtocolNotifyUsage;
import org.tianocore.ProtocolUsage;
@@ -36,17 +36,16 @@ import org.tianocore.ProtocolsDocument.Protocols; import org.tianocore.ProtocolsDocument.Protocols.Protocol;
import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsIdentification;
import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsVector;
-import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+import org.tianocore.frameworkwizard.module.ui.dialog.ProtocolsDlg;
/**
The class is used to create, update Protocol of MSA/MBD file
@@ -67,28 +66,6 @@ public class ModuleProtocols extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelC_Name = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private JLabel jLabelProtocolType = null;
-
- private JLabel jLabelArch = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -97,25 +74,13 @@ public class ModuleProtocols extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private JComboBox jComboBoxProtocolType = null;
+ private JScrollPane jScrollPaneTable = null;
- private JComboBox jComboBoxCName = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
-
- private JScrollPane jScrollPaneArch = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -126,56 +91,11 @@ public class ModuleProtocols extends IInternalFrame { private ProtocolsVector vid = new ProtocolsVector();
- private WorkspaceTools wt = new WorkspaceTools();
-
private EnumerationData ed = new EnumerationData();
- /**
- This method initializes jTextFieldFeatureFlag
-
- @return javax.swing.JTextField jTextFieldFeatureFlag
-
- **/
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldFeatureFlag;
- }
-
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxProtocolUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -222,28 +142,13 @@ public class ModuleProtocols extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -257,94 +162,43 @@ public class ModuleProtocols extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
- }
- return jTextAreaList;
- }
-
- /**
- * This method initializes jComboBoxProtocolType
- *
- * @return javax.swing.JComboBox
- */
- private JComboBox getJComboBoxProtocolType() {
- if (jComboBoxProtocolType == null) {
- jComboBoxProtocolType = new JComboBox();
- jComboBoxProtocolType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jComboBoxProtocolType.setPreferredSize(new java.awt.Dimension(320, 20));
- jComboBoxProtocolType.addItemListener(this);
- jComboBoxProtocolType.setToolTipText("Select Protocol Type");
- }
- return jComboBoxProtocolType;
- }
-
- /**
- * This method initializes jComboBoxCName
- *
- * @return javax.swing.JComboBox
- */
- private JComboBox getJComboBoxCName() {
- if (jComboBoxCName == null) {
- jComboBoxCName = new JComboBox();
- jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
-
- }
- return jComboBoxCName;
- }
-
- /**
- This method initializes iCheckBoxListArch
+ This method initializes jScrollPaneTable
- @return ICheckBoxList
+ @return javax.swing.JScrollPane
**/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return iCheckBoxListArch;
+ return jScrollPaneTable;
}
/**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
+ This method initializes jTable
+ @return javax.swing.JTable
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Guid C_Name");
+ model.addColumn("Type");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jScrollPaneArch;
+ return jTable;
}
-
- /**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
-
- **/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldHelpText;
- }
public static void main(String[] args) {
@@ -358,8 +212,6 @@ public class ModuleProtocols extends IInternalFrame { this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Protocols");
- initFrame();
- this.setViewMode(false);
}
/**
@@ -380,9 +232,9 @@ public class ModuleProtocols extends IInternalFrame { String arg1 = ed.getVProtocolType().get(0);
String arg2 = null;
if (protocols.getProtocolList().get(index).getUsage() != null) {
- arg2 = protocols.getProtocolList().get(index).getUsage().toString();
+ arg2 = protocols.getProtocolList().get(index).getUsage().toString();
}
-
+
String arg3 = protocols.getProtocolList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(protocols.getProtocolList().get(index)
.getSupArchList());
@@ -397,9 +249,9 @@ public class ModuleProtocols extends IInternalFrame { String arg1 = ed.getVProtocolType().get(1);
String arg2 = null;
if (protocols.getProtocolNotifyList().get(index).getUsage() != null) {
- arg2 = protocols.getProtocolNotifyList().get(index).getUsage().toString();
+ arg2 = protocols.getProtocolNotifyList().get(index).getUsage().toString();
}
-
+
String arg3 = protocols.getProtocolNotifyList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(protocols.getProtocolNotifyList().get(index)
.getSupArchList());
@@ -409,11 +261,7 @@ public class ModuleProtocols extends IInternalFrame { }
}
}
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getProtocolsName());
- reloadListArea();
+ showTable();
}
/**
@@ -441,19 +289,6 @@ public class ModuleProtocols extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jComboBoxUsage.setEnabled(!isView);
- this.jTextFieldFeatureFlag.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -461,69 +296,62 @@ public class ModuleProtocols extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
- jLabelHelpText.setText("Help Text");
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
- jLabelArch.setText("Arch Type");
- jLabelProtocolType = new JLabel();
- jLabelProtocolType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelProtocolType.setText("Protocol Type");
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelC_Name = new JLabel();
- jLabelC_Name.setText("C_Name Type");
- jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));
-
- jContentPane.add(jLabelC_Name, null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(getJComboBoxProtocolUsage(), null);
- jContentPane.add(jLabelProtocolType, null);
-
- jStarLabel1 = new StarLabel();
- jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(getJComboBoxList(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
+
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
-
- jContentPane.add(getJComboBoxProtocolType(), null);
- jContentPane.add(getJComboBoxCName(), null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+
+ private void showEdit(int index) {
+ ProtocolsDlg dlg = new ProtocolsDlg(vid.getProtocols(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addProtocols(dlg.getId());
+ } else {
+ this.vid.setProtocols(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+
+ /**
+ Clear all table rows
+
+ **/
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
/**
- This method initializes Usage type
+ Read content of vector and put then into table
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxProtocolType, ed.getVProtocolType());
- Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllProtocolDeclarationsFromWorkspace());
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVProtocolUsage());
+ private void showTable() {
+ clearAll();
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -534,55 +362,27 @@ public class ModuleProtocols extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check Name
- //
- if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
- if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
- Log.err("Incorrect data type for Protocol/ProtocolNotify Name");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeProtocols(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -650,204 +450,54 @@ public class ModuleProtocols extends IInternalFrame { Log.err("Update Protocols", e.getMessage());
}
}
-
+
/* (non-Javadoc)
- * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
- *
- * Override componentResized to resize all components when frame's size is changed
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
*/
- public void componentResized(ComponentEvent arg0) {
- int intCurrentWidth = this.getJContentPane().getWidth();
- int intCurrentHeight = this.getJContentPane().getHeight();
- int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
- int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
-
- resizeComponentWidth(this.jComboBoxProtocolType, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jComboBoxCName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
-
- relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,
- DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,
- DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- }
-
- private ProtocolsIdentification getCurrentProtocols() {
- String arg0 = this.jComboBoxCName.getSelectedItem().toString();
- String arg1 = this.jComboBoxProtocolType.getSelectedItem().toString();
- String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg3 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg5 = this.jTextFieldHelpText.getText();
- id = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addProtocols(getCurrentProtocols());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
return;
}
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeProtocols(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateProtocols(getCurrentProtocols(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getProtocols(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jComboBoxCName.setSelectedItem(vid.getProtocols(intSelectedItemId).getName());
- this.jComboBoxProtocolType.setSelectedItem(vid.getProtocols(intSelectedItemId).getType());
- this.jComboBoxUsage.setSelectedItem(vid.getProtocols(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getProtocols(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getProtocols(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getProtocols(intSelectedItemId).getSupArchList());
-
-
} else {
+ selectedRow = lsm.getMinSelectionIndex();
}
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getProtocols(index).getName() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
}
/* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*
- * Reflesh the frame when selected item changed
- *
*/
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- if (arg0.getSource() == this.jComboBoxProtocolType && arg0.getStateChange() == ItemEvent.SELECTED) {
- if (this.jComboBoxProtocolType.getSelectedItem().toString().equals(ed.getVProtocolType().get(0))) {
- Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolUsage());
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
} else {
- Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolNotifyUsage());
+ showEdit(selectedRow);
}
}
}
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
+ *
+ * Override componentResized to resize all components when frame's size is changed
+ */
+ public void componentResized(ComponentEvent arg0) {
+ int intCurrentWidth = this.getJContentPane().getWidth();
+ int intCurrentHeight = this.getJContentPane().getHeight();
+ int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
+ int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
+
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java index ec3c3b6bb7..515017349b 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java @@ -14,44 +14,39 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.SourceFilesDocument;
import org.tianocore.FilenameDocument.Filename;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.SourceFilesDocument.SourceFiles;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.SourceFiles.SourceFilesIdentification;
import org.tianocore.frameworkwizard.module.Identifications.SourceFiles.SourceFilesVector;
-import org.tianocore.frameworkwizard.workspace.Workspace;
+import org.tianocore.frameworkwizard.module.ui.dialog.SourceFilesDlg;
/**
The class is used to create, update SourceFile of MSA/MBD file
It extends IInternalFrame
-
-
**/
public class ModuleSourceFiles extends IInternalFrame {
@@ -65,22 +60,8 @@ public class ModuleSourceFiles extends IInternalFrame { //
private SourceFilesDocument.SourceFiles sourceFiles = null;
- private int intSelectedItemId = 0;
-
private JPanel jContentPane = null;
- private JLabel jLabelFileName = null;
-
- private JTextField jTextFieldFileName = null;
-
- private JButton jButtonOpenFile = null;
-
- private JLabel jLabelToolChainFamily = null;
-
- private StarLabel jStarLabel1 = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -89,92 +70,24 @@ public class ModuleSourceFiles extends IInternalFrame { private JCheckBox jCheckBoxArch = null;
- private JScrollPane jScrollPaneList = null;
-
- private JTextArea jTextAreaList = null;
-
- private JLabel jLabelArch = null;
-
private JScrollPane jScrollPane = null;
- private JLabel jLabelTagName = null;
-
- private JTextField jTextFieldTagName = null;
-
- private JLabel jLabelToolCode = null;
-
- private JTextField jTextFieldToolCode = null;
+ private JScrollPane jScrollPaneTable = null;
- private JTextField jTextFieldToolChainFamily = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
-
- private JScrollPane jScrollPaneArch = null;
+ private JTable jTable = null;
//
// Not used by UI
//
private OpeningModuleType omt = null;
-
- private ModuleSurfaceArea msa = null;
- private SourceFilesIdentification sfid = null;
+ private ModuleSurfaceArea msa = null;
private SourceFilesVector vSourceFiles = new SourceFilesVector();
- /**
- This method initializes jTextFieldFileName
-
- @return javax.swing.JTextField jTextFieldFileName
-
- **/
- private JTextField getJTextFieldSourceFilesDirectory() {
- if (jTextFieldFileName == null) {
- jTextFieldFileName = new JTextField();
- jTextFieldFileName.setBounds(new java.awt.Rectangle(140, 10, 250, 20));
- jTextFieldFileName.setPreferredSize(new java.awt.Dimension(250, 20));
- jTextFieldFileName.setToolTipText("Path is relative to the MSA file and must include the file name");
- }
- return jTextFieldFileName;
- }
+ private IDefaultTableModel model = null;
- /**
- This method initializes jButtonOpenFile
-
- @return javax.swing.JButton jButtonOpenFile
-
- **/
- private JButton getJButtonOpenFile() {
- if (jButtonOpenFile == null) {
- jButtonOpenFile = new JButton();
- jButtonOpenFile.setText("Browse");
- jButtonOpenFile.setBounds(new java.awt.Rectangle(395, 10, 85, 20));
- jButtonOpenFile.setPreferredSize(new java.awt.Dimension(85, 20));
- jButtonOpenFile.addActionListener(this);
- }
- return jButtonOpenFile;
- }
-
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -221,42 +134,13 @@ public class ModuleSourceFiles extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
- }
- return jTextAreaList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -270,93 +154,40 @@ public class ModuleSourceFiles extends IInternalFrame { }
/**
- * This method initializes jTextFieldTagName
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldTagName() {
- if (jTextFieldTagName == null) {
- jTextFieldTagName = new JTextField();
- jTextFieldTagName.setBounds(new java.awt.Rectangle(140, 35, 340, 20));
- jTextFieldTagName.setPreferredSize(new java.awt.Dimension(340, 20));
- jTextFieldTagName.setToolTipText("You may specify a specific tool chain tag name, such as BILL1");
- }
- return jTextFieldTagName;
- }
-
- /**
- * This method initializes jTextFieldToolCode
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldToolCode() {
- if (jTextFieldToolCode == null) {
- jTextFieldToolCode = new JTextField();
- jTextFieldToolCode.setBounds(new java.awt.Rectangle(140, 60, 340, 20));
- jTextFieldToolCode.setPreferredSize(new java.awt.Dimension(340, 20));
- jTextFieldToolCode.setToolTipText("You may specify a specific tool command, such as ASM");
- }
- return jTextFieldToolCode;
- }
-
- /**
- * This method initializes jTextFieldToolChainFamily
- *
- * @return javax.swing.JTextField
+ * This method initializes jScrollPaneTable
+ *
+ * @return javax.swing.JScrollPane
*/
- private JTextField getJTextFieldToolChainFamily() {
- if (jTextFieldToolChainFamily == null) {
- jTextFieldToolChainFamily = new JTextField();
- jTextFieldToolChainFamily.setBounds(new java.awt.Rectangle(140, 85, 340, 20));
- jTextFieldToolChainFamily.setPreferredSize(new java.awt.Dimension(340, 20));
- jTextFieldToolChainFamily.setToolTipText("You may specify a specific tool chain family, such as GCC");
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jTextFieldToolChainFamily;
+ return jScrollPaneTable;
}
/**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
+ * This method initializes jTable
+ *
+ * @return javax.swing.JTable
*/
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(140, 110, 340, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(340, 20));
- jTextFieldFeatureFlag.setToolTipText("RESERVED FOR FUTURE USE");
- }
- return jTextFieldFeatureFlag;
- }
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
- /**
- This method initializes iCheckBoxListArch
-
- @return ICheckBoxList
- **/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
- }
- return iCheckBoxListArch;
- }
+ model.addColumn("File Name");
- /**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
-
- **/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(140, 135, 340, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(340, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jScrollPaneArch;
+ return jTable;
}
public static void main(String[] args) {
@@ -382,7 +213,7 @@ public class ModuleSourceFiles extends IInternalFrame { public ModuleSourceFiles(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
- this.msa = inOmt.getXmlMsa();
+ this.msa = omt.getXmlMsa();
init(msa.getSourceFiles());
this.setVisible(true);
}
@@ -415,11 +246,7 @@ public class ModuleSourceFiles extends IInternalFrame { }
}
}
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vSourceFiles.getSourceFilesName());
- reloadListArea();
+ showTable();
}
/**
@@ -430,7 +257,6 @@ public class ModuleSourceFiles extends IInternalFrame { this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Source Files");
- initFrame();
this.setViewMode(false);
}
@@ -442,9 +268,6 @@ public class ModuleSourceFiles extends IInternalFrame { **/
public void setViewMode(boolean isView) {
if (isView) {
- this.jTextFieldFileName.setEnabled(!isView);
- this.jButtonOpenFile.setEnabled(!isView);
-
this.jButtonAdd.setEnabled(!isView);
this.jButtonRemove.setEnabled(!isView);
this.jButtonUpdate.setEnabled(!isView);
@@ -460,317 +283,18 @@ public class ModuleSourceFiles extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 120, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelToolCode = new JLabel();
- jLabelToolCode.setBounds(new java.awt.Rectangle(15, 60, 120, 20));
- jLabelToolCode.setText("Tool Code");
- jLabelTagName = new JLabel();
- jLabelTagName.setBounds(new java.awt.Rectangle(15, 35, 120, 20));
- jLabelTagName.setText("Tag Name");
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 120, 20));
- jLabelArch.setText("Sup Arch List");
- jLabelToolChainFamily = new JLabel();
- jLabelToolChainFamily.setBounds(new java.awt.Rectangle(15, 85, 120, 20));
- jLabelToolChainFamily.setText("Tool Chain Family");
- jLabelFileName = new JLabel();
- jLabelFileName.setText("File Name");
- jLabelFileName.setBounds(new java.awt.Rectangle(15, 10, 120, 20));
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
- jContentPane.add(jLabelFileName, null);
- jContentPane.add(getJTextFieldSourceFilesDirectory(), null);
- jContentPane.add(getJButtonOpenFile(), null);
- jContentPane.add(jLabelToolChainFamily, null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 10));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(jLabelTagName, null);
- jContentPane.add(getJTextFieldTagName(), null);
- jContentPane.add(jLabelToolCode, null);
- jContentPane.add(getJTextFieldToolCode(), null);
- jContentPane.add(getJTextFieldToolChainFamily(), null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(getJScrollPaneArch(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
- /* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- *
- * Override actionPerformed to listen all actions
- *
- */
- public void actionPerformed(ActionEvent arg0) {
- if (arg0.getSource() == jButtonOpenFile) {
- selectFile();
- }
- if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
- }
- if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
- return;
- }
- updateForList();
- }
- }
-
- /**
- This method initializes Usage type and Arch type
-
- **/
- private void initFrame() {
- EnumerationData ed = new EnumerationData();
-
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
- }
-
- private SourceFilesIdentification getCurrentSourceFiles() {
- String name = this.jTextFieldFileName.getText();
- String tagName = this.jTextFieldTagName.getText();
- String toolCode = this.jTextFieldToolCode.getText();
- String tcf = this.jTextFieldToolChainFamily.getText();
- String featureFlag = this.jTextFieldFeatureFlag.getText();
- Vector<String> arch = this.iCheckBoxListArch.getAllCheckedItemsString();
- sfid = new SourceFilesIdentification(name, tagName, toolCode, tcf, featureFlag, arch);
- return sfid;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vSourceFiles.size();
-
- vSourceFiles.addSourceFiles(getCurrentSourceFiles());
-
- jComboBoxList.addItem(sfid.getFilename());
- jComboBoxList.setSelectedItem(sfid.getFilename());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vSourceFiles.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vSourceFiles.size() < 1) {
- return;
- }
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vSourceFiles.removeSourceFiles(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vSourceFiles.size() < 1) {
- return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vSourceFiles.updateSourceFiles(getCurrentSourceFiles(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vSourceFiles.size(); index++) {
- jComboBoxList.addItem(vSourceFiles.getSourceFiles(index).getFilename());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vSourceFiles.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jTextFieldFileName.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getFilename());
- this.jTextFieldTagName.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getTagName());
- this.jTextFieldToolCode.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getToolCode());
- this.jTextFieldToolChainFamily.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getToolChainFamily());
- jTextFieldFeatureFlag.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vSourceFiles.getSourceFiles(intSelectedItemId).getSupArchList());
-
- } else {
- }
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vSourceFiles.size(); index++) {
- strListItem = strListItem + vSourceFiles.getSourceFiles(index).getFilename() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
- *
- */
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- }
-
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check Filename
- //
- if (isEmpty(this.jTextFieldFileName.getText())) {
- Log.err("File Name couldn't be empty");
- return false;
- }
- if (!DataValidation.isFilename(this.jTextFieldFileName.getText())) {
- Log.err("Incorrect data type for File Name");
- return false;
- }
-
- //
- // Check TagName
- //
- if (!isEmpty(this.jTextFieldTagName.getText())) {
- if (!DataValidation.isTagName(this.jTextFieldTagName.getText())) {
- Log.err("Incorrect data type for Tag Name");
- return false;
- }
- }
-
- //
- // Check ToolCode
- //
- if (!isEmpty(this.jTextFieldToolCode.getText())) {
- if (!DataValidation.isToolCode(this.jTextFieldToolCode.getText())) {
- Log.err("Incorrect data type for Tool Code");
- return false;
- }
- }
-
- //
- // Check ToolChainFamily
- //
- if (!isEmpty(this.jTextFieldToolChainFamily.getText())) {
- if (!DataValidation.isToolChainFamily(this.jTextFieldToolChainFamily.getText())) {
- Log.err("Incorrect data type for Tool Chain Family");
- return false;
- }
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
- }
- }
-
- return true;
- }
-
/**
Save all components of SourceFiles
if exists sourceFiles, set the value directly
@@ -815,21 +339,115 @@ public class ModuleSourceFiles extends IInternalFrame { this.msa.setSourceFiles(sourceFiles);
this.omt.setSaved(false);
} catch (Exception e) {
- e.printStackTrace();
Log.err("Update Source Files", e.getMessage());
}
}
+ private void showEdit(int index) {
+ SourceFilesDlg sfd = new SourceFilesDlg(this.vSourceFiles.getSourceFiles(index), new IFrame());
+ int result = sfd.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vSourceFiles.addSourceFiles(sfd.getSfid());
+ } else {
+ this.vSourceFiles.setSourceFiles(sfd.getSfid(), index);
+ }
+ this.showTable();
+ this.save();
+ sfd.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ sfd.dispose();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonAdd) {
+ showEdit(-1);
+ }
+ if (arg0.getSource() == jButtonUpdate) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
+ return;
+ }
+ showEdit(selectedRow);
+ }
+
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
+ }
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vSourceFiles.removeSourceFiles(selectedRow);
+ selectedRow = -1;
+ this.save();
+ }
+ }
+ }
+
/**
- Display a file open browser to let user select file
+ Clear all table rows
**/
- private void selectFile() {
- JFileChooser fc = new JFileChooser(Workspace.getCurrentWorkspace());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
- int result = fc.showOpenDialog(new JPanel());
- if (result == JFileChooser.APPROVE_OPTION) {
- this.jTextFieldFileName.setText(fc.getSelectedFile().getName());
+ /**
+ Read content of vector and put then into table
+
+ **/
+ private void showTable() {
+ clearAll();
+
+ if (vSourceFiles.size() > 0) {
+ for (int index = 0; index < vSourceFiles.size(); index++) {
+ model.addRow(vSourceFiles.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
+ //this.jScrollPane.setViewportView(this.jTable);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
+ */
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
+ return;
+ }
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
+ return;
+ } else {
+ selectedRow = lsm.getMinSelectionIndex();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
}
}
@@ -844,21 +462,12 @@ public class ModuleSourceFiles extends IInternalFrame { int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
- resizeComponentWidth(this.jTextFieldFileName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldTagName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldToolCode, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldToolChainFamily, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
- relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(this.jButtonOpenFile, intCurrentWidth, intPreferredWidth,
- DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
- relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,
- DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,
- DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSystemTables.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSystemTables.java index 3a32326455..bf78fb5611 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSystemTables.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSystemTables.java @@ -14,18 +14,18 @@ **/
package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.SystemTableUsage;
import org.tianocore.SystemTablesDocument;
@@ -33,16 +33,15 @@ import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.SystemTablesDocument.SystemTables;
import org.tianocore.SystemTablesDocument.SystemTables.SystemTableCNames;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.SystemTables.SystemTablesIdentification;
import org.tianocore.frameworkwizard.module.Identifications.SystemTables.SystemTablesVector;
+import org.tianocore.frameworkwizard.module.ui.dialog.SystemTablesDlg;
/**
The class is used to create, update SystemTable of MSA/MBD file
@@ -63,28 +62,6 @@ public class ModuleSystemTables extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelEntry = null;
-
- private JTextField jTextFieldGuidC_Name = null;
-
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelArch = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -93,21 +70,13 @@ public class ModuleSystemTables extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
+ private JScrollPane jScrollPaneTable = null;
- private JScrollPane jScrollPaneArch = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -118,69 +87,9 @@ public class ModuleSystemTables extends IInternalFrame { private SystemTablesVector vid = new SystemTablesVector();
- private EnumerationData ed = new EnumerationData();
-
- /**
- This method initializes jTextFieldEntry
-
- @return javax.swing.JTextField jTextFieldEntry
-
- **/
- private JTextField getJTextFieldEntry() {
- if (jTextFieldGuidC_Name == null) {
- jTextFieldGuidC_Name = new JTextField();
- jTextFieldGuidC_Name.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
- jTextFieldGuidC_Name.setPreferredSize(new java.awt.Dimension(320,20));
- jTextFieldGuidC_Name.setToolTipText("Enter the C Name of the System Table");
- }
- return jTextFieldGuidC_Name;
- }
-
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320,20));
- }
- return jComboBoxUsage;
- }
-
- /**
- * This method initializes jTextFieldFeatureFlag
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320,20));
- }
- return jTextFieldFeatureFlag;
- }
+ private IDefaultTableModel model = null;
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -227,28 +136,13 @@ public class ModuleSystemTables extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -262,115 +156,89 @@ public class ModuleSystemTables extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
+ This method initializes jScrollPaneTable
+
+ @return javax.swing.JScrollPane
+ **/
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jTextAreaList;
+ return jScrollPaneTable;
}
-
+
/**
- This method initializes iCheckBoxListArch
-
- @return ICheckBoxList
- **/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
- }
- return iCheckBoxListArch;
- }
-
- /**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
-
- **/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
- }
- return jScrollPaneArch;
- }
-
- /**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
+ This method initializes jTable
+ @return javax.swing.JTable
**/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Guid C_Name");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jTextFieldHelpText;
+ return jTable;
}
public static void main(String[] args) {
}
-
+
/**
- This method initializes this
-
- **/
- private void init() {
- this.setSize(500, 515);
- this.setContentPane(getJScrollPane());
- this.setTitle("System Tables");
- initFrame();
- this.setViewMode(false);
- }
-
- /**
- This method initializes this
- Fill values to all fields if these values are not empty
-
- @param inPackageDependencies
-
- **/
- private void init(SystemTables inSystemTables) {
- init();
- this.systemTables = inSystemTables;
-
- if (this.systemTables != null) {
- if (this.systemTables.getSystemTableCNamesList().size() > 0) {
- for (int index = 0; index < this.systemTables.getSystemTableCNamesList().size(); index++) {
- String arg0 = systemTables.getSystemTableCNamesList().get(index).getSystemTableCName();
- String arg1 = null;
- if (systemTables.getSystemTableCNamesList().get(index).getUsage() != null) {
- arg1 = systemTables.getSystemTableCNamesList().get(index).getUsage().toString();
- }
-
- String arg2 = systemTables.getSystemTableCNamesList().get(index).getFeatureFlag();
- Vector<String> arg3 = Tools.convertListToVector(systemTables.getSystemTableCNamesList().get(index).getSupArchList());
- String arg4 = systemTables.getSystemTableCNamesList().get(index).getHelpText();
-
- id = new SystemTablesIdentification(arg0, arg1, arg2, arg3, arg4);
- vid.addSystemTables(id);
- }
- }
- }
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getSystemTablesName());
- reloadListArea();
- }
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("System Tables");
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inSystemTables
+
+ **/
+ private void init(SystemTables inSystemTables) {
+ init();
+ this.systemTables = inSystemTables;
+
+ if (this.systemTables != null) {
+ if (this.systemTables.getSystemTableCNamesList().size() > 0) {
+ for (int index = 0; index < this.systemTables.getSystemTableCNamesList().size(); index++) {
+ String arg0 = systemTables.getSystemTableCNamesList().get(index).getSystemTableCName();
+ String arg1 = null;
+ if (systemTables.getSystemTableCNamesList().get(index).getUsage() != null) {
+ arg1 = systemTables.getSystemTableCNamesList().get(index).getUsage().toString();
+ }
+
+ String arg2 = systemTables.getSystemTableCNamesList().get(index).getFeatureFlag();
+ Vector<String> arg3 = Tools.convertListToVector(systemTables.getSystemTableCNamesList().get(index)
+ .getSupArchList());
+ String arg4 = systemTables.getSystemTableCNamesList().get(index).getHelpText();
+
+ id = new SystemTablesIdentification(arg0, arg1, arg2, arg3, arg4);
+ vid.addSystemTables(id);
+ }
+ }
+ }
+ showTable();
+ }
/**
This is the default constructor
@@ -397,19 +265,6 @@ public class ModuleSystemTables extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jTextFieldGuidC_Name.setEnabled(!isView);
- this.jComboBoxUsage.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -417,61 +272,63 @@ public class ModuleSystemTables extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
- jLabelArch.setText("Arch");
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelEntry = new JLabel();
- jLabelEntry.setText("Guid C_Name");
- jLabelEntry.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
- jLabelHelpText.setText("Help Text");
-
+
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
-
- jContentPane.add(jLabelEntry, null);
- jContentPane.add(getJTextFieldEntry(), null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(jLabelArch, null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(getJComboBoxUsage(), null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
-
- jContentPane.add(getJComboBoxList(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
+
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
+ private void showEdit(int index) {
+ SystemTablesDlg dlg = new SystemTablesDlg(vid.getSystemTables(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addSystemTables(dlg.getId());
+ } else {
+ this.vid.setSystemTables(dlg.getId(), index);
+ }
+ this.showTable();
+ this.save();
+ dlg.dispose();
+ }
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
+ }
+ }
+
/**
- This method initializes Usage type
+ Clear all table rows
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVSystemTableUsage());
-
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
+ }
+
+ /**
+ Read content of vector and put then into table
+
+ **/
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
+ }
+ }
+ this.jTable.repaint();
+ this.jTable.updateUI();
}
/* (non-Javadoc)
@@ -482,60 +339,27 @@ public class ModuleSystemTables extends IInternalFrame { */
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
- }
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ showEdit(-1);
}
if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
return;
}
- updateForList();
+ showEdit(selectedRow);
}
- }
- /**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
-
- **/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check GuidC_Name
- //
- if (isEmpty(this.jTextFieldGuidC_Name.getText())) {
- Log.err("Guid C_Name couldn't be empty");
- return false;
- }
-
- if (!isEmpty(this.jTextFieldGuidC_Name.getText())) {
- if (!DataValidation.isC_NameType(this.jTextFieldGuidC_Name.getText())) {
- Log.err("Incorrect data type for Guid C_Name");
- return false;
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
}
- }
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeSystemTables(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -561,7 +385,8 @@ public class ModuleSystemTables extends IInternalFrame { if (!isEmpty(vid.getSystemTables(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getSystemTables(index).getFeatureFlag());
}
- if (vid.getSystemTables(index).getSupArchList() != null && vid.getSystemTables(index).getSupArchList().size() > 0) {
+ if (vid.getSystemTables(index).getSupArchList() != null
+ && vid.getSystemTables(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getSystemTables(index).getSupArchList());
}
if (!isEmpty(vid.getSystemTables(index).getHelp())) {
@@ -578,7 +403,37 @@ public class ModuleSystemTables extends IInternalFrame { Log.err("Update System Tables", e.getMessage());
}
}
-
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
+ */
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
+ return;
+ }
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
+ return;
+ } else {
+ selectedRow = lsm.getMinSelectionIndex();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
+ }
+ }
+
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
@@ -590,180 +445,12 @@ public class ModuleSystemTables extends IInternalFrame { int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
- resizeComponentWidth(jTextFieldGuidC_Name, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
-
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
- }
-
- private SystemTablesIdentification getCurrentSystemTables() {
- String arg0 = this.jTextFieldGuidC_Name.getText();
- String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg2 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg4 = this.jTextFieldHelpText.getText();
-
- id = new SystemTablesIdentification(arg0, arg1, arg2, arg3, arg4);
- return id;
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addSystemTables(getCurrentSystemTables());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeSystemTables(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateSystemTables(getCurrentSystemTables(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getSystemTables(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jTextFieldGuidC_Name.setText(vid.getSystemTables(intSelectedItemId).getName());
- this.jComboBoxUsage.setSelectedItem(vid.getSystemTables(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getSystemTables(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getSystemTables(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getSystemTables(intSelectedItemId).getSupArchList());
-
- } else {
- }
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getSystemTables(index).getName() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
- *
- */
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleVariables.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleVariables.java index 1335694fb8..5dfbb1deef 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleVariables.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleVariables.java @@ -15,18 +15,18 @@ package org.tianocore.frameworkwizard.module.ui;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
+import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
import org.tianocore.VariableUsage;
import org.tianocore.VariablesDocument;
@@ -34,16 +34,15 @@ import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.VariablesDocument.Variables;
import org.tianocore.VariablesDocument.Variables.Variable;
import org.tianocore.frameworkwizard.common.DataType;
-import org.tianocore.frameworkwizard.common.DataValidation;
-import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.common.ui.StarLabel;
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identifications.Variables.VariablesIdentification;
import org.tianocore.frameworkwizard.module.Identifications.Variables.VariablesVector;
+import org.tianocore.frameworkwizard.module.ui.dialog.VariablesDlg;
/**
The class is used to create, update Variable of MSA/MBD file
@@ -62,22 +61,6 @@ public class ModuleVariables extends IInternalFrame { //
private JPanel jContentPane = null;
- private JLabel jLabelVariableName = null;
-
- private JTextField jTextFieldVariableName = null;
-
- private JLabel jLabelUsage = null;
-
- private JComboBox jComboBoxUsage = null;
-
- private StarLabel jStarLabel1 = null;
-
- private StarLabel jStarLabel2 = null;
-
- private JTextArea jTextAreaList = null;
-
- private JComboBox jComboBoxList = null;
-
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
@@ -86,31 +69,13 @@ public class ModuleVariables extends IInternalFrame { private JScrollPane jScrollPane = null;
- private JScrollPane jScrollPaneList = null;
-
- private JLabel jLabelGuidCName = null;
+ private JScrollPane jScrollPaneTable = null;
- private JTextField jTextFieldGuidC_Name = null;
-
- private JTextField jTextFieldFeatureFlag = null;
-
- private JLabel jLabelFeatureFlag = null;
-
- private JLabel jLabelArch = null;
-
- private ICheckBoxList iCheckBoxListArch = null;
-
- private JScrollPane jScrollPaneArch = null;
-
- private JLabel jLabelHelpText = null;
-
- private JTextField jTextFieldHelpText = null;
+ private JTable jTable = null;
//
// Not used by UI
//
- private int intSelectedItemId = 0;
-
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
@@ -121,56 +86,9 @@ public class ModuleVariables extends IInternalFrame { private VariablesVector vid = new VariablesVector();
- private EnumerationData ed = new EnumerationData();
+ private IDefaultTableModel model = null;
- /**
- This method initializes jTextFieldString
-
- @return javax.swing.JTextField jTextFieldString
-
- **/
- private JTextField getJTextFieldString() {
- if (jTextFieldVariableName == null) {
- jTextFieldVariableName = new JTextField();
- jTextFieldVariableName.setSize(new java.awt.Dimension(320, 20));
- jTextFieldVariableName.setPreferredSize(new java.awt.Dimension(320, 20));
- jTextFieldVariableName.setLocation(new java.awt.Point(160, 10));
- jTextFieldVariableName.setToolTipText("Enter a Hex Word Array, you must provide leading Zeros. 0x000a, 0x0010, бн");
- }
- return jTextFieldVariableName;
- }
-
- /**
- This method initializes jComboBoxUsage
-
- @return javax.swing.JComboBox jComboBoxUsage
-
- **/
- private JComboBox getJComboBoxUsage() {
- if (jComboBoxUsage == null) {
- jComboBoxUsage = new JComboBox();
- jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
- jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jComboBoxUsage;
- }
-
- /**
- This method initializes jComboBoxFileList
-
- @return javax.swing.JComboBox jComboBoxFileList
-
- **/
- private JComboBox getJComboBoxList() {
- if (jComboBoxList == null) {
- jComboBoxList = new JComboBox();
- jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
- jComboBoxList.addItemListener(this);
- jComboBoxList.addActionListener(this);
- jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
- }
- return jComboBoxList;
- }
+ private int selectedRow = -1;
/**
This method initializes jButtonAdd
@@ -217,28 +135,13 @@ public class ModuleVariables extends IInternalFrame { jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
- jButtonUpdate.setText("Update");
+ jButtonUpdate.setText("Edit");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
- * This method initializes jScrollPaneFileList
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPaneList() {
- if (jScrollPaneList == null) {
- jScrollPaneList = new JScrollPane();
- jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
- jScrollPaneList.setViewportView(getJTextAreaList());
- jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
- }
- return jScrollPaneList;
- }
-
- /**
This method initializes jScrollPane
@return javax.swing.JScrollPane
@@ -252,145 +155,90 @@ public class ModuleVariables extends IInternalFrame { }
/**
- * This method initializes jTextAreaFileList
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJTextAreaList() {
- if (jTextAreaList == null) {
- jTextAreaList = new JTextArea();
- jTextAreaList.setEditable(false);
-
- }
- return jTextAreaList;
- }
-
- /**
- * This method initializes jTextFieldGuidCName
- *
- * @return javax.swing.JTextField
- */
- private JTextField getJTextFieldGuidC_Name() {
- if (jTextFieldGuidC_Name == null) {
- jTextFieldGuidC_Name = new JTextField();
- jTextFieldGuidC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
- jTextFieldGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
- jTextFieldGuidC_Name.setToolTipText("Enter the C Name for the Variable Guid");
+ This method initializes jScrollPaneTable
+
+ @return javax.swing.JScrollPane
+ **/
+ private JScrollPane getJScrollPaneTable() {
+ if (jScrollPaneTable == null) {
+ jScrollPaneTable = new JScrollPane();
+ jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));
+ jScrollPaneTable.setPreferredSize(new Dimension(470, 420));
+ jScrollPaneTable.setViewportView(getJTable());
}
- return jTextFieldGuidC_Name;
+ return jScrollPaneTable;
}
/**
- This method initializes jTextFieldFeatureFlag
-
- @return javax.swing.JTextField jTextFieldFeatureFlag
+ This method initializes jTable
+ @return javax.swing.JTable
**/
- private JTextField getJTextFieldFeatureFlag() {
- if (jTextFieldFeatureFlag == null) {
- jTextFieldFeatureFlag = new JTextField();
- jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
- jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ private JTable getJTable() {
+ if (jTable == null) {
+ jTable = new JTable();
+ model = new IDefaultTableModel();
+ jTable = new JTable(model);
+ jTable.setRowHeight(20);
+
+ model.addColumn("Name");
+ model.addColumn("Guid C_Name");
+ model.addColumn("Usage");
+
+ jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jTable.getSelectionModel().addListSelectionListener(this);
+ jTable.getModel().addTableModelListener(this);
+ jTable.addMouseListener(this);
}
- return jTextFieldFeatureFlag;
+ return jTable;
}
- /**
- This method initializes iCheckBoxListArch
+ public static void main(String[] args) {
- @return ICheckBoxList
- **/
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {
- if (iCheckBoxListArch == null) {
- iCheckBoxListArch = new ICheckBoxList();
- iCheckBoxListArch.addFocusListener(this);
- iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
- }
- return iCheckBoxListArch;
}
/**
- This method initializes jScrollPaneArch
-
- @return javax.swing.JScrollPane
-
+ This method initializes this
+
**/
- private JScrollPane getJScrollPaneArch() {
- if (jScrollPaneArch == null) {
- jScrollPaneArch = new JScrollPane();
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
- }
- return jScrollPaneArch;
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Variables");
}
-
+
/**
- This method initializes jTextFieldHelpText
-
- @return javax.swing.JTextField
-
- **/
- private JTextField getJTextFieldHelpText() {
- if (jTextFieldHelpText == null) {
- jTextFieldHelpText = new JTextField();
- jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
- jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
- }
- return jTextFieldHelpText;
- }
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inPackageDependencies
- public static void main(String[] args) {
+ **/
+ private void init(Variables inVariables) {
+ init();
+ this.variables = inVariables;
+
+ if (this.variables != null) {
+ if (this.variables.getVariableList().size() > 0) {
+ for (int index = 0; index < this.variables.getVariableList().size(); index++) {
+ String arg0 = variables.getVariableList().get(index).getVariableName();
+ String arg1 = variables.getVariableList().get(index).getGuidCName();
+ String arg2 = null;
+ if (variables.getVariableList().get(index).getUsage() != null) {
+ arg2 = variables.getVariableList().get(index).getUsage().toString();
+ }
+ String arg3 = variables.getVariableList().get(index).getFeatureFlag();
+ Vector<String> arg4 = Tools.convertListToVector(variables.getVariableList().get(index)
+ .getSupArchList());
+ String arg5 = variables.getVariableList().get(index).getHelpText();
+ id = new VariablesIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ vid.addVariables(id);
+ }
+ }
+ }
+ showTable();
}
-
- /**
- This method initializes this
-
- **/
- private void init() {
- this.setSize(500, 515);
- this.setContentPane(getJScrollPane());
- this.setTitle("Variables");
- initFrame();
- this.setViewMode(false);
- }
-
- /**
- This method initializes this
- Fill values to all fields if these values are not empty
-
- @param inPackageDependencies
-
- **/
- private void init(Variables inVariables) {
- init();
- this.variables = inVariables;
-
- if (this.variables != null) {
- if (this.variables.getVariableList().size() > 0) {
- for (int index = 0; index < this.variables.getVariableList().size(); index++) {
- String arg0 = variables.getVariableList().get(index).getVariableName();
- String arg1 = variables.getVariableList().get(index).getGuidCName();
- String arg2 = null;
- if (variables.getVariableList().get(index).getUsage() != null) {
- arg2 = variables.getVariableList().get(index).getUsage().toString();
- }
-
- String arg3 = variables.getVariableList().get(index).getFeatureFlag();
- Vector<String> arg4 = Tools.convertListToVector(variables.getVariableList().get(index).getSupArchList());
- String arg5 = variables.getVariableList().get(index).getHelpText();
- id = new VariablesIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- vid.addVariables(id);
- }
- }
- }
- //
- // Update the list
- //
- Tools.generateComboBoxByVector(jComboBoxList, vid.getVariablesName());
- reloadListArea();
- }
/**
This is the default constructor
@@ -417,19 +265,6 @@ public class ModuleVariables extends IInternalFrame { }
/**
- Disable all components when the mode is view
-
- @param isView true - The view mode; false - The non-view mode
-
- **/
- public void setViewMode(boolean isView) {
- if (isView) {
- this.jTextFieldVariableName.setEnabled(!isView);
- this.jComboBoxUsage.setEnabled(!isView);
- }
- }
-
- /**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
@@ -437,146 +272,93 @@ public class ModuleVariables extends IInternalFrame { **/
private JPanel getJContentPane() {
if (jContentPane == null) {
- jLabelGuidCName = new JLabel();
- jLabelGuidCName.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
- jLabelGuidCName.setText("Guid C_Name");
- jLabelUsage = new JLabel();
- jLabelUsage.setText("Usage");
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
- jLabelVariableName = new JLabel();
- jLabelVariableName.setText("Variable Name");
- jLabelVariableName.setLocation(new java.awt.Point(15, 10));
- jLabelVariableName.setSize(new java.awt.Dimension(140, 20));
- jLabelArch = new JLabel();
- jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
- jLabelArch.setText("Arch");
- jLabelFeatureFlag = new JLabel();
- jLabelFeatureFlag.setText("Feature Flag");
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
-
jContentPane = new JPanel();
jContentPane.setLayout(null);
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));
-
- jContentPane.add(jLabelVariableName, null);
- jContentPane.add(jLabelGuidCName, null);
- jContentPane.add(getJTextFieldGuidC_Name(), null);
- jContentPane.add(getJTextFieldString(), null);
- jContentPane.add(jLabelUsage, null);
- jContentPane.add(getJComboBoxUsage(), null);
- jStarLabel1 = new StarLabel();
- jStarLabel1.setLocation(new java.awt.Point(0, 10));
- jStarLabel2 = new StarLabel();
- jStarLabel2.setLocation(new java.awt.Point(0, 35));
- jLabelHelpText = new JLabel();
- jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
- jLabelHelpText.setText("Help Text");
-
- jContentPane.add(jStarLabel1, null);
- jContentPane.add(jStarLabel2, null);
-
- jContentPane.add(getJComboBoxList(), null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
+
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
- jContentPane.add(getJScrollPaneList(), null);
-
- jContentPane.add(jLabelArch, null);
- jContentPane.add(jLabelFeatureFlag, null);
- jContentPane.add(getJTextFieldFeatureFlag(), null);
- jContentPane.add(getJScrollPaneArch(), null);
- jContentPane.add(jLabelHelpText, null);
- jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(getJScrollPaneTable(), null);
}
return jContentPane;
}
- /* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- *
- * Override actionPerformed to listen all actions
- *
- */
- public void actionPerformed(ActionEvent arg0) {
- if (arg0.getSource() == jButtonAdd) {
- if (!checkAdd()) {
- return;
+ private void showEdit(int index) {
+ VariablesDlg dlg = new VariablesDlg(vid.getVariables(index), new IFrame());
+ int result = dlg.showDialog();
+ if (result == DataType.RETURN_TYPE_OK) {
+ if (index == -1) {
+ this.vid.addVariables(dlg.getId());
+ } else {
+ this.vid.setVariables(dlg.getId(), index);
}
- addToList();
- }
- if (arg0.getSource() == jButtonRemove) {
- removeFromList();
+ this.showTable();
+ this.save();
+ dlg.dispose();
}
- if (arg0.getSource() == jButtonUpdate) {
- if (!checkAdd()) {
- return;
- }
- updateForList();
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ dlg.dispose();
}
}
/**
- This method initializes Usage type
+ Clear all table rows
**/
- private void initFrame() {
- Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
+ private void clearAll() {
+ if (model != null) {
+ for (int index = model.getRowCount() - 1; index >= 0; index--) {
+ model.removeRow(index);
+ }
+ }
}
/**
- Data validation for all fields
-
- @retval true - All datas are valid
- @retval false - At least one data is invalid
+ Read content of vector and put then into table
**/
- public boolean checkAdd() {
- //
- // Check if all fields have correct data types
- //
-
- //
- // Check VariableName
- //
- if (isEmpty(this.jTextFieldVariableName.getText())) {
- Log.err("Variable Name couldn't be empty");
- return false;
- }
-
- if (!isEmpty(this.jTextFieldVariableName.getText())) {
- if (!DataValidation.isHexWordArrayType(this.jTextFieldVariableName.getText())) {
- Log.err("Incorrect data type for Variable Name");
- return false;
+ private void showTable() {
+ clearAll();
+
+ if (vid.size() > 0) {
+ for (int index = 0; index < vid.size(); index++) {
+ model.addRow(vid.toStringVector(index));
}
}
-
- //
- // Check GuidC_Name
- //
- if (isEmpty(this.jTextFieldGuidC_Name.getText())) {
- Log.err("Guid C_Name couldn't be empty");
- return false;
+ this.jTable.repaint();
+ this.jTable.updateUI();
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonAdd) {
+ showEdit(-1);
}
-
- if (!isEmpty(this.jTextFieldGuidC_Name.getText())) {
- if (!DataValidation.isC_NameType(this.jTextFieldGuidC_Name.getText())) {
- Log.err("Incorrect data type for Guid C_Name");
- return false;
+ if (arg0.getSource() == jButtonUpdate) {
+ if (this.selectedRow < 0) {
+ Log.err("Please select one record first.");
+ return;
}
+ showEdit(selectedRow);
}
-
- //
- // Check FeatureFlag
- //
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
- if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
- Log.err("Incorrect data type for Feature Flag");
- return false;
+
+ if (arg0.getSource() == jButtonRemove) {
+ if (jTable.isEditing()) {
+ jTable.getCellEditor().stopCellEditing();
+ }
+ if (selectedRow > -1) {
+ this.model.removeRow(selectedRow);
+ this.vid.removeVariables(selectedRow);
+ selectedRow = -1;
+ this.save();
}
}
-
- return true;
}
/**
@@ -605,7 +387,8 @@ public class ModuleVariables extends IInternalFrame { if (!isEmpty(vid.getVariables(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getVariables(index).getFeatureFlag());
}
- if (vid.getVariables(index).getSupArchList() != null && vid.getVariables(index).getSupArchList().size() > 0) {
+ if (vid.getVariables(index).getSupArchList() != null
+ && vid.getVariables(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getVariables(index).getSupArchList());
}
if (!isEmpty(vid.getVariables(index).getHelp())) {
@@ -624,6 +407,36 @@ public class ModuleVariables extends IInternalFrame { }
/* (non-Javadoc)
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ *
+ */
+ public void valueChanged(ListSelectionEvent arg0) {
+ if (arg0.getValueIsAdjusting()) {
+ return;
+ }
+ ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();
+ if (lsm.isSelectionEmpty()) {
+ return;
+ } else {
+ selectedRow = lsm.getMinSelectionIndex();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ if (this.selectedRow < 0) {
+ return;
+ } else {
+ showEdit(selectedRow);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
@@ -634,182 +447,12 @@ public class ModuleVariables extends IInternalFrame { int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
- resizeComponentWidth(jTextFieldVariableName, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldGuidC_Name, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
- resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
-
- resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
- resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
- relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
- relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
- relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
+ resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
+ relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);
+ relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);
+ relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,
+ DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);
}
-
- private VariablesIdentification getCurrentVariables() {
- String arg0 = this.jTextFieldVariableName.getText();
- String arg1 = this.jTextFieldGuidC_Name.getText();
- String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
-
- String arg3 = this.jTextFieldFeatureFlag.getText();
- Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
- String arg5 = this.jTextFieldHelpText.getText();
-
- id = new VariablesIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
- return id;
- }
-
- /**
- Add current item to Vector
-
- **/
- private void addToList() {
- intSelectedItemId = vid.size();
-
- vid.addVariables(getCurrentVariables());
-
- jComboBoxList.addItem(id.getName());
- jComboBoxList.setSelectedItem(id.getName());
-
- //
- // Reset select item index
- //
- intSelectedItemId = vid.size();
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Remove current item from Vector
-
- **/
- private void removeFromList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- int intTempIndex = intSelectedItemId;
-
- jComboBoxList.removeItemAt(intSelectedItemId);
-
- vid.removeVariables(intTempIndex);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Update current item of Vector
-
- **/
- private void updateForList() {
- //
- // Check if exist items
- //
- if (this.vid.size() < 1) {
- return;
- }
-
- //
- // Backup selected item index
- //
- int intTempIndex = intSelectedItemId;
-
- vid.updateVariables(getCurrentVariables(), intTempIndex);
-
- jComboBoxList.removeAllItems();
- for (int index = 0; index < vid.size(); index++) {
- jComboBoxList.addItem(vid.getVariables(index).getName());
- }
-
- //
- // Restore selected item index
- //
- intSelectedItemId = intTempIndex;
-
- //
- // Reset select item index
- //
- jComboBoxList.setSelectedIndex(intSelectedItemId);
-
- //
- // Reload all fields of selected item
- //
- reloadFromList();
-
- //
- // Save to memory
- //
- save();
- }
-
- /**
- Refresh all fields' values of selected item of Vector
-
- **/
- private void reloadFromList() {
- if (vid.size() > 0) {
- //
- // Get selected item index
- //
- intSelectedItemId = jComboBoxList.getSelectedIndex();
-
- this.jTextFieldVariableName.setText(vid.getVariables(intSelectedItemId).getName());
- this.jTextFieldGuidC_Name.setText(vid.getVariables(intSelectedItemId).getGuid());
- this.jComboBoxUsage.setSelectedItem(vid.getVariables(intSelectedItemId).getUsage());
- this.jTextFieldHelpText.setText(vid.getVariables(intSelectedItemId).getHelp());
-
- jTextFieldFeatureFlag.setText(vid.getVariables(intSelectedItemId).getFeatureFlag());
- iCheckBoxListArch.setAllItemsUnchecked();
- iCheckBoxListArch.initCheckedItem(true, vid.getVariables(intSelectedItemId).getSupArchList());
-
- } else {
- }
-
- reloadListArea();
- }
-
- /**
- Update list area pane via the elements of Vector
-
- **/
- private void reloadListArea() {
- String strListItem = "";
- for (int index = 0; index < vid.size(); index++) {
- strListItem = strListItem + vid.getVariables(index).getName() + DataType.UNIX_LINE_SEPARATOR;
- }
- this.jTextAreaList.setText(strListItem);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- *
- * Reflesh the frame when selected item changed
- *
- */
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
- reloadFromList();
- }
- }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/BootModesDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/BootModesDlg.java new file mode 100644 index 0000000000..8a5b4b8992 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/BootModesDlg.java @@ -0,0 +1,389 @@ +/** @file
+
+ The file is used to create, update BootModes of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.BootModes.BootModesIdentification;
+
+/**
+ The class is used to create, update BootModes of MSA/MBD file
+ It extends IDialog
+
+
+
+ **/
+public class BootModesDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -3888558623432442561L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelBootModeName = null;
+
+ private JComboBox jComboBoxBootModeName = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelArch = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private BootModesIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ /**
+ This method initializes jComboBoxBootModeName
+
+ @return javax.swing.JComboBox jComboBoxBootModeName
+
+ **/
+ private JComboBox getJComboBoxBootModeName() {
+ if (jComboBoxBootModeName == null) {
+ jComboBoxBootModeName = new JComboBox();
+ jComboBoxBootModeName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxBootModeName.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxBootModeName;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 140, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 140, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 200);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Boot Modes");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inBootModesId
+
+ **/
+ private void init(BootModesIdentification inBootModesId) {
+ init();
+ this.id = inBootModesId;
+
+ if (this.id != null) {
+ this.jComboBoxBootModeName.setSelectedItem(id.getName());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inBootModesIdentification
+ @param iFrame
+
+ **/
+ public BootModesDlg(BootModesIdentification inBootModesIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inBootModesIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jComboBoxBootModeName.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelArch.setText("Arch");
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelBootModeName = new JLabel();
+ jLabelBootModeName.setText("Boot Mode Name");
+ jLabelBootModeName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
+ jLabelHelpText.setText("Help Text");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 165));
+
+ jContentPane.add(jLabelBootModeName, null);
+ jContentPane.add(getJComboBoxBootModeName(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setLocation(new java.awt.Point(0, 35));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(jLabelArch, null);
+
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes BootModeName groups and Usage type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxBootModeName, ed.getVBootModeNames());
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentBootModes();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private BootModesIdentification getCurrentBootModes() {
+ String arg0 = this.jComboBoxBootModeName.getSelectedItem().toString();
+
+ String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg2 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg3 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg4 = this.jTextFieldHelpText.getText();
+ id = new BootModesIdentification(arg0, arg1, arg2, arg3, arg4);
+ return id;
+ }
+
+ public BootModesIdentification getId() {
+ return id;
+ }
+
+ public void setId(BootModesIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/DataHubsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/DataHubsDlg.java new file mode 100644 index 0000000000..a10d8ebedc --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/DataHubsDlg.java @@ -0,0 +1,407 @@ +/** @file
+
+ The file is used to create, update DataHub of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.DataHubs.DataHubsIdentification;
+
+/**
+ The class is used to create, update DataHub of MSA/MBD file
+ It extends IInternalFrame
+
+
+
+ **/
+public class DataHubsDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -3667906991966638892L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JLabel jLabelDataHubRecord = null;
+
+ private JTextField jTextFieldDataHubRecord = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelArch = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private DataHubsIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jTextFieldDataHubRecord
+
+ @return javax.swing.JTextField jTextFieldDataHubRecord
+
+ **/
+ private JTextField getJTextFieldDataHubRecord() {
+ if (jTextFieldDataHubRecord == null) {
+ jTextFieldDataHubRecord = new JTextField();
+ jTextFieldDataHubRecord.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jTextFieldDataHubRecord.setPreferredSize(new java.awt.Dimension(320, 20));
+ jTextFieldDataHubRecord.setToolTipText("Enter the C Name of the Data Hub Record");
+ }
+ return jTextFieldDataHubRecord;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 140, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 140, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 200);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Data Hubs");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inDataHubsId
+
+ **/
+ private void init(DataHubsIdentification inDataHubsId) {
+ init();
+ this.id = inDataHubsId;
+
+ if (this.id != null) {
+ this.jTextFieldDataHubRecord.setText(id.getName());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inDataHubsIdentification
+ @param iFrame
+
+ **/
+ public DataHubsDlg(DataHubsIdentification inDataHubsIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inDataHubsIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jTextFieldDataHubRecord.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelDataHubRecord = new JLabel();
+ jLabelDataHubRecord.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelDataHubRecord.setText("Data Hub Record");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelArch.setText("Arch");
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
+ jLabelHelpText.setText("Help Text");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 165));
+
+ jContentPane.add(jLabelDataHubRecord, null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(jLabelArch, null);
+
+ jContentPane.add(getJTextFieldDataHubRecord(), null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setLocation(new java.awt.Point(0, 35));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVDataHubUsage());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentDataHubs();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check DataHubRecord
+ //
+ if (isEmpty(this.jTextFieldDataHubRecord.getText())) {
+ Log.err("Data Hub Record couldn't be empty");
+ return false;
+ }
+
+ if (!isEmpty(this.jTextFieldDataHubRecord.getText())) {
+ if (!DataValidation.isC_NameType(this.jTextFieldDataHubRecord.getText())) {
+ Log.err("Incorrect data type for Data Hub Record");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private DataHubsIdentification getCurrentDataHubs() {
+ String arg0 = this.jTextFieldDataHubRecord.getText();
+ String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg2 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg3 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg4 = this.jTextFieldHelpText.getText();
+
+ id = new DataHubsIdentification(arg0, arg1, arg2, arg3, arg4);
+ return id;
+ }
+
+ public DataHubsIdentification getId() {
+ return id;
+ }
+
+ public void setId(DataHubsIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/EventsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/EventsDlg.java new file mode 100644 index 0000000000..11510fd4b3 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/EventsDlg.java @@ -0,0 +1,436 @@ +/** @file
+
+ The file is used to create, update Event of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.Events.EventsIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update Event of MSA/MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class EventsDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -4396143706422842331L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelEventType = null;
+
+ private JLabel jLabelC_Name = null;
+
+ private JComboBox jComboBoxGuidC_Name = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JComboBox jComboBoxEventsType = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelArch = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private EventsIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ /**
+ This method initializes jTextFieldC_Name
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JComboBox getJComboBoxGuidC_Name() {
+ if (jComboBoxGuidC_Name == null) {
+ jComboBoxGuidC_Name = new JComboBox();
+ jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Event");
+ }
+ return jComboBoxGuidC_Name;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ * This method initializes jComboBoxEventsType
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getJComboBoxEventsType() {
+ if (jComboBoxEventsType == null) {
+ jComboBoxEventsType = new JComboBox();
+ jComboBoxEventsType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxEventsType.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxEventsType
+ .setToolTipText("Select Create event if the Module has an event that is waiting to be signaled. Select Signal if the Module will signal all events in an event group. Signal Event The events are named by GUID.");
+ }
+ return jComboBoxEventsType;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 225);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Events");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inEventsId
+
+ **/
+ private void init(EventsIdentification inEventsId) {
+ init();
+ this.id = inEventsId;
+
+ if (this.id != null) {
+ this.jComboBoxGuidC_Name.setSelectedItem(id.getName());
+ this.jComboBoxEventsType.setSelectedItem(id.getType());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+
+ jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inEventsIdentification
+ @param iFrame
+
+ **/
+ public EventsDlg(EventsIdentification inEventsIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inEventsIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jComboBoxGuidC_Name.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelArch.setText("Arch");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelC_Name = new JLabel();
+ jLabelC_Name.setText("Guid C_Name");
+ jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelEventType = new JLabel();
+ jLabelEventType.setText("Event Type");
+ jLabelEventType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
+ jLabelHelpText.setText("Help Text");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 190));
+
+ jContentPane.add(jLabelEventType, null);
+ jContentPane.add(jLabelC_Name, null);
+ jContentPane.add(getJComboBoxGuidC_Name(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+ jContentPane.add(getJComboBoxEventsType(), null);
+
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes events groups and usage type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxEventsType, ed.getVEventType());
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVEventUsage());
+ Tools.generateComboBoxByVector(jComboBoxGuidC_Name, wt.getAllGuidDeclarationsFromWorkspace());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentEvents();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check Name
+ //
+ if (isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
+ Log.err("Event Name couldn't be empty");
+ return false;
+ }
+
+ if (!isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
+ if (!DataValidation.isC_NameType(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
+ Log.err("Incorrect data type for Event Name");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private EventsIdentification getCurrentEvents() {
+ String arg0 = this.jComboBoxGuidC_Name.getSelectedItem().toString();
+ String arg1 = this.jComboBoxEventsType.getSelectedItem().toString();
+ String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg3 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg4 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg5 = this.jTextFieldHelpText.getText();
+ id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ return id;
+ }
+
+ public EventsIdentification getId() {
+ return id;
+ }
+
+ public void setId(EventsIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ExternsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ExternsDlg.java new file mode 100644 index 0000000000..c85a2231c3 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ExternsDlg.java @@ -0,0 +1,419 @@ +/** @file
+
+ The file is used to create, update DataHub of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.module.Identifications.Externs.ExternsIdentification;
+
+/**
+ The class is used to create, update DataHub of MSA/MBD file
+ It extends IInternalFrame
+
+
+
+ **/
+public class ExternsDlg extends IDialog implements ItemListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -7382008402932047191L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelName = null;
+
+ private JComboBox jComboBoxType = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JComboBox jComboBoxPcdIsDriver = null;
+
+ private JLabel jLabelC_Name = null;
+
+ private JTextField jTextFieldC_Name = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JLabel jLabelArch = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private ExternsIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ /**
+ This method initializes jComboBoxType
+
+ @return javax.swing.JComboBox jComboBoxType
+
+ **/
+ private JComboBox getJComboBoxType() {
+ if (jComboBoxType == null) {
+ jComboBoxType = new JComboBox();
+ jComboBoxType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxType.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxType.addItemListener(this);
+ }
+ return jComboBoxType;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ * This method initializes jComboBoxPcdIsDriver
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getJComboBoxPcdIsDriver() {
+ if (jComboBoxPcdIsDriver == null) {
+ jComboBoxPcdIsDriver = new JComboBox();
+ jComboBoxPcdIsDriver.setLocation(new java.awt.Point(160, 35));
+ jComboBoxPcdIsDriver.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxPcdIsDriver.setSize(new java.awt.Dimension(320, 20));
+ jComboBoxPcdIsDriver.addItemListener(this);
+ }
+ return jComboBoxPcdIsDriver;
+ }
+
+ /**
+ This method initializes jTextFieldC_Name
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldC_Name() {
+ if (jTextFieldC_Name == null) {
+ jTextFieldC_Name = new JTextField();
+ jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jTextFieldC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldC_Name;
+ }
+
+ /**
+ This method initializes jTextFieldFeatureFlag
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 120, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 120, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 180);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Externs");
+ initFrame();
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inExternsId
+
+ **/
+ private void init(ExternsIdentification inExternsId) {
+ init();
+ this.id = inExternsId;
+
+ if (this.id != null) {
+ if (id.getType().equals(EnumerationData.EXTERNS_PCD_IS_DRIVER)) {
+ this.jComboBoxPcdIsDriver.setSelectedItem(id.getName());
+ } else {
+ this.jTextFieldC_Name.setText(id.getName());
+ }
+ this.jComboBoxType.setSelectedItem(id.getType());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inBootModesIdentification
+ @param iFrame
+
+ **/
+ public ExternsDlg(ExternsIdentification inExternsIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inExternsIdentification);
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelC_Name = new JLabel();
+ jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelC_Name.setText("Value");
+ jLabelName = new JLabel();
+ jLabelName.setText("Choose Type");
+ jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelArch.setText("Arch");
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 145));
+
+ jContentPane.add(jLabelName, null);
+ jContentPane.add(getJComboBoxType(), null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+
+ jContentPane.add(getJComboBoxPcdIsDriver(), null);
+ jContentPane.add(jLabelC_Name, null);
+ jContentPane.add(getJTextFieldC_Name(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type and Externs type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(this.jComboBoxType, ed.getVExternTypes());
+ Tools.generateComboBoxByVector(this.jComboBoxPcdIsDriver, ed.getVPcdDriverTypes());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentExterns();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // When and only When type is not "Pcd Is Driver"
+ //
+ if (!this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_PCD_IS_DRIVER)) {
+ //
+ // Check CName
+ //
+ if (isEmpty(this.jTextFieldC_Name.getText())) {
+ Log.err("Value couldn't be empty");
+ return false;
+ }
+
+ if (!isEmpty(this.jTextFieldC_Name.getText())) {
+ if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_SPECIFICATION)) {
+ if (!DataValidation.isSentence(this.jTextFieldC_Name.getText())) {
+ Log.err("Incorrect data type for Specification");
+ return false;
+ }
+ } else {
+ if (!DataValidation.isC_NameType(this.jTextFieldC_Name.getText())) {
+ Log.err("Incorrect data type for C_Name");
+ return false;
+ }
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+ } else {
+ if (this.jComboBoxPcdIsDriver.getSelectedItem().toString().equals(DataType.EMPTY_SELECT_ITEM)) {
+ Log.err("You must select one PCD DRIVER type");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private ExternsIdentification getCurrentExterns() {
+ String arg0 = "";
+ if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_PCD_IS_DRIVER)) {
+ arg0 = this.jComboBoxPcdIsDriver.getSelectedItem().toString();
+ } else {
+ arg0 = this.jTextFieldC_Name.getText();
+ }
+ String arg1 = this.jComboBoxType.getSelectedItem().toString();
+
+ String arg2 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg3 = this.jArchCheckBox.getSelectedItemsVector();
+
+ id = new ExternsIdentification(arg0, arg1, arg2, arg3);
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ *
+ * Reflesh the frame when selected item changed
+ *
+ */
+ public void itemStateChanged(ItemEvent arg0) {
+ if (arg0.getSource() == jComboBoxType && arg0.getStateChange() == ItemEvent.SELECTED) {
+ if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_PCD_IS_DRIVER)) {
+ this.jComboBoxPcdIsDriver.setVisible(true);
+ this.jTextFieldC_Name.setVisible(false);
+ } else {
+ this.jComboBoxPcdIsDriver.setVisible(false);
+ this.jTextFieldC_Name.setVisible(true);
+ }
+ }
+ }
+
+ public ExternsIdentification getId() {
+ return id;
+ }
+
+ public void setId(ExternsIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/GuidsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/GuidsDlg.java new file mode 100644 index 0000000000..04f5232dd6 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/GuidsDlg.java @@ -0,0 +1,403 @@ +/** @file
+
+ The file is used to create, update Guids of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.Guids.GuidsIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update Guids of MSA/MBD file
+ It extends IInternalFrame
+
+
+
+ **/
+public class GuidsDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 6710858997766979803L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelC_Name = null;
+
+ private JComboBox jComboBoxCName = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelArch = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private GuidsIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ /**
+ This method initializes jTextFieldC_Name
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JComboBox getJComboBoxCName() {
+ if (jComboBoxCName == null) {
+ jComboBoxCName = new JComboBox();
+ jComboBoxCName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxCName;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jTextFieldFeatureFlag
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 140, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 140, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 200);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Guids");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inGuidsId
+
+ **/
+ private void init(GuidsIdentification inGuidsId) {
+ init();
+ this.id = inGuidsId;
+
+ if (this.id != null) {
+ this.jComboBoxCName.setSelectedItem(id.getName());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inGuidsIdentification
+ @param iFrame
+
+ **/
+ public GuidsDlg(GuidsIdentification inGuidsIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inGuidsIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jComboBoxUsage.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelC_Name = new JLabel();
+ jLabelC_Name.setText("C_Name");
+ jLabelC_Name.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelArch.setText("Arch");
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
+ jLabelHelpText.setText("Help Text");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 165));
+
+ jContentPane.add(jLabelC_Name, null);
+ jContentPane.add(getJComboBoxCName(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setLocation(new java.awt.Point(0, 35));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllGuidDeclarationsFromWorkspace());
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVGuidUsage());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentGuids();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check Name
+ //
+ if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
+ if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
+ Log.err("Incorrect data type for Guid Name");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private GuidsIdentification getCurrentGuids() {
+ String arg0 = this.jComboBoxCName.getSelectedItem().toString();
+ String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg2 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg3 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg4 = this.jTextFieldHelpText.getText();
+
+ id = new GuidsIdentification(arg0, arg1, arg2, arg3, arg4);
+ return id;
+ }
+
+ public GuidsIdentification getId() {
+ return id;
+ }
+
+ public void setId(GuidsIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/HiiPackagesDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/HiiPackagesDlg.java new file mode 100644 index 0000000000..e3cf02b5fe --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/HiiPackagesDlg.java @@ -0,0 +1,406 @@ +/** @file
+
+ The file is used to create, update Formset of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.HiiPackages.HiiPackagesIdentification;
+
+/**
+ The class is used to create, update Formset of MSA/MBD file
+ It extends IInternalFrame
+
+
+
+ **/
+public class HiiPackagesDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -6851574146786158116L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelName = null;
+
+ private JTextField jTextFieldName = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelArch = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private HiiPackagesIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ /**
+ This method initializes jTextFieldName
+
+ @return javax.swing.JTextField jTextFieldName
+
+ **/
+ private JTextField getJTextFieldName() {
+ if (jTextFieldName == null) {
+ jTextFieldName = new JTextField();
+ jTextFieldName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jTextFieldName.setPreferredSize(new java.awt.Dimension(320, 20));
+ jTextFieldName.setToolTipText("Enter the C Name of the HII Package");
+ }
+ return jTextFieldName;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 140, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 140, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 200);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Hii Packages");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inHiiPackagesId
+
+ **/
+ private void init(HiiPackagesIdentification inHiiPackagesId) {
+ init();
+ this.id = inHiiPackagesId;
+
+ if (this.id != null) {
+ this.jTextFieldName.setText(id.getName());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inHiiPackagesIdentification
+ @param iFrame
+
+ **/
+ public HiiPackagesDlg(HiiPackagesIdentification inHiiPackagesIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inHiiPackagesIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jTextFieldName.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelName = new JLabel();
+ jLabelName.setText("Name");
+ jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelArch.setText("Arch");
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
+ jLabelHelpText.setText("Help Text");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 165));
+
+ jContentPane.add(jLabelName, null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJTextFieldName(), null);
+ jContentPane.add(getJComboBoxUsage(), null);
+
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setLocation(new java.awt.Point(0, 35));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVHiiPackageUsage());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentHiiPackages();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check Hii Package Name
+ //
+ if (isEmpty(this.jTextFieldName.getText())) {
+ Log.err("Hii Package Name Record couldn't be empty");
+ return false;
+ }
+
+ if (!isEmpty(this.jTextFieldName.getText())) {
+ if (!DataValidation.isC_NameType(this.jTextFieldName.getText())) {
+ Log.err("Incorrect data type for Hii Package Name");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private HiiPackagesIdentification getCurrentHiiPackages() {
+ String arg0 = this.jTextFieldName.getText();
+ String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg2 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg3 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg4 = this.jTextFieldHelpText.getText();
+
+ id = new HiiPackagesIdentification(arg0, arg1, arg2, arg3, arg4);
+ return id;
+ }
+
+ public HiiPackagesIdentification getId() {
+ return id;
+ }
+
+ public void setId(HiiPackagesIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/HobsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/HobsDlg.java new file mode 100644 index 0000000000..d12841439d --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/HobsDlg.java @@ -0,0 +1,428 @@ +/** @file
+
+ The file is used to create, update Hob of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.Hobs.HobsIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update Hob of MSA/MBD file
+ It extends IInternalFrame
+
+ **/
+public class HobsDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -553473437579358325L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabel = null;
+
+ private JComboBox jComboBoxGuidC_Name = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JLabel jLabelHobType = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JComboBox jComboBoxHobType = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private JLabel jLabelArch = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private HobsIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ /**
+ This method initializes jTextField
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JComboBox getJComboBoxGuidC_Name() {
+ if (jComboBoxGuidC_Name == null) {
+ jComboBoxGuidC_Name = new JComboBox();
+ jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Hob");
+ }
+ return jComboBoxGuidC_Name;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jComboBoxHobType
+
+ @return javax.swing.JComboBox jComboBoxHobType
+
+ **/
+ private JComboBox getJComboBoxHobType() {
+ if (jComboBoxHobType == null) {
+ jComboBoxHobType = new JComboBox();
+ jComboBoxHobType.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxHobType.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxHobType;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 225);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Hobs");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inHobsId
+
+ **/
+ private void init(HobsIdentification inHobsId) {
+ init();
+ this.id = inHobsId;
+
+ if (this.id != null) {
+ this.jComboBoxGuidC_Name.setSelectedItem(id.getName());
+ this.jComboBoxHobType.setSelectedItem(id.getType());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inHobsIdentification
+ @param iFrame
+
+ **/
+ public HobsDlg(HobsIdentification inHobsIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inHobsIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jComboBoxGuidC_Name.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jComboBoxHobType.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ public JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelArch.setText("Arch");
+ jLabelHobType = new JLabel();
+ jLabelHobType.setText("Hob Type");
+ jLabelHobType.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabel = new JLabel();
+ jLabel.setText("Guid C_Name");
+ jLabel.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
+ jLabelHelpText.setText("Help Text");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 190));
+
+ jContentPane.add(jLabel, null);
+ jContentPane.add(getJComboBoxGuidC_Name(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(jLabelHobType, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(getJComboBoxHobType(), null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jContentPane.add(jStarLabel1, null);
+
+ jContentPane.add(jLabelArch, null);
+
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type and Hob type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVHobUsage());
+ Tools.generateComboBoxByVector(jComboBoxHobType, ed.getVHobType());
+ Tools.generateComboBoxByVector(jComboBoxGuidC_Name, wt.getAllGuidDeclarationsFromWorkspace());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentHobs();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check Name
+ //
+ if (isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
+ Log.err("Hob Name couldn't be empty");
+ return false;
+ }
+
+ if (!isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
+ if (!DataValidation.isC_NameType(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {
+ Log.err("Incorrect data type for Hob Name");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private HobsIdentification getCurrentHobs() {
+ String arg0 = this.jComboBoxGuidC_Name.getSelectedItem().toString();
+ String arg1 = this.jComboBoxHobType.getSelectedItem().toString();
+ String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg3 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg4 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg5 = this.jTextFieldHelpText.getText();
+ id = new HobsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ return id;
+ }
+
+ public HobsIdentification getId() {
+ return id;
+ }
+
+ public void setId(HobsIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/LibraryClassDefsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/LibraryClassDefsDlg.java new file mode 100644 index 0000000000..00fe724ae2 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/LibraryClassDefsDlg.java @@ -0,0 +1,532 @@ +/** @file
+
+ The file is used to create, update Library Class Definition of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
+import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update Library Class Definition of MSA/MBD file
+ It extends IInternalFrame
+
+ **/
+public class LibraryClassDefsDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -1743248695411382857L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JComboBox jComboBoxLibraryClassName = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JLabel jLabelLibraryClassName = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JLabel jLabelRecommendedInstanceVersion = null;
+
+ private JTextField jTextFieldRecommendedInstanceVersion = null;
+
+ private JLabel jLabelRecommendedInstanceGuid = null;
+
+ private JTextField jTextFieldRecommendedInstanceGuid = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelArch = null;
+
+ private JLabel jLabelModuleList = null;
+
+ private JScrollPane jScrollPaneModuleList = null;
+
+ private ICheckBoxList iCheckBoxListModule = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not for UI
+ //
+ private EnumerationData ed = new EnumerationData();
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ private LibraryClassIdentification lcid = null;
+
+ /**
+ This method initializes jComboBoxSelect
+
+ @return javax.swing.JComboBox jComboBoxSelect
+
+ **/
+ private JComboBox getJComboBoxLibraryClassName() {
+ if (jComboBoxLibraryClassName == null) {
+ jComboBoxLibraryClassName = new JComboBox();
+ jComboBoxLibraryClassName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxLibraryClassName.setPreferredSize(new Dimension(320, 20));
+ jComboBoxLibraryClassName.setEnabled(true);
+ }
+ return jComboBoxLibraryClassName;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxUsage.setPreferredSize(new Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ * This method initializes jTextFieldRecommendedInstanceVersion
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldRecommendedInstanceVersion() {
+ if (jTextFieldRecommendedInstanceVersion == null) {
+ jTextFieldRecommendedInstanceVersion = new JTextField();
+ jTextFieldRecommendedInstanceVersion.setPreferredSize(new java.awt.Dimension(260, 20));
+ jTextFieldRecommendedInstanceVersion.setSize(new java.awt.Dimension(260, 20));
+ jTextFieldRecommendedInstanceVersion.setLocation(new java.awt.Point(220, 85));
+ jTextFieldRecommendedInstanceVersion.setVisible(false);
+ }
+ return jTextFieldRecommendedInstanceVersion;
+ }
+
+ /**
+ * This method initializes jTextFieldRecommendedInstanceGuid
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldRecommendedInstanceGuid() {
+ if (jTextFieldRecommendedInstanceGuid == null) {
+ jTextFieldRecommendedInstanceGuid = new JTextField();
+ jTextFieldRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(220, 110, 190, 20));
+ jTextFieldRecommendedInstanceGuid.setPreferredSize(new java.awt.Dimension(190, 20));
+ jTextFieldRecommendedInstanceGuid.setVisible(false);
+ }
+ return jTextFieldRecommendedInstanceGuid;
+ }
+
+ /**
+ * This method initializes jButtonGenerateGuid
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 110, 65, 20));
+ jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.setVisible(false);
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes iCheckBoxListArch
+
+ @return ICheckBoxList
+ **/
+ private ICheckBoxList getICheckBoxListSupModuleList() {
+ if (iCheckBoxListModule == null) {
+ iCheckBoxListModule = new ICheckBoxList();
+ }
+ return iCheckBoxListModule;
+ }
+
+ /**
+ This method initializes jScrollPaneModuleList
+
+ @return javax.swing.JScrollPane
+
+ **/
+ private JScrollPane getJScrollPaneModuleList() {
+ if (jScrollPaneModuleList == null) {
+ jScrollPaneModuleList = new JScrollPane();
+ jScrollPaneModuleList.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
+ jScrollPaneModuleList.setPreferredSize(new java.awt.Dimension(320, 80));
+ jScrollPaneModuleList.setViewportView(getICheckBoxListSupModuleList());
+ }
+ return jScrollPaneModuleList;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 225, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 225, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public LibraryClassDefsDlg(LibraryClassIdentification inLibraryClassIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inLibraryClassIdentification);
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Library Class Definitions");
+ this.setBounds(new java.awt.Rectangle(0, 0, 500, 295));
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init(LibraryClassIdentification inLibraryClassIdentification) {
+ init();
+ this.lcid = inLibraryClassIdentification;
+ if (lcid != null) {
+ this.jComboBoxLibraryClassName.setSelectedItem(lcid.getLibraryClassName());
+ this.jComboBoxUsage.setSelectedItem(lcid.getUsage());
+ this.jTextFieldRecommendedInstanceVersion.setText(lcid.getRecommendedInstanceVersion());
+ this.jTextFieldRecommendedInstanceGuid.setText(lcid.getRecommendedInstanceGuid());
+ this.jTextFieldFeatureFlag.setText(lcid.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(lcid.getSupArchList());
+ this.iCheckBoxListModule.setAllItemsUnchecked();
+ this.iCheckBoxListModule.initCheckedItem(true, lcid.getSupModuleList());
+ this.jTextFieldHelpText.setText(lcid.getHelp());
+ }
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jComboBoxLibraryClassName.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
+ jLabelHelpText.setText("Help Text");
+ jLabelModuleList = new JLabel();
+ jLabelModuleList.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelModuleList.setText("Sup Module List");
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelArch.setText("Sup Arch List");
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelRecommendedInstanceGuid = new JLabel();
+ jLabelRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(15, 110, 200, 20));
+ jLabelRecommendedInstanceGuid.setText("Recommended Instance Guid");
+ jLabelRecommendedInstanceGuid.setVisible(false);
+ jLabelRecommendedInstanceVersion = new JLabel();
+ jLabelRecommendedInstanceVersion.setBounds(new java.awt.Rectangle(15, 85, 200, 20));
+ jLabelRecommendedInstanceVersion.setText("Recommended Instance Version");
+ jLabelRecommendedInstanceVersion.setVisible(false);
+ jLabelLibraryClassName = new JLabel();
+ jLabelLibraryClassName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelLibraryClassName.setText("Library Class Name");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelUsage.setText("Usage");
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 245));
+
+ jContentPane.add(getJComboBoxLibraryClassName(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(jLabelLibraryClassName, null);
+ jContentPane.add(jLabelRecommendedInstanceVersion, null);
+ jContentPane.add(getJTextFieldRecommendedInstanceVersion(), null);
+ jContentPane.add(jLabelRecommendedInstanceGuid, null);
+ jContentPane.add(getJTextFieldRecommendedInstanceGuid(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(jLabelArch, null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setLocation(new java.awt.Point(0, 35));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+ jContentPane.add(jLabelModuleList, null);
+ jContentPane.add(getJScrollPaneModuleList(), null);
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes all existing libraries and usage types
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxLibraryClassName, wt.getAllLibraryClassDefinitionsFromWorkspace());
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVLibraryUsage());
+ this.iCheckBoxListModule.setAllItems(ed.getVFrameworkModuleTypes());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ this.jTextFieldRecommendedInstanceGuid.setText(Tools.generateUuidString());
+ }
+
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentLibraryClass();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check LibraryClass
+ //
+ if (this.jComboBoxLibraryClassName.getSelectedItem() == null) {
+ Log.err("No Library Class can be added");
+ return false;
+ }
+ if (!DataValidation.isLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString())) {
+ Log.err("Incorrect data type for Library Class");
+ return false;
+ }
+
+ //
+ // Check RecommendedInstanceVersion
+ //
+ // if (!isEmpty(this.jTextFieldRecommendedInstanceVersion.getText())) {
+ // if (!DataValidation.isRecommendedInstanceVersion(this.jTextFieldRecommendedInstanceVersion.getText())) {
+ // Log.err("Incorrect data type for Recommended Instance Version");
+ // return false;
+ // }
+ // }
+
+ //
+ // Check RecommendedInstanceGuid
+ //
+ // if (!isEmpty(this.jTextFieldRecommendedInstanceGuid.getText())) {
+ // if (!DataValidation.isGuid(this.jTextFieldRecommendedInstanceGuid.getText())) {
+ // Log.err("Incorrect data type for Recommended Instance Guid");
+ // return false;
+ // }
+ // }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private LibraryClassIdentification getCurrentLibraryClass() {
+ String name = this.jComboBoxLibraryClassName.getSelectedItem().toString();
+ String usage = this.jComboBoxUsage.getSelectedItem().toString();
+ String version = this.jTextFieldRecommendedInstanceVersion.getText();
+ String guid = this.jTextFieldRecommendedInstanceGuid.getText();
+ String featureFlag = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arch = this.jArchCheckBox.getSelectedItemsVector();
+ Vector<String> module = this.iCheckBoxListModule.getAllCheckedItemsString();
+ String help = this.jTextFieldHelpText.getText();
+ lcid = new LibraryClassIdentification(name, usage, version, guid, arch, featureFlag, module, help);
+ return lcid;
+ }
+
+ public LibraryClassIdentification getLcid() {
+ return lcid;
+ }
+
+ public void setLcid(LibraryClassIdentification lcid) {
+ this.lcid = lcid;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/PCDsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/PCDsDlg.java new file mode 100644 index 0000000000..7972926d56 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/PCDsDlg.java @@ -0,0 +1,486 @@ +/** @file
+
+ The file is used to create, update PCD of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdCodedIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update PCD of MSA/MBD file
+ It extends IInternalFrame
+
+
+
+ **/
+public class PCDsDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 2227717658188438696L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelItemType = null;
+
+ private JLabel jLabelC_Name = null;
+
+ private JComboBox jComboBoxItemType = null;
+
+ private JComboBox jComboBoxCName = null;
+
+ private JLabel jLabelDefaultValue = null;
+
+ private JTextField jTextFieldDefaultValue = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private StarLabel jStarLabel3 = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelTokenSpaceGuid = null;
+
+ private JTextField jTextFieldTokenSpaceGuid = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelArch = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private PcdCodedIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ /**
+ This method initializes jComboBoxItemType
+
+ @return javax.swing.JComboBox jComboBoxItemType
+
+ **/
+ private JComboBox getJComboBoxItemType() {
+ if (jComboBoxItemType == null) {
+ jComboBoxItemType = new JComboBox();
+ jComboBoxItemType.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxItemType.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxItemType;
+ }
+
+ /**
+ This method initializes jTextFieldC_Name
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JComboBox getJComboBoxCName() {
+ if (jComboBoxCName == null) {
+ jComboBoxCName = new JComboBox();
+ jComboBoxCName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxCName;
+ }
+
+ /**
+ This method initializes jTextFieldDefaultValue
+
+ @return javax.swing.JTextField jTextFieldDefaultValue
+
+ **/
+ private JTextField getJTextFieldDefaultValue() {
+ if (jTextFieldDefaultValue == null) {
+ jTextFieldDefaultValue = new JTextField();
+ jTextFieldDefaultValue.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldDefaultValue.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldDefaultValue;
+ }
+
+ /**
+ * This method initializes jTextFieldHelpText
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ * This method initializes jTextFieldTokenSpaceGuid
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldTokenSpaceGuid() {
+ if (jTextFieldTokenSpaceGuid == null) {
+ jTextFieldTokenSpaceGuid = new JTextField();
+ jTextFieldTokenSpaceGuid.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldTokenSpaceGuid.setPreferredSize(new java.awt.Dimension(320, 20));
+ jTextFieldTokenSpaceGuid.setVisible(false);
+ }
+ return jTextFieldTokenSpaceGuid;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 225);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Pcd Coded");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inPcdCodedId
+
+ **/
+ private void init(PcdCodedIdentification inPcdCodedId) {
+ init();
+ this.id = inPcdCodedId;
+
+ if (this.id != null) {
+ this.jComboBoxCName.setSelectedItem(id.getName());
+ this.jTextFieldTokenSpaceGuid.setText(id.getGuid());
+ this.jTextFieldDefaultValue.setText(id.getValue());
+ this.jTextFieldHelpText.setText(id.getHelp());
+ this.jComboBoxItemType.setSelectedItem(id.getType());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inPcdCodedId
+ @param iFrame
+
+ **/
+ public PCDsDlg(PcdCodedIdentification inPcdCodedId, IFrame iFrame) {
+ super(iFrame, true);
+ init(inPcdCodedId);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jTextFieldDefaultValue.setEnabled(!isView);
+ this.jComboBoxItemType.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelArch.setText("Sup Arch List");
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelTokenSpaceGuid = new JLabel();
+ jLabelTokenSpaceGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelTokenSpaceGuid.setText("Token Space C_Name");
+ jLabelTokenSpaceGuid.setVisible(false);
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelHelpText.setText("Help Text");
+ jLabelC_Name = new JLabel();
+ jLabelC_Name.setText("C_Name");
+ jLabelC_Name.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelDefaultValue = new JLabel();
+ jLabelDefaultValue.setText("Default Value");
+ jLabelDefaultValue.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelItemType = new JLabel();
+ jLabelItemType.setText("Item Type");
+ jLabelItemType.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 190));
+
+ jContentPane.add(jLabelItemType, null);
+ jContentPane.add(jLabelC_Name, null);
+ jContentPane.add(getJComboBoxCName(), null);
+ jContentPane.add(jLabelDefaultValue, null);
+ jContentPane.add(getJTextFieldDefaultValue(), null);
+ jContentPane.add(getJComboBoxItemType(), null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setLocation(new java.awt.Point(0, 35));
+ jStarLabel3 = new StarLabel();
+ jStarLabel3.setLocation(new java.awt.Point(0, 85));
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+ jContentPane.add(jStarLabel3, null);
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+
+ jContentPane.add(jLabelTokenSpaceGuid, null);
+ jContentPane.add(getJTextFieldTokenSpaceGuid(), null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type, Item type and Datum type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllPcdDeclarationsFromWorkspace());
+ Tools.generateComboBoxByVector(jComboBoxItemType, ed.getVPcdItemTypes());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentPcdCoded();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check C_Name
+ //
+ if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
+ if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
+ Log.err("Incorrect data type for C_Name");
+ return false;
+ }
+ }
+
+ //
+ // Check TokenSpaceGuid
+ //
+ // if (!isEmpty(this.jTextFieldTokenSpaceGuid.getText())) {
+ // if (!DataValidation.isC_NameType(this.jTextFieldTokenSpaceGuid.getText())) {
+ // Log.err("Incorrect data type for Token Space C_Name");
+ // return false;
+ // }
+ // }
+
+ //
+ // Check DefaultValue
+ //
+ if (!isEmpty(this.jTextFieldDefaultValue.getText())) {
+ if (!DataValidation.isDefaultValueType(this.jTextFieldDefaultValue.getText())) {
+ Log.err("Incorrect data type for Default Value");
+ return false;
+ }
+ }
+
+ //
+ // Check HelpText
+ //
+ if (isEmpty(this.jTextFieldHelpText.getText())) {
+ Log.err("Help Text couldn't be empty");
+ return false;
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private PcdCodedIdentification getCurrentPcdCoded() {
+ String arg0 = this.jComboBoxCName.getSelectedItem().toString();
+ String arg1 = this.jTextFieldTokenSpaceGuid.getText();
+
+ String arg2 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg3 = this.jArchCheckBox.getSelectedItemsVector();
+
+ String arg4 = this.jTextFieldDefaultValue.getText();
+ String arg5 = this.jTextFieldHelpText.getText();
+ String arg6 = this.jComboBoxItemType.getSelectedItem().toString();
+ id = new PcdCodedIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+ return id;
+ }
+
+ public PcdCodedIdentification getId() {
+ return id;
+ }
+
+ public void setId(PcdCodedIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/PackageDepDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/PackageDepDlg.java new file mode 100644 index 0000000000..0f96bdf318 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/PackageDepDlg.java @@ -0,0 +1,443 @@ +/** @file
+
+ The file is used to create, update Include of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.PackageDependencies.PackageDependenciesIdentification;
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update Include of MSA/MBD file
+ It extends IInternalFrame
+
+
+
+ **/
+public class PackageDepDlg extends IDialog implements ItemListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 3465193035145152131L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelPackageName = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private JComboBox jComboBoxPackageName = null;
+
+ private JLabel jLabelPackageGuid = null;
+
+ private JTextField jTextFieldPackageGuid = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JLabel jLabelPackageVersion = null;
+
+ private JTextField jTextFieldPackageVersion = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelArch = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private PackageDependenciesIdentification pdid = null;
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ private Vector<PackageIdentification> vPackage = wt.getAllPackages();
+
+ /**
+ * This method initializes jComboBoxPackageName
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getJComboBoxPackageName() {
+ if (jComboBoxPackageName == null) {
+ jComboBoxPackageName = new JComboBox();
+ jComboBoxPackageName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxPackageName.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxPackageName.setToolTipText("If your Module requires a package list that here.");
+ jComboBoxPackageName.addItemListener(this);
+ }
+ return jComboBoxPackageName;
+ }
+
+ /**
+ * This method initializes jTextFieldPackageGuid
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldPackageGuid() {
+ if (jTextFieldPackageGuid == null) {
+ jTextFieldPackageGuid = new JTextField();
+ jTextFieldPackageGuid.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jTextFieldPackageGuid.setPreferredSize(new java.awt.Dimension(320, 20));
+ jTextFieldPackageGuid.setEditable(false);
+ jTextFieldPackageGuid.setVisible(false);
+ }
+ return jTextFieldPackageGuid;
+ }
+
+ /**
+ * This method initializes jButtonGenerateGuid
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 35, 65, 20));
+ jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ jButtonGenerateGuid.setVisible(false);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ * This method initializes jTextFieldPackageVersion
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldPackageVersion() {
+ if (jTextFieldPackageVersion == null) {
+ jTextFieldPackageVersion = new JTextField();
+ jTextFieldPackageVersion.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jTextFieldPackageVersion.setPreferredSize(new java.awt.Dimension(320, 20));
+ jTextFieldPackageVersion
+ .setToolTipText("If this module depends on a specific version of a package, enter the package version here. If the module can use the latest version that does not break backward compatibility, leave this field blank");
+ }
+ return jTextFieldPackageVersion;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 115, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 115, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 175);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Package Dependencies");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init(PackageDependenciesIdentification inPackageDependenciesIdentification) {
+ init();
+ this.pdid = inPackageDependenciesIdentification;
+ if (pdid != null) {
+ this.jComboBoxPackageName.setSelectedItem(pdid.getName());
+ this.jTextFieldPackageVersion.setText(pdid.getVersion());
+ this.jTextFieldPackageGuid.setText(pdid.getGuid());
+ jTextFieldFeatureFlag.setText(pdid.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(pdid.getSupArchList());
+ }
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public PackageDepDlg(PackageDependenciesIdentification inPackageDependenciesIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inPackageDependenciesIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jComboBoxPackageName.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelArch.setText("Sup Arch List");
+ jLabelPackageVersion = new JLabel();
+ jLabelPackageVersion.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelPackageVersion.setText("Package Version");
+ jLabelPackageGuid = new JLabel();
+ jLabelPackageGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelPackageGuid.setText("Package Guid");
+ jLabelPackageGuid.setVisible(false);
+ jLabelPackageName = new JLabel();
+ jLabelPackageName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelPackageName.setText("Package Name");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 140));
+
+ jContentPane.add(jLabelPackageName, null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(getJComboBoxPackageName(), null);
+ jContentPane.add(jLabelPackageGuid, null);
+ jContentPane.add(getJTextFieldPackageGuid(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(jLabelPackageVersion, null);
+ jContentPane.add(getJTextFieldPackageVersion(), null);
+
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentPackageDependencies();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ This method initializes Usage type, Package type and Arch type
+
+ **/
+ private void initFrame() {
+ for (int index = 0; index < vPackage.size(); index++) {
+ jComboBoxPackageName.addItem(vPackage.elementAt(index).getName());
+ }
+ }
+
+ /**
+ Data validation for all fields before add current item to Vector
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check PackageGuid
+ //
+// if (!isEmpty(this.jTextFieldPackageGuid.getText())) {
+// if (!DataValidation.isGuid(this.jTextFieldPackageGuid.getText())) {
+// Log.err("Incorrect data type for Package Guid");
+// return false;
+// }
+// }
+
+ //
+ // Check PackageVersion
+ //
+ if (!isEmpty(this.jTextFieldPackageVersion.getText())) {
+ if (!DataValidation.isVersion(this.jTextFieldPackageVersion.getText())) {
+ Log.err("Incorrect data type for Package Version");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+ private PackageDependenciesIdentification getCurrentPackageDependencies() {
+ String arg0 = this.jComboBoxPackageName.getSelectedItem().toString();
+ String arg1 = this.jTextFieldPackageVersion.getText();
+ String arg2 = this.jTextFieldPackageGuid.getText();
+
+ String arg3 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg4 = this.jArchCheckBox.getSelectedItemsVector();
+ pdid = new PackageDependenciesIdentification(arg0, arg1, arg2, arg3, arg4);
+ return pdid;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ *
+ * Reflesh the frame when selected item changed
+ *
+ */
+ public void itemStateChanged(ItemEvent arg0) {
+ if (arg0.getSource() == this.jComboBoxPackageName && arg0.getStateChange() == ItemEvent.SELECTED) {
+ for (int index = 0; index < vPackage.size(); index++) {
+ if (this.jComboBoxPackageName.getSelectedItem().toString().equals(vPackage.get(index).getName())) {
+ this.jTextFieldPackageGuid.setText(vPackage.get(index).getGuid());
+ }
+ }
+ }
+ }
+
+ public PackageDependenciesIdentification getPdid() {
+ return pdid;
+ }
+
+ public void setPdid(PackageDependenciesIdentification pdid) {
+ this.pdid = pdid;
+ }
+
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/PpisDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/PpisDlg.java new file mode 100644 index 0000000000..f7f50017ff --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/PpisDlg.java @@ -0,0 +1,432 @@ +/** @file
+
+ The file is used to create, update Ppi of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update Ppi of MSA/MBD file
+ It extends IInternalFrame
+
+ **/
+public class PpisDlg extends IDialog implements ItemListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -4284901202357037724L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelC_Name = null;
+
+ private JComboBox jComboBoxCName = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JLabel jLabelPpiType = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JComboBox jComboBoxPpiType = null;
+
+ private JLabel jLabelArch = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private PpisIdentification id = null;
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ private EnumerationData ed = new EnumerationData();
+
+ /**
+ This method initializes jTextFieldC_Name
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JComboBox getJComboBoxCName() {
+ if (jComboBoxCName == null) {
+ jComboBoxCName = new JComboBox();
+ jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxCName;
+ }
+
+ /**
+ This method initializes jTextFieldFeatureFlag
+
+ @return javax.swing.JTextField jTextFieldFeatureFlag
+
+ **/
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jComboBox
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBox() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ * This method initializes jComboBoxPpiType
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getJComboBoxPpiType() {
+ if (jComboBoxPpiType == null) {
+ jComboBoxPpiType = new JComboBox();
+ jComboBoxPpiType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxPpiType.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxPpiType.addItemListener(this);
+ }
+ return jComboBoxPpiType;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 225);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Ppis");
+ initFrame();
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inProtocolsId
+
+ **/
+ private void init(PpisIdentification inPpisId) {
+ init();
+ this.id = inPpisId;
+
+ if (this.id != null) {
+ this.jComboBoxCName.setSelectedItem(id.getName());
+ this.jComboBoxPpiType.setSelectedItem(id.getType());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inProtocolsIdentification
+ @param iFrame
+
+ **/
+ public PpisDlg(PpisIdentification inPpisIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inPpisIdentification);
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelArch.setText("Arch");
+ jLabelPpiType = new JLabel();
+ jLabelPpiType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelPpiType.setText("Ppi Type");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelC_Name = new JLabel();
+ jLabelC_Name.setText("C_Name Type");
+ jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
+ jLabelHelpText.setText("Help Text");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 190));
+
+ jContentPane.add(jLabelC_Name, null);
+ jContentPane.add(getJComboBoxCName(), null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBox(), null);
+ jContentPane.add(getJComboBoxPpiType(), null);
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(jLabelPpiType, null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllPpiDeclarationsFromWorkspace());
+ Tools.generateComboBoxByVector(jComboBoxPpiType, ed.getVPpiType());
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentPpis();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check Name
+ //
+ if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
+ if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
+ Log.err("Incorrect data type for Ppi/PpiNotify Name");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private PpisIdentification getCurrentPpis() {
+ String arg0 = this.jComboBoxCName.getSelectedItem().toString();
+ String arg1 = this.jComboBoxPpiType.getSelectedItem().toString();
+ String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg3 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg4 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg5 = this.jTextFieldHelpText.getText();
+
+ id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ *
+ * Reflesh the frame when selected item changed
+ *
+ */
+ public void itemStateChanged(ItemEvent arg0) {
+ if (arg0.getSource() == this.jComboBoxPpiType && arg0.getStateChange() == ItemEvent.SELECTED) {
+ if (this.jComboBoxPpiType.getSelectedItem().toString().equals(ed.getVPpiType().get(0))) {
+ Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVPpiUsage());
+ } else {
+ Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVPpiNotifyUsage());
+ }
+ }
+ }
+
+ public PpisIdentification getId() {
+ return id;
+ }
+
+ public void setId(PpisIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ProtocolsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ProtocolsDlg.java new file mode 100644 index 0000000000..0f4970cc88 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ProtocolsDlg.java @@ -0,0 +1,450 @@ +/** @file
+
+ The file is used to create, update Protocol of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update Protocol of MSA/MBD file
+ It extends IInternalFrame
+
+
+
+ **/
+public class ProtocolsDlg extends IDialog implements ItemListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -9084913640747858848L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelC_Name = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JLabel jLabelProtocolType = null;
+
+ private JLabel jLabelArch = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JComboBox jComboBoxProtocolType = null;
+
+ private JComboBox jComboBoxCName = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private ProtocolsIdentification id = null;
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ private EnumerationData ed = new EnumerationData();
+
+ /**
+ This method initializes jTextFieldFeatureFlag
+
+ @return javax.swing.JTextField jTextFieldFeatureFlag
+
+ **/
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxProtocolUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ * This method initializes jComboBoxProtocolType
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getJComboBoxProtocolType() {
+ if (jComboBoxProtocolType == null) {
+ jComboBoxProtocolType = new JComboBox();
+ jComboBoxProtocolType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxProtocolType.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxProtocolType.addItemListener(this);
+ jComboBoxProtocolType.setToolTipText("Select Protocol Type");
+ }
+ return jComboBoxProtocolType;
+ }
+
+ /**
+ * This method initializes jComboBoxCName
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getJComboBoxCName() {
+ if (jComboBoxCName == null) {
+ jComboBoxCName = new JComboBox();
+ jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
+
+ }
+ return jComboBoxCName;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 225);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Protocols");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inProtocolsId
+
+ **/
+ private void init(ProtocolsIdentification inProtocolsId) {
+ init();
+ this.id = inProtocolsId;
+
+ if (this.id != null) {
+ this.jComboBoxCName.setSelectedItem(id.getName());
+ this.jComboBoxProtocolType.setSelectedItem(id.getType());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+
+ jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inProtocolsIdentification
+ @param iFrame
+
+ **/
+ public ProtocolsDlg(ProtocolsIdentification inProtocolsIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inProtocolsIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jTextFieldFeatureFlag.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
+ jLabelHelpText.setText("Help Text");
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelArch.setText("Arch Type");
+ jLabelProtocolType = new JLabel();
+ jLabelProtocolType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelProtocolType.setText("Protocol Type");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelC_Name = new JLabel();
+ jLabelC_Name.setText("C_Name Type");
+ jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 190));
+
+ jContentPane.add(jLabelC_Name, null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxProtocolUsage(), null);
+ jContentPane.add(jLabelProtocolType, null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(getJComboBoxProtocolType(), null);
+ jContentPane.add(getJComboBoxCName(), null);
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxProtocolType, ed.getVProtocolType());
+ Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllProtocolDeclarationsFromWorkspace());
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVProtocolUsage());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentProtocols();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check Name
+ //
+ if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
+ if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
+ Log.err("Incorrect data type for Protocol/ProtocolNotify Name");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private ProtocolsIdentification getCurrentProtocols() {
+ String arg0 = this.jComboBoxCName.getSelectedItem().toString();
+ String arg1 = this.jComboBoxProtocolType.getSelectedItem().toString();
+ String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg3 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg4 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg5 = this.jTextFieldHelpText.getText();
+ id = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ *
+ * Reflesh the frame when selected item changed
+ *
+ */
+ public void itemStateChanged(ItemEvent arg0) {
+ if (arg0.getSource() == this.jComboBoxProtocolType && arg0.getStateChange() == ItemEvent.SELECTED) {
+ if (this.jComboBoxProtocolType.getSelectedItem().toString().equals(ed.getVProtocolType().get(0))) {
+ Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolUsage());
+ } else {
+ Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolNotifyUsage());
+ }
+ }
+ }
+
+ public ProtocolsIdentification getId() {
+ return id;
+ }
+
+ public void setId(ProtocolsIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SourceFilesDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SourceFilesDlg.java new file mode 100644 index 0000000000..3c868494ef --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SourceFilesDlg.java @@ -0,0 +1,469 @@ +/** @file
+
+ The file is used to create, update SourceFile of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.SourceFiles.SourceFilesIdentification;
+import org.tianocore.frameworkwizard.workspace.Workspace;
+
+/**
+ The class is used to create, update SourceFile of MSA/MBD file
+ It extends IInternalFrame
+
+
+
+ **/
+public class SourceFilesDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -6765742852142775378L;
+
+ //
+ // Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelFileName = null;
+
+ private JTextField jTextFieldFileName = null;
+
+ private JButton jButtonOpenFile = null;
+
+ private JLabel jLabelToolChainFamily = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private JLabel jLabelArch = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelTagName = null;
+
+ private JTextField jTextFieldTagName = null;
+
+ private JLabel jLabelToolCode = null;
+
+ private JTextField jTextFieldToolCode = null;
+
+ private JTextField jTextFieldToolChainFamily = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ //
+ // Not used by UI
+ //
+ private SourceFilesIdentification sfid = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ /**
+ This method initializes jTextFieldFileName
+
+ @return javax.swing.JTextField jTextFieldFileName
+
+ **/
+ private JTextField getJTextFieldSourceFilesDirectory() {
+ if (jTextFieldFileName == null) {
+ jTextFieldFileName = new JTextField();
+ jTextFieldFileName.setBounds(new java.awt.Rectangle(140, 10, 250, 20));
+ jTextFieldFileName.setPreferredSize(new java.awt.Dimension(250, 20));
+ jTextFieldFileName.setToolTipText("Path is relative to the MSA file and must include the file name");
+ }
+ return jTextFieldFileName;
+ }
+
+ /**
+ This method initializes jButtonOpenFile
+
+ @return javax.swing.JButton jButtonOpenFile
+
+ **/
+ private JButton getJButtonOpenFile() {
+ if (jButtonOpenFile == null) {
+ jButtonOpenFile = new JButton();
+ jButtonOpenFile.setText("Browse");
+ jButtonOpenFile.setBounds(new java.awt.Rectangle(395, 10, 85, 20));
+ jButtonOpenFile.setPreferredSize(new java.awt.Dimension(85, 20));
+ jButtonOpenFile.addActionListener(this);
+ }
+ return jButtonOpenFile;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ * This method initializes jTextFieldTagName
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldTagName() {
+ if (jTextFieldTagName == null) {
+ jTextFieldTagName = new JTextField();
+ jTextFieldTagName.setBounds(new java.awt.Rectangle(140, 35, 340, 20));
+ jTextFieldTagName.setPreferredSize(new java.awt.Dimension(340, 20));
+ jTextFieldTagName.setToolTipText("You may specify a specific tool chain tag name, such as BILL1");
+ }
+ return jTextFieldTagName;
+ }
+
+ /**
+ * This method initializes jTextFieldToolCode
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldToolCode() {
+ if (jTextFieldToolCode == null) {
+ jTextFieldToolCode = new JTextField();
+ jTextFieldToolCode.setBounds(new java.awt.Rectangle(140, 60, 340, 20));
+ jTextFieldToolCode.setPreferredSize(new java.awt.Dimension(340, 20));
+ jTextFieldToolCode.setToolTipText("You may specify a specific tool command, such as ASM");
+ }
+ return jTextFieldToolCode;
+ }
+
+ /**
+ * This method initializes jTextFieldToolChainFamily
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldToolChainFamily() {
+ if (jTextFieldToolChainFamily == null) {
+ jTextFieldToolChainFamily = new JTextField();
+ jTextFieldToolChainFamily.setBounds(new java.awt.Rectangle(140, 85, 340, 20));
+ jTextFieldToolChainFamily.setPreferredSize(new java.awt.Dimension(340, 20));
+ jTextFieldToolChainFamily.setToolTipText("You may specify a specific tool chain family, such as GCC");
+ }
+ return jTextFieldToolChainFamily;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(140, 110, 340, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(340, 20));
+ jTextFieldFeatureFlag.setToolTipText("RESERVED FOR FUTURE USE");
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public SourceFilesDlg(SourceFilesIdentification inSourceFilesIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inSourceFilesIdentification);
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 235);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Source Files");
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+
+ @param inSourceFiles The input data of SourceFilesDocument.SourceFiles
+
+ **/
+ private void init(SourceFilesIdentification inSourceFilesIdentifications) {
+ init();
+ this.sfid = inSourceFilesIdentifications;
+
+ if (this.sfid != null) {
+ this.jTextFieldFileName.setText(sfid.getFilename());
+ this.jTextFieldTagName.setText(sfid.getTagName());
+ this.jTextFieldToolCode.setText(sfid.getToolCode());
+ this.jTextFieldToolChainFamily.setText(sfid.getToolChainFamily());
+ jTextFieldFeatureFlag.setText(sfid.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(sfid.getSupArchList());
+ }
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jTextFieldFileName.setEnabled(!isView);
+ this.jButtonOpenFile.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(140, 135, 340, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(340, 20));
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 120, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelToolCode = new JLabel();
+ jLabelToolCode.setBounds(new java.awt.Rectangle(15, 60, 120, 20));
+ jLabelToolCode.setText("Tool Code");
+ jLabelTagName = new JLabel();
+ jLabelTagName.setBounds(new java.awt.Rectangle(15, 35, 120, 20));
+ jLabelTagName.setText("Tag Name");
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 120, 20));
+ jLabelArch.setText("Sup Arch List");
+ jLabelToolChainFamily = new JLabel();
+ jLabelToolChainFamily.setBounds(new java.awt.Rectangle(15, 85, 120, 20));
+ jLabelToolChainFamily.setText("Tool Chain Family");
+ jLabelFileName = new JLabel();
+ jLabelFileName.setText("File Name");
+ jLabelFileName.setBounds(new java.awt.Rectangle(15, 10, 120, 20));
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 185));
+
+ jContentPane.add(jLabelFileName, null);
+ jContentPane.add(getJTextFieldSourceFilesDirectory(), null);
+ jContentPane.add(getJButtonOpenFile(), null);
+ jContentPane.add(jLabelToolChainFamily, null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(jLabelTagName, null);
+ jContentPane.add(getJTextFieldTagName(), null);
+ jContentPane.add(jLabelToolCode, null);
+ jContentPane.add(getJTextFieldToolCode(), null);
+ jContentPane.add(getJTextFieldToolChainFamily(), null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOpenFile) {
+ selectFile();
+ }
+
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentSourceFiles();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ private SourceFilesIdentification getCurrentSourceFiles() {
+ String name = this.jTextFieldFileName.getText();
+ String tagName = this.jTextFieldTagName.getText();
+ String toolCode = this.jTextFieldToolCode.getText();
+ String tcf = this.jTextFieldToolChainFamily.getText();
+ String featureFlag = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arch = this.jArchCheckBox.getSelectedItemsVector();
+ sfid = new SourceFilesIdentification(name, tagName, toolCode, tcf, featureFlag, arch);
+ return sfid;
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check Filename
+ //
+ if (isEmpty(this.jTextFieldFileName.getText())) {
+ Log.err("File Name couldn't be empty");
+ return false;
+ }
+ if (!DataValidation.isFilename(this.jTextFieldFileName.getText())) {
+ Log.err("Incorrect data type for File Name");
+ return false;
+ }
+
+ //
+ // Check TagName
+ //
+ if (!isEmpty(this.jTextFieldTagName.getText())) {
+ if (!DataValidation.isTagName(this.jTextFieldTagName.getText())) {
+ Log.err("Incorrect data type for Tag Name");
+ return false;
+ }
+ }
+
+ //
+ // Check ToolCode
+ //
+ if (!isEmpty(this.jTextFieldToolCode.getText())) {
+ if (!DataValidation.isToolCode(this.jTextFieldToolCode.getText())) {
+ Log.err("Incorrect data type for Tool Code");
+ return false;
+ }
+ }
+
+ //
+ // Check ToolChainFamily
+ //
+ if (!isEmpty(this.jTextFieldToolChainFamily.getText())) {
+ if (!DataValidation.isToolChainFamily(this.jTextFieldToolChainFamily.getText())) {
+ Log.err("Incorrect data type for Tool Chain Family");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ Display a file open browser to let user select file
+
+ **/
+ private void selectFile() {
+ JFileChooser fc = new JFileChooser(Workspace.getCurrentWorkspace());
+
+ int result = fc.showOpenDialog(new JPanel());
+ if (result == JFileChooser.APPROVE_OPTION) {
+ this.jTextFieldFileName.setText(fc.getSelectedFile().getName());
+ }
+ }
+
+ public SourceFilesIdentification getSfid() {
+ return sfid;
+ }
+
+ public void setSfid(SourceFilesIdentification sfid) {
+ this.sfid = sfid;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SystemTablesDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SystemTablesDlg.java new file mode 100644 index 0000000000..d866e01cd9 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SystemTablesDlg.java @@ -0,0 +1,392 @@ +/** @file
+
+ The file is used to create, update SystemTable of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.SystemTables.SystemTablesIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update SystemTable of MSA/MBD file
+ It extends IInternalFrame
+
+
+
+ **/
+public class SystemTablesDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 7488769180379442276L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelEntry = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JComboBox jComboBoxGuidC_Name = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelArch = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private SystemTablesIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jTextField
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JComboBox getJComboBoxGuidC_Name() {
+ if (jComboBoxGuidC_Name == null) {
+ jComboBoxGuidC_Name = new JComboBox();
+ jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Hob");
+ }
+ return jComboBoxGuidC_Name;
+ }
+
+ /**
+ * This method initializes jTextFieldFeatureFlag
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 140, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 140, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 200);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("System Tables");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inSystemTablesId
+
+ **/
+ private void init(SystemTablesIdentification inSystemTablesId) {
+ init();
+ this.id = inSystemTablesId;
+
+ if (this.id != null) {
+ this.jComboBoxGuidC_Name.setSelectedItem(id.getName());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inBootModesIdentification
+ @param iFrame
+
+ **/
+ public SystemTablesDlg(SystemTablesIdentification inSystemTablesIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inSystemTablesIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jComboBoxUsage.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelArch.setText("Arch");
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelEntry = new JLabel();
+ jLabelEntry.setText("Guid C_Name");
+ jLabelEntry.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
+ jLabelHelpText.setText("Help Text");
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 165));
+
+ jContentPane.add(jLabelEntry, null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(getJComboBoxGuidC_Name(), null);
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVSystemTableUsage());
+ Tools.generateComboBoxByVector(jComboBoxGuidC_Name, wt.getAllGuidDeclarationsFromWorkspace());
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentSystemTables();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private SystemTablesIdentification getCurrentSystemTables() {
+ String arg0 = this.jComboBoxGuidC_Name.getSelectedItem().toString();
+ String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg2 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg3 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg4 = this.jTextFieldHelpText.getText();
+
+ id = new SystemTablesIdentification(arg0, arg1, arg2, arg3, arg4);
+ return id;
+ }
+
+ public SystemTablesIdentification getId() {
+ return id;
+ }
+
+ public void setId(SystemTablesIdentification id) {
+ this.id = id;
+ }
+}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/VariablesDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/VariablesDlg.java new file mode 100644 index 0000000000..1a215cec00 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/VariablesDlg.java @@ -0,0 +1,438 @@ +/** @file
+
+ The file is used to create, update Variable of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.frameworkwizard.module.ui.dialog;
+
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.tianocore.frameworkwizard.common.DataType;
+import org.tianocore.frameworkwizard.common.DataValidation;
+import org.tianocore.frameworkwizard.common.EnumerationData;
+import org.tianocore.frameworkwizard.common.Log;
+import org.tianocore.frameworkwizard.common.Tools;
+import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
+import org.tianocore.frameworkwizard.common.ui.IDialog;
+import org.tianocore.frameworkwizard.common.ui.IFrame;
+import org.tianocore.frameworkwizard.common.ui.StarLabel;
+import org.tianocore.frameworkwizard.module.Identifications.Variables.VariablesIdentification;
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
+
+/**
+ The class is used to create, update Variable of MSA/MBD file
+ It extends IInternalFrame
+
+ **/
+public class VariablesDlg extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -6998982978030439446L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelVariableName = null;
+
+ private JTextField jTextFieldVariableName = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JLabel jLabelGuidCName = null;
+
+ private JComboBox jComboBoxGuidC_Name = null;
+
+ private JTextField jTextFieldFeatureFlag = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private JLabel jLabelArch = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private ArchCheckBox jArchCheckBox = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ //
+ // Not used by UI
+ //
+ private VariablesIdentification id = null;
+
+ private EnumerationData ed = new EnumerationData();
+
+ private WorkspaceTools wt = new WorkspaceTools();
+
+ /**
+ This method initializes jTextFieldString
+
+ @return javax.swing.JTextField jTextFieldString
+
+ **/
+ private JTextField getJTextFieldString() {
+ if (jTextFieldVariableName == null) {
+ jTextFieldVariableName = new JTextField();
+ jTextFieldVariableName.setSize(new java.awt.Dimension(320, 20));
+ jTextFieldVariableName.setPreferredSize(new java.awt.Dimension(320, 20));
+ jTextFieldVariableName.setLocation(new java.awt.Point(160, 10));
+ jTextFieldVariableName
+ .setToolTipText("Enter a Hex Word Array, you must provide leading Zeros. 0x000a, 0x0010, бн");
+ }
+ return jTextFieldVariableName;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getJContentPane());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jTextFieldFeatureFlag
+
+ @return javax.swing.JTextField jTextFieldFeatureFlag
+
+ **/
+ private JTextField getJTextFieldFeatureFlag() {
+ if (jTextFieldFeatureFlag == null) {
+ jTextFieldFeatureFlag = new JTextField();
+ jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldFeatureFlag;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jTextField
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JComboBox getJComboBoxGuidC_Name() {
+ if (jComboBoxGuidC_Name == null) {
+ jComboBoxGuidC_Name = new JComboBox();
+ jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
+ jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Hob");
+ }
+ return jComboBoxGuidC_Name;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
+ jButtonOk.setText("Ok");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 225);
+ this.setContentPane(getJScrollPane());
+ this.setTitle("Variables");
+ initFrame();
+ this.setViewMode(false);
+ this.centerWindow();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inVariablesId
+
+ **/
+ private void init(VariablesIdentification inVariablesId) {
+ init();
+ this.id = inVariablesId;
+
+ if (this.id != null) {
+ this.jTextFieldVariableName.setText(id.getName());
+ this.jComboBoxGuidC_Name.setSelectedItem(id.getGuid());
+ this.jComboBoxUsage.setSelectedItem(id.getUsage());
+ this.jTextFieldHelpText.setText(id.getHelp());
+ this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
+ this.jArchCheckBox.setSelectedItems(id.getSupArchList());
+ }
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inHobsIdentification
+ @param iFrame
+
+ **/
+ public VariablesDlg(VariablesIdentification inVariablesIdentification, IFrame iFrame) {
+ super(iFrame, true);
+ init(inVariablesIdentification);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ if (isView) {
+ this.jTextFieldVariableName.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jArchCheckBox = new ArchCheckBox();
+ jArchCheckBox.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
+ jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
+ jLabelGuidCName = new JLabel();
+ jLabelGuidCName.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelGuidCName.setText("Guid C_Name");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelVariableName = new JLabel();
+ jLabelVariableName.setText("Variable Name");
+ jLabelVariableName.setLocation(new java.awt.Point(15, 10));
+ jLabelVariableName.setSize(new java.awt.Dimension(140, 20));
+ jLabelArch = new JLabel();
+ jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelArch.setText("Arch");
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setPreferredSize(new java.awt.Dimension(490, 190));
+
+ jContentPane.add(jLabelVariableName, null);
+ jContentPane.add(jLabelGuidCName, null);
+ jContentPane.add(getJComboBoxGuidC_Name(), null);
+ jContentPane.add(getJTextFieldString(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setLocation(new java.awt.Point(0, 35));
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
+ jLabelHelpText.setText("Help Text");
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+
+ jContentPane.add(jLabelArch, null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getJTextFieldFeatureFlag(), null);
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jArchCheckBox, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ if (checkAdd()) {
+ getCurrentVariables();
+ this.returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
+ }
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.returnType = DataType.RETURN_TYPE_CANCEL;
+ this.setVisible(false);
+ }
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
+ Tools.generateComboBoxByVector(jComboBoxGuidC_Name, wt.getAllGuidDeclarationsFromWorkspace());
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all fields have correct data types
+ //
+
+ //
+ // Check VariableName
+ //
+ if (isEmpty(this.jTextFieldVariableName.getText())) {
+ Log.err("Variable Name couldn't be empty");
+ return false;
+ }
+
+ if (!isEmpty(this.jTextFieldVariableName.getText())) {
+ if (!DataValidation.isHexWordArrayType(this.jTextFieldVariableName.getText())) {
+ Log.err("Incorrect data type for Variable Name");
+ return false;
+ }
+ }
+
+ //
+ // Check FeatureFlag
+ //
+ if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
+ if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
+ Log.err("Incorrect data type for Feature Flag");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private VariablesIdentification getCurrentVariables() {
+ String arg0 = this.jTextFieldVariableName.getText();
+ String arg1 = this.jComboBoxGuidC_Name.getSelectedItem().toString();
+ String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
+
+ String arg3 = this.jTextFieldFeatureFlag.getText();
+ Vector<String> arg4 = this.jArchCheckBox.getSelectedItemsVector();
+ String arg5 = this.jTextFieldHelpText.getText();
+
+ id = new VariablesIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
+ return id;
+ }
+
+ public VariablesIdentification getId() {
+ return id;
+ }
+
+ public void setId(VariablesIdentification id) {
+ this.id = id;
+ }
+}
|