Further cleanup of logging.
This commit is contained in:
Fabian Becker 2013-01-31 15:56:53 +00:00
parent d474eebfa2
commit d93c8bf2b0
7 changed files with 1194 additions and 1258 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,8 +28,7 @@ import javax.swing.plaf.basic.BasicComboBoxRenderer;
public class GOEPanel extends JPanel implements ItemListener {
private Object backupObject;
private PropertyChangeSupport propChangeSupport;
private static boolean TRACE = false;
private PropertyChangeSupport propChangeSupport;
/**
* The chooser component
*/

View File

@ -263,8 +263,7 @@ public class GenericObjectEditor implements PropertyEditor {
*
* @param type a value of type 'Class'
*/
public void setClassType(Class<?> type) {
//if (TRACE) System.out.println("GOE setClassType("+ (type == null? "<null>" : type.getName()) + ")");
public void setClassType(Class<?> type) {
classType = type;
if (editorComponent != null) {
editorComponent.updateClassType();
@ -337,7 +336,6 @@ public class GenericObjectEditor implements PropertyEditor {
*/
private void setObject(Object c) {
// This should really call equals() for comparison.
//if (TRACE) System.out.println("setObject "+ c.getClass().getName() + " " + c);
boolean trueChange = (c != getValue());
m_Backup = m_Object;

View File

@ -6,13 +6,14 @@ package eva2.gui;
*/
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* It represents one plot window in the client GUI.
*/
public class GraphWindow {
public static boolean TRACE = false;
private static final Logger LOGGER = Logger.getLogger(GraphWindow.class.getName());
static private int graphCounter = -1;
static private PlotContainer plotContainer;
private PlotInterface plotter;
@ -57,9 +58,6 @@ public class GraphWindow {
*
*/
private GraphWindow(String plotName, String strx, String stry) {
if (TRACE) {
System.out.println("Constructor GraphWindow");
}
name = plotName;
plotter = new Plot(plotName, strx, stry, true);
}
@ -76,9 +74,7 @@ public class GraphWindow {
*/
public Graph getNewGraph(String infoString) {
graphCounter++;
if (TRACE) {
System.out.println("Graph.getNewGraph No:" + graphCounter + " - " + infoString);
}
LOGGER.log(Level.FINEST, "Graph.getNewGraph No:{0} - {1} created.", new Object[]{graphCounter, infoString});
return new Graph(infoString, plotter, graphCounter);
}
}
@ -104,7 +100,7 @@ class PlotContainer extends ArrayList<GraphWindow> {
*
*/
public boolean containsName(String name) {
GraphWindow temp = null;
GraphWindow temp;
for (int i = 0; i < size(); i++) {
temp = (GraphWindow) (get(i));
if (name.equals(temp.getName())) {
@ -130,7 +126,7 @@ class PlotContainer extends ArrayList<GraphWindow> {
return actualPlot;
}
}
GraphWindow temp = null;
GraphWindow temp;
for (int i = 0; i < size(); i++) {
temp = (GraphWindow) (get(i));
if (name.equals(temp.getName())) {

View File

@ -9,94 +9,93 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.beans.*;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
/**
*
*/
public class JExtMenu extends JMenu{
public final static String ACTION = "Action";
/**
*
*/
public JExtMenu(){
//super();
//Mnemonic m = new Mnemonic(s);
//setText(m.getText());
//setMnemonic(m.getMnemonic());
}
/**
*
*/
public JExtMenu(String s){
super();
Mnemonic m = new Mnemonic(s);
setText(m.getText());
setMnemonic(m.getMnemonic());
}
/**
*
*/
public class JExtMenu extends JMenu {
public final static String ACTION = "Action";
/**
*
*/
public JExtMenu() {
//super();
//Mnemonic m = new Mnemonic(s);
//setText(m.getText());
//setMnemonic(m.getMnemonic());
}
/**
*
*/
public JExtMenu(String s) {
super();
Mnemonic m = new Mnemonic(s);
setText(m.getText());
setMnemonic(m.getMnemonic());
}
/**
*
*/
@Override
public JMenuItem add(Action a){
JMenuItem item = super.add(a);
Object o;
o = a.getValue(ExtAction.MNEMONIC);
if(o != null) {
item.setMnemonic(((Character)o).charValue());
}
o = a.getValue(ExtAction.TOOLTIP);
if(o != null) {
item.setToolTipText((String)o);
}
o = a.getValue(ExtAction.KEYSTROKE);
if(o != null) {
item.setAccelerator((KeyStroke)o);
}
return item;
}
/**
*
*/
@Override
protected PropertyChangeListener createActionChangeListener(JMenuItem b){
return new ExtActionChangedListener(b){
@Override
public void propertyChange(PropertyChangeEvent e) {
JMenuItem menuItem = (JMenuItem)component;
if(menuItem == null) {
return;
}
String propertyName = e.getPropertyName();
if(propertyName.equals(Action.NAME)) {
menuItem.setText((String)e.getNewValue());
}
else if(propertyName.equals("enabled")) {
menuItem.setEnabled(((Boolean)e.getNewValue()).booleanValue());
}
else if(propertyName.equals(Action.SMALL_ICON)){
Icon icon = (Icon)e.getNewValue();
menuItem.setIcon(icon);
menuItem.invalidate();
menuItem.repaint();
public JMenuItem add(Action a) {
JMenuItem item = super.add(a);
Object o;
o = a.getValue(ExtAction.MNEMONIC);
if (o != null) {
item.setMnemonic(((Character) o).charValue());
}
else if(propertyName.equals(ExtAction.MNEMONIC)) {
menuItem.setMnemonic(((Character)e.getNewValue()).charValue());
}
else if(propertyName.equals(ExtAction.TOOLTIP)) {
menuItem.setToolTipText((String)e.getNewValue());
}
else if(propertyName.equals(ExtAction.KEYSTROKE)) {
menuItem.setAccelerator((KeyStroke)e.getNewValue());
}
}
};
}
o = a.getValue(ExtAction.TOOLTIP);
if (o != null) {
item.setToolTipText((String) o);
}
o = a.getValue(ExtAction.KEYSTROKE);
if (o != null) {
item.setAccelerator((KeyStroke) o);
}
return item;
}
/**
*
*/
@Override
protected PropertyChangeListener createActionChangeListener(JMenuItem b) {
return new ExtActionChangedListener(b) {
@Override
public void propertyChange(PropertyChangeEvent e) {
JMenuItem menuItem = (JMenuItem) component;
if (menuItem == null) {
return;
}
String propertyName = e.getPropertyName();
if (propertyName.equals(Action.NAME)) {
menuItem.setText((String) e.getNewValue());
} else if (propertyName.equals("enabled")) {
menuItem.setEnabled(((Boolean) e.getNewValue()).booleanValue());
} else if (propertyName.equals(Action.SMALL_ICON)) {
Icon icon = (Icon) e.getNewValue();
menuItem.setIcon(icon);
menuItem.invalidate();
menuItem.repaint();
} else if (propertyName.equals(ExtAction.MNEMONIC)) {
menuItem.setMnemonic(((Character) e.getNewValue()).charValue());
} else if (propertyName.equals(ExtAction.TOOLTIP)) {
menuItem.setToolTipText((String) e.getNewValue());
} else if (propertyName.equals(ExtAction.KEYSTROKE)) {
menuItem.setAccelerator((KeyStroke) e.getNewValue());
}
}
};
}
}

View File

@ -92,20 +92,7 @@ public class ModuleServer {
}
}
// and the running modules
// @todo running modules sind abgeschaltet
// for (int i = 0; i < m_RunnungModules.size(); i++) {
// String AdapterName = null;
// try {
// AdapterName = ( (ModuleAdapter) m_RunnungModules.get(i)).getAdapterName();
// }
// catch (Exception ee) {
// System.err.println("Error: GetAdapterName" + ee.getMessage());
// }
// ModuleNameList.add(AdapterName);
// }
String[] x = new String[moduleNameList.size()];
moduleNameList.toArray(x);
return x;
@ -176,21 +163,6 @@ public class ModuleServer {
return (ModuleAdapter) moduleAdapter;
}
}
// // @todo running modules sind gerade noch abgeschaltet
// for (int i = 0; i < m_RunnungModules.size(); i++) {
// try {
// adapterName = ( (ModuleAdapter) m_RunnungModules.get(i)).getAdapterName();
// }
// catch (Exception e) {
// System.out.println("Error : GetAdapterName" + e);
// }
// if (adapterName.equals(selectedModuleName)) {
// if (TRACE)
// System.out.println(" Choose a running Module!!! " + adapterName);
// m_ModuleAdapter = ( (ModuleAdapter) m_RunnungModules.get(i));
// return (ModuleAdapter) m_ModuleAdapter;
// }
// }
LOGGER.log(Level.SEVERE, "No valid module defined: {0}", selectedModuleName);
return null;

View File

@ -6,164 +6,175 @@ import java.util.logging.Logger;
/**
* This class defines utility routines that use Java serialization. Any
* serializable object can be stored to a file, loaded, and cloned (returning
* a deep copy).
*
* serializable object can be stored to a file, loaded, and cloned (returning a
* deep copy).
*
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher, Marcel Kronfeld
**/
*
*/
public class Serializer {
/**
* The logging instance for this class.
*/
private static final Logger LOGGER = Logger.getLogger(Serializer.class.getName());
/**
* Private constructor to prevent instantiating module class.
*/
private Serializer() { }
/**
* Serialize the object o (and any Serializable objects it refers to) and
* store its serialized state in File f. If serializeInMem is true, the object
* is wrapped in a SerializedObject first, which seems to be more efficient than
* writing a nested object directly to a file.
*
* @param o the object to write
* @param outStream The stream to write to
* @param serializeInMem flag whether to wrap the object in a SerializedObject
* @throws IOException
**/
private static void store(Serializable o, OutputStream outStream, boolean serializeInMem) throws IOException {
ObjectOutputStream out = new ObjectOutputStream(outStream);
try {
Object objToStore = o;
if (serializeInMem) {
private Serializer() {
}
/**
* Serialize the object o (and any Serializable objects it refers to) and
* store its serialized state in File f. If serializeInMem is true, the
* object is wrapped in a SerializedObject first, which seems to be more
* efficient than writing a nested object directly to a file.
*
* @param o the object to write
* @param outStream The stream to write to
* @param serializeInMem flag whether to wrap the object in a
* SerializedObject
* @throws IOException
*
*/
private static void store(Serializable o, OutputStream outStream, boolean serializeInMem) throws IOException {
ObjectOutputStream out = new ObjectOutputStream(outStream);
try {
Object objToStore = o;
if (serializeInMem) {
objToStore = new SerializedObject((Object) o);
}
out.writeObject(objToStore);
} catch (java.io.NotSerializableException ex) {
out.writeObject(objToStore);
} catch (java.io.NotSerializableException ex) {
LOGGER.log(Level.SEVERE, "Object is not serializable!", ex);
}
out.flush();
out.close();
}
}
out.flush();
out.close();
}
/**
* Deserialize the contents of File f and return the resulting object.
* A SerializedObject is unwrapped once.
/**
* Deserialize the contents of File f and return the resulting object. A
* SerializedObject is unwrapped once.
*
* @param inputStream The Input stream to read from
* @param inputStream The Input stream to read from
* @throws ClassNotFoundException
* @throws IOException
* @return The deserialized Object from the file
**/
private static Object load(final InputStream inputStream) throws IOException, ClassNotFoundException {
ObjectInputStream objInputStream = new ObjectInputStream(inputStream);
Object ret = objInputStream.readObject();
if (ret instanceof SerializedObject) {
ret = ((SerializedObject) ret).getObject();
}
objInputStream.close();
return ret;
}
/**
* Use object serialization to make a "deep clone" of the object o.
* This method serializes o and all of its member objects, and then
* deserializes that graph of objects, which means that everything is
* copied. This differs from the clone() method of an object which is
* usually implemented to produce a "shallow" clone that copies references
* to other objects, instead of copying all referenced objects.
**/
public static Object deepClone(Object o) {
Object obj = null;
try {
// Write the object out to a byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(o);
out.flush();
out.close();
// Make an input stream from the byte array and read
// a copy of the object back in.
ObjectInputStream inputStream = new ObjectInputStream(
new ByteArrayInputStream(bos.toByteArray()));
obj = inputStream.readObject();
} catch (IOException ex) {
LOGGER.log(Level.WARNING, "Error while cloning object.", ex);
} catch (ClassNotFoundException ex) {
LOGGER.log(Level.WARNING, "Object class was not found.", ex);
}
return obj;
}
/**
* Serialize the string data and write it to the OutputStream.
*
* @param outStream The output stream
* @param data The string data
**/
public static void storeString(final OutputStream outStream, final String data) {
try {
outStream.write(data.getBytes());
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Could not write string to stream", ex);
}
}
*/
private static Object load(final InputStream inputStream) throws IOException, ClassNotFoundException {
ObjectInputStream objInputStream = new ObjectInputStream(inputStream);
Object ret = objInputStream.readObject();
if (ret instanceof SerializedObject) {
ret = ((SerializedObject) ret).getObject();
}
objInputStream.close();
return ret;
}
/**
* Deserialize the contents of the InputStream containing
* a string and return the resulting string.
/**
* Use object serialization to make a "deep clone" of the object o. This
* method serializes o and all of its member objects, and then deserializes
* that graph of objects, which means that everything is copied. This
* differs from the clone() method of an object which is usually implemented
* to produce a "shallow" clone that copies references to other objects,
* instead of copying all referenced objects.
*
*/
public static Object deepClone(Object o) {
Object obj = null;
try {
// Write the object out to a byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(o);
out.flush();
out.close();
// Make an input stream from the byte array and read
// a copy of the object back in.
ObjectInputStream inputStream = new ObjectInputStream(
new ByteArrayInputStream(bos.toByteArray()));
obj = inputStream.readObject();
} catch (IOException ex) {
LOGGER.log(Level.WARNING, "Error while cloning object.", ex);
} catch (ClassNotFoundException ex) {
LOGGER.log(Level.WARNING, "Object class was not found.", ex);
}
return obj;
}
/**
* Serialize the string data and write it to the OutputStream.
*
* @param outStream The output stream
* @param data The string data
*
*/
public static void storeString(final OutputStream outStream, final String data) {
try {
outStream.write(data.getBytes());
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Could not write string to stream", ex);
}
}
/**
* Deserialize the contents of the InputStream containing a string and
* return the resulting string.
*
* @param inputStream The input stream to read from
* @return The deserialized data from the stream
**/
public static String loadString(final InputStream inputStream) {
StringBuilder sBuilder = new StringBuilder();
try {
*
*/
public static String loadString(final InputStream inputStream) {
StringBuilder sBuilder = new StringBuilder();
try {
int data = inputStream.read();
while (data != -1) {
sBuilder.append((char) data);
data = inputStream.read();
}
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Could not load string from stream!", ex);
}
return sBuilder.toString();
}
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Could not load string from stream!", ex);
}
return sBuilder.toString();
}
/**
* Serialize the string s and
* store its serialized state in File with name Filename.
**/
public static void storeObject(OutputStream outStream, Serializable s) {
try {
store(s, outStream, true);
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Could not write object to stream.", ex);
}
}
/**
* Serialize the string s and store its serialized state in File with name
* Filename.
*/
public static void storeObject(OutputStream outStream, Serializable s) {
try {
store(s, outStream, true);
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Could not write object to stream.", ex);
}
}
/**
* Deserialize the contents of File with given name containing
* a string and return the resulting string. If the indicated file
* doesnt exist or an error occurs, null is returned.
**/
public static Object loadObject (InputStream inputStream) {
return loadObject(inputStream, true);
}
/**
* Deserialize the contents of File with given name containing a string and
* return the resulting string. If the indicated file doesn't exist or an
* error occurs, null is returned.
*
*/
public static Object loadObject(InputStream inputStream) {
return loadObject(inputStream, true);
}
/**
* Deserialize the contents of File with given name containing a string and
* return the resulting string. If the indicated file doesn't exist or an
* error occurs, null is returned. If casually is false, an error message is
* printed and an exception is raised if the file was not found or an error
* occured on loading.
*
*/
public static Object loadObject(InputStream inputStream, boolean casually) {
Object serializedObject = null;
/**
* Deserialize the contents of File with given name containing
* a string and return the resulting string. If the indicated file
* doesnt exist or an error occurs, null is returned.
* If casually is false, an error message is printed and an exception
* is raised if the file was not found or an error occured on loading.
**/
public static Object loadObject (InputStream inputStream, boolean casually) {
Object serializedObject = null;
try {
serializedObject = (Object) load(inputStream);
} catch (InvalidClassException ex) {
@ -178,6 +189,6 @@ public class Serializer {
}
}
return serializedObject;
}
}
}