treePanel.setLeavesImageName("functions.gif");
// treePanel.setExpandAllNodes(true);
treePanel.addPopupMenuItem("change description",'C',true,new ActionListener() {
public void actionPerformed(ActionEvent e) {
JAIOApplicationFunctionVO vo = (JAIOApplicationFunctionVO)FunctionsTreeFrame.this.treePanel.getSelectedNode().getUserObject();
String newValue = JOptionPane.showInputDialog(
FunctionsTreeFrame.this,
ClientSettings.getInstance().getResources().getResource("new description:"),
vo.getDescription()
);
if (newValue!=null) {
JAIOApplicationFunctionVO newVO = null;
try {
newVO = (JAIOApplicationFunctionVO)vo.clone();
newVO.setDescription(newValue);
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(
MDIFrame.getInstance(),
ClientSettings.getInstance().getResources().getResource(ex.getMessage()),
ClientSettings.getInstance().getResources().getResource("Error"),
JOptionPane.ERROR_MESSAGE
);
return;
}
Response res = ClientUtils.getData(
"updateFunction",
new JAIOApplicationFunctionVO[]{vo,newVO}
);
if (res.isError()) {
JOptionPane.showMessageDialog(
MDIFrame.getInstance(),
ClientSettings.getInstance().getResources().getResource(res.getErrorMessage()),
ClientSettings.getInstance().getResources().getResource("Error"),
JOptionPane.ERROR_MESSAGE
);
return;
}
vo.setDescription(newValue);
}
}
});
// enable drag 'n drop onto the treePanel...
treePanel.enableDrag("TREE",new TreeDragNDropListener() {
public boolean dragEnabled() {
// drag operation has started...
dragNode = (DefaultMutableTreeNode)treePanel.getSelectedNode();
return true;
}
public boolean dropEnabled(DefaultMutableTreeNode node,String treeId) {
// drop has terminated...
int num = 0; // default operation: move
if (!((JAIOApplicationFunctionVO) dragNode.getUserObject()).isFolder())
// the node is a function: ask user which operation to do...
num = JOptionPane.showOptionDialog(
FunctionsTreeFrame.this,
ClientSettings.getInstance().getResources().getResource("which operation?"),
ClientSettings.getInstance().getResources().getResource("node dropped"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
new Object[]{
ClientSettings.getInstance().getResources().getResource("move node"),
ClientSettings.getInstance().getResources().getResource("copy node"),
ClientSettings.getInstance().getResources().getResource("cancel")
},
null
);
if (num!=0 && num!=1)
// user has pressed cancel button...
return false;
// user has pressed move or copy button...
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)node.getParent();
if (parentNode==null)
// no drop allowed in root node...
return false;
// move or copy: prepare new v.o.
JAIOApplicationFunctionVO vo = null;
try {
vo = (JAIOApplicationFunctionVO)((JAIOApplicationFunctionVO) dragNode.getUserObject()).clone();
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(
MDIFrame.getInstance(),
ClientSettings.getInstance().getResources().getResource(ex.getMessage()),
ClientSettings.getInstance().getResources().getResource("Error"),
JOptionPane.ERROR_MESSAGE
);
return false;
}
// prepare new node...
JAIOApplicationFunctionVO sourceVO = (JAIOApplicationFunctionVO)dragNode.getUserObject();
DefaultMutableTreeNode newDragNode = null;
if (((JAIOApplicationFunctionVO) dragNode.getUserObject()).isFolder()) {
return false;
}
else {