Remove the assumption of package location under workspace and prompt user to specify package location.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@226 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jlin16 2006-05-22 04:59:10 +00:00
parent f387591c76
commit 33f1b48545
6 changed files with 73 additions and 14 deletions

View File

@ -288,7 +288,7 @@ public class DbFileContents {
p.addNewPackageName().setStringValue(name);
p.addNewGuid().setStringValue(guid);
p.addNewVersion().setStringValue(version);
p.addNewPath().setStringValue(installDir);
p.addNewPath().setStringValue(installDir + "/");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date date = new Date();

View File

@ -24,6 +24,7 @@ import java.awt.GridLayout;
import java.io.File;
import javax.swing.JButton;
import javax.swing.filechooser.FileFilter;
/**
GUI for create spd file
@ -137,6 +138,8 @@ public class PackageAction extends JFrame {
@return javax.swing.JButton
**/
private JButton getJButton() {
final FileFilter filter = new PkgFileFilter("spd");
if (jButton == null) {
jButton = new JButton();
jButton.setText("Save");
@ -145,8 +148,9 @@ public class PackageAction extends JFrame {
//
// save sfc contents to file
//
JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE"));
JFileChooser chooser = new JFileChooser(PackagingMain.dirForNewSpd);
chooser.setMultiSelectionEnabled(false);
chooser.setFileFilter(filter);
int retval = chooser.showSaveDialog(frame);
if (retval == JFileChooser.APPROVE_OPTION) {

View File

@ -416,7 +416,7 @@ public class PackageLibraryClass extends JFrame implements ActionListener {
if (jRadioButtonSelect.isSelected()) {
strLibClass = jComboBoxSelect.getSelectedItem().toString();
}
listItem.addElement(jTextField.getText() + this.Separator + strLibClass);
listItem.addElement(jTextField.getText().replace('\\', '/') + this.Separator + strLibClass);
}
//
// remove selected line
@ -517,25 +517,40 @@ public class PackageLibraryClass extends JFrame implements ActionListener {
// Select files from current workspace
//
JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE"));
File theFile = null;
String headerDest = null;
chooser.setMultiSelectionEnabled(false);
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int retval = chooser.showOpenDialog(frame);
if (retval == JFileChooser.APPROVE_OPTION) {
File theFile = chooser.getSelectedFile();
theFile = chooser.getSelectedFile();
String file = theFile.getPath();
if (!file.startsWith(System.getenv("WORKSPACE"))) {
JOptionPane.showMessageDialog(frame, "You can only select files in current workspace!");
return;
}
//
// record relative path of selected file. Assume top level package directory lies directly in workspace
//
int fileIndex = file.indexOf(System.getProperty("file.separator"), System.getenv("WORKSPACE").length() + 1);
jTextField.setText(file.substring(fileIndex + 1));
}
else {
return;
}
if (!theFile.getPath().startsWith(PackagingMain.dirForNewSpd)) {
//
//ToDo: copy elsewhere header file to new pkg dir, prompt user to chooser a location
//
JOptionPane.showMessageDialog(frame, "You must copy header file into current package directory!");
return;
}
headerDest = theFile.getPath();
int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), PackagingMain.dirForNewSpd.length());
jTextField.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));
}
});
}

View File

@ -32,6 +32,7 @@ import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.filechooser.FileFilter;
/**
GUI for create MsaFile elements of spd file
@ -318,6 +319,8 @@ public class PackageMsaFile extends JFrame implements ActionListener {
@return javax.swing.JButton
**/
private JButton getJButton() {
final FileFilter filter = new PkgFileFilter("msa");
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new java.awt.Rectangle(377,46,89,20));
@ -326,23 +329,39 @@ public class PackageMsaFile extends JFrame implements ActionListener {
jButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE"));
File theFile = null;
String msaDest = null;
chooser.setMultiSelectionEnabled(false);
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setFileFilter(new PkgFileFilter("msa"));
chooser.setFileFilter(filter);
int retval = chooser.showOpenDialog(frame);
if (retval == JFileChooser.APPROVE_OPTION) {
File theFile = chooser.getSelectedFile();
theFile = chooser.getSelectedFile();
String file = theFile.getPath();
if (!file.startsWith(System.getenv("WORKSPACE"))) {
JOptionPane.showMessageDialog(frame, "You can only select files in current workspace!");
return;
}
int fileIndex = file.indexOf(System.getProperty("file.separator"), System.getenv("WORKSPACE").length() + 1);
jTextField.setText(file.substring(fileIndex + 1));
}
else {
return;
}
if (!theFile.getPath().startsWith(PackagingMain.dirForNewSpd)) {
//
//ToDo: copy elsewhere msa to new pkg dir, prompt user to chooser a location
//
JOptionPane.showMessageDialog(frame, "You must copy msa file into current package directory!");
return;
}
msaDest = theFile.getPath();
int fileIndex = msaDest.indexOf(System.getProperty("file.separator"), PackagingMain.dirForNewSpd.length());
jTextField.setText(msaDest.substring(fileIndex + 1).replace('\\', '/'));
}
});
}

View File

@ -373,7 +373,7 @@ public class PackagePkgHeader extends JFrame implements ActionListener {
strLibClass = jComboBoxSelect.getSelectedItem().toString();
}
listItem.addElement(jTextField.getText() + Separator + strLibClass);
listItem.addElement(jTextField.getText().replace('\\', '/') + Separator + strLibClass);
}
if (arg0.getSource() == jButtonRemove) {

View File

@ -37,6 +37,8 @@ public class PackagingMain extends JFrame {
static JFrame frame;
static String dirForNewSpd = null;
private JPanel jContentPane = null;
private JButton jButton = null;
@ -227,6 +229,25 @@ public class PackagingMain extends JFrame {
jButton5.setText("Create Package Description File");
jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setMultiSelectionEnabled(false);
chooser.setDialogTitle("Please specify where to save the new spd file");
int retval = chooser.showSaveDialog(frame);
if (retval == JFileChooser.APPROVE_OPTION) {
try {
File theFile = chooser.getSelectedFile();
PackagingMain.dirForNewSpd = theFile.getPath();
} catch (Exception ee) {
System.out.println(ee.toString());
}
// pThis.dispose();
}
else {
return;
}
SpdFileContents sfc = new SpdFileContents();
ModalFrameUtil.showAsModal(new PackageAction(sfc), pThis);
}