BrightSide Workbench Full Report + Source Code
org.turro.contacts.util.ContactComboModel Class Reference
Inheritance diagram for org.turro.contacts.util.ContactComboModel:
Collaboration diagram for org.turro.contacts.util.ContactComboModel:

Public Member Functions

 ContactComboModel (Object[] data, String roleIn)
 
 ContactComboModel (List data, String roleIn)
 
Object getElementAt (int index)
 
int getSize ()
 
void sort (Comparator cmpr, boolean ascending)
 
String getSortDirection (Comparator< Contact > cmpr)
 
ListModel getSubModel (Object value, int nRows)
 
boolean isOnlyUsers ()
 
void setOnlyUsers (boolean onlyUsers)
 

Detailed Description

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

Definition at line 40 of file ContactComboModel.java.

Constructor & Destructor Documentation

◆ ContactComboModel() [1/2]

org.turro.contacts.util.ContactComboModel.ContactComboModel ( Object[]  data,
String  roleIn 
)

Definition at line 51 of file ContactComboModel.java.

51  {
52  this.data = data;
53  this.roleIn = roleIn;
54  onlyUsers = !Strings.isEmpty(roleIn);
55  }
Here is the caller graph for this function:

◆ ContactComboModel() [2/2]

org.turro.contacts.util.ContactComboModel.ContactComboModel ( List  data,
String  roleIn 
)

Definition at line 57 of file ContactComboModel.java.

57  {
58  this.data = data.toArray(new Object[data.size()]);
59  this.roleIn = roleIn;
60  onlyUsers = !Strings.isEmpty(roleIn);
61  }

Member Function Documentation

◆ getElementAt()

Object org.turro.contacts.util.ContactComboModel.getElementAt ( int  index)

Definition at line 64 of file ContactComboModel.java.

64  {
65  if(data == null || data.length <= index) return null;
66  return data[index];
67  }

◆ getSize()

int org.turro.contacts.util.ContactComboModel.getSize ( )

Definition at line 70 of file ContactComboModel.java.

70  {
71  return data.length;
72  }

◆ getSortDirection()

String org.turro.contacts.util.ContactComboModel.getSortDirection ( Comparator< Contact cmpr)

Definition at line 81 of file ContactComboModel.java.

81  {
82  return "natural";
83  }

◆ getSubModel()

ListModel org.turro.contacts.util.ContactComboModel.getSubModel ( Object  value,
int  nRows 
)

Definition at line 86 of file ContactComboModel.java.

86  {
87  if(value != null && value.equals(lastValue)) return this;
88  lastValue = value;
89  LinkedList lData = new LinkedList();
90  Dao dao = new ContactsPU();
91  WhereClause wc = new WhereClause();
92  wc.addClause("select contact from Contact as contact");
93  wc.addClause("where 1=1");
94  if(onlyUsers) {
95  wc.addClause("and contact.login is not null");
96  }
97  if(roleIn != null) {
98  wc.addClause(roleIn);
99  }
100  wc.addLikeFields(new String[]{ "contact.name" }, value.toString());
101  wc.addClause("order by contact.name");
102  if(nRows < 1) nRows = 10;
103  for(Object o : dao.getResultList(wc, nRows)) {
104  Contact c = (Contact) o;
105  if(!onlyUsers || (onlyUsers && c.isWebUser())) {
106  lData.add(c.getName());
107  }
108  }
109  return new ContactComboModel(lData, roleIn);
110  }
ContactComboModel(Object[] data, String roleIn)
Here is the call graph for this function:

◆ isOnlyUsers()

boolean org.turro.contacts.util.ContactComboModel.isOnlyUsers ( )

Definition at line 112 of file ContactComboModel.java.

112  {
113  return onlyUsers;
114  }

◆ setOnlyUsers()

void org.turro.contacts.util.ContactComboModel.setOnlyUsers ( boolean  onlyUsers)

Definition at line 116 of file ContactComboModel.java.

116  {
117  this.onlyUsers = onlyUsers;
118  }

◆ sort()

void org.turro.contacts.util.ContactComboModel.sort ( Comparator  cmpr,
boolean  ascending 
)

Definition at line 75 of file ContactComboModel.java.

75  {
76  Arrays.sort(data, cmpr);
77  fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1);
78  }

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