BrightSide Workbench Full Report + Source Code
org.turro.zkoss.input.DualSelectorListbox< T > Class Template Referenceabstract
Inheritance diagram for org.turro.zkoss.input.DualSelectorListbox< T >:
Collaboration diagram for org.turro.zkoss.input.DualSelectorListbox< T >:

Classes

class  ChooseEvent
 

Public Member Functions

 DualSelectorListbox ()
 
void chooseItem ()
 
void unchooseItem ()
 
void chooseAllItem ()
 
void unchooseAll ()
 
void top ()
 
void up ()
 
void down ()
 
void bottom ()
 
void setModel (List< T > candidate)
 
List< T > getChosenDataList ()
 
void render (Listitem item, T data, int index) throws Exception
 

Protected Member Functions

abstract void doRender (Listitem item, T data, int index)
 

Detailed Description

Original source from Potix found at: http://www.zkoss.org/zkdemo/listbox/dual_listbox

The original is a piece-of-art code, changes were made to support unknown-type items and allow multiple selections.

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 50 of file DualSelectorListbox.java.

Constructor & Destructor Documentation

◆ DualSelectorListbox()

Definition at line 60 of file DualSelectorListbox.java.

60  {
61  Executions.createComponents("/WEB-INF/_zul/bs/comps/dualSelector/dualSelectorListbox.zul", this, null);
62  Selectors.wireComponents(this, this, false);
63  Selectors.wireEventListeners(this, this);
64  chosenLb.setModel(selectedModel = new ListModelList<T>());
65  if(chosenLb.getModel() instanceof Selectable) {
66  ((Selectable) chosenLb.getModel()).setMultiple(true);
67  }
68  candidateLb.setItemRenderer(this);
69  chosenLb.setItemRenderer(this);
70  }

Member Function Documentation

◆ bottom()

Definition at line 150 of file DualSelectorListbox.java.

150  {
151  Iterator<T> iterator = new LinkedHashSet<T>(selectedModel.getSelection()).iterator();
152  while (iterator.hasNext()) {
153  T selectedItem = iterator.next();
154  selectedModel.remove(selectedItem);
155  selectedModel.add(selectedItem);
156  selectedModel.addToSelection(selectedItem);
157  }
158  Events.postEvent(new ChooseEvent(this, null));
159  }

◆ chooseAllItem()

void org.turro.zkoss.input.DualSelectorListbox< T >.chooseAllItem ( )

Definition at line 83 of file DualSelectorListbox.java.

83  {
84  for (int i = 0, j = optionsModel.getSize(); i < j; i++) {
85  selectedModel.add(optionsModel.getElementAt(i));
86  }
87  optionsModel.clear();
88  }
Here is the caller graph for this function:

◆ chooseItem()

Definition at line 73 of file DualSelectorListbox.java.

73  {
74  Events.postEvent(new ChooseEvent(this, chooseOne()));
75  }

◆ doRender()

abstract void org.turro.zkoss.input.DualSelectorListbox< T >.doRender ( Listitem  item,
data,
int  index 
)
abstractprotected
Here is the caller graph for this function:

◆ down()

Definition at line 131 of file DualSelectorListbox.java.

131  {
132  Set<T> selected = selectedModel.getSelection();
133  if (selected.isEmpty()) {
134  return;
135  }
136  int index = selectedModel.indexOf(selected.iterator().next());
137  if (index == selectedModel.size() - selected.size() || index < 0) {
138  return;
139  }
140  ArrayList<T> clone = (ArrayList<T>) new ArrayList<T>(selected).clone();
141  selectedModel.removeAll(selected);
142  selectedModel.addAll(++index, clone);
143  for(T selectedItem : clone) {
144  selectedModel.addToSelection(selectedItem);
145  }
146  Events.postEvent(new ChooseEvent(this, null));
147  }

◆ getChosenDataList()

List<T> org.turro.zkoss.input.DualSelectorListbox< T >.getChosenDataList ( )
Returns
current chosen data list

Definition at line 177 of file DualSelectorListbox.java.

177  {
178  return new ArrayList<T>(selectedModel);
179  }

◆ render()

void org.turro.zkoss.input.DualSelectorListbox< T >.render ( Listitem  item,
data,
int  index 
) throws Exception

Definition at line 196 of file DualSelectorListbox.java.

196  {
197  doRender(item, data, index);
198  }
abstract void doRender(Listitem item, T data, int index)
Here is the call graph for this function:

◆ setModel()

void org.turro.zkoss.input.DualSelectorListbox< T >.setModel ( List< T >  candidate)

Set new candidate ListModelList.

Parameters
candidateis the data of candidate list model

Definition at line 166 of file DualSelectorListbox.java.

166  {
167  candidateLb.setModel(this.optionsModel = new ListModelList<T>(candidate));
168  selectedModel.clear();
169  if(candidateLb.getModel() instanceof Selectable) {
170  ((Selectable) candidateLb.getModel()).setMultiple(true);
171  }
172  }
Here is the caller graph for this function:

◆ top()

Definition at line 99 of file DualSelectorListbox.java.

99  {
100  int i = 0;
101  Iterator<T> iterator = new LinkedHashSet<T>(selectedModel.getSelection()).iterator();
102  while (iterator.hasNext()) {
103  T selectedItem = iterator.next();
104  selectedModel.remove(selectedItem);
105  selectedModel.add(i++, selectedItem);
106  selectedModel.addToSelection(selectedItem);
107  }
108  Events.postEvent(new ChooseEvent(this, null));
109  }

◆ unchooseAll()

void org.turro.zkoss.input.DualSelectorListbox< T >.unchooseAll ( )

Definition at line 91 of file DualSelectorListbox.java.

91  {
92  for (int i = 0, j = selectedModel.getSize(); i < j; i++) {
93  optionsModel.add(selectedModel.getElementAt(i));
94  }
95  selectedModel.clear();
96  }

◆ unchooseItem()

void org.turro.zkoss.input.DualSelectorListbox< T >.unchooseItem ( )

Definition at line 78 of file DualSelectorListbox.java.

78  {
79  Events.postEvent(new ChooseEvent(this, unchooseOne()));
80  }

◆ up()

Definition at line 112 of file DualSelectorListbox.java.

112  {
113  Set<T> selected = selectedModel.getSelection();
114  if (selected.isEmpty()) {
115  return;
116  }
117  int index = selectedModel.indexOf(selected.iterator().next());
118  if (index == 0 || index < 0) {
119  return;
120  }
121  ArrayList<T> clone = (ArrayList<T>) new ArrayList<T>(selected).clone();
122  selectedModel.removeAll(selected);
123  selectedModel.addAll(--index, clone);
124  for(T selectedItem : clone) {
125  selectedModel.addToSelection(selectedItem);
126  }
127  Events.postEvent(new ChooseEvent(this, null));
128  }

The documentation for this class was generated from the following file: