use of si.ijs.acs.objectexplorer.engine.Converter in project ACS by ACS-Community.
the class ObjectExplorer method oETree1_MouseClicked.
/**
* Comment
*/
public void oETree1_MouseClicked(java.awt.event.MouseEvent mouseEvent) {
//TODO ?!?!?!?!?!?!?
if (SwingUtilities.isRightMouseButton(mouseEvent)) {
TreePath clickedPath = getOETree1().getPathForLocation(mouseEvent.getX(), mouseEvent.getY());
Object clicked = null;
if (clickedPath != null)
clicked = clickedPath.getLastPathComponent();
if (clicked instanceof Introspectable) {
Introspectable node = (Introspectable) clicked;
getconnectMenuItem().setEnabled(!node.isConnected());
getdisconnectMenuItem().setEnabled(node.isConnected() && !node.isNonSticky());
getJLabel1().setText(node.toString());
getTreeHandlerBean1().setClicked(node);
// disable/enable converters
Converter currentConverter = ObjectExplorer.getConverter(node);
int len = getconverterMenu().getItemCount();
for (int i = 0; i < len; i++) {
JMenuItem item = getconverterMenu().getItem(i);
if (item != null && item.getActionListeners() != null && item.getActionListeners().length == 1 && item.getActionListeners()[0] instanceof SetConverterActionListener) {
SetConverterActionListener scal = (SetConverterActionListener) item.getActionListeners()[0];
if (scal.getConverter() == currentConverter)
item.setEnabled(false);
else
item.setEnabled(true);
}
}
getoeTreePopup().show(getOETree1(), mouseEvent.getX(), mouseEvent.getY());
}
}
return;
}
use of si.ijs.acs.objectexplorer.engine.Converter in project ACS by ACS-Community.
the class ObjectExplorer method getconverterMenu.
/**
* Return the convertMenuItem property value.
* @return javax.swing.JMenuItem
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JMenu getconverterMenu() {
if (ivjconverterMenu == null) {
try {
ivjconverterMenu = new javax.swing.JMenu();
ivjconverterMenu.setName("converterMenu");
ivjconverterMenu.setText("convert");
// user code begin {1}
// list of converters is static
List converters = getConverterRepository();
if (converters.size() > 0) {
JMenuItem item = new JMenuItem("none");
item.addActionListener(new SetConverterActionListener(null));
ivjconverterMenu.add(item);
ivjconverterMenu.add(new JSeparator());
}
Iterator iter = converters.iterator();
while (iter.hasNext()) {
Converter converter = (Converter) iter.next();
JMenuItem item = new JMenuItem(converter.getDescription());
item.addActionListener(new SetConverterActionListener(converter));
ivjconverterMenu.add(item);
}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjconverterMenu;
}
use of si.ijs.acs.objectexplorer.engine.Converter in project ACS by ACS-Community.
the class ReporterBean method toString.
/**
*/
public static String toString(RemoteCall call, boolean expand) {
StringBuffer result = new StringBuffer(500);
result.append('[');
result.append(call.getSN());
result.append("] : ");
//result.append(System.currentTimeMillis());
result.append(IsoDateFormat.formatCurrentDate());
result.append(" |--------------------------------------------------------\n");
result.append(call.getIntrospectable().getName());
String name = null;
if (call.getAttribute() == null) {
if (call.getOperation() != null)
name = call.getOperation().getName();
else
throw (new NullPointerException("RemoteCall -- both Operation and Attribute are null"));
} else
name = call.getAttribute().toString();
// do the conversion
Converter converter;
if (call.isAttributeAccess())
converter = ObjectExplorer.getConverter(call.getAttribute().getIntrospectable());
else
converter = ObjectExplorer.getConverter(call.getOperation().getIntrospectable());
Object returnValue = call.getSyncReturnValue();
Object[] auxs = call.getAuxReturnValues();
if (converter != null && converter.acceptConvert(name))
returnValue = converter.convert(name, auxs, returnValue);
result.append('.');
result.append(name);
result.append('\n');
result.append(" --> Return value: ");
if ((call.getOperation() != null) && (call.getOperation().getReturnType().getType() == Void.TYPE))
result.append("void");
else {
if (returnValue == null)
result.append(DataFormatter.unpackReturnValue(returnValue, " ", 0, expand));
else if (returnValue.getClass().isArray())
result.append(DataElementFormatter.unpackArray(returnValue, " ", 0, expand));
else if (returnValue instanceof DataElement)
result.append(((DataElement) returnValue).toString(" ", 0, expand));
else
result.append(DataFormatter.unpackReturnValue(returnValue, " ", 0, expand));
}
result.append('\n');
if (auxs != null) {
for (int i = 0; i < auxs.length; i++) if (auxs[i] != null) {
if (auxs[i].getClass().isArray())
result.append(" --> Auxiliary return value '" + call.getOperation().getParameterNames()[i] + "' = " + DataElementFormatter.unpackArray(auxs[i], " ", 0, expand));
else if (auxs[i] instanceof DataElement)
result.append(" --> Auxiliary return value '" + call.getOperation().getParameterNames()[i] + "' = " + ((DataElement) auxs[i]).toString(" ", 0, expand) + "\n");
else
result.append(" --> Auxiliary return value '" + call.getOperation().getParameterNames()[i] + "' = " + DataFormatter.unpackReturnValue(auxs[i], " ", 0, expand) + "\n");
}
result.append('\n');
}
if (call.getThrowable() != null) {
result.append(" --> Exception: " + call.getThrowable() + "\n");
if (call.getThrowable() instanceof DataElement)
result.append(((DataElement) call.getThrowable()).toString("/ ", 0, expand));
else
result.append(DataFormatter.unpackReturnValue(call.getThrowable(), "/ ", 0, expand));
}
if (call.isTimeout()) {
result.append(" --> Timeout raised by the engine while waiting for response.\n");
}
return result.toString();
}
use of si.ijs.acs.objectexplorer.engine.Converter in project ACS by ACS-Community.
the class ObjectExplorer method oeTreeByName_MouseClicked.
// ----- * by rbertoncelj
// ----- Additional methods needed for new tree hierarchy -----
public void oeTreeByName_MouseClicked(java.awt.event.MouseEvent mouseEvent) {
if (SwingUtilities.isRightMouseButton(mouseEvent)) {
TreePath clickedPath = getOETreeByName().getPathForLocation(mouseEvent.getX(), mouseEvent.getY());
Object clicked = null;
if (clickedPath != null)
clicked = clickedPath.getLastPathComponent();
if (clicked instanceof Introspectable) {
Introspectable node = (Introspectable) clicked;
getconnectMenuItem().setEnabled(!node.isConnected());
getdisconnectMenuItem().setEnabled(node.isConnected());
getJLabel1().setText(node.toString());
//TODO is this ok?
getTreeHandlerBean1().setClicked(node);
// disable/enable converters
Converter currentConverter = ObjectExplorer.getConverter(node);
int len = getconverterMenu().getItemCount();
for (int i = 0; i < len; i++) {
JMenuItem item = getconverterMenu().getItem(i);
if (item != null && item.getActionListeners() != null && item.getActionListeners().length == 1 && item.getActionListeners()[0] instanceof SetConverterActionListener) {
SetConverterActionListener scal = (SetConverterActionListener) item.getActionListeners()[0];
if (scal.getConverter() == currentConverter)
item.setEnabled(false);
else
item.setEnabled(true);
}
}
getoeTreePopup().show(getOETreeByName(), mouseEvent.getX(), mouseEvent.getY());
}
}
return;
}
use of si.ijs.acs.objectexplorer.engine.Converter in project ACS by ACS-Community.
the class ObjectExplorer method loadConverters.
/**
* Load converters....
*/
private void loadConverters() {
try {
String fileName = (String) System.getProperty(CONVERTER_PROPERTY);
getNotificationBean1().reportDebug("ObjectExplorer::loadConverters", "Startup using '" + CONVERTER_PROPERTY + "' = '" + fileName + "'.");
if (fileName == null)
return;
BufferedReader reader = new BufferedReader(new FileReader(fileName));
String line = reader.readLine();
while (line != null) {
line = line.trim();
if (line.length() > 0 && !line.startsWith("#")) {
// line contains class name
try {
Class converterClass = Class.forName(line);
Converter converter = (Converter) converterClass.getConstructor(new Class[0]).newInstance(new Object[0]);
getNotificationBean1().reportDebug("ObjectExplorer::loadConverters", "Loaded converter '" + line + "' (" + converter.getDescription() + ").");
converterRepository.add(converter);
} catch (Throwable th) {
getNotificationBean1().reportDebug("ObjectExplorer::loadConverters", "Failed to load converter '" + line + "'.");
th.printStackTrace();
}
}
line = reader.readLine();
}
reader.close();
} catch (Throwable th) {
th.printStackTrace();
}
getNotificationBean1().reportDebug("ObjectExplorer::loadConverters", "Registered " + converterRepository.size() + " converter(s).");
}
Aggregations