]> 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
Use alias path as key to manage connectors.
[gpl/argeo-slc.git] / plugins / org.argeo.slc.akb.ui / src / main / java / org / argeo / slc / akb / ui / views / AkbDefaultView.java
1 package org.argeo.slc.akb.ui.views;
2
3 import javax.jcr.Repository;
4 import javax.jcr.Session;
5
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;
16
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);
20
21 public static final String ID = AkbUiPlugin.PLUGIN_ID + ".akbDefaultView";
22
23 /* DEPENDENCY INJECTION */
24 private Session session;
25
26 // This page widgets
27 private TableViewer itemViewer;
28 private Text filterTxt;
29 private final static String FILTER_HELP_MSG = "Search...";
30
31 @Override
32 public void createPartControl(Composite parent) {
33 GridLayout gl = new GridLayout();
34 gl.horizontalSpacing = gl.verticalSpacing = gl.marginWidth = 0;
35 parent.setLayout(gl);
36
37 // Filter
38 Composite cmp = new Composite(parent, SWT.NO_FOCUS);
39 cmp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
40 createFilterPart(cmp);
41
42 // // Table
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(
46 // peopleService));
47 //
48 // refreshFilteredList();
49 }
50
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
55 | SWT.ICON_CANCEL);
56 filterTxt.setMessage(FILTER_HELP_MSG);
57 filterTxt.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
58 filterTxt.addModifyListener(new ModifyListener() {
59
60 public void modifyText(ModifyEvent event) {
61 // refreshFilteredList();
62 }
63 });
64 }
65
66 // protected TableViewer createListPart(Composite parent,
67 // ILabelProvider labelProvider) {
68 // TableViewer v = new TableViewer(parent);
69 // v.setLabelProvider(labelProvider);
70 //
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);
75 //
76 // // Corresponding table & style
77 // Table table = v.getTable();
78 // table.setLinesVisible(true);
79 // table.setHeaderVisible(false);
80 //
81 // v.setContentProvider(new BasicNodeListContentProvider());
82 // v.addDoubleClickListener(peopleUiService
83 // .getNewNodeListDoubleClickListener(peopleService, null));
84 // return v;
85 // }
86
87 @Override
88 public void dispose() {
89 // JcrUtils.logoutQuietly(session);
90 super.dispose();
91 }
92
93 @Override
94 public void setFocus() {
95 }
96
97 // protected void refreshFilteredList() {
98 // try {
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);
106 // }
107 // }
108 //
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();
115 //
116 // Selector source = factory.selector(typeName, typeName);
117 //
118 // // no Default Constraint
119 // Constraint defaultC = null;
120 //
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);
127 // } else {
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)
134 // defaultC = currC;
135 // else
136 // defaultC = factory.and(defaultC, currC);
137 // }
138 // }
139 //
140 // Ordering order = null, order2 = null;
141 //
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));
148 //
149 // QueryObjectModel query;
150 // if (order == null) {
151 // query = factory.createQuery(source, defaultC, null, null);
152 // } else {
153 // if (order2 == null)
154 // query = factory.createQuery(source, defaultC,
155 // new Ordering[] { order }, null);
156 // else
157 // query = factory.createQuery(source, defaultC, new Ordering[] {
158 // order, order2 }, null);
159 // }
160 // query.setLimit(ROW_LIMIT.longValue());
161 // QueryResult result = query.execute();
162 // return result.getNodes();
163 // }
164
165 /* DEPENDENCY INJECTION */
166 public void setRepository(Repository repository) {
167 // try {
168 // session = repository.login();
169 // } catch (RepositoryException e) {
170 // throw new PeopleException("Unable to initialize "
171 // + "session for view " + ID, e);
172 // }
173 }
174 }