Search in sources :

Example 1 with RemoteNodeCouple

use of si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple in project ACS by ACS-Community.

the class TreeHandlerBean method addNode.

/**
	 * @author rbertoncelj
	 */
public void addNode(javax.swing.tree.TreeNode node, javax.swing.tree.TreeNode parentNode) {
    addNodes(new TreeNode[] { node }, parentNode);
    if (node instanceof BACIInvocation) {
        BACIInvocation invoc = (BACIInvocation) node;
        InvocationCouple ic = new InvocationCouple(invoc, null);
        ic.invocationByName = new DelegateInvocation(invoc, treeByName, (BACIRemoteAccess) remoteAccess);
        String curl = (String) ((OETreeNode) parentNode.getParent()).getUserObject() + ":" + parentNode.toString();
        RemoteNodeCouple rnc = (RemoteNodeCouple) devices.get(curl);
        if (rnc == null) {
            notifier.reportError("TreeHandlerBean::addNode - Unexpected null pointer (rnc).");
            return;
        }
        // yatagai : the name can not be the proper key -- does not work
        // when more than 1 sub node are added.
        // getInvList().put(invoc.getName(),ic);
        getInvList().put(invoc, ic);
        setNodesTreeByName(new TreeNode[] { ic.invocationByName }, rnc.deviceByName);
    //System.out.println("DEBUG Added to invList "+invoc.getName()+"!");
    }
}
Also used : InvocationCouple(si.ijs.acs.objectexplorer.engine.BACI.InvocationCouple) BACIInvocation(si.ijs.acs.objectexplorer.engine.BACI.BACIInvocation) BACIRemoteAccess(si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteAccess) RemoteNodeCouple(si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple) DelegateInvocation(si.ijs.acs.objectexplorer.engine.BACI.DelegateInvocation)

Example 2 with RemoteNodeCouple

use of si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple 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;
}
Also used : TreePath(javax.swing.tree.TreePath) BACIRemoteNode(si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode) RemoteNodeCouple(si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 3 with RemoteNodeCouple

use of si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple 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);
    }
}
Also used : BACIRemoteNode(si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode) RemoteNodeCouple(si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException)

Example 4 with RemoteNodeCouple

use of si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple 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();
}
Also used : BACIRemoteNode(si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode) RemoteNodeCouple(si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException)

Aggregations

RemoteNodeCouple (si.ijs.acs.objectexplorer.engine.BACI.RemoteNodeCouple)4 BACIRemoteNode (si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode)3 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 NonStickyConnectFailedRemoteException (si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException)2 TreePath (javax.swing.tree.TreePath)1 BACIInvocation (si.ijs.acs.objectexplorer.engine.BACI.BACIInvocation)1 BACIRemoteAccess (si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteAccess)1 DelegateInvocation (si.ijs.acs.objectexplorer.engine.BACI.DelegateInvocation)1 InvocationCouple (si.ijs.acs.objectexplorer.engine.BACI.InvocationCouple)1