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
This commit is contained in:
hche10x 2006-09-26 09:05:56 +00:00
parent e4e7fed9be
commit 007f887e70
3 changed files with 98 additions and 48 deletions

View File

@ -1807,25 +1807,19 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe
**/
private void init() {
//
// Set current workspace and check
// Check if exists WORKSPACE
//
Workspace.setCurrentWorkspace(System.getenv("WORKSPACE"));
this.checkWorkspace();
//
// 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);
}
//
// Init Global Data
//
@ -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);
}
}
}

View File

@ -20,6 +20,19 @@ import java.io.File;
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
//
@ -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;
}
//
// Check workspace directory
//
File f = new File(strWorkspace);
if (!f.isDirectory()) {
return false;
}
if (!f.exists()) {
return false;
return Workspace.WORKSPACE_NOT_DEFINED;
}
//
// Check FrameworkDatabase.db
// Check if WORKSPACE Environment exists
//
File f = new File(strWorkspace);
if (!f.exists()) {
return Workspace.WORKSPACE_NOT_EXIST;
}
//
// Check if WORKSPACE Environment is a directory
//
if (!f.isDirectory()) {
return Workspace.WORKSPACE_NOT_DIRECTORY;
}
//
// 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() {

View File

@ -2,11 +2,11 @@ package org.tianocore.frameworkwizard.workspace.ui;
import java.awt.event.ActionEvent;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
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;
}
@ -114,16 +115,6 @@ public class SwitchWorkspace extends IDialog {
return jButtonBrowse;
}
/**
@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);
}
}