diff --git a/plugins/TestingList.form b/plugins/TestingList.form
index 187b125..89b71a6 100644
--- a/plugins/TestingList.form
+++ b/plugins/TestingList.form
@@ -54,6 +54,7 @@
+
@@ -98,6 +99,12 @@
+
+
+
+
+
+
diff --git a/plugins/TestingList.java b/plugins/TestingList.java
index 8b43806..acb47cf 100644
--- a/plugins/TestingList.java
+++ b/plugins/TestingList.java
@@ -28,143 +28,141 @@ import javax.swing.JFileChooser;
import org.apache.commons.io.FilenameUtils;
public class TestingList extends Panel {
+
NetbeansPluginPanel testingList;
-
+
Task task = new Task() {
@Override
- protected Object execute() throws Exception {
-
- return true;
+ protected Object execute() throws Exception {
+
+ return true;
}
};
-
+
@Override
- protected JPanel create() {
- try {
+ protected JPanel create() {
+ try {
testingList = new NetbeansPluginPanel();
} catch (IOException ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
}
return testingList;
- }
+ }
//listen to script end of execution and get return value
@Override
protected void onExecutedFile(String fileName) {
try {
- switch(fileName){
- case "power-supply":
- Object ret = eval("ret");
- boolean success = (boolean) eval("success");
- Object deviceName = eval("deviceName");
- Object testName = eval("testName");
-
- String sSuccess = (success == true) ? "Success": "Failed";
- if (ret != null) {
- //SwingUtils.showMessage(getComponent(), "", ret.toString() + " - " + ret.getClass().getName());
- testingList.showResult(deviceName.toString(), testName.toString(), ret.toString(), sSuccess);
- }
+ switch (fileName) {
+ case "power-supply":
+ Object ret = eval("ret");
+ boolean success = (boolean) eval("success");
+ Object deviceName = eval("deviceName");
+ Object testName = eval("testName");
+
+ String sSuccess = (success == true) ? "Success" : "Failed";
+ if (ret != null) {
+ //SwingUtils.showMessage(getComponent(), "", ret.toString() + " - " + ret.getClass().getName());
+ testingList.showResult(deviceName.toString(), testName.toString(), ret.toString(), sSuccess);
+ }
break;
}
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
SwingUtils.showException(getComponent(), ex);
- }
+ }
}
-
public class NetbeansPluginPanel extends MonitoredPanel {
-
- Logger logger = Logger.getLogger("TestsLog");
- //these paths are converted to unix or win path according to host OS
- private final String TESTS_DEVICES_DEFAULT_DIR = new java.io.File( "." ).getCanonicalPath()+
- FilenameUtils.separatorsToSystem("/home/script/tests/production/");
- private final String TESTS_TESTS_DEFAULT_DIR = new java.io.File( "." ).getCanonicalPath()+
- FilenameUtils.separatorsToSystem("/home/script/tests/tests/");
- private final String TESTS_LOG_DEFAULT_DIR = new java.io.File( "." ).getCanonicalPath()+
- FilenameUtils.separatorsToSystem("/home/script/tests/log/TestsLog"+getnow()+".txt");
- //table1 columns indexes
- private final int COL_CHECK = 0;
- private final int COL_TIME = 1;
- private final int COL_DEVICENAME = 2;
- private final int COL_RESULT = 6;
- private final int COL_STATUS = 7;
- private final int COL_ICON = 8;
-
- private void initLogger(){
- try {
- FileHandler fh;
- // This block configure the logger with handler and formatter
- fh = new FileHandler( TESTS_LOG_DEFAULT_DIR);
- logger.addHandler(fh);
- SimpleFormatter formatter = new SimpleFormatter();
- fh.setFormatter(formatter);
- logger.log(Level.INFO,"New Testing Session");
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public NetbeansPluginPanel() throws IOException {
- initComponents();
- initLogger();
- buildTable();
- loadTests();
- }
- @SuppressWarnings("unchecked")
+ Logger logger = Logger.getLogger("TestsLog");
+ //these paths are converted to unix or win path according to host OS
+ private final String TESTS_DEVICES_DEFAULT_DIR = new java.io.File(".").getCanonicalPath()
+ + FilenameUtils.separatorsToSystem("/home/script/tests/production/");
+ private final String TESTS_TESTS_DEFAULT_DIR = new java.io.File(".").getCanonicalPath()
+ + FilenameUtils.separatorsToSystem("/home/script/tests/tests/");
+ private final String TESTS_LOG_DEFAULT_DIR = new java.io.File(".").getCanonicalPath()
+ + FilenameUtils.separatorsToSystem("/home/script/tests/log/TestsLog" + getnow() + ".txt");
+ //table1 columns indexes
+ private final int COL_CHECK = 0;
+ private final int COL_TIME = 1;
+ private final int COL_DEVICENAME = 2;
+ private final int COL_RESULT = 6;
+ private final int COL_STATUS = 7;
+ private final int COL_ICON = 8;
-
- //show test result in table
- public void showResult(String deviceName, String testName, String res, String status){
- int rowD=-1, colT=-1;
- //search for device name in table
- for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
- for (int col = 0; col <= jTable1.getColumnCount() - 1; col++) {
- if (deviceName.equals(jTable1.getValueAt(row, col))) {
- rowD = row;
- break;
- }
+ private void initLogger() {
+ try {
+ FileHandler fh;
+ // This block configure the logger with handler and formatter
+ fh = new FileHandler(TESTS_LOG_DEFAULT_DIR);
+ logger.addHandler(fh);
+ SimpleFormatter formatter = new SimpleFormatter();
+ fh.setFormatter(formatter);
+ logger.log(Level.INFO, "New Testing Session");
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
}
}
- if (rowD>0){
- //search for test name in table
- for (int col = 0; col <= jTable1.getColumnCount() - 1; col++) {
- if (testName.equals(jTable1.getValueAt(rowD, col))) {
- colT = col;
- break;
- }
- }
- }
- String iconSource = "/icons/button_help-16px.png";
- switch(status){
- case "Success":
- iconSource = "/icons/button_ok-16px.png";
- logger.log(Level.INFO, "Device: "+ testName + "Test: "+ testName + " Result: " + res + " (" + status + ")");
- break;
- case "Failed":
- iconSource = "/icons/button_close-16px.png";
- logger.log(Level.SEVERE, "Device: "+ testName + "Test: "+ testName + " Result: " + res + " (" + status + ")");
- break;
- case "Running":
- iconSource = "/icons/button_play-16px.png";
- logger.log(Level.INFO, "Running Test: "+ testName + " ... ");
- break;
- }
- ImageIcon icon = new ImageIcon(getClass().getResource(iconSource));
- jTable1.setValueAt(icon, rowD, COL_ICON);
-
- if(colT>0 && rowD>0){
- jTable1.setValueAt(getNow(), rowD, COL_TIME);
- jTable1.setValueAt(res, rowD, COL_RESULT);
- jTable1.setValueAt(status, rowD, COL_STATUS);
- jTable1.getCellEditor(rowD, COL_STATUS);
- }
- }
-
-
-
+
+ public NetbeansPluginPanel() throws IOException {
+ initComponents();
+ initLogger();
+ buildTable();
+ loadTests();
+ }
+
+ @SuppressWarnings("unchecked")
+
+ //show test result in table
+ public void showResult(String deviceName, String testName, String res, String status) {
+ int rowD = -1, colT = -1;
+ //search for device name in table
+ for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
+ for (int col = 0; col <= jTable1.getColumnCount() - 1; col++) {
+ if (deviceName.equals(jTable1.getValueAt(row, col))) {
+ rowD = row;
+ break;
+ }
+ }
+ }
+ if (rowD > 0) {
+ //search for test name in table
+ for (int col = 0; col <= jTable1.getColumnCount() - 1; col++) {
+ if (testName.equals(jTable1.getValueAt(rowD, col))) {
+ colT = col;
+ break;
+ }
+ }
+ }
+ String iconSource = "/icons/button_help-16px.png";
+ switch (status) {
+ case "Success":
+ iconSource = "/icons/button_ok-16px.png";
+ logger.log(Level.INFO, "Device: " + testName + "Test: " + testName + " Result: " + res + " (" + status + ")");
+ break;
+ case "Failed":
+ iconSource = "/icons/button_close-16px.png";
+ logger.log(Level.SEVERE, "Device: " + testName + "Test: " + testName + " Result: " + res + " (" + status + ")");
+ break;
+ case "Running":
+ iconSource = "/icons/button_play-16px.png";
+ logger.log(Level.INFO, "Running Test: " + testName + " ... ");
+ break;
+ }
+ ImageIcon icon = new ImageIcon(getClass().getResource(iconSource));
+ jTable1.setValueAt(icon, rowD, COL_ICON);
+
+ if (colT > 0 && rowD > 0) {
+ jTable1.setValueAt(getNow(), rowD, COL_TIME);
+ jTable1.setValueAt(res, rowD, COL_RESULT);
+ jTable1.setValueAt(status, rowD, COL_STATUS);
+ jTable1.getCellEditor(rowD, COL_STATUS);
+ }
+ }
+
+
// //GEN-BEGIN:initComponents
private void initComponents() {
@@ -212,6 +210,7 @@ public class TestingList extends Panel {
}
});
jTable1.getTableHeader().setReorderingAllowed(false);
+ jTable1.setDragEnabled(true);
jTable1.setRowHeight(22);
jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
@@ -246,6 +245,8 @@ public class TestingList extends Panel {
jTextField1.setColumns(20);
jTextField1.setRows(5);
+ jTextField1.setMaximumSize(new java.awt.Dimension(2147483647, 100));
+ jTextField1.setPreferredSize(new java.awt.Dimension(204, 40));
jScrollPane1.setViewportView(jTextField1);
add(jScrollPane1, java.awt.BorderLayout.PAGE_START);
@@ -259,63 +260,60 @@ public class TestingList extends Panel {
});
add(jButtonOpenLog, java.awt.BorderLayout.LINE_END);
}// //GEN-END:initComponents
-
+
private void jButtonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRunActionPerformed
- try {
- boolean var1 = true;
- int var2 = 2;// (Integer)spinner.getValue();
- int result;
- String deviceName = "RS";
- String testName = "Range Shifter Tests";
- HashMap args = new HashMap();
- args.put("relative", var1);
- args.put("steps", var2);
- args.put("deviceName",deviceName);
- args.put("testName",testName);
- run("power-supply", args);
- //this is just to try, must be modified
- showResult(deviceName, testName, "Test running", "Running");
+ try {
+ boolean var1 = true;
+ int var2 = 2;// (Integer)spinner.getValue();
+ int result;
+ String deviceName = "RS";
+ String testName = "Range Shifter Tests";
+ HashMap args = new HashMap();
+ args.put("relative", var1);
+ args.put("steps", var2);
+ args.put("deviceName", deviceName);
+ args.put("testName", testName);
+ run("power-supply", args);
+ //this is just to try, must be modified
+ showResult(deviceName, testName, "Test running", "Running");
//evalAsync("run('args', locals = {'relative':" + (var1 ? "True" :"False") + ", 'steps':" + var2 + "})");
-
- } catch (Exception ex) {
- SwingUtils.showException(this, ex);
- }
+
+ } catch (Exception ex) {
+ SwingUtils.showException(this, ex);
+ }
}//GEN-LAST:event_jButtonRunActionPerformed
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
- boolean bSelected = jCheckBox1.isSelected();
- for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
+ boolean bSelected = jCheckBox1.isSelected();
+ for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
jTable1.setValueAt(bSelected, row, 0);
- }
- updateStatus();
+ }
+ updateStatus();
}//GEN-LAST:event_jCheckBox1ActionPerformed
- public void updateStatus(){
- String sStatus, iconSource;
- boolean bSelected;
- for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
- bSelected = (boolean) jTable1.getValueAt(row, 0);
- if(bSelected){
- sStatus = "Pending";
- iconSource = "/icons/button_pause-16px.png";
- }
- else{
- sStatus = "Disabled";
- iconSource = "/icons/button_stop-16px.png";
- }
- ImageIcon icon = new ImageIcon(getClass().getResource(iconSource));
- jTable1.setValueAt(bSelected, row, COL_CHECK);
- jTable1.setValueAt(icon, row, COL_ICON);
- jTable1.setValueAt(sStatus, row, COL_STATUS);
- }
- }
-
+ public void updateStatus() {
+ String sStatus, iconSource;
+ boolean bSelected;
+ for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
+ bSelected = (boolean) jTable1.getValueAt(row, 0);
+ if (bSelected) {
+ sStatus = "Pending";
+ iconSource = "/icons/button_pause-16px.png";
+ } else {
+ sStatus = "Disabled";
+ iconSource = "/icons/button_stop-16px.png";
+ }
+ ImageIcon icon = new ImageIcon(getClass().getResource(iconSource));
+ jTable1.setValueAt(bSelected, row, COL_CHECK);
+ jTable1.setValueAt(icon, row, COL_ICON);
+ jTable1.setValueAt(sStatus, row, COL_STATUS);
+ }
+ }
+
private void jTable1InputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_jTable1InputMethodTextChanged
- // TODO add your handling code here:
}//GEN-LAST:event_jTable1InputMethodTextChanged
private void jTable1CaretPositionChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_jTable1CaretPositionChanged
- // TODO add your handling code here:
}//GEN-LAST:event_jTable1CaretPositionChanged
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
@@ -331,24 +329,23 @@ public class TestingList extends Panel {
private void jButtonOpenLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOpenLogActionPerformed
// TODO add your handling code here:
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
- String cmd;
- cmd = "notepad.exe " + TESTS_LOG_DEFAULT_DIR;
+ String cmd;
+ cmd = "notepad.exe " + TESTS_LOG_DEFAULT_DIR;
try {
Runtime.getRuntime().exec(cmd);
} catch (IOException ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
}
- }
- else {
- File log = new File(TESTS_LOG_DEFAULT_DIR);
+ } else {
+ File log = new File(TESTS_LOG_DEFAULT_DIR);
try {
Desktop.getDesktop().edit(log);
} catch (IOException ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
}
- }
+ }
}//GEN-LAST:event_jButtonOpenLogActionPerformed
-
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonOpenLog;
private javax.swing.JButton jButtonRun;
@@ -358,115 +355,115 @@ public class TestingList extends Panel {
private javax.swing.JTable jTable1;
private javax.swing.JTextArea jTextField1;
// End of variables declaration//GEN-END:variables
-
- //table management
- public void buildTable(){
- String sDate = getNow();
- ImageIcon icon = new ImageIcon(getClass().getResource("/icons/button_pause-16px.png"));
- DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
- jTable1.setModel(model);
- jTable1.getColumnModel().getColumn(COL_ICON).setMaxWidth(27);
- jTable1.getColumnModel().getColumn(COL_CHECK).setMaxWidth(27);
- jTable1.getColumnModel().getColumn(COL_DEVICENAME).setPreferredWidth(30);
- jTable1.getColumnModel().getColumn(COL_STATUS).setPreferredWidth(30);
- updateStatus();
- }
-
- //append test info to table
- public void addToTable(String deviceName, String deviceDescription, String testSuite, String testName){
- String sDate = "";
- if(testName.equals("") || deviceName.equals("")) return;
- ImageIcon icon = new ImageIcon(getClass().getResource("/icons/button_pause-16px.png"));
- DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
- model.addRow(new Object[] {false, sDate, deviceName, deviceDescription, testSuite, testName, "", "Pending", icon});
- jTable1.setModel(model);
- updateStatus();
- }
-
- //formatted time
- public String getNow(){
- DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- Date date = new Date();
- return dateFormat.format(date);
- }
-
- //time without format
- public String getnow(){
- DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
- Date date = new Date();
- return dateFormat.format(date);
- }
-
-
- public void loadTests() throws FileNotFoundException, IOException{
- Properties propDevice = new Properties();
- Properties propTest = new Properties();
- String fileName = TESTS_DEVICES_DEFAULT_DIR;
- this.jTextField1.setText(fileName + "\n");
- File folder = new File(fileName);
- File testsFolder = null;
- String sTestName;
- int iCounter = 0;
+
+ //table management
+ public void buildTable() {
+ String sDate = getNow();
+ ImageIcon icon = new ImageIcon(getClass().getResource("/icons/button_pause-16px.png"));
+ DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
+ jTable1.setModel(model);
+ jTable1.getColumnModel().getColumn(COL_ICON).setMaxWidth(27);
+ jTable1.getColumnModel().getColumn(COL_CHECK).setMaxWidth(27);
+ jTable1.getColumnModel().getColumn(COL_DEVICENAME).setPreferredWidth(30);
+ jTable1.getColumnModel().getColumn(COL_STATUS).setPreferredWidth(30);
+ updateStatus();
+ }
+
+ //append test info to table
+ public void addToTable(String deviceName, String deviceDescription, String testSuite, String testName) {
+ String sDate = "";
+ if (testName.equals("") || deviceName.equals("")) {
+ return;
+ }
+ ImageIcon icon = new ImageIcon(getClass().getResource("/icons/button_pause-16px.png"));
+ DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
+ model.addRow(new Object[]{false, sDate, deviceName, deviceDescription, testSuite, testName, "", "Pending", icon});
+ jTable1.setModel(model);
+ updateStatus();
+ }
+
+ //formatted time
+ public String getNow() {
+ DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+ Date date = new Date();
+ return dateFormat.format(date);
+ }
+
+ //time without format
+ public String getnow() {
+ DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+ Date date = new Date();
+ return dateFormat.format(date);
+ }
+
+ //scan tests directory, scan devices directory, search for their test cases and scan for tests.
+ public void loadTests() throws FileNotFoundException, IOException {
+ Properties propDevice = new Properties();
+ Properties propTest = new Properties();
+ String fileName = TESTS_DEVICES_DEFAULT_DIR;
+ this.jTextField1.setText(fileName + "\n");
+ File folder = new File(fileName);
+ File testsFolder = null;
+ String sTestName;
+ int iCounter = 0;
//search of devices and their tests
- //Scan the list of devices
- File[] listOfFiles = folder.listFiles();
- for (File listOfFile : listOfFiles) {
- if (listOfFile.isFile()) {
- this.jTextField1.append("\nFile " + listOfFile.getName());
- } else if (listOfFile.isDirectory()) {
- this.jTextField1.append("\nDirectory " + listOfFile.getName());
- File configFile = new File(listOfFile.getPath() + FilenameUtils.separatorsToSystem("/.config"));
- if(configFile.exists() && !configFile.isDirectory()){
- InputStream is = new FileInputStream(configFile);
- propDevice.load(is);
- //config of device was loaded. now load the config of each test belonging to the device
- sTestName = TESTS_TESTS_DEFAULT_DIR + propDevice.getProperty("tests");
- this.jTextField1.append("\nTest suite: " + sTestName);
- testsFolder = new File(sTestName);
- if(testsFolder.exists() && testsFolder.isDirectory()){
- File[] listOfTests = testsFolder.listFiles();
- for (File listOfTest : listOfTests) {
- if (listOfTest.isDirectory()) {
- this.jTextField1.append("\nTest: " + listOfTest.getPath());
- configFile = new File(listOfTest.getPath() + FilenameUtils.separatorsToSystem("/.config"));
- if(configFile.exists() && !configFile.isDirectory()){
- InputStream ist = new FileInputStream(configFile);
- propTest.load(ist);
- addToTable(propDevice.getProperty("name"),
- propDevice.getProperty("description"),
- propDevice.getProperty("tests"),
- propTest.getProperty("name"));
- this.jTextField1.append("\nProperties: ");
- this.jTextField1.append(propDevice.getProperty("name"));
- this.jTextField1.append(propDevice.getProperty("description"));
- this.jTextField1.append(propDevice.getProperty("tests"));
- this.jTextField1.append(propTest.getProperty("name"));
- iCounter++;
- }
+ //Scan the list of devices
+ File[] listOfFiles = folder.listFiles();
+ for (File listOfFile : listOfFiles) {
+ if (listOfFile.isFile()) {
+ this.jTextField1.append("\nFile " + listOfFile.getName());
+ } else if (listOfFile.isDirectory()) {
+ this.jTextField1.append("\nDirectory " + listOfFile.getName());
+ File configFile = new File(listOfFile.getPath() + FilenameUtils.separatorsToSystem("/.config"));
+ if (configFile.exists() && !configFile.isDirectory()) {
+ InputStream is = new FileInputStream(configFile);
+ propDevice.load(is);
+ //config of device was loaded. now load the config of each test belonging to the device
+ sTestName = TESTS_TESTS_DEFAULT_DIR + propDevice.getProperty("tests");
+ this.jTextField1.append("\nTest suite: " + sTestName);
+ testsFolder = new File(sTestName);
+ if (testsFolder.exists() && testsFolder.isDirectory()) {
+ File[] listOfTests = testsFolder.listFiles();
+ for (File listOfTest : listOfTests) {
+ if (listOfTest.isDirectory()) {
+ this.jTextField1.append("\nTest: " + listOfTest.getPath());
+ configFile = new File(listOfTest.getPath() + FilenameUtils.separatorsToSystem("/.config"));
+ if (configFile.exists() && !configFile.isDirectory()) {
+ InputStream ist = new FileInputStream(configFile);
+ propTest.load(ist);
+ addToTable(propDevice.getProperty("name"),
+ propDevice.getProperty("description"),
+ propDevice.getProperty("tests"),
+ propTest.getProperty("name"));
+ this.jTextField1.append("\nProperties: ");
+ this.jTextField1.append(propDevice.getProperty("name"));
+ this.jTextField1.append(propDevice.getProperty("description"));
+ this.jTextField1.append(propDevice.getProperty("tests"));
+ this.jTextField1.append(propTest.getProperty("name"));
+ iCounter++;
+ }
+ }
}
}
}
}
}
+ logger.log(Level.INFO, iCounter + " tests loaded.");
}
- logger.log(Level.INFO, iCounter + " tests loaded.");
- }
-
-
- public void selectFile(){
- final JFileChooser fc = new JFileChooser();
-
- int returnVal = fc.showOpenDialog(NetbeansPluginPanel.this);
+ public void selectFile() {
+ final JFileChooser fc = new JFileChooser();
+
+ int returnVal = fc.showOpenDialog(NetbeansPluginPanel.this);
+
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = fc.getSelectedFile();
+ //This is where a real application would open the file.
+ System.out.println("Opening: " + file.getName() + ".");
+ } else {
+ System.out.println("Open command cancelled by user.");
+ }
+ }
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- //This is where a real application would open the file.
- System.out.println("Opening: " + file.getName() + ".");
- } else {
- System.out.println("Open command cancelled by user." );
- }
}
-
-}
}