Révision 632
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/adapters/ReferencerAdapterFactory.java (revision 632) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
package org.txm.referencer.rcp.adapters; |
|
3 |
|
|
4 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
5 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
|
6 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
7 |
import org.osgi.framework.FrameworkUtil; |
|
8 |
import org.txm.rcp.adapters.TXMResultAdapter; |
|
9 |
import org.txm.rcp.adapters.TXMResultAdapterFactory; |
|
10 |
import org.txm.referencer.core.functions.Referencer; |
|
11 |
|
|
12 |
/** |
|
13 |
* A factory for creating Adapter objects. |
|
14 |
* |
|
15 |
* @author mdecorde |
|
16 |
* @author sjacquot |
|
17 |
*/ |
|
18 |
public class ReferencerAdapterFactory extends TXMResultAdapterFactory { |
|
19 |
|
|
20 |
|
|
21 |
public static final ImageDescriptor ICON = |
|
22 |
AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(ReferencerAdapterFactory.class).getSymbolicName(), |
|
23 |
"platform:/plugin/"+ FrameworkUtil.getBundle(ReferencerAdapterFactory.class).getSymbolicName() + "/icons/functions/Referencer.png"); //$NON-NLS-1$ |
|
24 |
|
|
25 |
@Override |
|
26 |
public Object getAdapter(Object adaptableObject, Class adapterType) { |
|
27 |
if(adapterType == IWorkbenchAdapter.class && adaptableObject instanceof Referencer) { |
|
28 |
return new TXMResultAdapter() { |
|
29 |
@Override |
|
30 |
public ImageDescriptor getImageDescriptor(Object object) { |
|
31 |
return ICON; |
|
32 |
} |
|
33 |
}; |
|
34 |
} |
|
35 |
return null; |
|
36 |
} |
|
37 |
|
|
38 |
|
|
39 |
} |
|
0 | 40 |
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/editors/LineLabelProvider.java (revision 632) | ||
---|---|---|
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.referencer.rcp.editors; |
|
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.referencer.core.functions.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/referencer/rcp/editors/ReferencerEditor.java (revision 632) | ||
---|---|---|
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.referencer.rcp.editors; |
|
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.jface.action.MenuManager; |
|
36 |
import org.eclipse.jface.viewers.TableViewer; |
|
37 |
import org.eclipse.osgi.util.NLS; |
|
38 |
import org.eclipse.swt.SWT; |
|
39 |
import org.eclipse.swt.events.KeyEvent; |
|
40 |
import org.eclipse.swt.events.KeyListener; |
|
41 |
import org.eclipse.swt.events.MouseAdapter; |
|
42 |
import org.eclipse.swt.events.MouseEvent; |
|
43 |
import org.eclipse.swt.events.SelectionEvent; |
|
44 |
import org.eclipse.swt.events.SelectionListener; |
|
45 |
import org.eclipse.swt.graphics.Font; |
|
46 |
import org.eclipse.swt.graphics.FontData; |
|
47 |
import org.eclipse.swt.graphics.Point; |
|
48 |
import org.eclipse.swt.layout.GridData; |
|
49 |
import org.eclipse.swt.layout.GridLayout; |
|
50 |
import org.eclipse.swt.widgets.Button; |
|
51 |
import org.eclipse.swt.widgets.Composite; |
|
52 |
import org.eclipse.swt.widgets.Display; |
|
53 |
import org.eclipse.swt.widgets.Menu; |
|
54 |
import org.eclipse.swt.widgets.TableColumn; |
|
55 |
import org.eclipse.ui.IEditorInput; |
|
56 |
import org.eclipse.ui.IEditorSite; |
|
57 |
import org.eclipse.ui.PartInitException; |
|
58 |
import org.txm.core.preferences.TXMPreferences; |
|
59 |
import org.txm.core.results.TXMResult; |
|
60 |
import org.txm.rcp.RCPMessages; |
|
61 |
import org.txm.rcp.StatusLine; |
|
62 |
import org.txm.rcp.editors.TXMEditor; |
|
63 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
64 |
import org.txm.rcp.editors.TableKeyListener; |
|
65 |
import org.txm.rcp.preferences.RCPPreferences; |
|
66 |
import org.txm.rcp.swt.widget.NavigationWidget; |
|
67 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
|
68 |
import org.txm.rcp.swt.widget.QueryWidget; |
|
69 |
import org.txm.rcp.views.QueriesView; |
|
70 |
import org.txm.rcp.views.corpora.CorporaView; |
|
71 |
import org.txm.referencer.core.functions.Referencer; |
|
72 |
import org.txm.referencer.core.functions.Referencer.Line; |
|
73 |
import org.txm.referencer.rcp.handlers.ReferencerToConc; |
|
74 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
75 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
76 |
import org.txm.searchengine.cqp.corpus.Property; |
|
77 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
78 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
79 |
import org.txm.statsengine.r.rcp.views.RVariablesView; |
|
80 |
|
|
81 |
/** |
|
82 |
* The Class ReferencerEditor display&update a Referencer TXMResult |
|
83 |
*/ |
|
84 |
public class ReferencerEditor extends TXMEditor<Referencer> { |
|
85 |
|
|
86 |
/** The Constant ID. */ |
|
87 |
public static final String ID = ReferencerEditor.class.getName(); |
|
88 |
|
|
89 |
/** The corpus. */ |
|
90 |
Corpus corpus; |
|
91 |
|
|
92 |
/** The referencer. */ |
|
93 |
Referencer referencer; |
|
94 |
|
|
95 |
/** The querywidget. */ |
|
96 |
QueryWidget querywidget; |
|
97 |
|
|
98 |
/** The props area. */ |
|
99 |
protected PropertiesSelector<Property> propsArea; |
|
100 |
|
|
101 |
/** The pattern area. */ |
|
102 |
protected PropertiesSelector<StructuralUnitProperty> patternArea; |
|
103 |
|
|
104 |
/** The navigation area. */ |
|
105 |
NavigationWidget navigationArea; |
|
106 |
|
|
107 |
/** The line table viewer. */ |
|
108 |
protected TableViewer viewer; |
|
109 |
|
|
110 |
/** The n column. */ |
|
111 |
protected TableColumn nColumn; |
|
112 |
|
|
113 |
/** The unit column. */ |
|
114 |
protected TableColumn unitColumn; |
|
115 |
|
|
116 |
/** The freq column. */ |
|
117 |
protected TableColumn freqColumn; |
|
118 |
|
|
119 |
/** The separator column. */ |
|
120 |
protected TableColumn separatorColumn; |
|
121 |
|
|
122 |
/** The lineperpage. */ |
|
123 |
int lineperpage = 100; |
|
124 |
|
|
125 |
/** The top line. */ |
|
126 |
int topLine=0; |
|
127 |
|
|
128 |
/** The bottom line. */ |
|
129 |
int bottomLine; |
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
/** The mess. */ |
|
134 |
String mess; |
|
135 |
|
|
136 |
|
|
137 |
@Override |
|
138 |
public void init(IEditorSite site, IEditorInput input) |
|
139 |
throws PartInitException { |
|
140 |
setSite(site); |
|
141 |
setInput(input); |
|
142 |
|
|
143 |
if (!(input instanceof TXMResultEditorInput)) { |
|
144 |
throw new PartInitException("Editor input is not a TXMResultEditorInput input editor: "+input); |
|
145 |
} |
|
146 |
|
|
147 |
TXMResult result = ((TXMResultEditorInput) input).getResult(); |
|
148 |
|
|
149 |
if (!(result instanceof Referencer)) { |
|
150 |
throw new PartInitException("TXMResult input is not a Referencer result: "+result); |
|
151 |
} |
|
152 |
|
|
153 |
this.referencer = ((Referencer) result); |
|
154 |
this.corpus = referencer.getCorpus(); |
|
155 |
|
|
156 |
} |
|
157 |
|
|
158 |
|
|
159 |
/** |
|
160 |
* Compute. |
|
161 |
* |
|
162 |
* @return true, if successful |
|
163 |
*/ |
|
164 |
@Override |
|
165 |
public void updateEditorFromResult(boolean update) { |
|
166 |
|
|
167 |
// JobHandler jobhandler = new JobHandler("refreshing...") { |
|
168 |
// @Override |
|
169 |
// protected IStatus run(IProgressMonitor monitor) { |
|
170 |
// this.runInit(monitor); |
|
171 |
// try { |
|
172 |
// JobsTimer.start(); |
|
173 |
// |
|
174 |
// monitor.worked(50); |
|
175 |
// |
|
176 |
// monitor.subTask(RCPMessages.ReferencerEditor_13); |
|
177 |
// syncExec(new Runnable() { |
|
178 |
// @Override |
|
179 |
// public void run() { |
|
180 |
fillDisplayArea(0, lineperpage); |
|
181 |
CorporaView.refresh(); |
|
182 |
CorporaView.expand(corpus); |
|
183 |
QueriesView.refresh(); |
|
184 |
RVariablesView.refresh(); |
|
185 |
//setPartName(referencer.getName()); //$NON-NLS-1$ |
|
186 |
|
|
187 |
viewer.getTable().setFocus(); |
|
188 |
System.out.println(NLS.bind(RCPMessages.CreatePartition_5, referencer.getNLines(), referencer.getV())); |
|
189 |
// } |
|
190 |
// }); |
|
191 |
// |
|
192 |
// monitor.worked(100); |
|
193 |
// } catch (ThreadDeath td) { |
|
194 |
// return Status.CANCEL_STATUS; |
|
195 |
// } catch (Exception e) { |
|
196 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
197 |
// } finally { |
|
198 |
// monitor.done(); |
|
199 |
// JobsTimer.stopAndPrint(); |
|
200 |
// } |
|
201 |
// return Status.OK_STATUS; |
|
202 |
// } |
|
203 |
// }; |
|
204 |
// jobhandler.startJob(); |
|
205 |
|
|
206 |
return; |
|
207 |
} |
|
208 |
|
|
209 |
/* (non-Javadoc) |
|
210 |
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
|
211 |
*/ |
|
212 |
@Override |
|
213 |
public void _createPartControl(Composite parent) { |
|
214 |
// super.createPartControl(parent); |
|
215 |
|
|
216 |
parent.setLayout(new GridLayout(1,true)); |
|
217 |
Composite paramArea = getCommandParametersGroup(); |
|
218 |
paramArea.setLayout(new GridLayout(3, false)); |
|
219 |
|
|
220 |
querywidget = new QueryWidget(paramArea, SWT.None); |
|
221 |
querywidget.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); |
|
222 |
querywidget.addKeyListener(new KeyListener() { |
|
223 |
@Override |
|
224 |
public void keyReleased(KeyEvent e) { } |
|
225 |
|
|
226 |
@Override |
|
227 |
public void keyPressed(KeyEvent e) { |
|
228 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) { |
|
229 |
referencer.setQuery(querywidget.getQuery()); |
|
230 |
compute(true); |
|
231 |
} |
|
232 |
} |
|
233 |
}); |
|
234 |
|
|
235 |
// [Edit] |
|
236 |
propsArea = new PropertiesSelector<Property>(paramArea, SWT.NONE); |
|
237 |
propsArea.setMaxPropertyNumber(1); |
|
238 |
propsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
239 |
false, false)); |
|
240 |
propsArea.setLayout(new GridLayout(3, false)); |
|
241 |
propsArea.addSelectionListener(new SelectionListener() { |
|
242 |
@Override |
|
243 |
public void widgetSelected(SelectionEvent e) { |
|
244 |
referencer.setProperty(propsArea.getSelectedProperties().get(0)); |
|
245 |
compute(true); |
|
246 |
} |
|
247 |
|
|
248 |
@Override |
|
249 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
250 |
}); |
|
251 |
|
|
252 |
// [Search] |
|
253 |
Button go = new Button(paramArea, SWT.PUSH); |
|
254 |
go.setText(RCPMessages.SEARCH); |
|
255 |
go.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
256 |
false, false)); |
|
257 |
Font f = go.getFont(); |
|
258 |
FontData defaultFont = f.getFontData()[0]; |
|
259 |
defaultFont.setStyle(SWT.BOLD); |
|
260 |
Font newf = new Font(go.getDisplay(), defaultFont); |
|
261 |
go.setFont(newf); |
|
262 |
|
|
263 |
go.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
|
264 |
go.addSelectionListener(new SelectionListener() { |
|
265 |
@Override |
|
266 |
public void widgetSelected(SelectionEvent e) { |
|
267 |
updateResultFromEditor(); |
|
268 |
compute(true); |
|
269 |
} |
|
270 |
|
|
271 |
@Override |
|
272 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
273 |
}); |
|
274 |
|
|
275 |
// [pattern : ... ] |
|
276 |
patternArea = new PropertiesSelector<StructuralUnitProperty>(paramArea, SWT.NONE); |
|
277 |
patternArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false,3,1)); |
|
278 |
patternArea.setLayout(new GridLayout(3, false)); |
|
279 |
patternArea.setText(RCPMessages.ReferencerEditor_6); |
|
280 |
patternArea.addSelectionListener(new SelectionListener() { |
|
281 |
@Override |
|
282 |
public void widgetSelected(SelectionEvent e) { |
|
283 |
referencer.setPattern(patternArea.getSelectedProperties()); |
|
284 |
compute(true); |
|
285 |
} |
|
286 |
|
|
287 |
@Override |
|
288 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
289 |
}); |
|
290 |
|
|
291 |
//pagination |
|
292 |
navigationArea = new NavigationWidget(paramArea, SWT.None); |
|
293 |
navigationArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false,3 ,1)); |
|
294 |
|
|
295 |
navigationArea.addFirstListener(new SelectionListener() { |
|
296 |
@Override |
|
297 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
298 |
} |
|
299 |
|
|
300 |
@Override |
|
301 |
public void widgetSelected(SelectionEvent e) { |
|
302 |
StatusLine.setMessage(RCPMessages.ReferencerEditor_17); |
|
303 |
fillDisplayArea(0, lineperpage); |
|
304 |
viewer.getTable().select(0); |
|
305 |
viewer.getTable().showSelection(); |
|
306 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
307 |
} |
|
308 |
}); |
|
309 |
navigationArea.addLastListener(new SelectionListener() { |
|
310 |
@Override |
|
311 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
312 |
} |
|
313 |
|
|
314 |
@Override |
|
315 |
public void widgetSelected(SelectionEvent e) { |
|
316 |
StatusLine.setMessage(RCPMessages.ReferencerEditor_19); |
|
317 |
fillDisplayArea(referencer.getNLines() |
|
318 |
- lineperpage, referencer.getNLines()); |
|
319 |
viewer.getTable().select(0); |
|
320 |
viewer.getTable().showSelection(); |
|
321 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
322 |
} |
|
323 |
}); |
|
324 |
navigationArea.addNextListener(new SelectionListener() { |
|
325 |
@Override |
|
326 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
327 |
} |
|
328 |
|
|
329 |
@Override |
|
330 |
public void widgetSelected(SelectionEvent e) { |
|
331 |
StatusLine.setMessage(RCPMessages.ReferencerEditor_21); |
|
332 |
fillDisplayArea(topLine + lineperpage, |
|
333 |
bottomLine + lineperpage); |
|
334 |
viewer.getTable().select(0); |
|
335 |
viewer.getTable().showSelection(); |
|
336 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
337 |
} |
|
338 |
}); |
|
339 |
navigationArea.addPreviousListener(new SelectionListener() { |
|
340 |
@Override |
|
341 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
342 |
} |
|
343 |
|
|
344 |
@Override |
|
345 |
public void widgetSelected(SelectionEvent e) { |
|
346 |
StatusLine.setMessage(RCPMessages.ReferencerEditor_23); |
|
347 |
fillDisplayArea(topLine - lineperpage, |
|
348 |
bottomLine - lineperpage); |
|
349 |
viewer.getTable().select(0); |
|
350 |
viewer.getTable().showSelection(); |
|
351 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
352 |
} |
|
353 |
}); |
|
354 |
|
|
355 |
//result |
|
356 |
|
|
357 |
Composite resultArea = getResultArea(); |
|
358 |
resultArea.setLayout(new GridLayout(1, false)); |
|
359 |
|
|
360 |
viewer = new TableViewer(resultArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); |
|
361 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
|
362 |
if (corpus != null && corpus.getFont() != null && corpus.getFont().length() > 0) { |
|
363 |
Font old = viewer.getTable().getFont(); |
|
364 |
FontData fD = old.getFontData()[0]; |
|
365 |
//Font f = new Font(old.getDevice(), corpus.getFont(), fD.getHeight(), fD.getStyle()); |
|
366 |
Font font = new Font(Display.getCurrent(), corpus.getFont(), fD.getHeight(), fD.getStyle()); |
|
367 |
viewer.getTable().setFont(font); |
|
368 |
} |
|
369 |
|
|
370 |
viewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
371 |
viewer.getTable().setLinesVisible(true); |
|
372 |
viewer.getTable().setHeaderVisible(true); |
|
373 |
|
|
374 |
viewer.setLabelProvider(new LineLabelProvider()); |
|
375 |
viewer.setContentProvider(new LineContentProvider()); |
|
376 |
viewer.setInput(new ArrayList<Property>()); |
|
377 |
|
|
378 |
viewer.getTable().addMouseListener(new MouseAdapter() { |
|
379 |
@Override |
|
380 |
public void mouseDoubleClick(MouseEvent e) { |
|
381 |
|
|
382 |
Point mouseposition = new Point(e.x |
|
383 |
+ viewer.getTable().getHorizontalBar() |
|
384 |
.getSelection(), e.y); |
|
385 |
int col = getPointedColumn(mouseposition); |
|
386 |
if (col == 1) { |
|
387 |
StatusLine.setMessage(RCPMessages.ReferencerEditor_25); |
|
388 |
sendSelectionToConc(); |
|
389 |
} else if (col == 2) { |
|
390 |
//System.out.println("Send to edition ?"); //$NON-NLS-1$ |
|
391 |
} |
|
392 |
} |
|
393 |
}); |
|
394 |
|
|
395 |
nColumn = new TableColumn(viewer.getTable(), SWT.LEFT); |
|
396 |
nColumn.setText(" "); //$NON-NLS-1$ |
|
397 |
nColumn.pack(); |
|
398 |
|
|
399 |
unitColumn = new TableColumn(viewer.getTable(), SWT.LEFT); |
|
400 |
unitColumn.setText(RCPMessages.ReferencerEditor_9); |
|
401 |
unitColumn.setToolTipText(RCPMessages.ReferencerEditor_9); |
|
402 |
unitColumn.setWidth(200); |
|
403 |
unitColumn.addSelectionListener(new SelectionListener() { |
|
404 |
@Override |
|
405 |
public void widgetSelected(SelectionEvent e) { |
|
406 |
|
|
407 |
} |
|
408 |
|
|
409 |
@Override |
|
410 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
411 |
} |
|
412 |
}); |
|
413 |
|
|
414 |
freqColumn = new TableColumn(viewer.getTable(), SWT.LEFT); |
|
415 |
freqColumn.setText(RCPMessages.ReferencerEditor_11); |
|
416 |
freqColumn.setToolTipText(RCPMessages.ReferencerEditor_11); |
|
417 |
freqColumn.setWidth(100); |
|
418 |
freqColumn.addSelectionListener(new SelectionListener() { |
|
419 |
@Override |
|
420 |
public void widgetSelected(SelectionEvent e) { |
|
421 |
|
|
422 |
} |
|
423 |
|
|
424 |
@Override |
|
425 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
426 |
} |
|
427 |
}); |
|
428 |
|
|
429 |
initializeFields(); |
|
430 |
|
|
431 |
|
|
432 |
// Register the context menu |
|
433 |
TXMEditor.initContextMenu(this.viewer.getTable(), "ReferencerEditorContextMenu", this.getSite(), this.viewer); // $NON-NLS-1$ |
|
434 |
|
|
435 |
|
|
436 |
} |
|
437 |
|
|
438 |
|
|
439 |
|
|
440 |
/** |
|
441 |
* Send selection to conc. |
|
442 |
*/ |
|
443 |
protected void sendSelectionToConc() { |
|
444 |
ReferencerToConc.link(this, this.viewer.getSelection()); |
|
445 |
} |
|
446 |
|
|
447 |
/** |
|
448 |
* Fill display area. |
|
449 |
* |
|
450 |
* @param from the from |
|
451 |
* @param to the to |
|
452 |
*/ |
|
453 |
public void fillDisplayArea(int from, int to) { |
|
454 |
from = Math.max(from, 0); |
|
455 |
to = Math.min(to, referencer.getNLines()); |
|
456 |
List<Line> lines = null; |
|
457 |
if (referencer.getNLines() > 0) { |
|
458 |
try { |
|
459 |
lines = referencer.getLines(from, to); |
|
460 |
} catch (Exception e) { |
|
461 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
462 |
lines = new ArrayList<Line>(); |
|
463 |
} |
|
464 |
} else { |
|
465 |
lines = new ArrayList<Line>(); |
|
466 |
} |
|
467 |
|
|
468 |
navigationArea.setInfoLineText(""+(from + 1), //$NON-NLS-1$ |
|
469 |
"-" + (to) + " / " + referencer.getNLines()); //$NON-NLS-1$ //$NON-NLS-2$ |
|
470 |
navigationArea.setPreviousEnabled(from > 0); |
|
471 |
navigationArea.setFirstEnabled(from > 0); |
|
472 |
navigationArea.setNextEnabled(to < referencer.getNLines() - 1); |
|
473 |
navigationArea.setLastEnabled(to < referencer.getNLines() - 1); |
|
474 |
|
|
475 |
unitColumn.setText(referencer.getProperty().getName()); |
|
476 |
|
|
477 |
String unitColumnHeader = ""; //$NON-NLS-1$ |
|
478 |
for (Property p : referencer.getPattern()) |
|
479 |
unitColumnHeader += p.getName() + ", "; //$NON-NLS-1$ |
|
480 |
if (unitColumnHeader.length() > 0) |
|
481 |
unitColumnHeader = unitColumnHeader.substring(0, unitColumnHeader |
|
482 |
.length() - 2); |
|
483 |
freqColumn.setText(unitColumnHeader); |
|
484 |
|
|
485 |
viewer.setInput(lines); |
|
486 |
viewer.refresh(); |
|
487 |
// System.out.println("table refreshed from "+from+" to "+to+" with : "+lines); |
|
488 |
topLine = from; |
|
489 |
bottomLine = to; |
|
490 |
for (TableColumn col : viewer.getTable().getColumns()) { |
|
491 |
col.pack(); |
|
492 |
} |
|
493 |
} |
|
494 |
|
|
495 |
/** |
|
496 |
* Gets the pointed column. |
|
497 |
* |
|
498 |
* @param mouseposition the mouseposition |
|
499 |
* @return the pointed column |
|
500 |
*/ |
|
501 |
public int getPointedColumn(Point mouseposition) { |
|
502 |
int x = mouseposition.x; // + lineTableViewer.getTable().get; |
|
503 |
int sumWidthColumn = this.nColumn.getWidth(); |
|
504 |
if (x < sumWidthColumn) |
|
505 |
return 0; |
|
506 |
|
|
507 |
sumWidthColumn += this.unitColumn.getWidth(); |
|
508 |
if (x < sumWidthColumn) |
|
509 |
return 1; |
|
510 |
|
|
511 |
sumWidthColumn += this.freqColumn.getWidth(); |
|
512 |
if (x < sumWidthColumn) |
|
513 |
return 2; |
|
514 |
|
|
515 |
return 2; |
|
516 |
} |
|
517 |
|
|
518 |
/* (non-Javadoc) |
|
519 |
* @see org.eclipse.ui.part.WorkbenchPart#setFocus() |
|
520 |
*/ |
|
521 |
@Override |
|
522 |
public void setFocus() { |
|
523 |
querywidget.setFocus(); |
|
524 |
} |
|
525 |
|
|
526 |
/** |
|
527 |
* Gets the referencer. |
|
528 |
* |
|
529 |
* @return the referencer |
|
530 |
*/ |
|
531 |
public Referencer getReferencer() { |
|
532 |
return this.referencer; |
|
533 |
} |
|
534 |
|
|
535 |
/** |
|
536 |
* Gets the corpus. |
|
537 |
* |
|
538 |
* @return the corpus |
|
539 |
*/ |
|
540 |
public Corpus getCorpus() { |
|
541 |
return this.corpus; |
|
542 |
} |
|
543 |
|
|
544 |
protected void initializeFields() { |
|
545 |
// word properties |
|
546 |
try { |
|
547 |
ArrayList<Property> selectedProps = new ArrayList<Property>(); |
|
548 |
ArrayList<Property> availables = new ArrayList<Property>(); |
|
549 |
availables.addAll(corpus.getOrderedProperties()); |
|
550 |
|
|
551 |
if (referencer.getProperty() != null) { |
|
552 |
selectedProps.add(referencer.getProperty()); |
|
553 |
availables.remove(referencer.getProperty()); |
|
554 |
this.propsArea.setProperties(availables, selectedProps); |
|
555 |
} else { |
|
556 |
this.propsArea.setCorpus(corpus); |
|
557 |
} |
|
558 |
|
|
559 |
} catch (CqiClientException e1) { |
|
560 |
org.txm.rcp.utils.Logger.printStackTrace(e1); |
|
561 |
} |
|
562 |
|
|
563 |
// references |
|
564 |
|
|
565 |
try { |
|
566 |
ArrayList<StructuralUnitProperty> availables2 = new ArrayList<StructuralUnitProperty>(); |
|
567 |
availables2.addAll(corpus.getStructuralUnitProperties()); |
|
568 |
Collections.sort(availables2); |
|
569 |
|
|
570 |
ArrayList<StructuralUnitProperty> selectedProps = new ArrayList<StructuralUnitProperty>(); |
|
571 |
if (referencer.getPattern() != null) { |
|
572 |
for(StructuralUnitProperty p : referencer.getPattern()) { |
|
573 |
selectedProps.add(p); |
|
574 |
availables2.remove(p); |
|
575 |
} |
|
576 |
} |
|
577 |
|
|
578 |
this.patternArea.setProperties(availables2, selectedProps); |
|
579 |
} catch (CqiClientException e1) { |
|
580 |
org.txm.rcp.utils.Logger.printStackTrace(e1); |
|
581 |
return; |
|
582 |
} |
|
583 |
|
|
584 |
if (referencer.getQuery() != null) { |
|
585 |
this.querywidget.setText(referencer.getQuery().getQueryString()); |
|
586 |
} |
|
587 |
} |
|
588 |
|
|
589 |
@Override |
|
590 |
public void updateResultFromEditor() { |
|
591 |
final Query query = querywidget.getQuery(); |
|
592 |
final List<Property> queryprops = propsArea.getSelectedProperties(); |
|
593 |
final List<StructuralUnitProperty> refs = patternArea.getSelectedProperties(); |
|
594 |
boolean hierarchicSort = TXMPreferences.getBoolean(RCPPreferences.SORTBYFREQ, RCPPreferences.PREFERENCES_NODE); |
|
595 |
|
|
596 |
referencer.setParameters(query, queryprops.get(0), refs, hierarchicSort); |
|
597 |
} |
|
598 |
} |
|
0 | 599 |
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/editors/LineContentProvider.java (revision 632) | ||
---|---|---|
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.referencer.rcp.editors; |
|
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.referencer.core.functions.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/referencer/rcp/handlers/ComputeReferencer.java (revision 632) | ||
---|---|---|
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.referencer.rcp.handlers; |
|
29 |
|
|
30 |
import org.eclipse.core.commands.ExecutionEvent; |
|
31 |
import org.eclipse.core.commands.ExecutionException; |
|
32 |
import org.txm.rcp.editors.TXMEditor; |
|
33 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
34 |
import org.txm.rcp.views.corpora.CorporaView; |
|
35 |
import org.txm.referencer.core.functions.Referencer; |
|
36 |
import org.txm.referencer.rcp.editors.ReferencerEditor; |
|
37 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
38 |
|
|
39 |
/** |
|
40 |
* Opens the Referencer editor with a corpus or a Referencer result . |
|
41 |
* |
|
42 |
* @author mdecorde |
|
43 |
* @author sjacquot |
|
44 |
*/ |
|
45 |
public class ComputeReferencer extends BaseAbstractHandler { |
|
46 |
|
|
47 |
// adds a double click listener to the Corpus View |
|
48 |
static { |
|
49 |
CorporaView.addDoubleClickListener(Referencer.class, ComputeReferencer.class); |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
@Override |
|
54 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
55 |
if (!this.checkCorpusEngine()) { |
|
56 |
return false; |
|
57 |
} |
|
58 |
|
|
59 |
Object selection = this.getSelection(event); |
|
60 |
Referencer referencer = null; |
|
61 |
|
|
62 |
// Creating from Corpus |
|
63 |
if (selection instanceof Corpus) { |
|
64 |
referencer = new Referencer((Corpus)selection); |
|
65 |
} |
|
66 |
// Reopening from existing result |
|
67 |
else if (selection instanceof Referencer) { |
|
68 |
referencer = (Referencer)selection; |
|
69 |
} |
|
70 |
// Error |
|
71 |
else { |
|
72 |
return super.logCanNotCompute(selection); |
|
73 |
} |
|
74 |
|
|
75 |
TXMEditor.openEditor(referencer, ReferencerEditor.ID); //$NON-NLS-1$ |
|
76 |
|
|
77 |
return null; |
|
78 |
} |
|
79 |
|
|
80 |
} |
|
0 | 81 |
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/handlers/ReferencerToConc.java (revision 632) | ||
---|---|---|
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.referencer.rcp.handlers; |
|
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.concordance.core.functions.Concordance; |
|
42 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
|
43 |
import org.txm.rcp.RCPMessages; |
|
44 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
45 |
import org.txm.referencer.core.functions.Referencer; |
|
46 |
import org.txm.referencer.core.functions.Referencer.Line; |
|
47 |
import org.txm.referencer.rcp.editors.ReferencerEditor; |
|
48 |
import org.txm.searchengine.cqp.ReferencePattern; |
|
49 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
50 |
import org.txm.searchengine.cqp.corpus.Property; |
|
51 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
52 |
|
|
53 |
// TODO: Auto-generated Javadoc |
|
54 |
/** |
|
55 |
* The Class ReferencerToConc. |
|
56 |
*/ |
|
57 |
public class ReferencerToConc extends AbstractHandler { |
|
58 |
|
|
59 |
/* (non-Javadoc) |
|
60 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
61 |
*/ |
|
62 |
@Override |
|
63 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
64 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
65 |
.getActiveWorkbenchWindow(event).getActivePage().getSelection(); |
|
66 |
|
|
67 |
ReferencerEditor refeditor = (ReferencerEditor) HandlerUtil |
|
68 |
.getActiveWorkbenchWindow(event).getActivePage() |
|
69 |
.getActivePart(); |
|
70 |
|
|
71 |
return link(refeditor, selection); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Link. |
|
76 |
* |
|
77 |
* @param refeditor the refeditor |
|
78 |
* @param iSelection the selection |
|
79 |
* @return the object |
|
80 |
*/ |
|
81 |
public static Object link(ReferencerEditor refeditor, ISelection iSelection) |
|
82 |
{ |
|
83 |
IStructuredSelection selection = (IStructuredSelection) iSelection; |
|
84 |
String query = getQuery(refeditor.getReferencer(), selection); |
|
85 |
if (query.length() == 0) |
|
86 |
return null; |
|
87 |
Corpus corpus = refeditor.getCorpus(); |
|
88 |
Concordance concordance = new Concordance(corpus); |
|
89 |
|
|
90 |
ReferencePattern rp = new ReferencePattern(); |
|
91 |
for (Property p : refeditor.getReferencer().getPattern()) |
|
92 |
rp.addProperty(p); |
|
93 |
|
|
94 |
concordance.setParameters(new Query(query), null, null, null, null, null, null, rp, rp, null, null); |
|
95 |
TXMResultEditorInput editorInput = new TXMResultEditorInput(concordance); |
|
96 |
|
|
97 |
IWorkbenchPage page = refeditor.getEditorSite().getWorkbenchWindow().getActivePage(); |
|
98 |
try { |
|
99 |
ConcordanceEditor conceditor = (ConcordanceEditor) page.openEditor(editorInput, |
|
100 |
ConcordanceEditor.class.getName()); //$NON-NLS-1$ |
|
101 |
} catch (PartInitException e) { |
|
102 |
System.err.println("Error: "+e.getLocalizedMessage()); |
|
103 |
} |
|
104 |
|
|
105 |
return null; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Gets the query. |
|
110 |
* |
|
111 |
* @param selection the selection |
|
112 |
* @return the query |
|
113 |
*/ |
|
114 |
private static String getQuery(Referencer referencer, IStructuredSelection selection) { |
|
115 |
String query = ""; //$NON-NLS-1$ |
|
116 |
|
|
117 |
Line fline = (Line) selection.getFirstElement(); |
|
118 |
int nbToken = 1; |
|
119 |
|
|
120 |
List<Line> lines = selection.toList(); |
|
121 |
|
|
122 |
Property prop = referencer.getProperty(); |
|
123 |
for (int t = 0; t < nbToken; t++) |
|
124 |
{ |
|
125 |
query += "["+prop + "=\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
126 |
|
|
127 |
for (Line line : lines) { |
|
128 |
String s = line.getPropValue(); |
|
129 |
s = Query.addBackSlash(s); |
|
130 |
query += s + "|"; //$NON-NLS-1$ |
|
131 |
} |
|
132 |
query = query.substring(0, query.length() - 1); |
|
133 |
query += "\"] "; //$NON-NLS-1$ |
|
134 |
} |
|
135 |
query = query.substring(0, query.length() - 1); |
|
136 |
return query; |
|
137 |
} |
|
138 |
} |
|
0 | 139 |
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/preferences/ReferencerPreferencePage.java (revision 632) | ||
---|---|---|
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.referencer.rcp.preferences; |
|
29 |
|
|
30 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
|
31 |
import org.txm.rcp.RCPMessages; |
|
32 |
import org.txm.rcp.preferences.RCPPreferences; |
|
33 |
import org.txm.rcp.preferences.RCPPreferencesPage; |
|
34 |
|
|
35 |
/** |
|
36 |
* This class represents a preference page that is contributed to the |
|
37 |
* Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we |
|
38 |
* can use the field support built into JFace that allows us to create a page |
|
39 |
* that is small and knows how to save, restore and apply itself. |
|
40 |
* <p> |
|
41 |
* This page is used to modif y preferences only. They are stored in the |
|
42 |
* preference store that belongs to the main plug-in class. That way, |
|
43 |
* preferences can be accessed directly via the preference store. |
|
44 |
*/ |
|
45 |
|
|
46 |
public class ReferencerPreferencePage extends RCPPreferencesPage { |
|
47 |
|
|
48 |
/** The referencer_sorttype. */ |
|
49 |
private BooleanFieldEditor referencer_sorttype; |
|
50 |
|
|
51 |
/** |
|
52 |
* Instantiates a new referencer preference page. |
|
53 |
*/ |
|
54 |
public ReferencerPreferencePage() { |
|
55 |
super(); |
|
56 |
setTitle(RCPMessages.ReferencerPreferencePage_2); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Creates the field editors. Field editors are abstractions of the common |
|
61 |
* GUI blocks needed to manipulate various types of preferences. Each field |
|
62 |
* editor knows how to save and restore itself. |
|
63 |
*/ |
|
64 |
@Override |
|
65 |
public void createFieldEditors() { |
|
66 |
|
|
67 |
referencer_sorttype = new BooleanFieldEditor(RCPPreferences.SORTBYFREQ, |
|
68 |
RCPMessages.ReferencerPreferencePage_3, getFieldEditorParent()); |
|
69 |
|
|
70 |
addField(referencer_sorttype); |
|
71 |
|
|
72 |
} |
|
73 |
} |
|
0 | 74 |
tmp/org.txm.referencer.rcp/build.properties (revision 632) | ||
---|---|---|
1 |
source.. = src/ |
|
2 |
output.. = bin/ |
|
3 |
bin.includes = META-INF/,\ |
|
4 |
.,\ |
|
5 |
plugin.xml,\ |
|
6 |
icons/,\ |
|
7 |
OSGI-INF/ |
|
0 | 8 |
tmp/org.txm.referencer.rcp/OSGI-INF/l10n/bundle_ru.properties (revision 632) | ||
---|---|---|
1 |
editor.name.14=Мастер ссылок |
|
2 |
command.name.44=Ссылки |
|
0 | 3 |
tmp/org.txm.referencer.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 632) | ||
---|---|---|
1 |
editor.name.14=Référenceur |
|
2 |
command.name.44=Références |
|
0 | 3 |
tmp/org.txm.referencer.rcp/OSGI-INF/l10n/bundle.properties (revision 632) | ||
---|---|---|
1 |
command.name.57 = RefToConc |
|
2 |
editor.name.14=Referencer |
|
3 |
command.name.44=References |
|
0 | 4 |
tmp/org.txm.referencer.rcp/plugin.xml (revision 632) | ||
---|---|---|
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.referencer.rcp.editors.ReferencerEditor" |
|
8 |
default="false" |
|
9 |
icon="icons/functions/referencer.png" |
|
10 |
id="org.txm.referencer.rcp.editors.ReferencerEditor" |
|
11 |
name="%editor.name.14"> |
|
12 |
</editor> |
|
13 |
</extension> |
|
14 |
<extension |
|
15 |
point="org.eclipse.ui.menus"> |
|
16 |
<menuContribution |
|
17 |
locationURI="menu:menu.tools"> |
|
18 |
<command |
|
19 |
commandId="org.txm.referencer.rcp.handlers.ComputeReferencer" |
|
20 |
icon="icons/functions/referencer.png" |
|
21 |
style="push"> |
|
22 |
<visibleWhen |
|
23 |
checkEnabled="false"> |
|
24 |
<reference |
|
25 |
definitionId="OneCorpusSelected"> |
|
26 |
</reference> |
|
27 |
</visibleWhen> |
|
28 |
</command> |
|
29 |
</menuContribution> |
|
30 |
<menuContribution |
|
31 |
allPopups="false" |
|
32 |
locationURI="toolbar:org.txm.rcp.toolbartools"> |
|
33 |
<command |
|
34 |
commandId="org.txm.referencer.rcp.handlers.ComputeReferencer" |
|
35 |
icon="icons/functions/referencer.png" |
|
36 |
style="push"> |
|
37 |
<visibleWhen |
|
38 |
checkEnabled="false"> |
|
39 |
<reference |
|
40 |
definitionId="OneCorpusSelected"> |
|
41 |
</reference> |
|
42 |
</visibleWhen> |
|
43 |
</command> |
|
44 |
</menuContribution> |
|
45 |
<menuContribution |
|
46 |
allPopups="false" |
|
47 |
locationURI="popup:org.txm.rcp.views.corpora.CorporaView"> |
|
48 |
<command |
|
49 |
commandId="org.txm.referencer.rcp.handlers.ComputeReferencer" |
|
50 |
icon="icons/functions/referencer.png" |
|
51 |
style="push"> |
|
52 |
<visibleWhen |
|
53 |
checkEnabled="false"> |
|
54 |
<reference |
|
55 |
definitionId="OneCorpusSelected"> |
|
56 |
</reference> |
|
57 |
</visibleWhen> |
|
58 |
</command> |
|
59 |
</menuContribution> |
|
60 |
<menuContribution |
|
61 |
locationURI="popup:ReferencerEditorContextMenu"> |
|
62 |
<command |
|
63 |
commandId="org.txm.referencer.rcp.handlers.ReferencerToConc" |
|
64 |
style="push"> |
|
65 |
</command> |
|
66 |
</menuContribution> |
|
67 |
</extension> |
|
68 |
<extension |
|
69 |
point="org.eclipse.ui.commands"> |
|
70 |
<command |
|
71 |
defaultHandler="org.txm.referencer.rcp.handlers.ReferencerToConc" |
|
72 |
id="org.txm.referencer.rcp.handlers.ReferencerToConc" |
|
73 |
name="%command.name.57"> |
|
74 |
</command> |
|
75 |
|
|
76 |
<command |
|
77 |
categoryId="org.txm.rcp.category.txm" |
|
78 |
defaultHandler="org.txm.referencer.rcp.handlers.ComputeReferencer" |
|
79 |
id="org.txm.referencer.rcp.handlers.ComputeReferencer" |
|
80 |
name="%command.name.44"> |
|
81 |
</command> |
|
82 |
</extension> |
|
83 |
<extension |
|
84 |
point="org.eclipse.core.expressions.definitions"> |
|
85 |
<definition |
|
86 |
id="OneReferencerSelected"> |
|
87 |
<with |
|
88 |
variable="selection"> |
|
89 |
<iterate |
|
90 |
ifEmpty="false" |
|
91 |
operator="and"> |
|
92 |
<instanceof |
|
93 |
value="org.txm.referencer.core.functions.Referencer"> |
|
94 |
</instanceof> |
|
95 |
</iterate> |
|
96 |
</with> |
|
97 |
</definition> |
|
98 |
</extension> |
|
99 |
<extension |
|
100 |
point="org.eclipse.core.runtime.adapters"> |
|
101 |
<factory |
|
102 |
adaptableType="org.txm.referencer.core.functions.Referencer" |
|
103 |
class="org.txm.referencer.rcp.adapters.ReferencerAdapterFactory"> |
|
104 |
<adapter |
|
105 |
type="org.eclipse.ui.model.IWorkbenchAdapter"> |
|
106 |
</adapter> |
|
107 |
</factory> |
|
108 |
</extension> |
|
109 |
<extension |
|
110 |
point="org.eclipse.ui.preferencePages"> |
|
111 |
<page |
|
112 |
category="org.txm.rcp.preferences.UserPreferencePage" |
|
113 |
class="org.txm.referencer.rcp.preferences.ReferencerPreferencePage" |
|
114 |
id="org.txm.referencer.rcp.preferences.ReferencerPreferencePage" |
|
115 |
name="Referencer"> |
|
116 |
</page> |
|
117 |
</extension> |
|
118 |
</plugin> |
|
0 | 119 |
tmp/org.txm.referencer.rcp/.settings/org.eclipse.jdt.core.prefs (revision 632) | ||
---|---|---|
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 |
tmp/org.txm.referencer.rcp/.classpath (revision 632) | ||
---|---|---|
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 |
<accessrules> |
|
6 |
<accessrule kind="accessible" pattern="**"/> |
|
7 |
</accessrules> |
|
8 |
</classpathentry> |
|
9 |
<classpathentry kind="src" path="src"/> |
|
10 |
<classpathentry kind="output" path="bin"/> |
|
11 |
</classpath> |
|
0 | 12 |
tmp/org.txm.referencer.rcp/META-INF/MANIFEST.MF (revision 632) | ||
---|---|---|
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 |
Require-Bundle: org.txm.utils;bundle-version="1.0.0", |
|
7 |
org.txm.referencer.core;bundle-version="1.0.0", |
|
8 |
org.txm.concordance.core;bundle-version="1.0.0", |
|
9 |
org.txm.searchengine.cqp.core;bundle-version="1.1.0", |
|
10 |
org.txm.concordance.rcp;bundle-version="1.0.0", |
|
11 |
org.txm.statsengine.r.rcp;bundle-version="1.0.0", |
|
12 |
org.eclipse.ui, |
|
13 |
org.eclipse.core.runtime, |
|
14 |
org.txm.core;bundle-version="0.7.0", |
|
15 |
org.txm.rcp;bundle-version="0.7.8", |
|
16 |
org.eclipse.core.expressions;bundle-version="3.4.600", |
|
17 |
org.txm.searchengine.core;bundle-version="1.0.0" |
|
18 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
|
19 |
Bundle-ActivationPolicy: lazy |
|
20 |
Export-Package: org.txm.referencer.rcp.adapters, |
|
21 |
org.txm.referencer.rcp.editors, |
|
22 |
org.txm.referencer.rcp.handlers, |
|
23 |
org.txm.referencer.rcp.preferences |
|
0 | 24 |
tmp/org.txm.referencer.rcp/.project (revision 632) | ||
---|---|---|
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 |
Formats disponibles : Unified diff