Révision 351
tmp/org.txm.referencer.rcp/.classpath (revision 351) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
|
5 |
<classpathentry kind="src" path="src"/> |
|
6 |
<classpathentry kind="output" path="bin"/> |
|
7 |
</classpath> |
|
0 | 8 |
tmp/org.txm.referencer.rcp/META-INF/MANIFEST.MF (revision 351) | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Bundle-ManifestVersion: 2 |
|
3 |
Bundle-Name: Referencer RCP |
|
4 |
Bundle-SymbolicName: org.txm.referencer.rcp;singleton:=true |
|
5 |
Bundle-Version: 1.0.0.qualifier |
|
6 |
Bundle-Activator: org.txm.referencer.rcp.Activator |
|
7 |
Require-Bundle: org.eclipse.ui, |
|
8 |
org.eclipse.core.runtime, |
|
9 |
org.txm.core;bundle-version="0.7.0", |
|
10 |
org.txm.rcp;bundle-version="0.7.8", |
|
11 |
org.txm.concordance.core;bundle-version="1.0.0", |
|
12 |
org.eclipse.core.expressions;bundle-version="3.4.600" |
|
13 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
|
14 |
Bundle-ActivationPolicy: lazy |
|
15 |
Export-Package: org.txm.rcp.editors.referencer |
|
0 | 16 |
tmp/org.txm.referencer.rcp/.project (revision 351) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.txm.referencer.rcp</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.pde.ManifestBuilder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
<buildCommand> |
|
19 |
<name>org.eclipse.pde.SchemaBuilder</name> |
|
20 |
<arguments> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
23 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.pde.PluginNature</nature> |
|
26 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
27 |
</natures> |
|
28 |
</projectDescription> |
|
0 | 29 |
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/Activator.java (revision 351) | ||
---|---|---|
1 |
package org.txm.referencer.rcp; |
|
2 |
|
|
3 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
4 |
import org.osgi.framework.BundleContext; |
|
5 |
|
|
6 |
/** |
|
7 |
* The activator class controls the plug-in life cycle |
|
8 |
*/ |
|
9 |
public class Activator extends AbstractUIPlugin { |
|
10 |
|
|
11 |
// The plug-in ID |
|
12 |
public static final String PLUGIN_ID = "org.txm.referencer.rcp"; //$NON-NLS-1$ |
|
13 |
|
|
14 |
// The shared instance |
|
15 |
private static Activator plugin; |
|
16 |
|
|
17 |
/** |
|
18 |
* The constructor |
|
19 |
*/ |
|
20 |
public Activator() { |
|
21 |
} |
|
22 |
|
|
23 |
/* |
|
24 |
* (non-Javadoc) |
|
25 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) |
|
26 |
*/ |
|
27 |
public void start(BundleContext context) throws Exception { |
|
28 |
super.start(context); |
|
29 |
plugin = this; |
|
30 |
} |
|
31 |
|
|
32 |
/* |
|
33 |
* (non-Javadoc) |
|
34 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) |
|
35 |
*/ |
|
36 |
public void stop(BundleContext context) throws Exception { |
|
37 |
plugin = null; |
|
38 |
super.stop(context); |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* Returns the shared instance |
|
43 |
* |
|
44 |
* @return the shared instance |
|
45 |
*/ |
|
46 |
public static Activator getDefault() { |
|
47 |
return plugin; |
|
48 |
} |
|
49 |
|
|
50 |
} |
|
0 | 51 |
tmp/org.txm.referencer.rcp/src/org/txm/rcp/editors/referencer/ReferencerEditor.java (revision 351) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.editors.referencer; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.Collections; |
|
32 |
import java.util.List; |
|
33 |
|
|
34 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
35 |
import org.eclipse.core.runtime.IStatus; |
|
36 |
import org.eclipse.core.runtime.Status; |
|
37 |
import org.eclipse.jface.action.MenuManager; |
|
38 |
import org.eclipse.jface.viewers.TableViewer; |
|
39 |
import org.eclipse.osgi.util.NLS; |
|
40 |
import org.eclipse.swt.SWT; |
|
41 |
import org.eclipse.swt.events.KeyEvent; |
|
42 |
import org.eclipse.swt.events.KeyListener; |
|
43 |
import org.eclipse.swt.events.MouseAdapter; |
|
44 |
import org.eclipse.swt.events.MouseEvent; |
|
45 |
import org.eclipse.swt.events.SelectionEvent; |
|
46 |
import org.eclipse.swt.events.SelectionListener; |
|
47 |
import org.eclipse.swt.graphics.Font; |
|
48 |
import org.eclipse.swt.graphics.FontData; |
|
49 |
import org.eclipse.swt.graphics.Image; |
|
50 |
import org.eclipse.swt.graphics.Point; |
|
51 |
import org.eclipse.swt.layout.GridData; |
|
52 |
import org.eclipse.swt.layout.GridLayout; |
|
53 |
import org.eclipse.swt.widgets.Button; |
|
54 |
import org.eclipse.swt.widgets.Composite; |
|
55 |
import org.eclipse.swt.widgets.Display; |
|
56 |
import org.eclipse.swt.widgets.Menu; |
|
57 |
import org.eclipse.swt.widgets.TableColumn; |
|
58 |
import org.eclipse.ui.IEditorInput; |
|
59 |
import org.eclipse.ui.IEditorSite; |
|
60 |
import org.eclipse.ui.PartInitException; |
|
61 |
import org.eclipse.ui.part.EditorPart; |
|
62 |
import org.txm.core.preferences.TXMPreferences; |
|
63 |
import org.txm.functions.referencer.Referencer; |
|
64 |
import org.txm.functions.referencer.Referencer.Line; |
|
65 |
import org.txm.rcp.JobsTimer; |
|
66 |
import org.txm.rcp.Messages; |
|
67 |
import org.txm.rcp.StatusLine; |
|
68 |
import org.txm.rcp.commands.editor.CustomizableEditor; |
|
69 |
import org.txm.rcp.commands.link.ReferencerToConc; |
|
70 |
import org.txm.rcp.editors.TableKeyListener; |
|
71 |
import org.txm.rcp.editors.input.ReferencerEditorInput; |
|
72 |
import org.txm.rcp.preferences.RCPPreferences; |
|
73 |
import org.txm.rcp.swt.widget.NavigationWidget; |
|
74 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
|
75 |
import org.txm.rcp.swt.widget.QueryWidget; |
|
76 |
import org.txm.rcp.utils.JobHandler; |
|
77 |
import org.txm.rcp.views.QueriesView; |
|
78 |
import org.txm.rcp.views.corpora.CorporaView; |
|
79 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
80 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
81 |
import org.txm.searchengine.cqp.corpus.Property; |
|
82 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
83 |
import org.txm.statsengine.r.rcp.views.RVariablesView; |
|
84 |
|
|
85 |
// TODO: Auto-generated Javadoc |
|
86 |
/** |
|
87 |
* The Class ReferencerEditor. |
|
88 |
*/ |
|
89 |
public class ReferencerEditor extends EditorPart implements CustomizableEditor{ |
|
90 |
|
|
91 |
/** The Constant ID. */ |
|
92 |
public static final String ID = "org.txm.rcp.editors.referencer.ReferencerEditor"; //$NON-NLS-1$ |
|
93 |
|
|
94 |
/** The corpus. */ |
|
95 |
Corpus corpus; |
|
96 |
|
|
97 |
/** The referencer. */ |
|
98 |
Referencer referencer; |
|
99 |
|
|
100 |
/** The querywidget. */ |
|
101 |
QueryWidget querywidget; |
|
102 |
|
|
103 |
/** The props area. */ |
|
104 |
protected PropertiesSelector propsArea; |
|
105 |
|
|
106 |
/** The pattern area. */ |
|
107 |
protected PropertiesSelector patternArea; |
|
108 |
|
|
109 |
/** The navigation area. */ |
|
110 |
NavigationWidget navigationArea; |
|
111 |
|
|
112 |
/** The line table viewer. */ |
|
113 |
protected TableViewer viewer; |
|
114 |
|
|
115 |
/** The n column. */ |
|
116 |
protected TableColumn nColumn; |
|
117 |
|
|
118 |
/** The unit column. */ |
|
119 |
protected TableColumn unitColumn; |
|
120 |
|
|
121 |
/** The freq column. */ |
|
122 |
protected TableColumn freqColumn; |
|
123 |
|
|
124 |
/** The separator column. */ |
|
125 |
protected TableColumn separatorColumn; |
|
126 |
|
|
127 |
/** The lineperpage. */ |
|
128 |
int lineperpage = 100; |
|
129 |
|
|
130 |
/** The top line. */ |
|
131 |
int topLine=0; |
|
132 |
|
|
133 |
/** The bottom line. */ |
|
134 |
int bottomLine; |
|
135 |
|
|
136 |
/* (non-Javadoc) |
|
137 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
|
138 |
*/ |
|
139 |
@Override |
|
140 |
public void doSave(IProgressMonitor arg0) { |
|
141 |
// TODO Auto-generated method stub |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
/* (non-Javadoc) |
|
146 |
* @see org.eclipse.ui.part.EditorPart#doSaveAs() |
|
147 |
*/ |
|
148 |
@Override |
|
149 |
public void doSaveAs() { |
|
150 |
// TODO Auto-generated method stub |
|
151 |
|
|
152 |
} |
|
153 |
|
|
154 |
/* (non-Javadoc) |
|
155 |
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) |
|
156 |
*/ |
|
157 |
@Override |
|
158 |
public void init(IEditorSite site, IEditorInput input) |
|
159 |
throws PartInitException { |
|
160 |
setSite(site); |
|
161 |
setInput(input); |
|
162 |
|
|
163 |
this.corpus = ((ReferencerEditorInput) input).getCorpus(); |
|
164 |
this.referencer = ((ReferencerEditorInput) input).getReferencer(); |
|
165 |
} |
|
166 |
|
|
167 |
/* (non-Javadoc) |
|
168 |
* @see org.eclipse.ui.part.EditorPart#isDirty() |
|
169 |
*/ |
|
170 |
@Override |
|
171 |
public boolean isDirty() { |
|
172 |
// TODO Auto-generated method stub |
|
173 |
return false; |
|
174 |
} |
|
175 |
|
|
176 |
/* (non-Javadoc) |
|
177 |
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() |
|
178 |
*/ |
|
179 |
@Override |
|
180 |
public boolean isSaveAsAllowed() { |
|
181 |
// TODO Auto-generated method stub |
|
182 |
return false; |
|
183 |
} |
|
184 |
|
|
185 |
/** The mess. */ |
|
186 |
String mess; |
|
187 |
|
|
188 |
/** The source. */ |
|
189 |
private Object source; |
|
190 |
|
|
191 |
/** |
|
192 |
* Compute. |
|
193 |
* |
|
194 |
* @return true, if successful |
|
195 |
*/ |
|
196 |
public boolean compute() |
|
197 |
{ |
|
198 |
mess = NLS.bind(Messages.ReferencerEditor_0, |
|
199 |
new Object[]{querywidget.getQuery(), corpus, propsArea.getProperties().get(0), |
|
200 |
patternArea.getProperties()})+ "\n"; //$NON-NLS-1$ |
|
201 |
|
|
202 |
final Query query = querywidget.getQuery(); |
|
203 |
final List<Property> queryprops = propsArea.getProperties(); |
|
204 |
final List<Property> refs = patternArea.getProperties(); |
|
205 |
|
|
206 |
System.out.println(NLS.bind(Messages.ReferencerEditor_5, query)); |
|
207 |
JobHandler jobhandler = new JobHandler(mess) { |
|
208 |
@Override |
|
209 |
protected IStatus run(IProgressMonitor monitor) { |
|
210 |
this.runInit(monitor); |
|
211 |
try { |
|
212 |
JobsTimer.start(); |
|
213 |
monitor.beginTask(mess, 100); |
|
214 |
boolean docompute = false; |
|
215 |
if (referencer != null) { |
|
216 |
if (referencer.getQuery().equals(query)) |
|
217 |
{ |
|
218 |
boolean clean = false; |
|
219 |
if (!referencer.getProperty().toString().equals(queryprops.get(0).toString())) |
|
220 |
{ |
|
221 |
referencer.setProperty(propsArea.getProperties().get(0)); |
|
222 |
clean = true; |
|
223 |
} |
|
224 |
|
|
225 |
if (!referencer.getPattern().toString().equals(refs.toString())) |
|
226 |
{ |
|
227 |
ArrayList<Property> pattern = new ArrayList<Property>(refs); |
|
228 |
referencer.setPattern(pattern); |
|
229 |
clean = true; |
|
230 |
} |
|
231 |
|
|
232 |
if (clean) |
|
233 |
{ |
|
234 |
referencer.clearAllLines(); |
|
235 |
docompute = true; |
|
236 |
} |
|
237 |
|
|
238 |
} |
|
239 |
else |
|
240 |
docompute = true; |
|
241 |
} |
|
242 |
else |
|
243 |
docompute = true; |
|
244 |
|
|
245 |
if (docompute) { |
|
246 |
Property p = queryprops.get(0); |
|
247 |
ArrayList<Property> pattern = new ArrayList<Property>(refs); |
|
248 |
boolean hierarchicSort = TXMPreferences.getBoolean(RCPPreferences.PREFERENCES_NODE, RCPPreferences.SORTBYFREQ); |
|
249 |
referencer = new Referencer(corpus, query, p, pattern, hierarchicSort); |
|
250 |
this.acquireSemaphore(); |
|
251 |
corpus.addResult(referencer); |
|
252 |
this.releaseSemaphore(); |
|
253 |
} |
|
254 |
|
|
255 |
try { |
|
256 |
if (query.getQueryString().equals("")) //$NON-NLS-1$ |
|
257 |
return Status.CANCEL_STATUS; |
|
258 |
|
|
259 |
monitor.subTask(Messages.ReferencerEditor_8); |
|
260 |
if (!referencer.getQueryMatches()) |
|
261 |
{ |
|
262 |
System.out.println(Messages.ReferencerEditor_7); |
|
263 |
return Status.CANCEL_STATUS; |
|
264 |
} |
|
265 |
|
|
266 |
if (monitor.isCanceled()) |
|
267 |
return Status.CANCEL_STATUS; |
|
268 |
|
|
269 |
monitor.subTask(Messages.ReferencerEditor_10); |
|
270 |
if (!referencer.getQueryindexes()) |
|
271 |
return Status.CANCEL_STATUS; |
|
272 |
|
|
273 |
if (monitor.isCanceled()) |
|
274 |
return Status.CANCEL_STATUS; |
|
275 |
|
|
276 |
monitor.subTask(Messages.ReferencerEditor_12); |
|
277 |
if (!referencer.groupPositionsbyId()) |
|
278 |
return Status.CANCEL_STATUS; |
|
279 |
|
|
280 |
if (monitor.isCanceled()) |
|
281 |
return Status.CANCEL_STATUS; |
|
282 |
|
|
283 |
} catch (Exception e) { |
|
284 |
// TODO Auto-generated catch block |
|
285 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
286 |
} |
|
287 |
|
|
288 |
if (monitor.isCanceled()) |
|
289 |
return Status.CANCEL_STATUS; |
|
290 |
|
|
291 |
monitor.worked(50); |
|
292 |
|
|
293 |
monitor.subTask(Messages.ReferencerEditor_13); |
|
294 |
syncExec(new Runnable() { |
|
295 |
@Override |
|
296 |
public void run() { |
|
297 |
fillDisplayArea(0, lineperpage); |
|
298 |
CorporaView.refresh(); |
|
299 |
CorporaView.expand(corpus); |
|
300 |
QueriesView.refresh(); |
|
301 |
RVariablesView.refresh(); |
|
302 |
setPartName(corpus.getName()+":"+referencer.getName()); //$NON-NLS-1$ |
|
303 |
|
|
304 |
viewer.getTable().setFocus(); |
|
305 |
System.out.println(NLS.bind(Messages.CreatePartition_5, referencer.getNLines(), referencer.getV())); |
|
306 |
} |
|
307 |
}); |
|
308 |
|
|
309 |
monitor.worked(100); |
|
310 |
} catch (ThreadDeath td) { |
|
311 |
return Status.CANCEL_STATUS; |
|
312 |
} catch (Exception e) { |
|
313 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
314 |
} finally { |
|
315 |
monitor.done(); |
|
316 |
JobsTimer.stopAndPrint(); |
|
317 |
} |
|
318 |
return Status.OK_STATUS; |
|
319 |
} |
|
320 |
}; |
|
321 |
jobhandler.startJob(); |
|
322 |
|
|
323 |
return true; |
|
324 |
} |
|
325 |
|
|
326 |
/* (non-Javadoc) |
|
327 |
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
|
328 |
*/ |
|
329 |
@Override |
|
330 |
public void createPartControl(Composite arg0) { |
|
331 |
arg0.setLayout(new GridLayout(1,true)); |
|
332 |
Composite paramArea = new Composite(arg0, SWT.NONE); |
|
333 |
paramArea.setLayout(new GridLayout(3, false)); |
|
334 |
paramArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
335 |
true, false)); |
|
336 |
|
|
337 |
Composite resultArea = new Composite(arg0, SWT.NONE); |
|
338 |
resultArea.setLayout(new GridLayout(1, false)); |
|
339 |
resultArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
340 |
true, true)); |
|
341 |
// [Query |
|
342 |
querywidget = new QueryWidget(paramArea, SWT.None); |
|
343 |
querywidget.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, |
|
344 |
true, false)); |
|
345 |
querywidget.addKeyListener(new KeyListener() { |
|
346 |
@Override |
|
347 |
public void keyReleased(KeyEvent e) {} |
|
348 |
|
|
349 |
@Override |
|
350 |
public void keyPressed(KeyEvent e) { |
|
351 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) |
|
352 |
{ |
|
353 |
compute(); |
|
354 |
} |
|
355 |
} |
|
356 |
}); |
|
357 |
|
|
358 |
// [Edit] |
|
359 |
propsArea = new PropertiesSelector(paramArea, SWT.NONE); |
|
360 |
propsArea.setMaxPropertyNumber(1); |
|
361 |
propsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
362 |
false, false)); |
|
363 |
propsArea.setLayout(new GridLayout(3, false)); |
|
364 |
ArrayList<Property> availables = new ArrayList<Property>(); |
|
365 |
try { |
|
366 |
availables = new ArrayList<Property>(corpus.getOrderedProperties()); |
|
367 |
} catch (CqiClientException e1) { |
|
368 |
// TODO Auto-generated catch block |
|
369 |
org.txm.rcp.utils.Logger.printStackTrace(e1); |
|
370 |
} |
|
371 |
|
|
372 |
ArrayList<Property> selectedProps = new ArrayList<Property>(); |
|
373 |
if (referencer != null) { |
|
374 |
selectedProps.add(referencer.getProperty()); |
|
375 |
availables.remove(referencer.getProperty()); |
|
376 |
this.propsArea.setProperties(availables, selectedProps); |
|
377 |
} else { |
|
378 |
this.propsArea.setCorpus(corpus); |
|
379 |
} |
|
380 |
|
|
381 |
// [Search] |
|
382 |
Button go = new Button(paramArea, SWT.PUSH); |
|
383 |
go.setText(Messages.SEARCH); |
|
384 |
go.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
385 |
false, false)); |
|
386 |
Font f = go.getFont(); |
|
387 |
FontData defaultFont = f.getFontData()[0]; |
|
388 |
defaultFont.setStyle(SWT.BOLD); |
|
389 |
Font newf = new Font(go.getDisplay(), defaultFont); |
|
390 |
go.setFont(newf); |
|
391 |
|
|
392 |
go.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
|
393 |
go.addSelectionListener(new SelectionListener() { |
|
394 |
@Override |
|
395 |
public void widgetSelected(SelectionEvent e) { |
|
396 |
compute(); |
|
397 |
} |
|
398 |
|
|
399 |
@Override |
|
400 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
401 |
} |
|
402 |
}); |
|
403 |
|
|
404 |
// [pattern : ... ] |
|
405 |
patternArea = new PropertiesSelector(paramArea, SWT.NONE); |
|
406 |
patternArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false,3,1)); |
|
407 |
patternArea.setLayout(new GridLayout(3, false)); |
|
408 |
patternArea.setText(Messages.ReferencerEditor_6); |
|
409 |
availables = new ArrayList<Property>(); |
|
410 |
try { |
|
411 |
availables = new ArrayList<Property>(corpus.getStructuralUnitProperties()); |
|
412 |
Collections.sort(availables); |
|
413 |
} catch (CqiClientException e1) { |
|
414 |
// TODO Auto-generated catch block |
|
415 |
org.txm.rcp.utils.Logger.printStackTrace(e1); |
|
416 |
return; |
|
417 |
} |
|
418 |
|
|
419 |
selectedProps = new ArrayList<Property>(); |
|
420 |
if (referencer != null) { |
|
421 |
for(Property p : referencer.getPattern()) { |
|
422 |
selectedProps.add(p); |
|
423 |
availables.remove(p); |
|
424 |
} |
|
425 |
} |
|
426 |
|
|
427 |
if (selectedProps.size() == 0) { // no referencer result was selected |
|
428 |
for (int i = 0 ; i < availables.size() ; i++) { |
|
429 |
Property p = availables.get(i); |
|
430 |
if (p.getQualifiedName().endsWith("text_id")) { |
|
431 |
selectedProps.add(availables.get(i)); |
|
432 |
availables.remove(i); |
|
433 |
} |
|
434 |
} |
|
435 |
} |
|
436 |
|
|
437 |
this.patternArea.setProperties(availables, selectedProps); |
|
438 |
|
|
439 |
//pagination |
|
440 |
navigationArea = new NavigationWidget(paramArea, SWT.None); |
|
441 |
navigationArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false,3 ,1)); |
|
442 |
|
|
443 |
navigationArea.addFirstListener(new SelectionListener() { |
|
444 |
@Override |
|
445 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
446 |
} |
|
447 |
|
|
448 |
@Override |
|
449 |
public void widgetSelected(SelectionEvent e) { |
|
450 |
StatusLine.setMessage(Messages.ReferencerEditor_17); |
|
451 |
fillDisplayArea(0, lineperpage); |
|
452 |
viewer.getTable().select(0); |
|
453 |
viewer.getTable().showSelection(); |
|
454 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
455 |
} |
|
456 |
}); |
|
457 |
navigationArea.addLastListener(new SelectionListener() { |
|
458 |
@Override |
|
459 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
460 |
} |
|
461 |
|
|
462 |
@Override |
|
463 |
public void widgetSelected(SelectionEvent e) { |
|
464 |
StatusLine.setMessage(Messages.ReferencerEditor_19); |
|
465 |
fillDisplayArea(referencer.getNLines() |
|
466 |
- lineperpage, referencer.getNLines()); |
|
467 |
viewer.getTable().select(0); |
|
468 |
viewer.getTable().showSelection(); |
|
469 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
470 |
} |
|
471 |
}); |
|
472 |
navigationArea.addNextListener(new SelectionListener() { |
|
473 |
@Override |
|
474 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
475 |
} |
|
476 |
|
|
477 |
@Override |
|
478 |
public void widgetSelected(SelectionEvent e) { |
|
479 |
StatusLine.setMessage(Messages.ReferencerEditor_21); |
|
480 |
fillDisplayArea(topLine + lineperpage, |
|
481 |
bottomLine + lineperpage); |
|
482 |
viewer.getTable().select(0); |
|
483 |
viewer.getTable().showSelection(); |
|
484 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
485 |
} |
|
486 |
}); |
|
487 |
navigationArea.addPreviousListener(new SelectionListener() { |
|
488 |
@Override |
|
489 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
490 |
} |
|
491 |
|
|
492 |
@Override |
|
493 |
public void widgetSelected(SelectionEvent e) { |
|
494 |
StatusLine.setMessage(Messages.ReferencerEditor_23); |
|
495 |
fillDisplayArea(topLine - lineperpage, |
|
496 |
bottomLine - lineperpage); |
|
497 |
viewer.getTable().select(0); |
|
498 |
viewer.getTable().showSelection(); |
|
499 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
500 |
} |
|
501 |
}); |
|
502 |
//result |
|
503 |
|
|
504 |
viewer = new TableViewer(resultArea, SWT.MULTI |
|
505 |
| SWT.FULL_SELECTION | SWT.BORDER); |
|
506 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
|
507 |
if (corpus != null && corpus.getFont() != null && corpus.getFont().length() > 0) { |
|
508 |
Font old = viewer.getTable().getFont(); |
|
509 |
FontData fD = old.getFontData()[0]; |
|
510 |
//Font f = new Font(old.getDevice(), corpus.getFont(), fD.getHeight(), fD.getStyle()); |
|
511 |
Font font = new Font(Display.getCurrent(), corpus.getFont(), fD.getHeight(), fD.getStyle()); |
|
512 |
viewer.getTable().setFont(font); |
|
513 |
} |
|
514 |
|
|
515 |
createContextMenu(viewer); |
|
516 |
viewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
517 |
true, true)); |
|
518 |
viewer.getTable().setLinesVisible(true); |
|
519 |
viewer.getTable().setHeaderVisible(true); |
|
520 |
|
|
521 |
viewer.setLabelProvider(new LineLabelProvider()); |
|
522 |
viewer.setContentProvider(new LineContentProvider()); |
|
523 |
viewer.setInput(new ArrayList<Property>()); |
|
524 |
|
|
525 |
viewer.getTable().addMouseListener(new MouseAdapter() { |
|
526 |
@Override |
|
527 |
public void mouseDoubleClick(MouseEvent e) { |
|
528 |
|
|
529 |
Point mouseposition = new Point(e.x |
|
530 |
+ viewer.getTable().getHorizontalBar() |
|
531 |
.getSelection(), e.y); |
|
532 |
int col = getPointedColumn(mouseposition); |
|
533 |
if (col == 1) { |
|
534 |
StatusLine.setMessage(Messages.ReferencerEditor_25); |
|
535 |
sendSelectionToConc(); |
|
536 |
} else if (col == 2) { |
|
537 |
//System.out.println("Send to edition ?"); //$NON-NLS-1$ |
|
538 |
} |
|
539 |
} |
|
540 |
}); |
|
541 |
|
|
542 |
nColumn = new TableColumn(viewer.getTable(), SWT.LEFT); |
|
543 |
nColumn.setText(" "); //$NON-NLS-1$ |
|
544 |
nColumn.pack(); |
|
545 |
|
|
546 |
unitColumn = new TableColumn(viewer.getTable(), SWT.LEFT); |
|
547 |
unitColumn.setText(Messages.ReferencerEditor_9); |
|
548 |
unitColumn.setToolTipText(Messages.ReferencerEditor_9); |
|
549 |
unitColumn.setWidth(200); |
|
550 |
unitColumn.addSelectionListener(new SelectionListener() { |
|
551 |
@Override |
|
552 |
public void widgetSelected(SelectionEvent e) { |
|
553 |
|
|
554 |
} |
|
555 |
|
|
556 |
@Override |
|
557 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
558 |
} |
|
559 |
}); |
|
560 |
|
|
561 |
freqColumn = new TableColumn(viewer.getTable(), SWT.LEFT); |
|
562 |
freqColumn.setText(Messages.ReferencerEditor_11); |
|
563 |
freqColumn.setToolTipText(Messages.ReferencerEditor_11); |
|
564 |
freqColumn.setWidth(100); |
|
565 |
freqColumn.addSelectionListener(new SelectionListener() { |
|
566 |
@Override |
|
567 |
public void widgetSelected(SelectionEvent e) { |
|
568 |
|
|
569 |
} |
|
570 |
|
|
571 |
@Override |
|
572 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
573 |
} |
|
574 |
}); |
|
575 |
|
|
576 |
if (referencer != null) |
|
577 |
{ |
|
578 |
this.fillDisplayArea(0, referencer.getNLines()); |
|
579 |
this.setPartName(referencer.getCorpus()+ ": "+referencer.getName()); //$NON-NLS-1$ |
|
580 |
this.querywidget.setText(referencer.getQuery().getQueryString()); |
|
581 |
} |
|
582 |
|
|
583 |
|
|
584 |
} |
|
585 |
|
|
586 |
/** |
|
587 |
* Creates the context menu. |
|
588 |
* |
|
589 |
* @param tableViewer the table viewer |
|
590 |
*/ |
|
591 |
private void createContextMenu(TableViewer tableViewer) { |
|
592 |
|
|
593 |
MenuManager menuManager = new MenuManager(); |
|
594 |
Menu menu = menuManager.createContextMenu(tableViewer.getTable()); |
|
595 |
|
|
596 |
// Set the MenuManager |
|
597 |
tableViewer.getTable().setMenu(menu); |
|
598 |
getSite().registerContextMenu(menuManager, tableViewer); |
|
599 |
// Make the selection available |
|
600 |
getSite().setSelectionProvider(tableViewer); |
|
601 |
} |
|
602 |
|
|
603 |
/** |
|
604 |
* Send selection to conc. |
|
605 |
*/ |
|
606 |
protected void sendSelectionToConc() { |
|
607 |
ReferencerToConc.link(this, this.viewer.getSelection()); |
|
608 |
} |
|
609 |
|
|
610 |
/** |
|
611 |
* Fill display area. |
|
612 |
* |
|
613 |
* @param from the from |
|
614 |
* @param to the to |
|
615 |
*/ |
|
616 |
public void fillDisplayArea(int from, int to) |
|
617 |
{ |
|
618 |
from = Math.max(from, 0); |
|
619 |
to = Math.min(to, referencer.getNLines()); |
|
620 |
List<Line> lines = null; |
|
621 |
if (referencer.getNLines() > 0) { |
|
622 |
try { |
|
623 |
lines = referencer.getLines(from, to); |
|
624 |
} catch (Exception e) { |
|
625 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
626 |
lines = new ArrayList<Line>(); |
|
627 |
} |
|
628 |
} else |
|
629 |
lines = new ArrayList<Line>(); |
|
630 |
|
|
631 |
navigationArea.setInfoLineText(""+(from + 1), //$NON-NLS-1$ |
|
632 |
"-" + (to) + " / " + referencer.getNLines()); //$NON-NLS-1$ //$NON-NLS-2$ |
|
633 |
navigationArea.setPreviousEnabled(from > 0); |
|
634 |
navigationArea.setFirstEnabled(from > 0); |
|
635 |
navigationArea.setNextEnabled(to < referencer.getNLines() - 1); |
|
636 |
navigationArea.setLastEnabled(to < referencer.getNLines() - 1); |
|
637 |
|
|
638 |
unitColumn.setText(referencer.getProperty().toString()); |
|
639 |
|
|
640 |
String unitColumnHeader = ""; //$NON-NLS-1$ |
|
641 |
for (Property p : referencer.getPattern()) |
|
642 |
unitColumnHeader += p.toString() + ", "; //$NON-NLS-1$ |
|
643 |
if (unitColumnHeader.length() > 0) |
|
644 |
unitColumnHeader = unitColumnHeader.substring(0, unitColumnHeader |
|
645 |
.length() - 2); |
|
646 |
freqColumn.setText(unitColumnHeader); |
|
647 |
|
|
648 |
viewer.setInput(lines); |
|
649 |
viewer.refresh(); |
|
650 |
// System.out.println("table refreshed from "+from+" to "+to+" with : "+lines); |
|
651 |
topLine = from; |
|
652 |
bottomLine = to; |
|
653 |
for (TableColumn col : viewer.getTable().getColumns()) |
|
654 |
col.pack(); |
|
655 |
} |
|
656 |
|
|
657 |
/** |
|
658 |
* Gets the pointed column. |
|
659 |
* |
|
660 |
* @param mouseposition the mouseposition |
|
661 |
* @return the pointed column |
|
662 |
*/ |
|
663 |
public int getPointedColumn(Point mouseposition) { |
|
664 |
int x = mouseposition.x; // + lineTableViewer.getTable().get; |
|
665 |
int sumWidthColumn = this.nColumn.getWidth(); |
|
666 |
if (x < sumWidthColumn) |
|
667 |
return 0; |
|
668 |
|
|
669 |
sumWidthColumn += this.unitColumn.getWidth(); |
|
670 |
if (x < sumWidthColumn) |
|
671 |
return 1; |
|
672 |
|
|
673 |
sumWidthColumn += this.freqColumn.getWidth(); |
|
674 |
if (x < sumWidthColumn) |
|
675 |
return 2; |
|
676 |
|
|
677 |
return 2; |
|
678 |
} |
|
679 |
|
|
680 |
/* (non-Javadoc) |
|
681 |
* @see org.eclipse.ui.part.WorkbenchPart#setFocus() |
|
682 |
*/ |
|
683 |
@Override |
|
684 |
public void setFocus() { |
|
685 |
querywidget.setFocus(); |
|
686 |
} |
|
687 |
|
|
688 |
/** |
|
689 |
* Gets the referencer. |
|
690 |
* |
|
691 |
* @return the referencer |
|
692 |
*/ |
|
693 |
public Referencer getReferencer() { |
|
694 |
return this.referencer; |
|
695 |
} |
|
696 |
|
|
697 |
/** |
|
698 |
* Gets the corpus. |
|
699 |
* |
|
700 |
* @return the corpus |
|
701 |
*/ |
|
702 |
public Corpus getCorpus() { |
|
703 |
return this.corpus; |
|
704 |
} |
|
705 |
|
|
706 |
/* (non-Javadoc) |
|
707 |
* @see org.txm.rcp.commands.editor.CustomizableEditor#setName(java.lang.String) |
|
708 |
*/ |
|
709 |
@Override |
|
710 |
public void setName(String name) { |
|
711 |
this.setPartName(name); |
|
712 |
} |
|
713 |
|
|
714 |
/* (non-Javadoc) |
|
715 |
* @see org.txm.rcp.commands.editor.CustomizableEditor#setIcon(org.eclipse.swt.graphics.Image) |
|
716 |
*/ |
|
717 |
@Override |
|
718 |
public void setIcon(Image image) { |
|
719 |
this.setTitleImage(image); |
|
720 |
} |
|
721 |
|
|
722 |
/* (non-Javadoc) |
|
723 |
* @see org.txm.rcp.commands.editor.CustomizableEditor#setSource(java.lang.Object) |
|
724 |
*/ |
|
725 |
@Override |
|
726 |
public void setSource(Object source) |
|
727 |
{ |
|
728 |
this.source = source; |
|
729 |
} |
|
730 |
|
|
731 |
/* (non-Javadoc) |
|
732 |
* @see org.txm.rcp.commands.editor.CustomizableEditor#getSource() |
|
733 |
*/ |
|
734 |
@Override |
|
735 |
public Object getSource() { |
|
736 |
return referencer; |
|
737 |
} |
|
738 |
|
|
739 |
@Override |
|
740 |
public Object toConcordance() { return null;} |
|
741 |
@Override |
|
742 |
public Object toIndex() { return null;} |
|
743 |
@Override |
|
744 |
public Object toProgression() { return null;} |
|
745 |
|
|
746 |
@Override |
|
747 |
public boolean usingCorpus(Corpus corpus) { |
|
748 |
return this.corpus.getName().equals(corpus.getName()); |
|
749 |
} |
|
750 |
|
|
751 |
@Override |
|
752 |
public boolean updateCorpus(Corpus corpus) { |
|
753 |
// TODO Auto-generated method stub |
|
754 |
return false; |
|
755 |
} |
|
756 |
} |
|
0 | 757 |
tmp/org.txm.referencer.rcp/src/org/txm/rcp/editors/referencer/LineContentProvider.java (revision 351) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.editors.referencer; |
|
29 |
|
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
|
33 |
import org.eclipse.jface.viewers.Viewer; |
|
34 |
import org.txm.functions.referencer.Referencer; |
|
35 |
|
|
36 |
|
|
37 |
// TODO: Auto-generated Javadoc |
|
38 |
/** |
|
39 |
* The IStructuredContentProvider used by the reference and line tables. |
|
40 |
* |
|
41 |
* @author mdecorde |
|
42 |
*/ |
|
43 |
public class LineContentProvider implements IStructuredContentProvider { |
|
44 |
|
|
45 |
/* |
|
46 |
* (non-Javadoc) |
|
47 |
* |
|
48 |
* @see |
|
49 |
* org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java |
|
50 |
* .lang.Object) |
|
51 |
*/ |
|
52 |
@Override |
|
53 |
public Object[] getElements(Object inputElement) { |
|
54 |
@SuppressWarnings("unchecked") |
|
55 |
List<Referencer.Line> lines = (List<Referencer.Line>) inputElement; |
|
56 |
return lines.toArray(); |
|
57 |
} |
|
58 |
|
|
59 |
/* |
|
60 |
* (non-Javadoc) |
|
61 |
* |
|
62 |
* @see org.eclipse.jface.viewers.IContentProvider#dispose() |
|
63 |
*/ |
|
64 |
@Override |
|
65 |
public void dispose() { |
|
66 |
// TODO Auto-generated method stub |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
/* |
|
71 |
* (non-Javadoc) |
|
72 |
* |
|
73 |
* @see |
|
74 |
* org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface |
|
75 |
* .viewers.Viewer, java.lang.Object, java.lang.Object) |
|
76 |
*/ |
|
77 |
@Override |
|
78 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
|
79 |
// TODO Auto-generated method stub |
|
80 |
} |
|
81 |
|
|
82 |
} |
|
0 | 83 |
tmp/org.txm.referencer.rcp/src/org/txm/rcp/editors/referencer/LineLabelProvider.java (revision 351) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.editors.referencer; |
|
29 |
|
|
30 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
|
31 |
import org.eclipse.jface.viewers.ITableLabelProvider; |
|
32 |
import org.eclipse.swt.graphics.Image; |
|
33 |
import org.txm.functions.referencer.Referencer; |
|
34 |
|
|
35 |
|
|
36 |
// TODO: Auto-generated Javadoc |
|
37 |
/** |
|
38 |
* The Class LineLabelProvider. |
|
39 |
*/ |
|
40 |
public class LineLabelProvider implements ITableLabelProvider { |
|
41 |
|
|
42 |
/* (non-Javadoc) |
|
43 |
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) |
|
44 |
*/ |
|
45 |
@Override |
|
46 |
public Image getColumnImage(Object element, int columnIndex) { |
|
47 |
return null; |
|
48 |
} |
|
49 |
|
|
50 |
/* (non-Javadoc) |
|
51 |
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) |
|
52 |
*/ |
|
53 |
@Override |
|
54 |
public String getColumnText(Object element, int columnIndex) { |
|
55 |
Referencer.Line line = (Referencer.Line) element; |
|
56 |
switch (columnIndex) { |
|
57 |
case 0: |
|
58 |
return ""; //$NON-NLS-1$ |
|
59 |
case 1: |
|
60 |
return line.getPropValue(); |
|
61 |
case 2: |
|
62 |
StringBuffer str = new StringBuffer(); |
|
63 |
for(String ref : line.getReferences()) |
|
64 |
{ |
|
65 |
str.append(", "+ref+"("+line.getCount(ref)+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
66 |
} |
|
67 |
return str.substring(2); |
|
68 |
default: |
|
69 |
return ""; //$NON-NLS-1$ |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
/* (non-Javadoc) |
|
74 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) |
|
75 |
*/ |
|
76 |
@Override |
|
77 |
public void addListener(ILabelProviderListener listener) { |
|
78 |
// TODO Auto-generated method stub |
|
79 |
} |
|
80 |
|
|
81 |
/* (non-Javadoc) |
|
82 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
public void dispose() { |
|
86 |
// TODO Auto-generated method stub |
|
87 |
} |
|
88 |
|
|
89 |
/* (non-Javadoc) |
|
90 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) |
|
91 |
*/ |
|
92 |
@Override |
|
93 |
public boolean isLabelProperty(Object element, String property) { |
|
94 |
// TODO Auto-generated method stub |
|
95 |
return false; |
|
96 |
} |
|
97 |
|
|
98 |
/* (non-Javadoc) |
|
99 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) |
|
100 |
*/ |
|
101 |
@Override |
|
102 |
public void removeListener(ILabelProviderListener listener) { |
|
103 |
// TODO Auto-generated method stub |
|
104 |
} |
|
105 |
} |
|
0 | 106 |
tmp/org.txm.referencer.rcp/src/org/txm/rcp/commands/link/ReferencerToConc.java (revision 351) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.commands.link; |
|
29 |
|
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import org.eclipse.core.commands.AbstractHandler; |
|
33 |
import org.eclipse.core.commands.ExecutionEvent; |
|
34 |
import org.eclipse.core.commands.ExecutionException; |
|
35 |
import org.eclipse.jface.viewers.ISelection; |
|
36 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
37 |
import org.eclipse.osgi.util.NLS; |
|
38 |
import org.eclipse.ui.IWorkbenchPage; |
|
39 |
import org.eclipse.ui.PartInitException; |
|
40 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
41 |
import org.txm.functions.ReferencePattern; |
|
42 |
import org.txm.functions.referencer.Referencer; |
|
43 |
import org.txm.functions.referencer.Referencer.Line; |
|
44 |
import org.txm.rcp.Messages; |
|
45 |
import org.txm.rcp.editors.concordances.ConcordancesEditor; |
|
46 |
import org.txm.rcp.editors.input.ConcordancesEditorInput; |
|
47 |
import org.txm.rcp.editors.referencer.ReferencerEditor; |
|
48 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
49 |
import org.txm.searchengine.cqp.corpus.Property; |
|
50 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
51 |
|
|
52 |
// TODO: Auto-generated Javadoc |
|
53 |
/** |
|
54 |
* The Class ReferencerToConc. |
|
55 |
*/ |
|
56 |
public class ReferencerToConc extends AbstractHandler { |
|
57 |
|
|
58 |
/* (non-Javadoc) |
|
59 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
60 |
*/ |
|
61 |
@Override |
|
62 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
63 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
64 |
.getActiveWorkbenchWindow(event).getActivePage().getSelection(); |
|
65 |
|
|
66 |
ReferencerEditor refeditor = (ReferencerEditor) HandlerUtil |
|
67 |
.getActiveWorkbenchWindow(event).getActivePage() |
|
68 |
.getActivePart(); |
|
69 |
|
|
70 |
return link(refeditor, selection); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Link. |
|
75 |
* |
|
76 |
* @param refeditor the refeditor |
|
77 |
* @param iSelection the selection |
|
78 |
* @return the object |
|
79 |
*/ |
|
80 |
public static Object link(ReferencerEditor refeditor, ISelection iSelection) |
|
81 |
{ |
|
82 |
IStructuredSelection selection = (IStructuredSelection) iSelection; |
|
83 |
String query = getQuery(selection); |
|
84 |
if (query.length() == 0) |
|
85 |
return null; |
|
86 |
Corpus corpus = refeditor.getCorpus(); |
|
87 |
ConcordancesEditorInput editorInput = new ConcordancesEditorInput( |
|
88 |
corpus, null); |
|
89 |
|
|
90 |
IWorkbenchPage page = refeditor.getEditorSite().getWorkbenchWindow() |
|
91 |
.getActivePage(); |
|
92 |
try { |
|
93 |
ConcordancesEditor conceditor = (ConcordancesEditor) page |
|
94 |
.openEditor(editorInput, |
|
95 |
"org.txm.rcp.editors.ConcordancesEditor"); //$NON-NLS-1$ |
|
96 |
conceditor.setQuery(query); |
|
97 |
ReferencePattern rp = new ReferencePattern(); |
|
98 |
for(Property p : refeditor.getReferencer().getPattern()) |
|
99 |
rp.addProperty(p); |
|
100 |
conceditor.setRefViewPattern(rp); |
|
101 |
conceditor.compute(); |
|
102 |
} catch (PartInitException e) { |
|
103 |
System.err.println(NLS.bind(Messages.GetConcordances_4, e)); |
|
104 |
} |
|
105 |
|
|
106 |
return null; |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Gets the query. |
|
111 |
* |
|
112 |
* @param selection the selection |
|
113 |
* @return the query |
|
114 |
*/ |
|
115 |
private static String getQuery(IStructuredSelection selection) { |
|
116 |
String query = ""; //$NON-NLS-1$ |
|
117 |
|
|
118 |
Line fline = (Line) selection.getFirstElement(); |
|
119 |
Referencer ref = fline.getReferencer(); |
|
120 |
int nbToken = 1; |
|
121 |
|
|
122 |
List<Line> lines = selection.toList(); |
|
123 |
|
|
124 |
Property prop = ref.getProperty(); |
|
125 |
for (int t = 0; t < nbToken; t++) |
|
126 |
{ |
|
127 |
query += "["+prop + "=\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
128 |
|
|
129 |
for (Line line : lines) { |
|
130 |
String s = line.getPropValue(); |
|
131 |
s = Query.addBackSlash(s); |
|
132 |
query += s + "|"; //$NON-NLS-1$ |
|
133 |
} |
|
134 |
query = query.substring(0, query.length() - 1); |
|
135 |
query += "\"] "; //$NON-NLS-1$ |
|
136 |
} |
|
137 |
query = query.substring(0, query.length() - 1); |
|
138 |
return query; |
|
139 |
} |
|
140 |
} |
|
0 | 141 |
tmp/org.txm.referencer.rcp/build.properties (revision 351) | ||
---|---|---|
1 |
source.. = src/ |
|
2 |
output.. = bin/ |
|
3 |
bin.includes = META-INF/,\ |
|
4 |
.,\ |
|
5 |
plugin.xml |
|
0 | 6 |
tmp/org.txm.referencer.rcp/plugin.xml (revision 351) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<?eclipse version="3.4"?> |
|
3 |
<plugin> |
|
4 |
<extension |
|
5 |
point="org.eclipse.ui.editors"> |
|
6 |
<editor |
|
7 |
class="org.txm.rcp.editors.referencer.ReferencerEditor" |
|
8 |
default="false" |
|
9 |
icon="icons/functions/Referencer.png" |
|
10 |
id="org.txm.rcp.editors.referencer.ReferencerEditor" |
|
11 |
name="%editor.name.14"> |
|
12 |
</editor> |
|
13 |
</extension> |
|
14 |
<extension |
|
15 |
point="org.eclipse.ui.menus"> |
|
16 |
<menuContribution |
|
17 |
locationURI="popup:org.txm.rcp.editors.referencer.ReferencerEditor"> |
|
18 |
<command |
|
19 |
commandId="org.txm.rcp.commands.link.ReferencerToConc" |
|
20 |
label="%command.label.73" |
|
21 |
style="push"> |
|
22 |
</command> |
|
23 |
</menuContribution> |
|
24 |
<menuContribution |
|
25 |
locationURI="menu:menu.tools"> |
|
26 |
<command |
|
27 |
commandId="org.txm.rcp.commands.function.ComputeReferencer" |
|
28 |
icon="icons/functions/Referencer.png" |
|
29 |
label="%command.label.108" |
|
30 |
style="push" |
|
31 |
tooltip="%command.tooltip.62"> |
|
32 |
<visibleWhen |
|
33 |
checkEnabled="false"> |
|
34 |
<reference |
|
35 |
definitionId="OneCorpusSelected"> |
|
36 |
</reference> |
|
37 |
</visibleWhen> |
|
38 |
</command> |
|
39 |
</menuContribution> |
|
40 |
<menuContribution |
|
41 |
allPopups="false" |
|
42 |
locationURI="toolbar:org.txm.rcp.toolbartools"> |
|
43 |
<command |
|
44 |
commandId="org.txm.rcp.commands.function.ComputeReferencer" |
|
45 |
icon="icons/functions/Referencer.png" |
|
46 |
label="%command.label.108" |
|
47 |
style="push" |
|
48 |
tooltip="%command.tooltip.62"> |
|
49 |
<visibleWhen |
|
50 |
checkEnabled="false"> |
|
51 |
<reference |
|
52 |
definitionId="OneCorpusSelected"> |
|
53 |
</reference> |
|
54 |
</visibleWhen> |
|
55 |
</command> |
|
56 |
</menuContribution> |
|
57 |
<menuContribution |
|
58 |
allPopups="false" |
|
59 |
locationURI="popup:org.txm.rcp.views.CorporaView"> |
|
60 |
<command |
|
61 |
commandId="org.txm.rcp.commands.function.ComputeReferencer" |
|
62 |
icon="icons/functions/Referencer.png" |
|
63 |
label="%command.label.108" |
|
64 |
style="push" |
|
65 |
tooltip="%command.tooltip.62"> |
|
66 |
<visibleWhen |
|
67 |
checkEnabled="false"> |
|
68 |
<reference |
|
69 |
definitionId="OneCorpusSelected"> |
|
70 |
</reference> |
|
71 |
</visibleWhen> |
|
72 |
</command> |
|
73 |
</menuContribution> |
|
74 |
</extension> |
|
75 |
<extension |
|
76 |
point="org.eclipse.ui.commands"> |
|
77 |
<command |
|
78 |
defaultHandler="org.txm.rcp.commands.link.ReferencerToConc" |
|
79 |
id="org.txm.rcp.commands.link.ReferencerToConc" |
|
80 |
name="%command.name.57"> |
|
81 |
</command> |
|
82 |
<command |
|
83 |
categoryId="org.txm.rcp.category.txm" |
|
84 |
defaultHandler="org.txm.rcp.commands.function.ComputeReferencer" |
|
85 |
id="org.txm.rcp.commands.function.ComputeReferencer" |
|
86 |
name="%command.name.44"> |
|
87 |
</command> |
|
88 |
</extension> |
|
89 |
<extension |
|
90 |
point="org.eclipse.core.expressions.definitions"> |
|
91 |
<definition |
|
92 |
id="OneReferencerSelected"> |
|
93 |
<with |
|
94 |
variable="selection"> |
|
95 |
<iterate |
|
96 |
ifEmpty="false" |
|
97 |
operator="and"> |
|
98 |
<instanceof |
|
99 |
value="org.txm.functions.referencer.Referencer"> |
|
100 |
</instanceof> |
|
101 |
</iterate> |
|
102 |
</with> |
|
103 |
</definition> |
|
104 |
</extension> |
|
105 |
<extension |
|
106 |
point="org.eclipse.core.runtime.adapters"> |
|
107 |
<factory |
|
108 |
adaptableType="org.txm.functions.referencer.Referencer" |
|
109 |
class="org.txm.rcp.AdapterFactory"> |
|
110 |
<adapter |
|
111 |
type="org.eclipse.ui.model.IWorkbenchAdapter"> |
|
112 |
</adapter> |
|
113 |
</factory> |
|
114 |
</extension> |
|
115 |
<extension |
|
116 |
point="org.eclipse.ui.preferencePages"> |
|
117 |
<page |
|
118 |
category="org.txm.rcp.preferences.UserPreferencePage" |
|
119 |
class="org.txm.rcp.preferences.ReferencerPreferencePage" |
|
120 |
id="org.txm.rcp.preferences.ReferencerPreferencePage" |
|
121 |
name="%page.name.16"> |
|
122 |
</page> |
|
123 |
</extension> |
|
124 |
</plugin> |
|
0 | 125 |
tmp/org.txm.referencer.rcp/.settings/org.eclipse.jdt.core.prefs (revision 351) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
|
3 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 |
|
4 |
org.eclipse.jdt.core.compiler.compliance=1.6 |
|
5 |
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
|
6 |
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
|
7 |
org.eclipse.jdt.core.compiler.source=1.6 |
|
0 | 8 |
Formats disponibles : Unified diff