Révision 3985
TXM/trunk/bundles/org.txm.texts.rcp/src/org/txm/texts/rcp/TextViewColumnLabelProvider.java (revision 3985) | ||
---|---|---|
21 | 21 |
public String getText(Object element) { |
22 | 22 |
|
23 | 23 |
Text text = (Text)element; |
24 |
return editor.getResult().getLines().get(text.getName()).get(n); |
|
24 |
return editor.getResult() |
|
25 |
.getLines() |
|
26 |
.get(text.getName()) |
|
27 |
.get(n); |
|
25 | 28 |
} |
26 | 29 |
} |
TXM/trunk/bundles/org.txm.texts.rcp/src/org/txm/texts/rcp/TextsViewEditor.java (revision 3985) | ||
---|---|---|
16 | 16 |
import org.eclipse.jface.viewers.TableViewerColumn; |
17 | 17 |
import org.eclipse.jface.viewers.Viewer; |
18 | 18 |
import org.eclipse.swt.SWT; |
19 |
import org.eclipse.swt.events.KeyEvent; |
|
20 |
import org.eclipse.swt.events.KeyListener; |
|
21 |
import org.eclipse.swt.events.SelectionEvent; |
|
22 |
import org.eclipse.swt.events.SelectionListener; |
|
19 | 23 |
import org.eclipse.swt.graphics.Image; |
20 | 24 |
import org.eclipse.swt.graphics.Point; |
21 | 25 |
import org.eclipse.swt.layout.GridData; |
22 | 26 |
import org.eclipse.swt.layout.GridLayout; |
27 |
import org.eclipse.swt.widgets.Button; |
|
23 | 28 |
import org.eclipse.swt.widgets.TableColumn; |
24 | 29 |
import org.txm.Toolbox; |
25 | 30 |
import org.txm.core.results.Parameter; |
... | ... | |
35 | 40 |
import org.txm.rcp.swt.HashMapWidget; |
36 | 41 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
37 | 42 |
import org.txm.rcp.utils.SWTEditorsUtils; |
43 |
import org.txm.rcp.views.corpora.CorporaView; |
|
44 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
45 |
import org.txm.searchengine.cqp.corpus.Partition; |
|
46 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
|
38 | 47 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
48 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
49 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
|
50 |
import org.txm.searchengine.cqp.corpus.query.SubcorpusCQLQuery; |
|
39 | 51 |
import org.txm.texts.core.TextsView; |
40 | 52 |
|
41 | 53 |
public class TextsViewEditor extends TXMEditor<TextsView> { |
... | ... | |
72 | 84 |
propertiesSelector = new PropertiesSelector<>(this.getMainParametersComposite(), "Metadata"); |
73 | 85 |
propertiesSelector.setProperties(properties); |
74 | 86 |
propertiesSelector.addSelectionListener(computeSelectionListener); |
87 |
propertiesSelector.setShowSimpleNames(); |
|
88 |
|
|
89 |
Button deleteButton = new Button(this.getMainParametersComposite(), SWT.PUSH); |
|
90 |
deleteButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE)); |
|
91 |
deleteButton.setToolTipText("Remove selected texts from the view"); |
|
92 |
deleteButton.addSelectionListener(new SelectionListener() { |
|
93 |
|
|
94 |
@Override |
|
95 |
public void widgetSelected(SelectionEvent e) { |
|
75 | 96 |
|
97 |
deleteSelection(); |
|
98 |
|
|
99 |
} |
|
100 |
|
|
101 |
@Override |
|
102 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
103 |
}); |
|
104 |
|
|
105 |
|
|
76 | 106 |
negativeFiltersText = new HashMapWidget(this.getMainParametersComposite(), SWT.NONE, "Negative filters: "); |
77 | 107 |
//negativeFiltersText.addSelectionListener(computeSelectionListener); |
78 | 108 |
GridData gdata = new GridData(GridData.FILL, GridData.FILL, false, false); |
... | ... | |
83 | 113 |
} |
84 | 114 |
negativeFiltersText.setDefaultValues(defaultValues); |
85 | 115 |
|
116 |
Button subcorpusButton = new Button(this.getMainParametersComposite(), SWT.PUSH); |
|
117 |
subcorpusButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_SUBCORPUS)); |
|
118 |
subcorpusButton.setToolTipText("Create a subcorpus of the shown texts"); |
|
119 |
subcorpusButton.addSelectionListener(new SelectionListener() { |
|
120 |
|
|
121 |
@Override |
|
122 |
public void widgetSelected(SelectionEvent e) { |
|
123 |
|
|
124 |
try { |
|
125 |
Subcorpus subcorpus = new Subcorpus(getResult().getCorpus()); |
|
126 |
subcorpus.setName("subcorpus"); |
|
127 |
|
|
128 |
ArrayList<String> selectedValues = null; |
|
129 |
if (viewer.getSelection().isEmpty()) { |
|
130 |
selectedValues = new ArrayList<String>(getResult().getLines().keySet()); |
|
131 |
} else { |
|
132 |
selectedValues = new ArrayList<String>(); |
|
133 |
for (Object o : viewer.getStructuredSelection().toList()) { |
|
134 |
Text l = (Text) o; |
|
135 |
selectedValues.add(l.getName()); |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
String regexp = ""; //$NON-NLS-1$ |
|
140 |
for (String v : selectedValues) { |
|
141 |
regexp += CQLQuery.addBackSlash(v) + "|"; //$NON-NLS-1$ |
|
142 |
} |
|
143 |
regexp = regexp.substring(0, regexp.length() - 1); |
|
144 |
|
|
145 |
StructuralUnit su = getResult().getCorpus().getStructuralUnit("text"); |
|
146 |
|
|
147 |
StructuralUnitProperty sup = su.getProperty("id"); |
|
148 |
SubcorpusCQLQuery query = new SubcorpusCQLQuery(su, sup, regexp, selectedValues); |
|
149 |
|
|
150 |
subcorpus.setQuery(query); |
|
151 |
|
|
152 |
subcorpus.compute(); |
|
153 |
|
|
154 |
CorporaView.refreshObject(subcorpus); |
|
155 |
} |
|
156 |
catch (Exception e1) { |
|
157 |
// TODO Auto-generated catch block |
|
158 |
e1.printStackTrace(); |
|
159 |
} |
|
160 |
|
|
161 |
} |
|
162 |
|
|
163 |
@Override |
|
164 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
165 |
}); |
|
166 |
|
|
167 |
Button partitionButton = new Button(this.getMainParametersComposite(), SWT.PUSH); |
|
168 |
partitionButton.setImage(IImageKeys.getImage("platform:/plugin/org.txm.searchengine.cqp.rcp/icons/functions/partition.png")); |
|
169 |
partitionButton.setToolTipText("Create a partition of the shown texts"); |
|
170 |
partitionButton.addSelectionListener(new SelectionListener() { |
|
171 |
|
|
172 |
@Override |
|
173 |
public void widgetSelected(SelectionEvent e) { |
|
174 |
try { |
|
175 |
Partition partition = new Partition(getResult().getCorpus()); |
|
176 |
|
|
177 |
StructuralUnit su = getResult().getCorpus().getStructuralUnit("text"); |
|
178 |
StructuralUnitProperty sup = su.getProperty("id"); |
|
179 |
|
|
180 |
ArrayList<String> selectedValues = null; |
|
181 |
if (viewer.getSelection().isEmpty()) { |
|
182 |
selectedValues = new ArrayList<String>(getResult().getLines().keySet()); |
|
183 |
} else { |
|
184 |
selectedValues = new ArrayList<String>(); |
|
185 |
for (Object o : viewer.getStructuredSelection().toList()) { |
|
186 |
Text l = (Text) o; |
|
187 |
selectedValues.add(l.getName()); |
|
188 |
} |
|
189 |
} |
|
190 |
partition.setParameters("text@id", sup, selectedValues); |
|
191 |
|
|
192 |
partition.compute(); |
|
193 |
CorporaView.refreshObject(partition); |
|
194 |
} |
|
195 |
catch (Exception e1) { |
|
196 |
// TODO Auto-generated catch block |
|
197 |
e1.printStackTrace(); |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
201 |
@Override |
|
202 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
203 |
}); |
|
204 |
|
|
86 | 205 |
viewer = new TableViewer(this.getResultArea(), SWT.MULTI|SWT.VIRTUAL); |
87 | 206 |
viewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
88 | 207 |
viewer.getTable().setHeaderVisible(true); |
89 | 208 |
viewer.getTable().setLinesVisible(true); |
90 | 209 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
91 | 210 |
|
211 |
viewer.getTable().addKeyListener(new KeyListener() { |
|
212 |
|
|
213 |
@Override |
|
214 |
public void keyReleased(KeyEvent e) { |
|
215 |
|
|
216 |
if (e.keyCode == SWT.DEL) { |
|
217 |
deleteSelection(); |
|
218 |
} |
|
219 |
|
|
220 |
} |
|
221 |
|
|
222 |
@Override |
|
223 |
public void keyPressed(KeyEvent e) { } |
|
224 |
}); |
|
225 |
|
|
92 | 226 |
viewerComparator = new TableLinesViewerComparator(Toolbox.getCollator(this.getResult())) { |
93 | 227 |
@Override |
94 | 228 |
public int compare(Viewer viewer, Object e1, Object e2) { |
... | ... | |
146 | 280 |
|
147 | 281 |
} |
148 | 282 |
|
283 |
protected void deleteSelection() { |
|
284 |
|
|
285 |
try { |
|
286 |
ArrayList<String> selectedValues = null; |
|
287 |
if (viewer.getSelection().isEmpty()) { |
|
288 |
return; |
|
289 |
} |
|
290 |
|
|
291 |
TextsView result = getResult(); |
|
292 |
for (Object o : viewer.getStructuredSelection().toList()) { |
|
293 |
Text t = (Text)o; |
|
294 |
result.getLines().remove(t.getName()); |
|
295 |
} |
|
296 |
result.setAltered(); |
|
297 |
result.setDirty(); |
|
298 |
updateEditorFromResult(false); |
|
299 |
} |
|
300 |
catch (Exception e1) { |
|
301 |
// TODO Auto-generated catch block |
|
302 |
e1.printStackTrace(); |
|
303 |
} |
|
304 |
|
|
305 |
} |
|
306 |
|
|
149 | 307 |
@Override |
150 | 308 |
public void updateResultFromEditor() { |
151 | 309 |
|
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/editors/TableLinesViewerComparator.java (revision 3985) | ||
---|---|---|
7 | 7 |
import java.util.Date; |
8 | 8 |
import java.util.List; |
9 | 9 |
|
10 |
import org.eclipse.jface.viewers.ISelection; |
|
11 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
12 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
10 | 13 |
import org.eclipse.jface.viewers.TableViewer; |
11 | 14 |
import org.eclipse.jface.viewers.Viewer; |
12 | 15 |
import org.eclipse.jface.viewers.ViewerComparator; |
... | ... | |
154 | 157 |
* @param index |
155 | 158 |
*/ |
156 | 159 |
public void addSelectionAdapter(final TableViewer viewer, final TableColumn column, final int index) { |
160 |
|
|
157 | 161 |
column.addSelectionListener(new SelectionAdapter() { |
158 | 162 |
@Override |
159 | 163 |
public void widgetSelected(SelectionEvent e) { |
... | ... | |
164 | 168 |
} else { |
165 | 169 |
setColumn(index); |
166 | 170 |
|
171 |
IStructuredSelection sel = viewer.getStructuredSelection(); |
|
172 |
|
|
167 | 173 |
viewer.getTable().setSortDirection(getDirection()); |
168 | 174 |
viewer.getTable().setSortColumn(column); |
169 | 175 |
|
... | ... | |
173 | 179 |
else { |
174 | 180 |
viewer.refresh(); |
175 | 181 |
} |
182 |
|
|
183 |
viewer.setSelection(sel); |
|
176 | 184 |
} |
177 | 185 |
} |
178 | 186 |
}); |
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SimpleSubcorpusPanel.java (revision 3985) | ||
---|---|---|
57 | 57 |
|
58 | 58 |
Label propertyLabel = new Label(this, SWT.NONE); |
59 | 59 |
propertyLabel.setText(TXMUIMessages.ampPropertyColon); |
60 |
propertyLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, |
|
61 |
false, false)); |
|
60 |
propertyLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); |
|
62 | 61 |
|
63 | 62 |
propertyCombo = new Combo(this, SWT.READ_ONLY); |
64 | 63 |
propertyCombo.setLayoutData(new GridData(GridData.FILL,GridData.FILL, true, false)); |
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/PropertiesSelector.java (revision 3985) | ||
---|---|---|
86 | 86 |
Label propLabel; |
87 | 87 |
|
88 | 88 |
/** The prop separator. */ |
89 |
String propSeparator = " ; "; //$NON-NLS-1$
|
|
89 |
String propSeparator = ", "; //$NON-NLS-1$
|
|
90 | 90 |
|
91 | 91 |
ArrayList<Listener> listeners = new ArrayList<>(); |
92 |
|
|
93 |
private boolean showSimpleNames = false; |
|
92 | 94 |
|
93 | 95 |
|
94 | 96 |
/** |
... | ... | |
212 | 214 |
} |
213 | 215 |
|
214 | 216 |
if (p instanceof StructuralUnitProperty) { |
215 |
buffer.append(((StructuralUnitProperty)p).getFullName()); |
|
217 |
if (showSimpleNames) { |
|
218 |
buffer.append(((StructuralUnitProperty)p).getName()); |
|
219 |
} else { |
|
220 |
buffer.append(((StructuralUnitProperty)p).getFullName()); |
|
221 |
} |
|
222 |
|
|
216 | 223 |
} else if (p instanceof VirtualProperty) { |
217 | 224 |
buffer.append(((VirtualProperty)p).getFullName()); |
218 | 225 |
} else if (p instanceof Property) { |
... | ... | |
409 | 416 |
public void addValueChangeListener(Listener listener) { |
410 | 417 |
listeners.add(listener); |
411 | 418 |
} |
419 |
|
|
420 |
public void setShowSimpleNames() { |
|
421 |
|
|
422 |
this.showSimpleNames = true; |
|
423 |
} |
|
412 | 424 |
} |
TXM/trunk/bundles/org.txm.texts.core/src/org/txm/texts/core/TextsView.java (revision 3985) | ||
---|---|---|
1 | 1 |
package org.txm.texts.core; |
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 |
import java.io.ObjectOutputStream; |
|
5 | 4 |
import java.io.PrintWriter; |
6 | 5 |
import java.io.StringReader; |
7 | 6 |
import java.io.StringWriter; |
8 | 7 |
import java.util.ArrayList; |
9 |
import java.util.HashMap; |
|
10 | 8 |
import java.util.LinkedHashMap; |
11 | 9 |
import java.util.List; |
12 | 10 |
import java.util.Properties; |
... | ... | |
14 | 12 |
import org.apache.commons.lang.StringUtils; |
15 | 13 |
import org.eclipse.osgi.util.NLS; |
16 | 14 |
import org.txm.core.results.Parameter; |
17 |
import org.txm.core.results.TXMParameters; |
|
18 | 15 |
import org.txm.core.results.TXMResult; |
19 | 16 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
20 | 17 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
21 | 18 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
22 |
import org.txm.searchengine.cqp.corpus.Property; |
|
23 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
|
24 | 19 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
25 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
|
26 | 20 |
import org.txm.utils.TXMProgressMonitor; |
27 | 21 |
import org.txm.utils.logger.Log; |
28 | 22 |
|
... | ... | |
58 | 52 |
@Override |
59 | 53 |
public boolean saveParameters() throws Exception { |
60 | 54 |
|
61 |
|
|
62 | 55 |
String s = ""; |
63 | 56 |
for (StructuralUnitProperty sup : pColumns) { |
64 | 57 |
if (s.length() > 0) s += "\t"; |
Formats disponibles : Unified diff