IDEMPIERE-4903 : Add double click events on WTreeMaintenance (#1122)
* IDEMPIERE-4903 : Add double click events on WTreeMaintenance * IDEMPIERE-4903 : Add double click events on WTreeMaintenance Fix errors, detail in ticket * peer review and tests Co-authored-by: Carlos Ruiz <carg67@gmail.com>
This commit is contained in:
parent
916a5a9233
commit
a5b5494294
|
@ -117,6 +117,7 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
|
|||
//
|
||||
centerTree = new Tree();
|
||||
centerTree.addEventListener(Events.ON_SELECT, this);
|
||||
centerTree.addEventListener(Events.ON_DOUBLE_CLICK, this);
|
||||
} // preInit
|
||||
|
||||
/**
|
||||
|
@ -223,8 +224,18 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
|
|||
ZKUpdateUtil.setVflex(centerList, true);
|
||||
centerList.setSizedByContent(false);
|
||||
centerList.addEventListener(Events.ON_SELECT, this);
|
||||
centerList.addDoubleClickListener(centerListListener);
|
||||
} // jbInit
|
||||
|
||||
EventListener<Event> centerListListener = new EventListener<Event>() {
|
||||
public void onEvent(Event event) throws Exception {
|
||||
if (Events.ON_DOUBLE_CLICK.equals(event.getName())) {
|
||||
add();
|
||||
bAdd.setDisabled(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
|
@ -247,31 +258,46 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
|
|||
action_treeAddAll();
|
||||
else if (e.getTarget() == bAdd)
|
||||
{
|
||||
SimpleListModel model = (SimpleListModel) centerList.getModel();
|
||||
int i = centerList.getSelectedIndex();
|
||||
if (i >= 0) {
|
||||
action_treeAdd((ListItem)model.getElementAt(i));
|
||||
}
|
||||
add();
|
||||
}
|
||||
|
||||
else if (e.getTarget() == bDelete)
|
||||
{
|
||||
SimpleListModel model = (SimpleListModel) centerList.getModel();
|
||||
int i = centerList.getSelectedIndex();
|
||||
if (i >= 0) {
|
||||
action_treeDelete((ListItem)model.getElementAt(i));
|
||||
}
|
||||
remove();
|
||||
}
|
||||
else if (e.getTarget() == bDeleteAll)
|
||||
action_treeDeleteAll();
|
||||
else if (e.getTarget() == centerList)
|
||||
onListSelection(e);
|
||||
else if (e.getTarget() == centerTree)
|
||||
onTreeSelection(e);
|
||||
else if (e.getTarget() == centerTree) {
|
||||
if (e.getName().equals(Events.ON_DOUBLE_CLICK))
|
||||
remove();
|
||||
else
|
||||
onTreeSelection(e);
|
||||
}
|
||||
else if (e.getTarget() == searchBox.getButton() || e.getTarget() == searchBox.getTextbox())
|
||||
searchElement();
|
||||
} // actionPerformed
|
||||
|
||||
void add() {
|
||||
SimpleListModel model = (SimpleListModel) centerList.getModel();
|
||||
int i = centerList.getSelectedIndex();
|
||||
if (i >= 0) {
|
||||
action_treeAdd((ListItem)model.getElementAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
void remove() {
|
||||
|
||||
if (cbAllNodes.isChecked())
|
||||
return;
|
||||
|
||||
SimpleListModel model = (SimpleListModel) centerList.getModel();
|
||||
int i = centerList.getSelectedIndex();
|
||||
if (i >= 0) {
|
||||
action_treeDelete((ListItem)model.getElementAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void searchElement() {
|
||||
String filter = searchBox.getText() == null ? "" : searchBox.getText();
|
||||
filter = Util.deleteAccents(filter.trim().toUpperCase());
|
||||
|
@ -420,9 +446,10 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
|
|||
stn = new DefaultTreeNode<Object>(new MTreeNode(item.id, 0, item.name, item.description, 0, item.isSummary,
|
||||
item.imageIndicator, false, null), new ArrayList<TreeNode<Object>>());
|
||||
model.addNode(stn);
|
||||
// May cause Error if in tree
|
||||
addNode(item);
|
||||
}
|
||||
// May cause Error if in tree
|
||||
addNode(item);
|
||||
|
||||
}
|
||||
} // action_treeAdd
|
||||
|
||||
|
|
Loading…
Reference in New Issue