Révision 536
tmp/org.txm.referencer.rcp/OSGI-INF/l10n/bundle_ru.properties (revision 536) | ||
---|---|---|
117 | 117 |
command.label.45 = \u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0444\u0430\u0439\u043B |
118 | 118 |
command.label.46 = \u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0444\u0430\u0439\u043B |
119 | 119 |
command.label.47 = \u0412\u044B\u0440\u0435\u0437\u0430\u0442\u044C \u0444\u0430\u0439\u043B |
120 |
command.label.48 = \u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 |
|
121 |
command.label.49 = \u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 |
|
122 | 120 |
command.label.5 = XML-TEI-BFM |
123 | 121 |
command.label.50 = \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C |
124 | 122 |
command.label.51 = \u042D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C |
tmp/org.txm.referencer.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 536) | ||
---|---|---|
148 | 148 |
command.label.45 = \u00C3\u0089diter... |
149 | 149 |
command.label.46 = Copier |
150 | 150 |
command.label.47 = Couper |
151 |
command.label.48 = Description |
|
152 |
command.label.49 = Description |
|
153 | 151 |
command.label.5 = XML-TEI BFM |
154 | 152 |
command.label.50 = Charger |
155 | 153 |
command.label.51 = Donn\u00C3\u00A9es... |
tmp/org.txm.referencer.rcp/OSGI-INF/l10n/bundle.properties (revision 536) | ||
---|---|---|
136 | 136 |
command.label.45 = Edit... |
137 | 137 |
command.label.46 = Copy File |
138 | 138 |
command.label.47 = Cut File |
139 |
command.label.48 = Description |
|
140 |
command.label.49 = Description |
|
141 | 139 |
command.label.5 = XML-TEI BFM |
142 | 140 |
command.label.50 = Load |
143 | 141 |
command.label.51 = Data... |
tmp/org.txm.specificities.rcp/plugin.xml (revision 536) | ||
---|---|---|
11 | 11 |
name="Specificities Chart"> |
12 | 12 |
</editor> |
13 | 13 |
<editor |
14 |
class="org.txm.specificities.rcp.editors.SpecificitiesTableEditor"
|
|
14 |
class="org.txm.specificities.rcp.editors.SpecificitiesEditor" |
|
15 | 15 |
default="false" |
16 | 16 |
icon="icons/functions/specificities.png" |
17 | 17 |
id="org.txm.specificities.rcp.editors.SpecificitiesTableEditor" |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesTableEditor.java (revision 536) | ||
---|---|---|
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.specificities.rcp.editors; |
|
29 |
|
|
30 |
import java.lang.reflect.InvocationTargetException; |
|
31 |
import java.text.Collator; |
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.Comparator; |
|
34 |
import java.util.List; |
|
35 |
import java.util.Locale; |
|
36 |
|
|
37 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
38 |
import org.eclipse.core.runtime.IStatus; |
|
39 |
import org.eclipse.core.runtime.Status; |
|
40 |
import org.eclipse.jface.action.MenuManager; |
|
41 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
|
42 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
|
43 |
import org.eclipse.jface.viewers.TableViewer; |
|
44 |
import org.eclipse.jface.viewers.Viewer; |
|
45 |
import org.eclipse.osgi.util.NLS; |
|
46 |
import org.eclipse.swt.SWT; |
|
47 |
import org.eclipse.swt.events.SelectionEvent; |
|
48 |
import org.eclipse.swt.events.SelectionListener; |
|
49 |
import org.eclipse.swt.layout.GridData; |
|
50 |
import org.eclipse.swt.layout.GridLayout; |
|
51 |
import org.eclipse.swt.widgets.Composite; |
|
52 |
import org.eclipse.swt.widgets.Label; |
|
53 |
import org.eclipse.swt.widgets.Menu; |
|
54 |
import org.eclipse.swt.widgets.ScrollBar; |
|
55 |
import org.eclipse.swt.widgets.Spinner; |
|
56 |
import org.eclipse.swt.widgets.Table; |
|
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.PlatformUI; |
|
62 |
import org.eclipse.ui.part.EditorPart; |
|
63 |
import org.txm.core.results.TXMResult; |
|
64 |
import org.txm.objects.TxmObject; |
|
65 |
import org.txm.rcp.RCPMessages; |
|
66 |
import org.txm.rcp.StatusLine; |
|
67 |
import org.txm.rcp.editors.TXMEditorPart; |
|
68 |
import org.txm.rcp.editors.TableKeyListener; |
|
69 |
import org.txm.rcp.utils.JobHandler; |
|
70 |
import org.txm.specificities.core.functions.Specificities; |
|
71 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences; |
|
72 |
import org.txm.specificities.rcp.messages.SpecificitiesUIMessages; |
|
73 |
import org.txm.statsengine.core.StatException; |
|
74 |
import org.txm.utils.logger.Log; |
|
75 |
/** |
|
76 |
* Display a table editor with specificites index. |
|
77 |
* |
|
78 |
* @author sloiseau, mdecorde, sjaquot |
|
79 |
* |
|
80 |
*/ |
|
81 |
public class SpecificitiesTableEditor extends TXMEditorPart { |
|
82 |
|
|
83 |
public static String ID = SpecificitiesTableEditor.class.getName(); |
|
84 |
|
|
85 |
/** The specificities table. */ |
|
86 |
private Table specificitesTable; |
|
87 |
private TableViewer viewer; |
|
88 |
|
|
89 |
/** Column for table typeNameTable. */ |
|
90 |
private TableColumn typeNameColumn; |
|
91 |
|
|
92 |
/** Column for table typeFrequencyColumn. */ |
|
93 |
private TableColumn typeFrequencyColumn; |
|
94 |
|
|
95 |
/** The current comparator: updated when user click on a column header */ |
|
96 |
protected Comparator currentComparator; |
|
97 |
|
|
98 |
/** All columns for the table specificitesTable. */ |
|
99 |
private List<TableColumn> specificitesTableColumn = new ArrayList<TableColumn>(); |
|
100 |
|
|
101 |
/** The result of specificities*/ |
|
102 |
private Specificities specificitiesResult; |
|
103 |
|
|
104 |
/** The table lines : table input */ |
|
105 |
private SpecificitiesTableLines tableLines; |
|
106 |
|
|
107 |
/** The source. */ |
|
108 |
private Object source; |
|
109 |
|
|
110 |
/* (non-Javadoc) |
|
111 |
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) |
|
112 |
*/ |
|
113 |
@Override |
|
114 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException { |
|
115 |
super.init(site, input); |
|
116 |
|
|
117 |
SpecificitiesResultEditorInput spinput = (SpecificitiesResultEditorInput) getEditorInput(); |
|
118 |
this.specificitiesResult = (Specificities) ((SpecificitiesResultEditorInput) getEditorInput()).getResult(); |
|
119 |
if (this.specificitiesResult.getLexicalTable()!= null && this.specificitiesResult.getLexicalTable().getPartition() != null) { |
|
120 |
setPartName(this.specificitiesResult.getLexicalTable().getPartition().getName()+": "+specificitiesResult.getName()); //$NON-NLS-1$ |
|
121 |
} else if (spinput.getSubcorpus() != null) { |
|
122 |
setPartName(spinput.getSubcorpus().getName()+": "+specificitiesResult.getName()); //$NON-NLS-1$ |
|
123 |
} else { |
|
124 |
setPartName(specificitiesResult.getName()); |
|
125 |
} |
|
126 |
} |
|
127 |
|
|
128 |
/* (non-Javadoc) |
|
129 |
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
|
130 |
*/ |
|
131 |
@Override |
|
132 |
public void createPartControl(Composite parent) { |
|
133 |
super.createPartControl(parent); |
|
134 |
|
|
135 |
Composite parametersArea = getCommandParametersGroup(); |
|
136 |
|
|
137 |
new Label(parametersArea, SWT.NONE).setText("Maximum score"); |
|
138 |
|
|
139 |
Spinner maxScore = new Spinner(parametersArea, SWT.BORDER); |
|
140 |
maxScore.setToolTipText("The maximum score to show"); |
|
141 |
maxScore.setMinimum(0); |
|
142 |
maxScore.setSelection(SpecificitiesPreferences.getInt(SpecificitiesPreferences.MAX_SCORE, SpecificitiesPreferences.PREFERENCES_NODE)); |
|
143 |
|
|
144 |
Composite displayArea = getDisplayArea(); |
|
145 |
//displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
146 |
try { |
|
147 |
composeDisplayArea(displayArea); |
|
148 |
} catch (StatException e) { |
|
149 |
System.err.println(NLS.bind(SpecificitiesUIMessages.SpecificitiesTableEditor_0, e.getMessage())); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
/** Sort. */ |
|
154 |
protected void sort() { |
|
155 |
if (currentComparator != null) { |
|
156 |
try { |
|
157 |
PlatformUI.getWorkbench().getProgressService().busyCursorWhile( |
|
158 |
new IRunnableWithProgress() { |
|
159 |
@Override |
|
160 |
public void run(IProgressMonitor monitor) |
|
161 |
throws InvocationTargetException, |
|
162 |
InterruptedException { |
|
163 |
tableLines.sort(currentComparator); |
|
164 |
} |
|
165 |
}); |
|
166 |
StatusLine.setMessage(RCPMessages.SORT_DONE); |
|
167 |
fillDisplay(); |
|
168 |
} catch (Exception e) { |
|
169 |
System.err.println(NLS.bind(SpecificitiesUIMessages.SpecificitiesTableEditor_1, e)); |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Compose display area. |
|
176 |
* |
|
177 |
* @param parent the parent |
|
178 |
* @throws StatException the stat exception |
|
179 |
*/ |
|
180 |
private void composeDisplayArea(final Composite parent) throws StatException { |
|
181 |
|
|
182 |
GridLayout layout = new GridLayout(2, false); |
|
183 |
layout.marginWidth = layout.marginHeight = layout.horizontalSpacing = 0; |
|
184 |
parent.setLayout(layout); |
|
185 |
|
|
186 |
// create table viewer |
|
187 |
viewer = new TableViewer(parent, SWT.VIRTUAL | SWT.MULTI | SWT.FULL_SELECTION); |
|
188 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
|
189 |
viewer.getTable().setLinesVisible(true); |
|
190 |
viewer.getTable().setHeaderVisible(true); |
|
191 |
viewer.setLabelProvider(new SpecificitiesTableLabelProvider()); |
|
192 |
|
|
193 |
specificitesTable = viewer.getTable(); |
|
194 |
GridData table2Data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2); |
|
195 |
specificitesTable.setLayoutData(table2Data); |
|
196 |
|
|
197 |
// create 1st column |
|
198 |
typeNameColumn = new TableColumn(specificitesTable, |
|
199 |
SWT.NONE); |
|
200 |
typeNameColumn.setText(RCPMessages.ReferencerEditor_9); |
|
201 |
typeNameColumn.setToolTipText(RCPMessages.ReferencerEditor_9); |
|
202 |
typeNameColumn.setAlignment(SWT.RIGHT); |
|
203 |
typeNameColumn.pack(); |
|
204 |
typeNameColumn.setWidth((int) (typeNameColumn.getWidth()*1.5)); |
|
205 |
|
|
206 |
Object oparent = specificitiesResult.getParent(); |
|
207 |
Locale locale = Locale.getDefault(); |
|
208 |
if (oparent instanceof TxmObject) { |
|
209 |
String lang = (String) ((TxmObject) oparent).getAttribute("lang"); //$NON-NLS-1$ |
|
210 |
if (lang != null) |
|
211 |
locale = new Locale(lang); |
|
212 |
} |
|
213 |
final Collator collator = Collator.getInstance(locale); |
|
214 |
collator.setStrength(Collator.TERTIARY); |
|
215 |
typeNameColumn.addSelectionListener(new SelectionListener() { |
|
216 |
@Override |
|
217 |
public void widgetSelected(SelectionEvent e) { |
|
218 |
StatusLine.setMessage(RCPMessages.SORT_COLUMN); |
|
219 |
Comparator column_comparator = new Comparator() { |
|
220 |
@Override |
|
221 |
public int compare(Object o1, Object o2) { |
|
222 |
Object[] line1 = (Object[]) o1; |
|
223 |
Object[] line2 = (Object[]) o2; |
|
224 |
return collator.compare(line1[0], line2[0]); |
|
225 |
} |
|
226 |
}; |
|
227 |
if (specificitesTable.getSortColumn() != typeNameColumn) { |
|
228 |
specificitesTable.setSortColumn( |
|
229 |
typeNameColumn); |
|
230 |
specificitesTable.setSortDirection(SWT.UP); |
|
231 |
} else if (specificitesTable |
|
232 |
.getSortDirection() == SWT.UP) { |
|
233 |
specificitesTable.setSortDirection( |
|
234 |
SWT.DOWN); |
|
235 |
column_comparator = new ReverseComparator(column_comparator); |
|
236 |
} else { |
|
237 |
specificitesTable.setSortDirection(SWT.UP); |
|
238 |
} |
|
239 |
currentComparator = column_comparator; |
|
240 |
sort(); |
|
241 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
242 |
} |
|
243 |
|
|
244 |
@Override |
|
245 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
246 |
} |
|
247 |
}); |
|
248 |
|
|
249 |
// create 2nd column |
|
250 |
typeFrequencyColumn = new TableColumn(viewer |
|
251 |
.getTable(), SWT.NONE); |
|
252 |
typeFrequencyColumn.setText(RCPMessages.FrequencyListEditorInput_4 |
|
253 |
+ " "+SpecificitiesUIMessages.SpecificitiesTableEditor_11+" " |
|
254 |
+ specificitiesResult.getCorpusSize()); |
|
255 |
typeFrequencyColumn.setToolTipText(RCPMessages.FrequencyListEditorInput_4 |
|
256 |
+ SpecificitiesUIMessages.SpecificitiesTableEditor_11 |
|
257 |
+ specificitiesResult.getCorpusSize()); |
|
258 |
typeFrequencyColumn.setAlignment(SWT.RIGHT); |
|
259 |
typeFrequencyColumn.pack(); |
|
260 |
typeFrequencyColumn.addSelectionListener(new SelectionListener() { |
|
261 |
@Override |
|
262 |
public void widgetSelected(SelectionEvent e) { |
|
263 |
StatusLine.setMessage(RCPMessages.SORT_COLUMN); |
|
264 |
Comparator<Object[]> column_comparator = new Comparator<Object[]>() { |
|
265 |
@Override |
|
266 |
public int compare(Object[] line1, Object[] line2) { // Compare two |
|
267 |
return ((Integer) line1[1]).compareTo(((Integer) line2[1])); |
|
268 |
} |
|
269 |
}; |
|
270 |
if (specificitesTable.getSortColumn() != typeFrequencyColumn) { |
|
271 |
specificitesTable.setSortColumn( |
|
272 |
typeFrequencyColumn); |
|
273 |
specificitesTable.setSortDirection(SWT.UP); |
|
274 |
} else if (specificitesTable |
|
275 |
.getSortDirection() == SWT.UP) { |
|
276 |
specificitesTable.setSortDirection( |
|
277 |
SWT.DOWN); |
|
278 |
column_comparator = new ReverseComparator(column_comparator); |
|
279 |
} else { |
|
280 |
specificitesTable.setSortDirection(SWT.UP); |
|
281 |
} |
|
282 |
currentComparator = column_comparator; |
|
283 |
sort(); |
|
284 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
285 |
} |
|
286 |
|
|
287 |
@Override |
|
288 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
289 |
} |
|
290 |
}); |
|
291 |
|
|
292 |
// add a separator column |
|
293 |
TableColumn separatorColumn = new TableColumn(specificitesTable, SWT.NONE); |
|
294 |
separatorColumn.setResizable(false); |
|
295 |
specificitesTableColumn.add(separatorColumn); |
|
296 |
|
|
297 |
String[] partNames = null; |
|
298 |
int[] partSize = null; |
|
299 |
try { |
|
300 |
partNames = specificitiesResult.getPartShortNames(); |
|
301 |
partSize = specificitiesResult.getPartSizes(); |
|
302 |
} catch (StatException e) { |
|
303 |
System.err.println(NLS.bind(SpecificitiesUIMessages.SpecificitiesTableEditor_5, e)); |
|
304 |
Log.printStackTrace(e); |
|
305 |
return; |
|
306 |
} |
|
307 |
// System.out.println("partnames: "+Arrays.toString(partNames)); |
|
308 |
// for (int i = 0; i < |
|
309 |
// specificitesResult.getSpecificitesIndex()[0].length; i++) |
|
310 |
for (int i = 0; i < partNames.length ; i++) { // for each part |
|
311 |
final int columnIndex = i; |
|
312 |
|
|
313 |
//FREQ COLUMN |
|
314 |
final TableColumn freqpartTableColumn = new TableColumn( |
|
315 |
specificitesTable, SWT.NONE); |
|
316 |
freqpartTableColumn.setText(partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ |
|
317 |
freqpartTableColumn.setToolTipText(partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ |
|
318 |
// System.out.println("create column "+partNames[i]); |
|
319 |
freqpartTableColumn.setAlignment(SWT.RIGHT); |
|
320 |
freqpartTableColumn.pack(); |
|
321 |
freqpartTableColumn.addSelectionListener(new SelectionListener() { |
|
322 |
@Override |
|
323 |
public void widgetSelected(SelectionEvent e) { |
|
324 |
StatusLine.setMessage(RCPMessages.SORT_COLUMN); |
|
325 |
Comparator<Object> column_comparator = new Comparator<Object>() { |
|
326 |
@Override |
|
327 |
public int compare(Object o1, Object o2) { // Compare |
|
328 |
// two Integer |
|
329 |
Object[] line1 = (Object[]) o1; |
|
330 |
Object[] line2 = (Object[]) o2; |
|
331 |
return new Integer( |
|
332 |
((int[]) line1[2])[columnIndex]) |
|
333 |
.compareTo(new Integer( |
|
334 |
((int[]) line2[2])[columnIndex])); |
|
335 |
} |
|
336 |
}; |
|
337 |
|
|
338 |
if (specificitesTable.getSortColumn() != freqpartTableColumn) { |
|
339 |
specificitesTable.setSortColumn(freqpartTableColumn); |
|
340 |
specificitesTable.setSortDirection(SWT.DOWN); |
|
341 |
column_comparator = new ReverseComparator(column_comparator); |
|
342 |
} else if (specificitesTable.getSortDirection() == SWT.UP) { |
|
343 |
specificitesTable.setSortDirection(SWT.DOWN); |
|
344 |
column_comparator = new ReverseComparator(column_comparator); |
|
345 |
} else { |
|
346 |
specificitesTable.setSortDirection(SWT.UP); |
|
347 |
} |
|
348 |
currentComparator = column_comparator; |
|
349 |
sort(); |
|
350 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
351 |
} |
|
352 |
|
|
353 |
@Override |
|
354 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
355 |
} |
|
356 |
}); |
|
357 |
specificitesTableColumn.add(freqpartTableColumn); |
|
358 |
|
|
359 |
//SCORE COLUMN |
|
360 |
final TableColumn partTableColumn = new TableColumn( |
|
361 |
specificitesTable, SWT.NONE); |
|
362 |
partTableColumn.setText("score");//partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ |
|
363 |
partTableColumn.setToolTipText(partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ |
|
364 |
// System.out.println("create column "+partNames[i]); |
|
365 |
partTableColumn.setAlignment(SWT.RIGHT); |
|
366 |
partTableColumn.pack(); |
|
367 |
partTableColumn.addSelectionListener(new SelectionListener() { |
|
368 |
@Override |
|
369 |
public void widgetSelected(SelectionEvent e) { |
|
370 |
StatusLine.setMessage(RCPMessages.SORT_COLUMN); |
|
371 |
Comparator<Object> column_comparator = new Comparator<Object>() { |
|
372 |
@Override |
|
373 |
public int compare(Object o1, Object o2) { // Compare |
|
374 |
Object[] line1 = (Object[]) o1; |
|
375 |
Object[] line2 = (Object[]) o2; |
|
376 |
return new Double( |
|
377 |
((double[]) line1[3])[columnIndex]) |
|
378 |
.compareTo(new Double( |
|
379 |
((double[]) line2[3])[columnIndex])); |
|
380 |
} |
|
381 |
}; |
|
382 |
if (specificitesTable.getSortColumn() != partTableColumn) { |
|
383 |
specificitesTable.setSortColumn(partTableColumn); |
|
384 |
specificitesTable.setSortDirection(SWT.DOWN); |
|
385 |
column_comparator = new ReverseComparator(column_comparator); |
|
386 |
} else if (specificitesTable.getSortDirection() == SWT.UP) { |
|
387 |
specificitesTable.setSortDirection(SWT.DOWN); |
|
388 |
column_comparator = new ReverseComparator(column_comparator); |
|
389 |
} else { |
|
390 |
specificitesTable.setSortDirection( |
|
391 |
SWT.UP); |
|
392 |
} |
|
393 |
currentComparator = column_comparator; |
|
394 |
sort(); |
|
395 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
396 |
} |
|
397 |
|
|
398 |
@Override |
|
399 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
400 |
} |
|
401 |
}); |
|
402 |
|
|
403 |
specificitesTableColumn.add(partTableColumn); |
|
404 |
} |
|
405 |
|
|
406 |
specificitesTable.setHeaderVisible(true); |
|
407 |
|
|
408 |
// Horizontal bar on second table takes up a little extra space. |
|
409 |
// To keep vertical scroll bars in sink, force table1 to end above |
|
410 |
// horizontal scrollbar |
|
411 |
ScrollBar hBarRight = specificitesTable.getHorizontalBar(); |
|
412 |
Label spacer = new Label(parent, SWT.NONE); |
|
413 |
GridData spacerData = new GridData(); |
|
414 |
spacerData.heightHint = hBarRight.getSize().y; |
|
415 |
spacer.setLayoutData(spacerData); |
|
416 |
spacer.setVisible(false); |
|
417 |
|
|
418 |
// -------------------------------------- |
|
419 |
// make the contextual menu for displaying graphics. |
|
420 |
// -------------------------------------- |
|
421 |
|
|
422 |
// Menu menu = new Menu(specificitesTable); // old ways |
|
423 |
MenuManager menuManager = new MenuManager(); |
|
424 |
Menu menu = menuManager.createContextMenu(specificitesTable); |
|
425 |
specificitesTable.setMenu(menu); |
|
426 |
getSite().setSelectionProvider(viewer); |
|
427 |
getSite().registerContextMenu(menuManager, viewer); |
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
// and first sort |
|
432 |
specificitesTable.setSortColumn(typeNameColumn); |
|
433 |
specificitesTable.setSortDirection(SWT.UP); |
|
434 |
currentComparator = new Comparator() { |
|
435 |
@Override |
|
436 |
public int compare(Object o1, Object o2) { |
|
437 |
Object[] line1 = (Object[]) o1; |
|
438 |
Object[] line2 = (Object[]) o2; |
|
439 |
return collator.compare(line1[0], line2[0]); |
|
440 |
} |
|
441 |
}; |
|
442 |
|
|
443 |
// compute the specif scores |
|
444 |
computeResult(); |
|
445 |
|
|
446 |
} |
|
447 |
|
|
448 |
public Table getSpecificitesTable() { |
|
449 |
return specificitesTable; |
|
450 |
} |
|
451 |
|
|
452 |
/** |
|
453 |
* Fills display. |
|
454 |
*/ |
|
455 |
private void fillDisplay() { |
|
456 |
|
|
457 |
viewer.setInput(tableLines); |
|
458 |
|
|
459 |
// Pack the columns so the label of the sort column is not truncated due of the sorting order arrow display |
|
460 |
// Refresh and pack the columns |
|
461 |
viewer.getControl().setRedraw(false); |
|
462 |
viewer.refresh(); |
|
463 |
for (TableColumn col : viewer.getTable().getColumns()) { |
|
464 |
col.pack(); |
|
465 |
} |
|
466 |
viewer.getControl().setRedraw(true); |
|
467 |
} |
|
468 |
|
|
469 |
/* (non-Javadoc) |
|
470 |
* @see org.eclipse.ui.part.WorkbenchPart#setFocus() |
|
471 |
*/ |
|
472 |
@Override |
|
473 |
public void setFocus() { |
|
474 |
StatusLine.setMessage(SpecificitiesUIMessages.SpecificitiesTableEditor_17); |
|
475 |
specificitesTable.setFocus(); |
|
476 |
} |
|
477 |
|
|
478 |
/** |
|
479 |
* Instantiates a new specificities table editor. |
|
480 |
*/ |
|
481 |
public SpecificitiesTableEditor() { |
|
482 |
} |
|
483 |
|
|
484 |
/* (non-Javadoc) |
|
485 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
|
486 |
*/ |
|
487 |
@Override |
|
488 |
public void doSave(IProgressMonitor monitor) { |
|
489 |
} |
|
490 |
|
|
491 |
/* (non-Javadoc) |
|
492 |
* @see org.eclipse.ui.part.EditorPart#doSaveAs() |
|
493 |
*/ |
|
494 |
@Override |
|
495 |
public void doSaveAs() { |
|
496 |
} |
|
497 |
|
|
498 |
/* (non-Javadoc) |
|
499 |
* @see org.eclipse.ui.part.EditorPart#isDirty() |
|
500 |
*/ |
|
501 |
@Override |
|
502 |
public boolean isDirty() { |
|
503 |
return false; |
|
504 |
} |
|
505 |
|
|
506 |
/* (non-Javadoc) |
|
507 |
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() |
|
508 |
*/ |
|
509 |
@Override |
|
510 |
public boolean isSaveAsAllowed() { |
|
511 |
return false; |
|
512 |
} |
|
513 |
|
|
514 |
/** |
|
515 |
* Gets the specificities result. |
|
516 |
* |
|
517 |
* @return the specificities result |
|
518 |
*/ |
|
519 |
public Specificities getSpecificitiesResult() { |
|
520 |
return this.specificitiesResult; |
|
521 |
} |
|
522 |
|
|
523 |
public SpecificitiesTableLines getTableLines() { |
|
524 |
return tableLines; |
|
525 |
} |
|
526 |
|
|
527 |
@Override |
|
528 |
public boolean isResultUsingParent(TXMResult parent) { |
|
529 |
if (this.specificitiesResult == null) return false; |
|
530 |
if (this.specificitiesResult.getCorpus() == null) return false; |
|
531 |
return this.specificitiesResult.getCorpus().getName().equals(parent.getName()); |
|
532 |
} |
|
533 |
|
|
534 |
@Override |
|
535 |
public void computeResult() { |
|
536 |
JobHandler job = new JobHandler("Computing specificities...") { |
|
537 |
|
|
538 |
@Override |
|
539 |
protected IStatus run(IProgressMonitor monitor) { |
|
540 |
this.runInit(monitor); |
|
541 |
try { |
|
542 |
if (!specificitiesResult.compute(true, monitor)) { |
|
543 |
System.out.println("Error: Specificities not computed."); |
|
544 |
return Status.CANCEL_STATUS; |
|
545 |
} |
|
546 |
|
|
547 |
// units |
|
548 |
String[] typeNames = specificitiesResult.getTypeNames(); |
|
549 |
// units' total freq |
|
550 |
int[] typeFreq = specificitiesResult.getFormFrequencies(); |
|
551 |
// units' index fr each part |
|
552 |
double[][] specIndex = specificitiesResult.getSpecificitesIndex(); |
|
553 |
int[][] specFreqs = specificitiesResult.getFrequency(); |
|
554 |
|
|
555 |
// units' total in parts |
|
556 |
//final int[] sortedPartIndexes = specificitesResult.getSortedPartIndexes(); |
|
557 |
|
|
558 |
// Create an array of lines to fill the tables |
|
559 |
// System.out.println("len types: "+typeNames.length); |
|
560 |
// System.out.println("len freq: "+typeFreq.length); |
|
561 |
// System.out.println("len spec: "+specFreqs.length); |
|
562 |
// System.out.println("len specidx: "+specIndex.length); |
|
563 |
Object[] lines = new Object[typeNames.length]; |
|
564 |
for (int j = 0; j < lines.length; j++) |
|
565 |
lines[j] = new Object[] { typeNames[j], new Integer(typeFreq[j]), specFreqs[j], specIndex[j] }; |
|
566 |
|
|
567 |
// final SpecificitesTableLines |
|
568 |
tableLines = new SpecificitiesTableLines(lines); |
|
569 |
|
|
570 |
// set the TableViewer input |
|
571 |
viewer.setContentProvider(new IStructuredContentProvider() { |
|
572 |
@Override |
|
573 |
public Object[] getElements(Object inputElement) { |
|
574 |
return ((SpecificitiesTableLines) inputElement).getLines(); |
|
575 |
} |
|
576 |
|
|
577 |
@Override |
|
578 |
public void dispose() { } |
|
579 |
|
|
580 |
@Override |
|
581 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
|
582 |
} |
|
583 |
}); |
|
584 |
|
|
585 |
this.syncExec(new Runnable() { |
|
586 |
@Override |
|
587 |
public void run() { |
|
588 |
viewer.refresh(); |
|
589 |
SpecificitiesTableEditor.this.firePropertyChange(EditorPart.PROP_DIRTY); |
|
590 |
// Draw lines |
|
591 |
fillDisplay(); |
|
592 |
sort(); |
|
593 |
specificitesTable.setFocus(); |
|
594 |
} |
|
595 |
}); |
|
596 |
|
|
597 |
} catch (Exception e) { |
|
598 |
System.out.println("Error while computing specificities: "+e.getLocalizedMessage()); |
|
599 |
Log.printStackTrace(e); |
|
600 |
} |
|
601 |
return Status.OK_STATUS; |
|
602 |
} |
|
603 |
}; |
|
604 |
job.schedule(); |
|
605 |
} |
|
606 |
|
|
607 |
@Override |
|
608 |
protected void initializeFields() { |
|
609 |
// TODO Auto-generated method stub |
|
610 |
|
|
611 |
} |
|
612 |
} |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 536) | ||
---|---|---|
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.specificities.rcp.editors; |
|
29 |
|
|
30 |
import java.lang.reflect.InvocationTargetException; |
|
31 |
import java.text.Collator; |
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.Comparator; |
|
34 |
import java.util.List; |
|
35 |
import java.util.Locale; |
|
36 |
|
|
37 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
38 |
import org.eclipse.core.runtime.IStatus; |
|
39 |
import org.eclipse.core.runtime.Status; |
|
40 |
import org.eclipse.jface.action.MenuManager; |
|
41 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
|
42 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
|
43 |
import org.eclipse.jface.viewers.TableViewer; |
|
44 |
import org.eclipse.jface.viewers.Viewer; |
|
45 |
import org.eclipse.osgi.util.NLS; |
|
46 |
import org.eclipse.swt.SWT; |
|
47 |
import org.eclipse.swt.events.SelectionEvent; |
|
48 |
import org.eclipse.swt.events.SelectionListener; |
|
49 |
import org.eclipse.swt.layout.GridData; |
|
50 |
import org.eclipse.swt.layout.GridLayout; |
|
51 |
import org.eclipse.swt.widgets.Composite; |
|
52 |
import org.eclipse.swt.widgets.Label; |
|
53 |
import org.eclipse.swt.widgets.Menu; |
|
54 |
import org.eclipse.swt.widgets.ScrollBar; |
|
55 |
import org.eclipse.swt.widgets.Spinner; |
|
56 |
import org.eclipse.swt.widgets.Table; |
|
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.PlatformUI; |
|
62 |
import org.eclipse.ui.part.EditorPart; |
|
63 |
import org.txm.core.results.TXMResult; |
|
64 |
import org.txm.index.core.functions.Index; |
|
65 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
|
66 |
import org.txm.objects.TxmObject; |
|
67 |
import org.txm.rcp.RCPMessages; |
|
68 |
import org.txm.rcp.StatusLine; |
|
69 |
import org.txm.rcp.editors.TXMEditorPart; |
|
70 |
import org.txm.rcp.editors.TableKeyListener; |
|
71 |
import org.txm.rcp.utils.JobHandler; |
|
72 |
import org.txm.specificities.core.functions.Specificities; |
|
73 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences; |
|
74 |
import org.txm.specificities.rcp.messages.SpecificitiesUIMessages; |
|
75 |
import org.txm.statsengine.core.StatException; |
|
76 |
import org.txm.utils.logger.Log; |
|
77 |
/** |
|
78 |
* Display a table editor with specificites index. |
|
79 |
* |
|
80 |
* @author sloiseau, mdecorde, sjaquot |
|
81 |
* |
|
82 |
*/ |
|
83 |
public class SpecificitiesEditor extends TXMEditorPart { |
|
84 |
|
|
85 |
public static String ID = SpecificitiesEditor.class.getName(); |
|
86 |
|
|
87 |
/** The specificities table. */ |
|
88 |
private Table specificitesTable; |
|
89 |
private TableViewer viewer; |
|
90 |
|
|
91 |
/** Column for table typeNameTable. */ |
|
92 |
private TableColumn typeNameColumn; |
|
93 |
|
|
94 |
/** Column for table typeFrequencyColumn. */ |
|
95 |
private TableColumn typeFrequencyColumn; |
|
96 |
|
|
97 |
/** The current comparator: updated when user click on a column header */ |
|
98 |
protected Comparator currentComparator; |
|
99 |
|
|
100 |
/** All columns for the table specificitesTable. */ |
|
101 |
private List<TableColumn> specificitesTableColumn = new ArrayList<TableColumn>(); |
|
102 |
|
|
103 |
/** The result of specificities*/ |
|
104 |
private Specificities specificitiesResult; |
|
105 |
|
|
106 |
/** The table lines : table input */ |
|
107 |
private SpecificitiesTableLines tableLines; |
|
108 |
|
|
109 |
/** The source. */ |
|
110 |
private Object source; |
|
111 |
|
|
112 |
/* (non-Javadoc) |
|
113 |
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) |
|
114 |
*/ |
|
115 |
@Override |
|
116 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException { |
|
117 |
super.init(site, input); |
|
118 |
|
|
119 |
SpecificitiesResultEditorInput spinput = (SpecificitiesResultEditorInput) getEditorInput(); |
|
120 |
this.specificitiesResult = (Specificities) ((SpecificitiesResultEditorInput) getEditorInput()).getResult(); |
|
121 |
if (this.specificitiesResult.getLexicalTable()!= null && this.specificitiesResult.getLexicalTable().getPartition() != null) { |
|
122 |
setPartName(this.specificitiesResult.getLexicalTable().getPartition().getName()+": "+specificitiesResult.getName()); //$NON-NLS-1$ |
|
123 |
} else if (spinput.getSubcorpus() != null) { |
|
124 |
setPartName(spinput.getSubcorpus().getName()+": "+specificitiesResult.getName()); //$NON-NLS-1$ |
|
125 |
} else { |
|
126 |
setPartName(specificitiesResult.getName()); |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
/* (non-Javadoc) |
|
131 |
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
|
132 |
*/ |
|
133 |
@Override |
|
134 |
public void createPartControl(Composite parent) { |
|
135 |
super.createPartControl(parent); |
|
136 |
|
|
137 |
Composite parametersArea = getCommandParametersGroup(); |
|
138 |
|
|
139 |
new Label(parametersArea, SWT.NONE).setText("Maximum score"); |
|
140 |
|
|
141 |
Spinner maxScore = new Spinner(parametersArea, SWT.BORDER); |
|
142 |
maxScore.setToolTipText("The maximum score to show"); |
|
143 |
maxScore.setMinimum(0); |
|
144 |
maxScore.setSelection(SpecificitiesPreferences.getInt(SpecificitiesPreferences.MAX_SCORE, SpecificitiesPreferences.PREFERENCES_NODE)); |
|
145 |
|
|
146 |
Composite displayArea = getDisplayArea(); |
|
147 |
//displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
148 |
try { |
|
149 |
composeDisplayArea(displayArea); |
|
150 |
} catch (StatException e) { |
|
151 |
System.err.println(NLS.bind(SpecificitiesUIMessages.SpecificitiesTableEditor_0, e.getMessage())); |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
155 |
/** Sort. */ |
|
156 |
protected void sort() { |
|
157 |
if (currentComparator != null) { |
|
158 |
try { |
|
159 |
PlatformUI.getWorkbench().getProgressService().busyCursorWhile( |
|
160 |
new IRunnableWithProgress() { |
|
161 |
@Override |
|
162 |
public void run(IProgressMonitor monitor) |
|
163 |
throws InvocationTargetException, |
|
164 |
InterruptedException { |
|
165 |
tableLines.sort(currentComparator); |
|
166 |
} |
|
167 |
}); |
|
168 |
StatusLine.setMessage(RCPMessages.SORT_DONE); |
|
169 |
fillDisplay(); |
|
170 |
} catch (Exception e) { |
|
171 |
System.err.println(NLS.bind(SpecificitiesUIMessages.SpecificitiesTableEditor_1, e)); |
|
172 |
} |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* Compose display area. |
|
178 |
* |
|
179 |
* @param parent the parent |
|
180 |
* @throws StatException the stat exception |
|
181 |
*/ |
|
182 |
private void composeDisplayArea(final Composite parent) throws StatException { |
|
183 |
|
|
184 |
GridLayout layout = new GridLayout(2, false); |
|
185 |
layout.marginWidth = layout.marginHeight = layout.horizontalSpacing = 0; |
|
186 |
parent.setLayout(layout); |
|
187 |
|
|
188 |
// create table viewer |
|
189 |
viewer = new TableViewer(parent, SWT.VIRTUAL | SWT.MULTI | SWT.FULL_SELECTION); |
|
190 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
|
191 |
viewer.getTable().setLinesVisible(true); |
|
192 |
viewer.getTable().setHeaderVisible(true); |
|
193 |
viewer.setLabelProvider(new SpecificitiesTableLabelProvider()); |
|
194 |
|
|
195 |
specificitesTable = viewer.getTable(); |
|
196 |
GridData table2Data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2); |
|
197 |
specificitesTable.setLayoutData(table2Data); |
|
198 |
|
|
199 |
// create 1st column |
|
200 |
typeNameColumn = new TableColumn(specificitesTable, |
|
201 |
SWT.NONE); |
|
202 |
typeNameColumn.setText(RCPMessages.ReferencerEditor_9); |
|
203 |
typeNameColumn.setToolTipText(RCPMessages.ReferencerEditor_9); |
|
204 |
typeNameColumn.setAlignment(SWT.RIGHT); |
|
205 |
typeNameColumn.pack(); |
|
206 |
typeNameColumn.setWidth((int) (typeNameColumn.getWidth()*1.5)); |
|
207 |
|
|
208 |
Object oparent = specificitiesResult.getParent(); |
|
209 |
Locale locale = Locale.getDefault(); |
|
210 |
if (oparent instanceof TxmObject) { |
|
211 |
String lang = (String) ((TxmObject) oparent).getAttribute("lang"); //$NON-NLS-1$ |
|
212 |
if (lang != null) |
|
213 |
locale = new Locale(lang); |
|
214 |
} |
|
215 |
final Collator collator = Collator.getInstance(locale); |
|
216 |
collator.setStrength(Collator.TERTIARY); |
|
217 |
typeNameColumn.addSelectionListener(new SelectionListener() { |
|
218 |
@Override |
|
219 |
public void widgetSelected(SelectionEvent e) { |
|
220 |
StatusLine.setMessage(RCPMessages.SORT_COLUMN); |
|
221 |
Comparator column_comparator = new Comparator() { |
|
222 |
@Override |
|
223 |
public int compare(Object o1, Object o2) { |
|
224 |
Object[] line1 = (Object[]) o1; |
|
225 |
Object[] line2 = (Object[]) o2; |
|
226 |
return collator.compare(line1[0], line2[0]); |
|
227 |
} |
|
228 |
}; |
|
229 |
if (specificitesTable.getSortColumn() != typeNameColumn) { |
|
230 |
specificitesTable.setSortColumn( |
|
231 |
typeNameColumn); |
|
232 |
specificitesTable.setSortDirection(SWT.UP); |
|
233 |
} else if (specificitesTable |
|
234 |
.getSortDirection() == SWT.UP) { |
|
235 |
specificitesTable.setSortDirection( |
|
236 |
SWT.DOWN); |
|
237 |
column_comparator = new ReverseComparator(column_comparator); |
|
238 |
} else { |
|
239 |
specificitesTable.setSortDirection(SWT.UP); |
|
240 |
} |
|
241 |
currentComparator = column_comparator; |
|
242 |
sort(); |
|
243 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
244 |
} |
|
245 |
|
|
246 |
@Override |
|
247 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
248 |
} |
|
249 |
}); |
|
250 |
|
|
251 |
// create 2nd column |
|
252 |
typeFrequencyColumn = new TableColumn(viewer |
|
253 |
.getTable(), SWT.NONE); |
|
254 |
typeFrequencyColumn.setText(RCPMessages.FrequencyListEditorInput_4 |
|
255 |
+ " "+SpecificitiesUIMessages.SpecificitiesTableEditor_11+" " |
|
256 |
+ specificitiesResult.getCorpusSize()); |
|
257 |
typeFrequencyColumn.setToolTipText(RCPMessages.FrequencyListEditorInput_4 |
|
258 |
+ SpecificitiesUIMessages.SpecificitiesTableEditor_11 |
|
259 |
+ specificitiesResult.getCorpusSize()); |
|
260 |
typeFrequencyColumn.setAlignment(SWT.RIGHT); |
|
261 |
typeFrequencyColumn.pack(); |
|
262 |
typeFrequencyColumn.addSelectionListener(new SelectionListener() { |
|
263 |
@Override |
|
264 |
public void widgetSelected(SelectionEvent e) { |
|
265 |
StatusLine.setMessage(RCPMessages.SORT_COLUMN); |
|
266 |
Comparator<Object[]> column_comparator = new Comparator<Object[]>() { |
|
267 |
@Override |
|
268 |
public int compare(Object[] line1, Object[] line2) { // Compare two |
|
269 |
return ((Integer) line1[1]).compareTo(((Integer) line2[1])); |
|
270 |
} |
|
271 |
}; |
|
272 |
if (specificitesTable.getSortColumn() != typeFrequencyColumn) { |
|
273 |
specificitesTable.setSortColumn( |
|
274 |
typeFrequencyColumn); |
|
275 |
specificitesTable.setSortDirection(SWT.UP); |
|
276 |
} else if (specificitesTable |
|
277 |
.getSortDirection() == SWT.UP) { |
|
278 |
specificitesTable.setSortDirection( |
|
279 |
SWT.DOWN); |
|
280 |
column_comparator = new ReverseComparator(column_comparator); |
|
281 |
} else { |
|
282 |
specificitesTable.setSortDirection(SWT.UP); |
|
283 |
} |
|
284 |
currentComparator = column_comparator; |
|
285 |
sort(); |
|
286 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
287 |
} |
|
288 |
|
|
289 |
@Override |
|
290 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
291 |
} |
|
292 |
}); |
|
293 |
|
|
294 |
// add a separator column |
|
295 |
TableColumn separatorColumn = new TableColumn(specificitesTable, SWT.NONE); |
|
296 |
separatorColumn.setResizable(false); |
|
297 |
specificitesTableColumn.add(separatorColumn); |
|
298 |
|
|
299 |
String[] partNames = null; |
|
300 |
int[] partSize = null; |
|
301 |
try { |
|
302 |
partNames = specificitiesResult.getPartShortNames(); |
|
303 |
partSize = specificitiesResult.getPartSizes(); |
|
304 |
} catch (StatException e) { |
|
305 |
System.err.println(NLS.bind(SpecificitiesUIMessages.SpecificitiesTableEditor_5, e)); |
|
306 |
Log.printStackTrace(e); |
|
307 |
return; |
|
308 |
} |
|
309 |
// System.out.println("partnames: "+Arrays.toString(partNames)); |
|
310 |
// for (int i = 0; i < |
|
311 |
// specificitesResult.getSpecificitesIndex()[0].length; i++) |
|
312 |
for (int i = 0; i < partNames.length ; i++) { // for each part |
|
313 |
final int columnIndex = i; |
|
314 |
|
|
315 |
//FREQ COLUMN |
|
316 |
final TableColumn freqpartTableColumn = new TableColumn( |
|
317 |
specificitesTable, SWT.NONE); |
|
318 |
freqpartTableColumn.setText(partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ |
|
319 |
freqpartTableColumn.setToolTipText(partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ |
|
320 |
// System.out.println("create column "+partNames[i]); |
|
321 |
freqpartTableColumn.setAlignment(SWT.RIGHT); |
|
322 |
freqpartTableColumn.pack(); |
|
323 |
freqpartTableColumn.addSelectionListener(new SelectionListener() { |
|
324 |
@Override |
|
325 |
public void widgetSelected(SelectionEvent e) { |
|
326 |
StatusLine.setMessage(RCPMessages.SORT_COLUMN); |
|
327 |
Comparator<Object> column_comparator = new Comparator<Object>() { |
|
328 |
@Override |
|
329 |
public int compare(Object o1, Object o2) { // Compare |
|
330 |
// two Integer |
|
331 |
Object[] line1 = (Object[]) o1; |
|
332 |
Object[] line2 = (Object[]) o2; |
|
333 |
return new Integer( |
|
334 |
((int[]) line1[2])[columnIndex]) |
|
335 |
.compareTo(new Integer( |
|
336 |
((int[]) line2[2])[columnIndex])); |
|
337 |
} |
|
338 |
}; |
|
339 |
|
|
340 |
if (specificitesTable.getSortColumn() != freqpartTableColumn) { |
|
341 |
specificitesTable.setSortColumn(freqpartTableColumn); |
|
342 |
specificitesTable.setSortDirection(SWT.DOWN); |
|
343 |
column_comparator = new ReverseComparator(column_comparator); |
|
344 |
} else if (specificitesTable.getSortDirection() == SWT.UP) { |
|
345 |
specificitesTable.setSortDirection(SWT.DOWN); |
|
346 |
column_comparator = new ReverseComparator(column_comparator); |
|
347 |
} else { |
|
348 |
specificitesTable.setSortDirection(SWT.UP); |
|
349 |
} |
|
350 |
currentComparator = column_comparator; |
|
351 |
sort(); |
|
352 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
353 |
} |
|
354 |
|
|
355 |
@Override |
|
356 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
357 |
} |
|
358 |
}); |
|
359 |
specificitesTableColumn.add(freqpartTableColumn); |
|
360 |
|
|
361 |
//SCORE COLUMN |
|
362 |
final TableColumn partTableColumn = new TableColumn( |
|
363 |
specificitesTable, SWT.NONE); |
|
364 |
partTableColumn.setText("score");//partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ |
|
365 |
partTableColumn.setToolTipText(partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ |
|
366 |
// System.out.println("create column "+partNames[i]); |
|
367 |
partTableColumn.setAlignment(SWT.RIGHT); |
|
368 |
partTableColumn.pack(); |
|
369 |
partTableColumn.addSelectionListener(new SelectionListener() { |
|
370 |
@Override |
|
371 |
public void widgetSelected(SelectionEvent e) { |
|
372 |
StatusLine.setMessage(RCPMessages.SORT_COLUMN); |
|
373 |
Comparator<Object> column_comparator = new Comparator<Object>() { |
|
374 |
@Override |
|
375 |
public int compare(Object o1, Object o2) { // Compare |
|
376 |
Object[] line1 = (Object[]) o1; |
|
377 |
Object[] line2 = (Object[]) o2; |
|
378 |
return new Double( |
|
379 |
((double[]) line1[3])[columnIndex]) |
|
380 |
.compareTo(new Double( |
|
381 |
((double[]) line2[3])[columnIndex])); |
|
382 |
} |
|
383 |
}; |
|
384 |
if (specificitesTable.getSortColumn() != partTableColumn) { |
|
385 |
specificitesTable.setSortColumn(partTableColumn); |
|
386 |
specificitesTable.setSortDirection(SWT.DOWN); |
|
387 |
column_comparator = new ReverseComparator(column_comparator); |
|
388 |
} else if (specificitesTable.getSortDirection() == SWT.UP) { |
|
389 |
specificitesTable.setSortDirection(SWT.DOWN); |
|
390 |
column_comparator = new ReverseComparator(column_comparator); |
|
391 |
} else { |
|
392 |
specificitesTable.setSortDirection( |
|
393 |
SWT.UP); |
|
394 |
} |
|
395 |
currentComparator = column_comparator; |
|
396 |
sort(); |
|
397 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
398 |
} |
|
399 |
|
|
400 |
@Override |
|
401 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
402 |
} |
|
403 |
}); |
|
404 |
|
|
405 |
specificitesTableColumn.add(partTableColumn); |
|
406 |
} |
|
407 |
|
|
408 |
specificitesTable.setHeaderVisible(true); |
|
409 |
|
|
410 |
// Horizontal bar on second table takes up a little extra space. |
|
411 |
// To keep vertical scroll bars in sink, force table1 to end above |
|
412 |
// horizontal scrollbar |
|
413 |
ScrollBar hBarRight = specificitesTable.getHorizontalBar(); |
|
414 |
Label spacer = new Label(parent, SWT.NONE); |
|
415 |
GridData spacerData = new GridData(); |
|
416 |
spacerData.heightHint = hBarRight.getSize().y; |
|
417 |
spacer.setLayoutData(spacerData); |
|
418 |
spacer.setVisible(false); |
|
419 |
|
|
420 |
// -------------------------------------- |
|
421 |
// make the contextual menu for displaying graphics. |
|
422 |
// -------------------------------------- |
|
423 |
|
|
424 |
// Menu menu = new Menu(specificitesTable); // old ways |
|
425 |
MenuManager menuManager = new MenuManager(); |
|
426 |
Menu menu = menuManager.createContextMenu(specificitesTable); |
|
427 |
specificitesTable.setMenu(menu); |
|
428 |
getSite().setSelectionProvider(viewer); |
|
429 |
getSite().registerContextMenu(menuManager, viewer); |
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
// and first sort |
|
434 |
specificitesTable.setSortColumn(typeNameColumn); |
|
435 |
specificitesTable.setSortDirection(SWT.UP); |
|
436 |
currentComparator = new Comparator() { |
|
437 |
@Override |
|
438 |
public int compare(Object o1, Object o2) { |
|
439 |
Object[] line1 = (Object[]) o1; |
|
440 |
Object[] line2 = (Object[]) o2; |
|
441 |
return collator.compare(line1[0], line2[0]); |
|
442 |
} |
|
443 |
}; |
|
444 |
|
|
445 |
// compute the specif scores |
|
446 |
computeResult(); |
|
447 |
|
|
448 |
} |
|
449 |
|
|
450 |
public Table getSpecificitesTable() { |
|
451 |
return specificitesTable; |
|
452 |
} |
|
453 |
|
|
454 |
/** |
|
455 |
* Fills display. |
|
456 |
*/ |
|
457 |
private void fillDisplay() { |
|
458 |
|
|
459 |
viewer.setInput(tableLines); |
|
460 |
|
|
461 |
// Pack the columns so the label of the sort column is not truncated due of the sorting order arrow display |
|
462 |
// Refresh and pack the columns |
|
463 |
viewer.getControl().setRedraw(false); |
|
464 |
viewer.refresh(); |
|
465 |
for (TableColumn col : viewer.getTable().getColumns()) { |
|
466 |
col.pack(); |
|
467 |
} |
|
468 |
viewer.getControl().setRedraw(true); |
|
469 |
} |
|
470 |
|
|
471 |
/* (non-Javadoc) |
|
472 |
* @see org.eclipse.ui.part.WorkbenchPart#setFocus() |
|
473 |
*/ |
|
474 |
@Override |
|
475 |
public void setFocus() { |
|
476 |
StatusLine.setMessage(SpecificitiesUIMessages.SpecificitiesTableEditor_17); |
|
477 |
specificitesTable.setFocus(); |
|
478 |
} |
|
479 |
|
|
480 |
/** |
|
481 |
* Instantiates a new specificities table editor. |
|
482 |
*/ |
|
483 |
public SpecificitiesEditor() { |
|
484 |
} |
|
485 |
|
|
486 |
/* (non-Javadoc) |
|
487 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
|
488 |
*/ |
|
489 |
@Override |
|
490 |
public void doSave(IProgressMonitor monitor) { |
|
491 |
} |
|
492 |
|
|
493 |
/* (non-Javadoc) |
|
494 |
* @see org.eclipse.ui.part.EditorPart#doSaveAs() |
|
495 |
*/ |
|
496 |
@Override |
|
497 |
public void doSaveAs() { |
|
498 |
} |
|
499 |
|
|
500 |
/* (non-Javadoc) |
|
501 |
* @see org.eclipse.ui.part.EditorPart#isDirty() |
|
502 |
*/ |
|
503 |
@Override |
|
504 |
public boolean isDirty() { |
|
505 |
return false; |
|
506 |
} |
|
507 |
|
|
508 |
/* (non-Javadoc) |
|
509 |
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() |
|
510 |
*/ |
|
511 |
@Override |
|
512 |
public boolean isSaveAsAllowed() { |
|
513 |
return false; |
|
514 |
} |
|
515 |
|
|
516 |
/** |
|
517 |
* Gets the specificities result. |
|
518 |
* |
|
519 |
* @return the specificities result |
|
520 |
*/ |
|
521 |
public Specificities getSpecificitiesResult() { |
|
522 |
return this.specificitiesResult; |
|
523 |
} |
|
524 |
|
|
525 |
public SpecificitiesTableLines getTableLines() { |
|
526 |
return tableLines; |
|
527 |
} |
|
528 |
|
|
529 |
@Override |
|
530 |
public boolean isResultUsingParent(TXMResult parent) { |
|
531 |
if (this.specificitiesResult == null) return false; |
|
532 |
if (this.specificitiesResult.getCorpus() == null) return false; |
|
533 |
return this.specificitiesResult.getCorpus().getName().equals(parent.getName()); |
|
534 |
} |
|
535 |
|
|
536 |
@Override |
|
537 |
public void computeResult() { |
|
538 |
JobHandler job = new JobHandler("Computing specificities...") { |
|
539 |
|
|
540 |
@Override |
|
541 |
protected IStatus run(IProgressMonitor monitor) { |
|
542 |
this.runInit(monitor); |
|
543 |
try { |
|
544 |
if (!specificitiesResult.compute(true, monitor)) { |
|
545 |
System.out.println("Error: Specificities not computed."); |
|
546 |
return Status.CANCEL_STATUS; |
|
547 |
} |
|
548 |
|
|
549 |
// units |
|
550 |
String[] typeNames = specificitiesResult.getTypeNames(); |
|
551 |
// units' total freq |
|
552 |
int[] typeFreq = specificitiesResult.getFormFrequencies(); |
|
553 |
// units' index fr each part |
|
554 |
double[][] specIndex = specificitiesResult.getSpecificitesIndex(); |
|
555 |
int[][] specFreqs = specificitiesResult.getFrequency(); |
|
556 |
|
|
557 |
// units' total in parts |
|
558 |
//final int[] sortedPartIndexes = specificitesResult.getSortedPartIndexes(); |
|
559 |
|
|
560 |
// Create an array of lines to fill the tables |
|
561 |
// System.out.println("len types: "+typeNames.length); |
|
562 |
// System.out.println("len freq: "+typeFreq.length); |
|
563 |
// System.out.println("len spec: "+specFreqs.length); |
|
564 |
// System.out.println("len specidx: "+specIndex.length); |
|
565 |
Object[] lines = new Object[typeNames.length]; |
|
566 |
for (int j = 0; j < lines.length; j++) |
|
567 |
lines[j] = new Object[] { typeNames[j], new Integer(typeFreq[j]), specFreqs[j], specIndex[j] }; |
|
568 |
|
|
569 |
// final SpecificitesTableLines |
|
570 |
tableLines = new SpecificitiesTableLines(lines); |
|
571 |
|
|
572 |
// set the TableViewer input |
|
573 |
viewer.setContentProvider(new IStructuredContentProvider() { |
|
574 |
@Override |
|
575 |
public Object[] getElements(Object inputElement) { |
|
576 |
return ((SpecificitiesTableLines) inputElement).getLines(); |
|
577 |
} |
|
578 |
|
|
579 |
@Override |
|
580 |
public void dispose() { } |
|
581 |
|
|
582 |
@Override |
|
583 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
|
584 |
} |
|
585 |
}); |
|
586 |
|
|
587 |
this.syncExec(new Runnable() { |
|
588 |
@Override |
|
589 |
public void run() { |
|
590 |
viewer.refresh(); |
|
591 |
SpecificitiesEditor.this.firePropertyChange(EditorPart.PROP_DIRTY); |
|
592 |
// Draw lines |
|
593 |
fillDisplay(); |
|
594 |
sort(); |
|
595 |
specificitesTable.setFocus(); |
|
596 |
} |
|
597 |
}); |
|
598 |
|
|
599 |
} catch (Exception e) { |
|
600 |
System.out.println("Error while computing specificities: "+e.getLocalizedMessage()); |
|
601 |
Log.printStackTrace(e); |
|
602 |
} |
|
603 |
return Status.OK_STATUS; |
|
604 |
} |
|
605 |
}; |
|
606 |
job.schedule(); |
|
607 |
} |
|
608 |
|
|
609 |
@Override |
|
610 |
protected void initializeFields() { |
|
611 |
// TODO Auto-generated method stub |
|
612 |
|
|
613 |
} |
|
614 |
} |
|
0 | 615 |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/handlers/ComputeSpecifictiesBarChart.java (revision 536) | ||
---|---|---|
19 | 19 |
import org.txm.rcp.IImageKeys; |
20 | 20 |
import org.txm.specificities.core.functions.Specificities; |
21 | 21 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences; |
22 |
import org.txm.specificities.rcp.editors.SpecificitiesTableEditor;
|
|
22 |
import org.txm.specificities.rcp.editors.SpecificitiesEditor; |
|
23 | 23 |
import org.txm.specificities.rcp.editors.SpecificitiesTableLines; |
24 | 24 |
import org.txm.specificities.rcp.messages.SpecificitiesUIMessages; |
25 | 25 |
|
... | ... | |
35 | 35 |
IWorkbenchWindow iww = HandlerUtil.getActiveWorkbenchWindow(event); |
36 | 36 |
IWorkbenchPage iwp = iww.getActivePage(); |
37 | 37 |
IEditorPart ieditor = iwp.getActiveEditor(); |
38 |
if (!(ieditor instanceof SpecificitiesTableEditor)) {
|
|
38 |
if (!(ieditor instanceof SpecificitiesEditor)) { |
|
39 | 39 |
System.out.println("Editor is not SpecificitiesTableEditor: " + ieditor.getClass()); |
40 | 40 |
return null; |
41 | 41 |
} |
42 | 42 |
|
43 |
SpecificitiesTableEditor editor = (SpecificitiesTableEditor)ieditor;
|
|
43 |
SpecificitiesEditor editor = (SpecificitiesEditor)ieditor;
|
|
44 | 44 |
Specificities specificitiesResult = editor.getSpecificitiesResult(); |
45 | 45 |
Table specificitesTable = editor.getSpecificitesTable(); |
46 | 46 |
SpecificitiesTableLines tableLines = editor.getTableLines(); |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/handlers/ComputeSpecifities.java (revision 536) | ||
---|---|---|
63 | 63 |
import org.txm.specificities.rcp.dialogs.ComputeSpecificitiesDialog; |
64 | 64 |
import org.txm.specificities.rcp.dialogs.ComputeSpecificitiesForSubcorpusDialog; |
65 | 65 |
import org.txm.specificities.rcp.editors.SpecificitiesResultEditorInput; |
66 |
import org.txm.specificities.rcp.editors.SpecificitiesTableEditor;
|
|
66 |
import org.txm.specificities.rcp.editors.SpecificitiesEditor; |
|
67 | 67 |
import org.txm.statsengine.core.StatException; |
68 | 68 |
import org.txm.statsengine.r.rcp.views.RVariablesView; |
69 | 69 |
import org.txm.utils.logger.Log; |
... | ... | |
210 | 210 |
|
211 | 211 |
editorInput = new SpecificitiesResultEditorInput(specifResFinal); |
212 | 212 |
|
213 |
TXMEditorPart.openEditor(editorInput, SpecificitiesTableEditor.ID);
|
|
213 |
TXMEditorPart.openEditor(editorInput, SpecificitiesEditor.ID); |
|
214 | 214 |
} |
215 | 215 |
}); |
216 | 216 |
|
tmp/org.txm.searchengine.cqp.rcp/META-INF/MANIFEST.MF (revision 536) | ||
---|---|---|
13 | 13 |
org.eclipse.ui |
14 | 14 |
Export-Package: org.txm.rcp.commands.base, |
15 | 15 |
org.txm.searchengine.cqp.rcp, |
16 |
org.txm.searchengine.cqp.rcp.editor, |
|
16 | 17 |
org.txm.searchengine.cqp.rcp.preferences |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/DiagnosticPreferencePage.java (revision 536) | ||
---|---|---|
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.searchengine.cqp.rcp.preferences; |
|
29 |
|
|
30 |
import org.eclipse.jface.preference.IntegerFieldEditor; |
|
31 |
import org.eclipse.ui.IWorkbench; |
|
32 |
import org.eclipse.ui.preferences.ScopedPreferenceStore; |
|
33 |
import org.txm.rcp.Application; |
|
34 |
import org.txm.rcp.RCPMessages; |
|
35 |
import org.txm.rcp.preferences.TXMPreferencePage; |
|
36 |
import org.txm.rcp.preferences.TXMPreferenceStore; |
|
37 |
import org.txm.searchengine.cqp.CQPPreferences; |
|
38 |
// TODO: Auto-generated Javadoc |
|
39 |
/** |
|
40 |
* This class represents a preference page that is contributed to the |
|
41 |
* Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we |
|
42 |
* can use the field support built into JFace that allows us to create a page |
|
43 |
* that is small and knows how to save, restore and apply itself. |
|
44 |
* <p> |
|
45 |
* This page is used to modify preferences only. They are stored in the |
|
46 |
* preference store that belongs to the main plug-in class. That way, |
|
47 |
* preferences can be accessed directly via the preference store. |
|
48 |
*/ |
|
49 |
|
|
50 |
public class DiagnosticPreferencePage extends TXMPreferencePage { |
|
51 |
|
|
52 |
/** The diag_maxvalue. */ |
|
53 |
private IntegerFieldEditor diag_maxvalue; |
|
54 |
|
|
55 |
@Override |
|
56 |
public void init(IWorkbench workbench) { |
|
57 |
this.setPreferenceStore(new TXMPreferenceStore(CQPPreferences.PREFERENCES_NODE)); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Instantiates a new diagnostic preference page. |
|
62 |
*/ |
|
63 |
public DiagnosticPreferencePage() { |
|
64 |
super(); |
|
65 |
setTitle(RCPMessages.DiagnosticPreferencePage_1); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Creates the field editors. Field editors are abstractions of the common |
|
70 |
* GUI blocks needed to manipulate various types of preferences. Each field |
|
71 |
* editor knows how to save and restore itself. |
|
72 |
*/ |
|
73 |
@Override |
|
74 |
public void createFieldEditors() { |
|
75 |
|
|
76 |
diag_maxvalue = new IntegerFieldEditor(CQPPreferences.MAXVALUE, RCPMessages.DiagnosticPreferencePage_2, getFieldEditorParent()); |
|
77 |
diag_maxvalue.setValidRange(1, 9999); |
|
78 |
addField(diag_maxvalue); |
|
79 |
} |
|
80 |
} |
|
0 | 81 |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/DiagnosticEditor.java (revision 536) | ||
---|---|---|
1 |
package org.txm.searchengine.cqp.rcp.editor; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.eclipse.swt.SWT; |
|
6 |
import org.eclipse.swt.browser.Browser; |
|
7 |
import org.eclipse.swt.layout.GridData; |
|
8 |
import org.eclipse.swt.layout.GridLayout; |
|
9 |
import org.eclipse.swt.layout.RowData; |
|
10 |
import org.eclipse.swt.widgets.Composite; |
|
11 |
import org.eclipse.swt.widgets.Label; |
|
12 |
import org.eclipse.swt.widgets.Spinner; |
|
13 |
import org.eclipse.ui.IEditorInput; |
|
14 |
import org.eclipse.ui.IEditorSite; |
|
15 |
import org.eclipse.ui.PartInitException; |
|
16 |
import org.txm.core.results.TXMParameters; |
|
17 |
import org.txm.functions.diagnostic.Diagnostic; |
|
18 |
import org.txm.rcp.editors.TXMEditorPart; |
|
19 |
import org.txm.rcp.preferences.RCPPreferences; |
|
20 |
import org.txm.searchengine.cqp.CQPPreferences; |
|
21 |
|
|
22 |
public class DiagnosticEditor extends TXMEditorPart { |
|
23 |
|
|
24 |
private Spinner maxScore; |
|
25 |
private Browser browser; |
|
26 |
protected Diagnostic diag; |
|
27 |
|
|
28 |
@Override |
|
29 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException { |
|
30 |
super.init(site, input); |
|
31 |
if (getResultData() instanceof Diagnostic) |
|
32 |
this.diag = (Diagnostic) getResultData(); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
protected void initializeFields() { |
|
37 |
// TODO Auto-generated method stub |
|
38 |
|
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public void createPartControl(Composite parent) { |
|
43 |
super.createPartControl(parent); |
|
44 |
|
|
45 |
Composite parametersArea = getCommandParametersGroup(); |
|
46 |
|
|
47 |
new Label(parametersArea, SWT.NONE).setText("V max"); |
|
48 |
|
|
49 |
maxScore = new Spinner(parametersArea, SWT.BORDER); |
|
50 |
maxScore.setToolTipText("The maximum number of word property values to show"); |
|
51 |
maxScore.setMinimum(0); |
Formats disponibles : Unified diff