use of javax.swing.tree.TreePath in project ACS by ACS-Community.
the class CDBLogic method valueChanged.
/**
* Called whenever the value of the selection changes.
* @param event the event that characterizes the change.
*/
public void valueChanged(TreeSelectionEvent event) {
TreePath tp = event.getPath();
String path = stringPath(tp);
Browser.getInstance().setPath(path);
// check that selected node has a corresponding tabbed pane
if (tabbedPanes.containsKey(path)) {
// update selected components
selectedTable = tables.get(path);
selectedTableModel = tableModels.get(path);
selectedXMLArea = (JTextArea) xmls.get(path);
selectedTabbedPane = (JTabbedPane) tabbedPanes.get(path);
// set selected tabbedPane
Browser.getInstance().setRightComp(selectedTabbedPane, true);
} else {
//Browser.getInstance().display(" No tabbed pane available for this node", false);
// set selected components
selectedTabbedPane = null;
selectedTable = null;
selectedTableModel = null;
selectedXMLArea = null;
// set an emty text area
JTextArea empty = new JTextArea();
empty.setBackground(Color.LIGHT_GRAY);
empty.setEditable(false);
Browser.getInstance().setRightComp(empty, false);
}
}
use of javax.swing.tree.TreePath 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 javax.swing.tree.TreePath 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 javax.swing.tree.TreePath in project ACS by ACS-Community.
the class TreeHandlerBean method removeNode.
/**
* removeNode method comment.
*/
public void removeNode(javax.swing.tree.TreeNode node) {
if (node.getParent() == null) {
return;
}
InvocationCouple ic = getInvocationCouple((Invocation) node);
if (ic == null) {
notifier.reportError("TreeHandlerBean::removeNode - Unexpected null pointer (ic).");
return;
}
/*
* Selecet parent if the note that is to be deleted is currently selected
*/
if (tree.getSelectionPath() != null) {
if (tree.getSelectionPath().getLastPathComponent() == node)
tree.setSelectionPath(new TreePath(((DefaultMutableTreeNode) node.getParent()).getPath()));
} else if (treeByName.getSelectionPath() == null) {
if (treeByName.getSelectionPath().getLastPathComponent() == ic.invocationByName)
treeByName.setSelectionPath(new TreePath(((DefaultMutableTreeNode) ic.invocationByName.getParent()).getPath()));
}
/*
* remove node from treeByType
*/
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
model.removeNodeFromParent((MutableTreeNode) ic.invocationByType);
/*
* remove node from treeByName
*/
model = (DefaultTreeModel) treeByName.getModel();
model.removeNodeFromParent((MutableTreeNode) ic.invocationByName);
}
use of javax.swing.tree.TreePath in project ACS by ACS-Community.
the class TreeMouseListener method mousePressed.
/**
* @see java.awt.event.MouseListener
*/
public void mousePressed(MouseEvent e) {
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
if (selPath == null) {
// No object selected but the user expand/compress a node
return;
}
if (e.getClickCount() == 2) {
tree.setSelectionPath(selPath);
/*class TabShower implements Runnable {
TreePath selectedPath;
public TabShower(TreePath path) {
selectedPath=path;
}
public void run() {
showLoggingConfigTab(selectedPath);
}
};
TabShower shower = new TabShower(selPath);
Thread t = new Thread(shower);
t.run();*/
showLoggingConfigTab(selPath);
return;
}
if (e.isPopupTrigger()) {
//Toolkit tk = Toolkit.getDefaultToolkit();
PointerInfo pi = MouseInfo.getPointerInfo();
Point mouseLocation = pi.getLocation();
SwingUtilities.convertPointFromScreen(mouseLocation, tree);
popupMenu.show(tree, mouseLocation.x, mouseLocation.y);
}
}
Aggregations