diff options
author | hche10x <hche10x@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-26 09:05:56 +0000 |
---|---|---|
committer | hche10x <hche10x@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-26 09:05:56 +0000 |
commit | 007f887e703143af653d2304b9cbc9b422b0efca (patch) | |
tree | 722d5af68a0d2ef7f0c7f49e987bda43dbe98d0f /Tools/Source | |
parent | e4e7fed9be13fe380b66ef324bc45c43ab6f0ce5 (diff) | |
download | edk2-007f887e703143af653d2304b9cbc9b422b0efca.zip edk2-007f887e703143af653d2304b9cbc9b422b0efca.tar.gz edk2-007f887e703143af653d2304b9cbc9b422b0efca.tar.bz2 |
1. Fix EDKT306 Output different error message for different condition in workspace validation
2. Fix EDKT307 Workspace selection support is required by wizard
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1629 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Source')
3 files changed, 90 insertions, 40 deletions
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java index 5efa81b..ad08749 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java @@ -1808,25 +1808,19 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe **/
private void init() {
//
- // Show splash screen
- //
- SplashScreen ss = new SplashScreen();
- ss.setVisible(true);
-
- //
// Set current workspace and check
// Check if exists WORKSPACE
- //
//
Workspace.setCurrentWorkspace(System.getenv("WORKSPACE"));
- if (!Workspace.checkCurrentWorkspace()) {
- JOptionPane.showConfirmDialog(null, "Workspace is not setup correctly. Please setup first.", "Warning",
- JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
- this.dispose();
- System.exit(0);
- }
+ this.checkWorkspace();
//
+ // Show splash screen
+ //
+ SplashScreen ss = new SplashScreen();
+ ss.setVisible(true);
+
+ //
// Init Global Data
//
GlobalData.init();
@@ -3675,4 +3669,48 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe JOptionPane.INFORMATION_MESSAGE);
}
}
+
+ /**
+ Check if WORKSPACE Environment is valid
+
+ **/
+ private void checkWorkspace() {
+ switch (Workspace.checkCurrentWorkspace()) {
+ case Workspace.WORKSPACE_VALID:
+ break;
+ case Workspace.WORKSPACE_NOT_DEFINED:
+ JOptionPane
+ .showConfirmDialog(
+ null,
+ "WORKSPACE Environment Variable Is Not Defined, Please select a valid WORKSPACE directory. " +
+ DataType.LINE_SEPARATOR + DataType.LINE_SEPARATOR + "NOTICE:" +
+ DataType.LINE_SEPARATOR + "This does not change the System Environment Variable." +
+ DataType.LINE_SEPARATOR + "It only applies to where the Wizard will manage modification and file creations.",
+ "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
+ SwitchWorkspace sw = new SwitchWorkspace(this, true);
+ int result = sw.showDialog();
+ if (result == DataType.RETURN_TYPE_CANCEL) {
+ this.dispose();
+ System.exit(0);
+ } else if (result == DataType.RETURN_TYPE_OK) {
+ sw.dispose();
+ break;
+ }
+ case Workspace.WORKSPACE_NOT_EXIST:
+ JOptionPane.showConfirmDialog(null, "Defined WORKSPACE Is Not Existed", "Error",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
+ this.dispose();
+ System.exit(0);
+ case Workspace.WORKSPACE_NOT_DIRECTORY:
+ JOptionPane.showConfirmDialog(null, "Defined WORKSPACE Is Not A Directory", "Error",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
+ this.dispose();
+ System.exit(0);
+ case Workspace.WORKSPACE_NOT_VALID:
+ JOptionPane.showConfirmDialog(null, "WORKSPACE Environment Variable Is Not Valid", "Error",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
+ this.dispose();
+ System.exit(0);
+ }
+ }
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/Workspace.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/Workspace.java index 40692c6..5785aaf 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/Workspace.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/Workspace.java @@ -21,6 +21,19 @@ import org.tianocore.frameworkwizard.common.DataType; public class Workspace {
//
+ // Define static return value
+ //
+ public final static int WORKSPACE_VALID = 0;
+
+ public final static int WORKSPACE_NOT_DEFINED = 1;
+
+ public final static int WORKSPACE_NOT_EXIST = 2;
+
+ public final static int WORKSPACE_NOT_DIRECTORY = 3;
+
+ public final static int WORKSPACE_NOT_VALID = 4;
+
+ //
// Define class members
//
private static String currentWorkspace = null;
@@ -66,7 +79,7 @@ public class Workspace { @retval false - The current WORKSPACE doesn't exist
*/
- public static boolean checkCurrentWorkspace() {
+ public static int checkCurrentWorkspace() {
return checkWorkspace(getCurrentWorkspace());
}
@@ -79,30 +92,38 @@ public class Workspace { @retval false - The current WORKSPACE doesn't exist
*/
- public static boolean checkWorkspace(String strWorkspace) {
+ public static int checkWorkspace(String strWorkspace) {
+ //
+ // Check if WORKSPACE Environment is defined
+ //
if (strWorkspace == null || strWorkspace == "") {
- return false;
+ return Workspace.WORKSPACE_NOT_DEFINED;
}
+
//
- // Check workspace directory
+ // Check if WORKSPACE Environment exists
//
File f = new File(strWorkspace);
- if (!f.isDirectory()) {
- return false;
- }
if (!f.exists()) {
- return false;
+ return Workspace.WORKSPACE_NOT_EXIST;
+ }
+
+ //
+ // Check if WORKSPACE Environment is a directory
+ //
+ if (!f.isDirectory()) {
+ return Workspace.WORKSPACE_NOT_DIRECTORY;
}
//
- // Check FrameworkDatabase.db
+ // Check if FrameworkDatabase.db exists
//
f = new File(strWorkspace + Workspace.getStrWorkspaceDatabaseFile());
if (!f.exists()) {
- return false;
+ return Workspace.WORKSPACE_NOT_VALID;
}
- return true;
+ return Workspace.WORKSPACE_VALID;
}
public static String getStrWorkspaceDatabaseFile() {
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/ui/SwitchWorkspace.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/ui/SwitchWorkspace.java index f81bfce..e5f28c5 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/ui/SwitchWorkspace.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/ui/SwitchWorkspace.java @@ -2,11 +2,11 @@ package org.tianocore.frameworkwizard.workspace.ui; import java.awt.event.ActionEvent;
+import javax.swing.JButton;
import javax.swing.JFileChooser;
-import javax.swing.JPanel;
import javax.swing.JLabel;
+import javax.swing.JPanel;
import javax.swing.JTextField;
-import javax.swing.JButton;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.Log;
@@ -51,7 +51,8 @@ public class SwitchWorkspace extends IDialog { jTextFieldOld = new JTextField();
jTextFieldOld.setBounds(new java.awt.Rectangle(140, 10, 320, 20));
jTextFieldOld.setEditable(false);
- jTextFieldOld.setText(Workspace.getCurrentWorkspace());
+ jTextFieldOld.setText(Workspace.getCurrentWorkspace() == null ? "Not Defined"
+ : Workspace.getCurrentWorkspace());
}
return jTextFieldOld;
}
@@ -115,16 +116,6 @@ public class SwitchWorkspace extends IDialog { }
/**
-
- @param args
-
- **/
- public static void main(String[] args) {
- // TODO Auto-generated method stub
-
- }
-
- /**
* This is the default constructor
*
*/
@@ -150,7 +141,7 @@ public class SwitchWorkspace extends IDialog { private void initialize() {
this.setSize(472, 132);
this.setContentPane(getJContentPane());
- this.setTitle("Change workspace");
+ this.setTitle("Select workspace");
this.centerWindow();
}
@@ -185,7 +176,7 @@ public class SwitchWorkspace extends IDialog { Log.wrn("Switch Workspace", "New workspace must be entered!");
return false;
}
- if (!Workspace.checkWorkspace(this.jTextFieldNew.getText())) {
+ if (Workspace.checkWorkspace(this.jTextFieldNew.getText()) != Workspace.WORKSPACE_VALID) {
Log.wrn("Switch Workspace", "Please select a valid workspace!");
return false;
}
@@ -207,9 +198,9 @@ public class SwitchWorkspace extends IDialog { if (!check()) {
return;
} else {
- this.setVisible(false);
Workspace.setCurrentWorkspace(this.jTextFieldNew.getText());
returnType = DataType.RETURN_TYPE_OK;
+ this.setVisible(false);
}
}
|