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 {
// source node is a function...
if (((JAIOApplicationFunctionVO)node.getUserObject()).isFolder()) {
// destination node is a folder...
vo.setProgressiveHie03SYS18(((JAIOApplicationFunctionVO)node.getUserObject()).getProgressiveHIE03());
if (((JAIOApplicationFunctionVO)((DefaultMutableTreeNode)node.getLastChild()).getUserObject()).getPosOrderSYS18()!=null)
vo.setPosOrderSYS18(
((JAIOApplicationFunctionVO)((DefaultMutableTreeNode)node.getLastChild()).getUserObject()).getPosOrderSYS18().add(new BigDecimal(1))
);
else
vo.setPosOrderSYS18(new BigDecimal(1));
}
else {
// destination node is a leaf...
vo.setProgressiveHie03SYS18(((JAIOApplicationFunctionVO)node.getUserObject()).getProgressiveHie03SYS18());
vo.setPosOrderSYS18(new BigDecimal((
((JAIOApplicationFunctionVO)((DefaultMutableTreeNode)node).getUserObject()).getPosOrderSYS18().doubleValue()+
((JAIOApplicationFunctionVO)((DefaultMutableTreeNode)node.getNextSibling()).getUserObject()).getPosOrderSYS18().doubleValue()
)/2));
if (num==1)
vo.setCopyNode(true);
}
newDragNode = new OpenSwingTreeNode(vo);
}
// call server side...
Response res = ClientUtils.getData(
"updateFunction",
new JAIOApplicationFunctionVO[]{
sourceVO,
vo
}
);
if (res.isError()) {
JOptionPane.showMessageDialog(
MDIFrame.getInstance(),
ClientSettings.getInstance().getResources().getResource(res.getErrorMessage()),
ClientSettings.getInstance().getResources().getResource("Error"),
JOptionPane.ERROR_MESSAGE
);
return false;
}