use of si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode in project ACS by ACS-Community.
the class TreeHandlerBean method disconnect.
/**
* @author Miha Kadunc
* @author rbertoncelj
*/
public void disconnect() {
notifier.reportDebug("TreeHandlerBean::disconnect", "Requesting engine to disconnect the introspectable..:");
if (clicked instanceof BACIRemoteNode) {
BACIRemoteNode myNode = (BACIRemoteNode) clicked;
RemoteNodeCouple rnc;
String curl;
if (myNode.getUserObject() instanceof String) {
curl = (String) myNode.getUserObject();
} else {
curl = (String) ((OETreeNode) myNode.getParent()).getUserObject() + ":" + myNode.toString();
}
rnc = (RemoteNodeCouple) devices.get(curl);
if (rnc == null) {
clicked = null;
notifier.reportError("TreeHandlerBean::disconnect - Unexpected null pointer (rnc).");
return;
}
/*
* Clean treeByType
*/
if (rnc.deviceByType.isConnected()) {
OETreeNode clk = (OETreeNode) rnc.deviceByType;
clk.setChildrenDefined(true);
rnc.deviceByType.disconnect();
TreePath clkPath = new TreePath(clk.getPath());
if (clkPath.isDescendant(tree.getSelectionPath()) || (clkPath.equals(tree.getSelectionPath()))) {
this.selectedNode = clk;
tree.setSelectionPath(clkPath);
handler.setObject(null);
}
tree.collapsePath(clkPath);
clk.removeAllChildren();
((DefaultTreeModel) tree.getModel()).reload(clk);
clk.setChildrenDefined(false);
}
/*
* Clean treeByName
*/
OETreeNode clk = (OETreeNode) rnc.deviceByName;
clk.setChildrenDefined(true);
rnc.deviceByName.disconnect();
TreePath clkPath = new TreePath(clk.getPath());
if (clkPath.isDescendant(treeByName.getSelectionPath()) || (clkPath.equals(treeByName.getSelectionPath()))) {
this.selectedNode = clk;
treeByName.setSelectionPath(clkPath);
handler.setObject(null);
}
treeByName.collapsePath(clkPath);
purgeChildren(clk);
clk.removeAllChildren();
((DefaultTreeModel) treeByName.getModel()).reload(clk);
clk.setChildrenDefined(false);
} else {
notifier.reportError("TreeHandlerBean::disconnect - clicked not instanceof BACIRemoteNode.");
if (clicked instanceof OETreeNode) {
if (clicked.isConnected()) {
OETreeNode clk = (OETreeNode) clicked;
clk.setChildrenDefined(true);
clicked.disconnect();
TreePath clkPath = new TreePath(clk.getPath());
if (clkPath.isDescendant(tree.getSelectionPath()) || (clkPath.equals(tree.getSelectionPath()))) {
this.selectedNode = clk;
tree.setSelectionPath(clkPath);
handler.setObject(null);
}
tree.collapsePath(clkPath);
purgeChildren(clk);
clk.removeAllChildren();
((DefaultTreeModel) tree.getModel()).reload(clk);
clk.setChildrenDefined(false);
}
}
}
clicked = null;
}
use of si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode in project ACS by ACS-Community.
the class TreeHandlerBean method getDevices.
/**
* @author Miha Kadunc
* @author rbertoncelj
*/
public synchronized void getDevices(FirstTimeExpandedEvent event) {
OETreeNode node = event.getTreeNode();
if (event.getSource() == treeByName) {
if (node instanceof BACIRemoteNode) {
BACIRemoteNode myNode = (BACIRemoteNode) node;
RemoteNodeCouple rnc;
String curl;
if (myNode.getUserObject() instanceof String) {
curl = (String) myNode.getUserObject();
rnc = (RemoteNodeCouple) devices.get(curl);
} else {
myNode.getParent();
curl = (String) ((OETreeNode) myNode.getParent()).getUserObject() + ":" + myNode.toString();
RemoteNodeCouple newRnc = (RemoteNodeCouple) devices.get(curl);
rnc = newRnc;
}
if (rnc == null) {
notifier.reportError("TreeHandlerBean::getDevices - Unexpected null pointer (rnc).");
return;
}
rnc.deviceByType.getChildCount();
return;
}
}
notifier.reportDebug("TreeHandlerBean::getDevices", "node: " + node + " " + node.getUserObject());
try {
if (node == null)
return;
if ((node.getUserObject() instanceof String) && (node.getUserObject().equals("root"))) {
// only OETree1 can can trigger search
if (node.getParentTree() == treeByName)
return;
notifier.reportMessage("Initializing " + accessType + " engine. Please wait...");
notifier.reportDebug("TreeHandlerBean::setAccess", "Selected engine: " + accessType);
// clear treeByName
treeByName.clearTree();
invList.clear();
devices.clear();
setAccess(node);
} else {
(new SubNodesSearching(this, node)).start();
}
return;
} catch (Exception e) {
notifier.reportError("Error while searching for devices of " + node, e);
}
}
use of si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode in project ACS by ACS-Community.
the class TreeHandlerBean method connect.
/**
* @author Miha Kadunc
* @author rbertoncelj
*/
public void connect() {
//System.out.println("Connecting to "+clicked);
try {
clicked.connect();
} catch (NonStickyConnectFailedRemoteException nscfre) {
// return from method gracefully
return;
}
((DefaultTreeModel) tree.getModel()).reload((TreeNode) clicked);
if ((tree.getSelectionPath() != null) && (tree.getSelectionPath().getLastPathComponent() == clicked)) {
this.selectedNode = null;
handler.setObject(clicked);
}
if (clicked instanceof BACIRemoteNode) {
BACIRemoteNode myNode = (BACIRemoteNode) clicked;
RemoteNodeCouple rnc;
String curl;
if (myNode.getUserObject() instanceof String) {
curl = (String) myNode.getUserObject();
rnc = (RemoteNodeCouple) devices.get(curl);
} else {
myNode.getParent();
curl = (String) ((OETreeNode) myNode.getParent()).getUserObject() + ":" + myNode.toString();
RemoteNodeCouple newRnc = (RemoteNodeCouple) devices.get(curl);
rnc = newRnc;
}
if (rnc == null) {
clicked = null;
//System.out.println("DEBUG: thb connect - null rnc.");
return;
}
((DefaultTreeModel) treeByName.getModel()).reload((TreeNode) rnc.deviceByName);
}
clicked = null;
tree.repaint();
treeByName.repaint();
}
Aggregations