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 = new Tree();
|
||||||
centerTree.addEventListener(Events.ON_SELECT, this);
|
centerTree.addEventListener(Events.ON_SELECT, this);
|
||||||
|
centerTree.addEventListener(Events.ON_DOUBLE_CLICK, this);
|
||||||
} // preInit
|
} // preInit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -223,8 +224,18 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
|
||||||
ZKUpdateUtil.setVflex(centerList, true);
|
ZKUpdateUtil.setVflex(centerList, true);
|
||||||
centerList.setSizedByContent(false);
|
centerList.setSizedByContent(false);
|
||||||
centerList.addEventListener(Events.ON_SELECT, this);
|
centerList.addEventListener(Events.ON_SELECT, this);
|
||||||
|
centerList.addDoubleClickListener(centerListListener);
|
||||||
} // jbInit
|
} // 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
|
* Dispose
|
||||||
*/
|
*/
|
||||||
|
@ -247,31 +258,46 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
|
||||||
action_treeAddAll();
|
action_treeAddAll();
|
||||||
else if (e.getTarget() == bAdd)
|
else if (e.getTarget() == bAdd)
|
||||||
{
|
{
|
||||||
SimpleListModel model = (SimpleListModel) centerList.getModel();
|
add();
|
||||||
int i = centerList.getSelectedIndex();
|
|
||||||
if (i >= 0) {
|
|
||||||
action_treeAdd((ListItem)model.getElementAt(i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (e.getTarget() == bDelete)
|
else if (e.getTarget() == bDelete)
|
||||||
{
|
{
|
||||||
SimpleListModel model = (SimpleListModel) centerList.getModel();
|
remove();
|
||||||
int i = centerList.getSelectedIndex();
|
|
||||||
if (i >= 0) {
|
|
||||||
action_treeDelete((ListItem)model.getElementAt(i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (e.getTarget() == bDeleteAll)
|
else if (e.getTarget() == bDeleteAll)
|
||||||
action_treeDeleteAll();
|
action_treeDeleteAll();
|
||||||
else if (e.getTarget() == centerList)
|
else if (e.getTarget() == centerList)
|
||||||
onListSelection(e);
|
onListSelection(e);
|
||||||
else if (e.getTarget() == centerTree)
|
else if (e.getTarget() == centerTree) {
|
||||||
onTreeSelection(e);
|
if (e.getName().equals(Events.ON_DOUBLE_CLICK))
|
||||||
|
remove();
|
||||||
|
else
|
||||||
|
onTreeSelection(e);
|
||||||
|
}
|
||||||
else if (e.getTarget() == searchBox.getButton() || e.getTarget() == searchBox.getTextbox())
|
else if (e.getTarget() == searchBox.getButton() || e.getTarget() == searchBox.getTextbox())
|
||||||
searchElement();
|
searchElement();
|
||||||
} // actionPerformed
|
} // 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() {
|
private void searchElement() {
|
||||||
String filter = searchBox.getText() == null ? "" : searchBox.getText();
|
String filter = searchBox.getText() == null ? "" : searchBox.getText();
|
||||||
filter = Util.deleteAccents(filter.trim().toUpperCase());
|
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,
|
stn = new DefaultTreeNode<Object>(new MTreeNode(item.id, 0, item.name, item.description, 0, item.isSummary,
|
||||||
item.imageIndicator, false, null), new ArrayList<TreeNode<Object>>());
|
item.imageIndicator, false, null), new ArrayList<TreeNode<Object>>());
|
||||||
model.addNode(stn);
|
model.addNode(stn);
|
||||||
|
// May cause Error if in tree
|
||||||
|
addNode(item);
|
||||||
}
|
}
|
||||||
// May cause Error if in tree
|
|
||||||
addNode(item);
|
|
||||||
}
|
}
|
||||||
} // action_treeAdd
|
} // action_treeAdd
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue