]>
git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.akb.ui/src/main/java/org/argeo/slc/akb/ui/views/AkbDefaultView.java
ac3e5a49d9aa656fac60395452f180afe0c75372
1 package org
.argeo
.slc
.akb
.ui
.views
;
3 import javax
.jcr
.Repository
;
4 import javax
.jcr
.Session
;
6 import org
.argeo
.slc
.akb
.ui
.AkbUiPlugin
;
7 import org
.eclipse
.jface
.viewers
.TableViewer
;
8 import org
.eclipse
.swt
.SWT
;
9 import org
.eclipse
.swt
.events
.ModifyEvent
;
10 import org
.eclipse
.swt
.events
.ModifyListener
;
11 import org
.eclipse
.swt
.layout
.GridData
;
12 import org
.eclipse
.swt
.layout
.GridLayout
;
13 import org
.eclipse
.swt
.widgets
.Composite
;
14 import org
.eclipse
.swt
.widgets
.Text
;
15 import org
.eclipse
.ui
.part
.ViewPart
;
17 /** Basic view that display a list of items with a quick search field. */
18 public class AkbDefaultView
extends ViewPart
{
19 // private final static Log log = LogFactory.getLog(QuickSearchView.class);
21 public static final String ID
= AkbUiPlugin
.PLUGIN_ID
+ ".akbDefaultView";
23 /* DEPENDENCY INJECTION */
24 private Session session
;
27 private TableViewer itemViewer
;
28 private Text filterTxt
;
29 private final static String FILTER_HELP_MSG
= "Search...";
32 public void createPartControl(Composite parent
) {
33 GridLayout gl
= new GridLayout();
34 gl
.horizontalSpacing
= gl
.verticalSpacing
= gl
.marginWidth
= 0;
38 Composite cmp
= new Composite(parent
, SWT
.NO_FOCUS
);
39 cmp
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
40 createFilterPart(cmp
);
43 // cmp = new Composite(parent, SWT.NO_FOCUS);
44 // cmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
45 // itemViewer = createListPart(cmp, new EntitySingleColumnLabelProvider(
48 // refreshFilteredList();
51 private void createFilterPart(Composite parent
) {
52 parent
.setLayout(new GridLayout());
53 // Text Area for the filter
54 filterTxt
= new Text(parent
, SWT
.BORDER
| SWT
.SEARCH
| SWT
.ICON_SEARCH
56 filterTxt
.setMessage(FILTER_HELP_MSG
);
57 filterTxt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
58 filterTxt
.addModifyListener(new ModifyListener() {
60 public void modifyText(ModifyEvent event
) {
61 // refreshFilteredList();
66 // protected TableViewer createListPart(Composite parent,
67 // ILabelProvider labelProvider) {
68 // TableViewer v = new TableViewer(parent);
69 // v.setLabelProvider(labelProvider);
71 // TableColumn singleColumn = new TableColumn(v.getTable(), SWT.V_SCROLL);
72 // TableColumnLayout tableColumnLayout = new TableColumnLayout();
73 // tableColumnLayout.setColumnData(singleColumn, new ColumnWeightData(85));
74 // parent.setLayout(tableColumnLayout);
76 // // Corresponding table & style
77 // Table table = v.getTable();
78 // table.setLinesVisible(true);
79 // table.setHeaderVisible(false);
81 // v.setContentProvider(new BasicNodeListContentProvider());
82 // v.addDoubleClickListener(peopleUiService
83 // .getNewNodeListDoubleClickListener(peopleService, null));
88 public void dispose() {
89 // JcrUtils.logoutQuietly(session);
94 public void setFocus() {
97 // protected void refreshFilteredList() {
99 // List<Node> persons = JcrUtils.nodeIteratorToList(doSearch(session,
100 // filterTxt.getText(), PeopleTypes.PEOPLE_PERSON,
101 // PeopleNames.PEOPLE_LAST_NAME,
102 // PeopleNames.PEOPLE_PRIMARY_EMAIL));
103 // personViewer.setInput(persons);
104 // } catch (RepositoryException e) {
105 // throw new PeopleException("Unable to list persons", e);
109 // /** Build repository request */
110 // private NodeIterator doSearch(Session session, String filter,
111 // String typeName, String orderProperty, String orderProperty2)
112 // throws RepositoryException {
113 // QueryManager queryManager = session.getWorkspace().getQueryManager();
114 // QueryObjectModelFactory factory = queryManager.getQOMFactory();
116 // Selector source = factory.selector(typeName, typeName);
118 // // no Default Constraint
119 // Constraint defaultC = null;
121 // // Parse the String
122 // String[] strs = filter.trim().split(" ");
123 // if (strs.length == 0) {
124 // // StaticOperand so = factory.literal(session.getValueFactory()
125 // // .createValue("*"));
126 // // defaultC = factory.fullTextSearch("selector", null, so);
128 // for (String token : strs) {
129 // StaticOperand so = factory.literal(session.getValueFactory()
130 // .createValue("*" + token + "*"));
131 // Constraint currC = factory.fullTextSearch(
132 // source.getSelectorName(), null, so);
133 // if (defaultC == null)
136 // defaultC = factory.and(defaultC, currC);
140 // Ordering order = null, order2 = null;
142 // if (orderProperty != null && !"".equals(orderProperty.trim()))
143 // order = factory.ascending(factory.lowerCase(factory.propertyValue(
144 // source.getSelectorName(), orderProperty)));
145 // if (orderProperty2 != null && !"".equals(orderProperty2.trim()))
146 // order2 = factory.ascending(factory.propertyValue(
147 // source.getSelectorName(), orderProperty2));
149 // QueryObjectModel query;
150 // if (order == null) {
151 // query = factory.createQuery(source, defaultC, null, null);
153 // if (order2 == null)
154 // query = factory.createQuery(source, defaultC,
155 // new Ordering[] { order }, null);
157 // query = factory.createQuery(source, defaultC, new Ordering[] {
158 // order, order2 }, null);
160 // query.setLimit(ROW_LIMIT.longValue());
161 // QueryResult result = query.execute();
162 // return result.getNodes();
165 /* DEPENDENCY INJECTION */
166 public void setRepository(Repository repository
) {
168 // session = repository.login();
169 // } catch (RepositoryException e) {
170 // throw new PeopleException("Unable to initialize "
171 // + "session for view " + ID, e);