use of org.zkoss.zk.au.out.AuFocus in project adempiere by adempiere.
the class ADSortTab method migrateValueAcrossLists.
/**
* @param event
*/
void migrateValueAcrossLists(Event event) {
Object source = event.getTarget();
if (source instanceof ListItem) {
source = ((ListItem) source).getListbox();
}
Listbox listFrom = (source == bAdd || source == noList) ? noList : yesList;
Listbox listTo = (source == bAdd || source == noList) ? yesList : noList;
SimpleListModel lmFrom = (source == bAdd || source == noList) ? noModel : yesModel;
SimpleListModel lmTo = (lmFrom == yesModel) ? noModel : yesModel;
Set selectedItems = listFrom.getSelectedItems();
List<ListElement> selObjects = new ArrayList<ListElement>();
for (Object obj : selectedItems) {
ListItem listItem = (ListItem) obj;
int index = listFrom.getIndexOfItem(listItem);
ListElement selObject = (ListElement) lmFrom.getElementAt(index);
selObjects.add(selObject);
}
for (ListElement selObject : selObjects) {
if (selObject == null || !selObject.isUpdateable())
continue;
lmFrom.removeElement(selObject);
lmTo.addElement(selObject);
// Enable explicit Save
setIsChanged(true);
}
for (ListElement selObject : selObjects) {
int index = lmTo.indexOf(selObject);
listTo.setSelectedIndex(index);
}
if (listTo.getSelectedItem() != null) {
AuFocus focus = new AuFocus(listTo.getSelectedItem());
Clients.response(focus);
}
}
use of org.zkoss.zk.au.out.AuFocus in project adempiere by adempiere.
the class ADSortTab method migrateValueWithinYesList.
// migrateValueAcrossLists
/**
* Move within Yes List
* @param event event
*/
void migrateValueWithinYesList(Event event) {
Object[] selObjects = yesList.getSelectedItems().toArray();
if (selObjects == null)
return;
int length = selObjects.length;
if (length == 0)
return;
//
int[] indices = yesList.getSelectedIndices();
//
boolean change = false;
//
Object source = event.getTarget();
if (source == bUp) {
for (int i = 0; i < length; i++) {
int index = indices[i];
if (index == 0)
break;
ListElement selObject = (ListElement) yesModel.getElementAt(index);
ListElement newObject = (ListElement) yesModel.getElementAt(index - 1);
if (!selObject.isUpdateable() || !newObject.isUpdateable())
break;
yesModel.setElementAt(newObject, index);
yesModel.setElementAt(selObject, index - 1);
indices[i] = index - 1;
change = true;
}
} else if (source == bDown) {
for (int i = length - 1; i >= 0; i--) {
int index = indices[i];
if (index >= yesModel.getSize() - 1)
break;
ListElement selObject = (ListElement) yesModel.getElementAt(index);
ListElement newObject = (ListElement) yesModel.getElementAt(index + 1);
if (!selObject.isUpdateable() || !newObject.isUpdateable())
break;
yesModel.setElementAt(newObject, index);
yesModel.setElementAt(selObject, index + 1);
yesList.setSelectedIndex(index + 1);
indices[i] = index + 1;
change = true;
}
}
//
if (change) {
yesList.setSelectedIndices(indices);
setIsChanged(true);
if (yesList.getSelectedItem() != null) {
AuFocus focus = new AuFocus(yesList.getSelectedItem());
Clients.response(focus);
}
}
}
use of org.zkoss.zk.au.out.AuFocus in project adempiere by adempiere.
the class ADSortTab method init.
/**
* Static Layout
* @throws Exception
*/
private void init() throws Exception {
this.setStyle("height: 100%; width: 100%;");
//
noLabel.setValue("No");
yesLabel.setValue("Yes");
//yesList.setHeight("100%");
//noList.setHeight("100%");
yesList.setVflex(true);
noList.setVflex(true);
EventListener mouseListener = new EventListener() {
public void onEvent(Event event) throws Exception {
if (Events.ON_DOUBLE_CLICK.equals(event.getName())) {
migrateValueAcrossLists(event);
}
}
};
yesList.addDoubleClickListener(mouseListener);
noList.addDoubleClickListener(mouseListener);
//
EventListener actionListener = new EventListener() {
public void onEvent(Event event) throws Exception {
migrateValueAcrossLists(event);
}
};
yesList.setSeltype("multiple");
noList.setSeltype("multiple");
bAdd.setImage(ServletFns.resolveThemeURL("~./images/Detail24.png"));
bAdd.addEventListener(Events.ON_CLICK, actionListener);
bRemove.setImage(ServletFns.resolveThemeURL("~./images/Parent24.png"));
bRemove.addEventListener(Events.ON_CLICK, actionListener);
EventListener crossListMouseListener = new DragListener();
yesList.addOnDropListener(crossListMouseListener);
noList.addOnDropListener(crossListMouseListener);
yesList.setItemDraggable(true);
noList.setItemDraggable(true);
actionListener = new EventListener() {
public void onEvent(Event event) throws Exception {
migrateValueWithinYesList(event);
}
};
bUp.setImage(ServletFns.resolveThemeURL("~./images/Previous24.png"));
bUp.addEventListener(Events.ON_CLICK, actionListener);
bDown.setImage(ServletFns.resolveThemeURL("~./images/Next24.png"));
bDown.addEventListener(Events.ON_CLICK, actionListener);
EventListener yesListMouseMotionListener = new EventListener() {
public void onEvent(Event event) throws Exception {
if (event instanceof DropEvent) {
DropEvent me = (DropEvent) event;
ListItem startItem = (ListItem) me.getDragged();
ListItem endItem = (ListItem) me.getTarget();
if (startItem.getListbox() == endItem.getListbox() && startItem.getListbox() == yesList) {
int startIndex = yesList.getIndexOfItem(startItem);
int endIndex = yesList.getIndexOfItem(endItem);
Object endElement = yesModel.getElementAt(endIndex);
Object element = yesModel.getElementAt(startIndex);
yesModel.removeElement(element);
endIndex = yesModel.indexOf(endElement);
yesModel.add(endIndex, element);
yesList.setSelectedIndex(endIndex);
if (yesList.getSelectedItem() != null) {
AuFocus focus = new AuFocus(yesList.getSelectedItem());
Clients.response(focus);
}
setIsChanged(true);
}
}
}
};
yesList.addOnDropListener(yesListMouseMotionListener);
ListHead listHead = new ListHead();
listHead.setParent(yesList);
ListHeader listHeader = new ListHeader();
listHeader.appendChild(yesLabel);
listHeader.setParent(listHead);
listHead = new ListHead();
listHead.setParent(noList);
listHeader = new ListHeader();
listHeader.appendChild(noLabel);
listHeader.setParent(listHead);
Span span = new Span();
span.setParent(this);
span.setStyle("height: 99%; display: inline-block; width: 40%;");
span.appendChild(noList);
Vbox vbox = new Vbox();
vbox.appendChild(bAdd);
vbox.appendChild(bRemove);
span = new Span();
span.setParent(this);
span.setStyle("height: 99%; display: inline-block; width: 46px");
span.appendChild(vbox);
span = new Span();
span.setParent(this);
span.setStyle("height: 99%; display: inline-block; width: 40%");
span.appendChild(yesList);
vbox = new Vbox();
vbox.appendChild(bUp);
vbox.appendChild(bDown);
span = new Span();
span.setParent(this);
span.setStyle("height: 99%; display: inline-block; width: 46px");
span.appendChild(vbox);
}
use of org.zkoss.zk.au.out.AuFocus in project adempiere by adempiere.
the class ADTabPanel method setFocusToField.
/**
* set focus to first active editor
*/
private void setFocusToField() {
WEditor toFocus = null;
for (WEditor editor : editors) {
if (editor.isHasFocus() && editor.isVisible() && editor.getComponent().getParent() != null) {
toFocus = editor;
break;
}
if (toFocus == null) {
if (editor.isVisible() && editor.isReadWrite() && editor.getComponent().getParent() != null) {
toFocus = editor;
}
}
}
if (toFocus != null) {
Component c = toFocus.getComponent();
if (c instanceof EditorBox) {
c = ((EditorBox) c).getTextbox();
}
Clients.response(new AuFocus(c));
}
}
use of org.zkoss.zk.au.out.AuFocus in project adempiere by adempiere.
the class GridTabRowRenderer method setFocusToEditor.
/**
* set focus to first active editor
*/
public void setFocusToEditor() {
if (currentRow != null && currentRow.getParent() != null) {
WEditor toFocus = null;
WEditor firstEditor = null;
for (WEditor editor : getEditors()) {
if (editor.isHasFocus() && editor.isVisible() && editor.getComponent().getParent() != null) {
toFocus = editor;
break;
}
if (editor.isVisible() && editor.getComponent().getParent() != null) {
if (toFocus == null && editor.isReadWrite()) {
toFocus = editor;
}
if (firstEditor == null)
firstEditor = editor;
}
}
if (toFocus != null) {
Component c = toFocus.getComponent();
if (c instanceof EditorBox) {
c = ((EditorBox) c).getTextbox();
}
Clients.response(new AuFocus(c));
} else if (firstEditor != null) {
Component c = firstEditor.getComponent();
if (c instanceof EditorBox) {
c = ((EditorBox) c).getTextbox();
}
Clients.response(new AuFocus(c));
}
}
}
Aggregations