diff --git a/src/eva2/gui/OptimizationEditorPanel.java b/src/eva2/gui/OptimizationEditorPanel.java index 8ef1959b..2d9e699e 100644 --- a/src/eva2/gui/OptimizationEditorPanel.java +++ b/src/eva2/gui/OptimizationEditorPanel.java @@ -3,8 +3,8 @@ package eva2.gui; import eva2.gui.editor.GenericObjectEditor; import eva2.optimization.tools.FileTools; import eva2.tools.BasicResourceLoader; -import eva2.tools.EVAHELP; import eva2.tools.SerializedObject; +import eva2.tools.StringTools; import eva2.util.annotation.Description; import eva2.yaml.BeanSerializer; @@ -320,7 +320,7 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener { if (classesLongNames.size() > 1) { classNameMap = new HashMap<>(); for (String className : classesLongNames) { - classNameMap.put(EVAHELP.cutClassName(className), className); + classNameMap.put(StringTools.cutClassName(className), className); } Vector classesList = new Vector<>(classesLongNames); objectChooser.setModel(new DefaultComboBoxModel(classesList)); @@ -415,7 +415,6 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener { + "from the current classpath. Is the resource folder at the right place?\nIs the class abstract or the default constructor missing?", "GenericObjectEditor", JOptionPane.ERROR_MESSAGE); - EVAHELP.getSystemPropertyString(); } } } diff --git a/src/eva2/gui/PropertyDialog.java b/src/eva2/gui/PropertyDialog.java index b3e1b9bd..3d0b9c7b 100644 --- a/src/eva2/gui/PropertyDialog.java +++ b/src/eva2/gui/PropertyDialog.java @@ -2,7 +2,7 @@ package eva2.gui; import eva2.EvAInfo; import eva2.tools.BasicResourceLoader; -import eva2.tools.EVAHELP; +import eva2.tools.StringTools; import javax.swing.*; import java.awt.*; @@ -37,9 +37,9 @@ public class PropertyDialog extends JDialog { protected static String getFrameNameFromEditor(PropertyEditor editor) { if (editor.getValue().getClass().isArray()) { - return "Array of " + EVAHELP.cutClassName(editor.getValue().getClass().getComponentType().getName()); + return "Array of " + StringTools.cutClassName(editor.getValue().getClass().getComponentType().getName()); } else { - return EVAHELP.cutClassName(editor.getValue().getClass().getName()); + return StringTools.cutClassName(editor.getValue().getClass().getName()); } } diff --git a/src/eva2/gui/PropertyPanel.java b/src/eva2/gui/PropertyPanel.java index d22a75dc..4a31ae27 100644 --- a/src/eva2/gui/PropertyPanel.java +++ b/src/eva2/gui/PropertyPanel.java @@ -1,6 +1,6 @@ package eva2.gui; -import eva2.tools.EVAHELP; +import eva2.tools.StringTools; import javax.swing.*; import java.awt.*; @@ -37,7 +37,7 @@ public class PropertyPanel extends JPanel { public final void showDialog() { Window parent = (Window)this.getRootPane().getParent(); if (propertyDialog == null) { - propertyDialog = new PropertyDialog(parent, propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName())); + propertyDialog = new PropertyDialog(parent, propertyEditor, StringTools.cutClassName(propertyEditor.getClass().getName())); propertyDialog.setPreferredSize(new Dimension(500, 300)); propertyDialog.setModal(true); propertyDialog.setVisible(true); diff --git a/src/eva2/gui/PropertySheetPanel.java b/src/eva2/gui/PropertySheetPanel.java index 7c8f3055..18dd5152 100644 --- a/src/eva2/gui/PropertySheetPanel.java +++ b/src/eva2/gui/PropertySheetPanel.java @@ -1,7 +1,7 @@ package eva2.gui; import eva2.gui.editor.GenericObjectEditor; -import eva2.tools.EVAHELP; +import eva2.tools.StringTools; import eva2.util.annotation.Description; import eva2.util.annotation.Hidden; import eva2.util.annotation.Parameter; @@ -664,7 +664,7 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi * @return */ protected String getHelpFileName() { - return EVAHELP.cutClassName(className) + ".html"; + return StringTools.cutClassName(className) + ".html"; } /** diff --git a/src/eva2/gui/editor/ArrayEditor.java b/src/eva2/gui/editor/ArrayEditor.java index 9b476262..c58219ab 100644 --- a/src/eva2/gui/editor/ArrayEditor.java +++ b/src/eva2/gui/editor/ArrayEditor.java @@ -1,8 +1,8 @@ package eva2.gui.editor; import eva2.gui.*; -import eva2.tools.EVAHELP; import eva2.tools.SerializedObject; +import eva2.tools.StringTools; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -689,7 +689,7 @@ public class ArrayEditor extends JPanel implements PropertyEditor { if (listModel.getSize() == 0) { rep = "Empty"; } else { - rep = listModel.getSize() + " of " + EVAHELP.cutClassName(elementClass.getName()); + rep = listModel.getSize() + " of " + StringTools.cutClassName(elementClass.getName()); Object maybeName = BeanInspector.callIfAvailable(listModel.get(0), "getName", new Object[]{}); if (maybeName != null) { rep = rep + " (" + maybeName + "...)"; diff --git a/src/eva2/optimization/tools/AbstractObjectEditor.java b/src/eva2/optimization/tools/AbstractObjectEditor.java index 80eb2d3e..5eb26435 100644 --- a/src/eva2/optimization/tools/AbstractObjectEditor.java +++ b/src/eva2/optimization/tools/AbstractObjectEditor.java @@ -6,7 +6,7 @@ import eva2.gui.HtmlDemo; import eva2.gui.PropertyEditorProvider; import eva2.gui.PropertySheetPanel; import eva2.gui.editor.GenericObjectEditor; -import eva2.tools.EVAHELP; +import eva2.tools.StringTools; import eva2.util.annotation.Parameter; import javax.swing.*; @@ -20,7 +20,6 @@ import java.util.Hashtable; * TODO * This class should be unified with GenericObjectEditor. */ - public abstract class AbstractObjectEditor implements PropertyEditor, java.beans.PropertyChangeListener { /** * Handles property change notification @@ -63,7 +62,6 @@ public abstract class AbstractObjectEditor implements PropertyEditor, java.beans propertyChangeSupport.firePropertyChange("", backupObject, object); } - /********************************* PropertyEditor *************************/ /** * Returns true since the Object can be shown * @@ -153,8 +151,6 @@ public abstract class AbstractObjectEditor implements PropertyEditor, java.beans */ abstract public Class getClassType(); -// abstract public Vector getClassesFromProperties(); - /** * This method returns a property panel to * edit the parameters @@ -169,7 +165,7 @@ public abstract class AbstractObjectEditor implements PropertyEditor, java.beans result.setLayout(new BorderLayout()); result.setVisible(true); - // Define the upper area containing the desription and the help button + // Define the upper area containing the description and the help button String globalInfo = this.getGlobalInfo(); JTextArea jt = new JTextArea(); StringBuffer helpText; @@ -184,7 +180,7 @@ public abstract class AbstractObjectEditor implements PropertyEditor, java.beans helpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { - HtmlDemo temp = new HtmlDemo(EVAHELP.cutClassName(object.getClass().getName()) + ".html"); + HtmlDemo temp = new HtmlDemo(StringTools.cutClassName(object.getClass().getName()) + ".html"); temp.show(); } }); @@ -222,7 +218,7 @@ public abstract class AbstractObjectEditor implements PropertyEditor, java.beans } public String getHelpFileName() { - return EVAHELP.cutClassName(object.getClass().getName()) + ".html"; + return StringTools.cutClassName(object.getClass().getName()) + ".html"; } /** diff --git a/src/eva2/optimization/tools/GeneralGenericObjectEditorPanel.java b/src/eva2/optimization/tools/GeneralGenericObjectEditorPanel.java index 3d2c33cd..e5afa270 100644 --- a/src/eva2/optimization/tools/GeneralGenericObjectEditorPanel.java +++ b/src/eva2/optimization/tools/GeneralGenericObjectEditorPanel.java @@ -2,7 +2,6 @@ package eva2.optimization.tools; import eva2.gui.editor.GenericObjectEditor; -import eva2.tools.EVAHELP; import javax.swing.*; import java.awt.*; @@ -330,7 +329,6 @@ public class GeneralGenericObjectEditorPanel extends JPanel implements ItemListe + "from the current classpath", "GenericObjectEditor", JOptionPane.ERROR_MESSAGE); - EVAHELP.getSystemPropertyString(); } } } diff --git a/src/eva2/tools/EVAHELP.java b/src/eva2/tools/EVAHELP.java deleted file mode 100644 index 5c5d6ae4..00000000 --- a/src/eva2/tools/EVAHELP.java +++ /dev/null @@ -1,151 +0,0 @@ -package eva2.tools; - -import java.io.*; -import java.net.InetAddress; -import java.util.Enumeration; -import java.util.Properties; - -/** - * - */ -public class EVAHELP { - - private static long timestamp; - - /** - * - */ - /** - * - */ - public static String getmyRUP() { - String Out = ""; - String HostName = ""; - try { - HostName = InetAddress.getLocalHost().getHostName(); - } catch (Exception e) { - System.out.println("ERROR getting HostName EVAHELP " + e.getMessage()); - } - - try { - BufferedReader in = null; - Process pro = null; - String command = "rup " + HostName; - pro = Runtime.getRuntime().exec(command); - in = new BufferedReader(new InputStreamReader(pro.getInputStream())); - String line = null; - while ((line = in.readLine()) != null) { - //System.out.println(line); - Out += line; - } - } catch (Exception e) { - System.out.println("Error in calling the command:" + e.getMessage()); - } - return Out; - } - - /** - * - */ - public static void setTimeStamp() { - timestamp = System.currentTimeMillis(); - } - - /** - * - */ - public static long getTimeStamp() { - return System.currentTimeMillis() - timestamp; - } - - /** - * - */ - public static void returnForExit() { - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - System.out.println("return for exit:"); - try { - in.readLine(); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - } - - /** - * - */ - public static String getSystemPropertyString() { - StringBuilder sBuf = new StringBuilder(); - Properties prop = System.getProperties(); - Enumeration list = prop.propertyNames(); - while (list.hasMoreElements()) { - Object o = list.nextElement(); - //System.out.println("o="+o.toString()); - sBuf.append(o.toString()); - sBuf.append(" = "); - sBuf.append(System.getProperty(o.toString())); - sBuf.append("\n"); - } - return sBuf.toString(); - } - - /** - * @param longName The FQDN of a class - * @return Returns the class Name without package. - */ - public static String cutClassName(final String longName) { - final int dotPos = longName.lastIndexOf('.'); - String className = longName; - if (dotPos != -1) { - className = className.substring(dotPos + 1); - } - return className; // now is shortName - } - - /** - * - */ - public static void freeMemory() { - Runtime currR = Runtime.getRuntime(); - long freeM = currR.freeMemory(); - freeM /= 1024; - //System.out.println("Available memory : "+freeM+" Kbytes"); - System.gc(); - currR = Runtime.getRuntime(); - freeM = currR.freeMemory(); - freeM /= 1024; - //System.out.println("after gc:Available memory : "+freeM+" bytes"); - } - - /** - * Log a String to a log-file indicated by the file name. If the file - * exists, the String is appended. - * - * @param msg - * @param fileName - */ - public static void logString(String msg, String fileName) { - final File logFile = new File(fileName); - try { - BufferedWriter bW = new BufferedWriter( - new PrintWriter(new FileOutputStream(logFile, logFile.exists()))); - bW.write(msg); - bW.close(); - } catch (IOException ex) { - System.err.println("couldnt log to destination " + fileName + ": " + ex.getMessage()); - } - } - - /** - * Deletes the given file in the current directory. If the file does not - * exist nothing happens. - * - * @param fileName The name of the log file - */ - public static void clearLog(String fileName) { - File logFile = new File(fileName); - if (logFile.exists()) { - logFile.delete(); - } - } -} \ No newline at end of file diff --git a/src/eva2/tools/StringSelection.java b/src/eva2/tools/StringSelection.java index 936c8461..740cba40 100644 --- a/src/eva2/tools/StringSelection.java +++ b/src/eva2/tools/StringSelection.java @@ -194,10 +194,6 @@ public class StringSelection implements Serializable { return false; } return isSelected(selIndex); -// for (int i=0; i