Closedown

This commit is contained in:
boccioli_m
2015-10-15 10:56:41 +02:00
parent d2ae02b903
commit 99c05b409e
3 changed files with 62 additions and 20 deletions

View File

@@ -32,6 +32,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -67,7 +68,7 @@ import static org.python.bouncycastle.util.Arrays.append;
* @author boccioli_m
*/
public class TestingList extends Panel {
Properties properties = new Properties();
Task task = new Task() {
@Override
protected Object execute() throws Exception {
@@ -348,6 +349,7 @@ public class TestingList extends Panel {
property = props.getProperty("showEnabledTestsOnly");
property = property.replace("\"","");
showEnabledTestsOnly("true".equals(property));
properties = props;
reader.close();
} catch (FileNotFoundException ex) {
@@ -359,6 +361,32 @@ public class TestingList extends Panel {
}
}
/**
* save general properties
*/
private void saveProperties(){
File configFile = TESTS_PROPERTIES_DEFAULT_DIR.toFile();
/*
try {
if (!configFile.isFile()) configFile.createNewFile();
FileReader reader = new FileReader(configFile);
Properties props = properties;
OutputStream out = new FileOutputStream( configFile );
props.store(out, "TestingList for pshell: configuration properties");
out.close();
} catch (FileNotFoundException ex) {
// file does not exist
System.out.println(ex.toString());
} catch (IOException ex) {
// I/O error
System.out.println(ex.toString());
}
*/
}
/**
* close the custom panel if present
@@ -367,6 +395,9 @@ public class TestingList extends Panel {
jPanelCustomFrame.removeAll();
jPanelCustom.setVisible(false);
repaint();
//store custom panel in the properties
//properties.setProperty("customPanel", "");
saveProperties();
}
@@ -416,9 +447,11 @@ public class TestingList extends Panel {
*
*/
private void loadCustomPanel(String sPanelClassName){
if (sPanelClassName == null || sPanelClassName == "") return;
closeCustomPanel();
if (sPanelClassName == null || sPanelClassName == "") {
return;
}
try {
closeCustomPanel();
//create a class to visualise the details panel
Class panelClass = getController().getClassByName(sPanelClassName);
JPanel detailsPanel = (JPanel) panelClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{""});
@@ -426,6 +459,9 @@ public class TestingList extends Panel {
this.jLabelCustomPanelName.setText(sPanelClassName);
repaint();
revalidate();
//store custom panel in the properties
//properties.setProperty("customPanel", sPanelClassName);
saveProperties();
jPanelCustom.setVisible(true);
} catch (ClassNotFoundException ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
@@ -1218,11 +1254,16 @@ public class TestingList extends Panel {
* @param show if false, show all tests. If true, show only selected tests.
*/
public void showEnabledTestsOnly(boolean show) {
String filter;
if (show) {
filterTests("true");
filter ="true";
} else {
filterTests("");
filter ="";
}
filterTests(filter);
//store filter in the properties
//properties.setProperty("showEnabledTestsOnly", filter);
saveProperties();
//if only enabled tests are visible, disable the move buttons
this.jButtonMoveUp.setEnabled(!show);
this.jButtonMoveDown.setEnabled(!show);
@@ -2332,6 +2373,9 @@ public class TestingList extends Panel {
}
in.close();
loadTests();
//store current file in the properties
//properties.setProperty("listFilter", file.toString());
saveProperties();
} catch (Exception ex) {
ex.printStackTrace();
SwingUtils.showMessage(this, "loadListFilter()", ex.toString());