Révision 3566
TXM/trunk/org.txm.texts.core/build.properties (revision 3566) | ||
---|---|---|
1 |
source.. = src/ |
|
2 |
output.. = bin/ |
|
3 |
bin.includes = META-INF/,\ |
|
4 |
.,\ |
|
5 |
plugin.xml |
|
0 | 6 |
TXM/trunk/org.txm.texts.core/plugin.xml (revision 3566) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<?eclipse version="3.4"?> |
|
3 |
<plugin> |
|
4 |
<extension |
|
5 |
point="org.eclipse.core.runtime.preferences"> |
|
6 |
<initializer |
|
7 |
class="org.txm.texts.core.TextsViewPreferences"> |
|
8 |
</initializer> |
|
9 |
</extension> |
|
10 |
|
|
11 |
</plugin> |
|
0 | 12 |
TXM/trunk/org.txm.texts.core/.settings/org.eclipse.jdt.core.prefs (revision 3566) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
|
3 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 |
|
4 |
org.eclipse.jdt.core.compiler.compliance=1.8 |
|
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.8 |
|
0 | 8 |
TXM/trunk/org.txm.texts.core/.classpath (revision 3566) | ||
---|---|---|
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.8"/> |
|
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 |
TXM/trunk/org.txm.texts.core/META-INF/MANIFEST.MF (revision 3566) | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Bundle-ManifestVersion: 2 |
|
3 |
Bundle-Name: org.txm.texts.core |
|
4 |
Bundle-SymbolicName: org.txm.texts.core;singleton:=true |
|
5 |
Bundle-Version: 1.0.0.qualifier |
|
6 |
Automatic-Module-Name: org.txm.texts.core |
|
7 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 |
|
8 |
Require-Bundle: org.txm.core;bundle-version="0.8.2";visibility:=reexport, |
|
9 |
org.txm.searchengine.core;bundle-version="1.0.0";visibility:=reexport, |
|
10 |
org.txm.utils.core;visibility:=reexport, |
|
11 |
org.txm.searchengine.cqp.core;visibility:=reexport |
|
12 |
Export-Package: org.txm.texts.core |
|
0 | 13 |
TXM/trunk/org.txm.texts.core/.project (revision 3566) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.txm.texts.core</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 |
TXM/trunk/org.txm.texts.core/src/org/txm/texts/core/TextsView.java (revision 3566) | ||
---|---|---|
1 |
package org.txm.texts.core; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.PrintWriter; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.LinkedHashMap; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.apache.commons.lang.StringUtils; |
|
10 |
import org.eclipse.osgi.util.NLS; |
|
11 |
import org.txm.core.results.Parameter; |
|
12 |
import org.txm.core.results.TXMParameters; |
|
13 |
import org.txm.core.results.TXMResult; |
|
14 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
|
15 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
16 |
import org.txm.searchengine.cqp.corpus.Property; |
|
17 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
18 |
import org.txm.utils.TXMProgressMonitor; |
|
19 |
import org.txm.utils.logger.Log; |
|
20 |
|
|
21 |
public class TextsView extends TXMResult { |
|
22 |
|
|
23 |
@Parameter(key = "columns") |
|
24 |
ArrayList<StructuralUnitProperty> pColumns; |
|
25 |
|
|
26 |
// @Parameter(key = "positiveFilters") |
|
27 |
// ArrayList<String> positiveFilters; |
|
28 |
|
|
29 |
@Parameter(key = "negativeFilters") |
|
30 |
String negativeFilters; |
|
31 |
|
|
32 |
private LinkedHashMap<String, ArrayList<String>> result; |
|
33 |
|
|
34 |
public CQPCorpus getCorpus() { |
|
35 |
return (CQPCorpus)parent; |
|
36 |
} |
|
37 |
|
|
38 |
public TextsView(CQPCorpus corpus) { |
|
39 |
|
|
40 |
super(corpus); |
|
41 |
} |
|
42 |
|
|
43 |
public TextsView(String parametersNodePath) { |
|
44 |
|
|
45 |
super(parametersNodePath); |
|
46 |
} |
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
@Override |
|
51 |
public boolean saveParameters() throws Exception { |
|
52 |
|
|
53 |
this.saveParameter("columns", StringUtils.join(pColumns, "\t")); |
|
54 |
// this.saveParameter("positiveFilters", StringUtils.join(positiveFilters, "\t")); |
|
55 |
this.saveParameter("negativeFilters", negativeFilters); |
|
56 |
return true; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public boolean loadParameters() throws Exception { |
|
61 |
|
|
62 |
String v = this.getStringParameterValue("columns").toString(); |
|
63 |
if ("*".equals(v)) { |
|
64 |
; |
|
65 |
this.pColumns = new ArrayList<>(getCorpus().getStructuralUnit("text").getUserDefinedOrderedProperties()); |
|
66 |
for (int i = 0 ; i < pColumns.size() ; i++) { |
|
67 |
if (pColumns.get(i).getName().equals("id")) { |
|
68 |
pColumns.remove(i); |
|
69 |
break; |
|
70 |
} |
|
71 |
} |
|
72 |
} else { |
|
73 |
this.pColumns = new ArrayList(Property.stringToProperties(getCorpus(), v)); |
|
74 |
} |
|
75 |
|
|
76 |
v = this.getStringParameterValue("negativeFilters").toString(); |
|
77 |
if (v.contains("=")) { |
|
78 |
this.negativeFilters = v; |
|
79 |
} else { |
|
80 |
this.negativeFilters = ""; |
|
81 |
} |
|
82 |
|
|
83 |
// v = this.getStringParameterValue("positiveFilters").toString(); |
|
84 |
// if (v.contains("=")) { |
|
85 |
// this.positiveFilters = new ArrayList<>(Arrays.asList(v.split("\t"))); |
|
86 |
// } else { |
|
87 |
// this.positiveFilters = new ArrayList<>(); |
|
88 |
// } |
|
89 |
|
|
90 |
return pColumns != null; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public boolean setParameters(TXMParameters parameters) throws Exception { |
|
95 |
|
|
96 |
if (parameters.get("columns") != null) { |
|
97 |
|
|
98 |
Object o = parameters.get("columns"); |
|
99 |
if (o instanceof List) { |
|
100 |
pColumns = new ArrayList((List)o); |
|
101 |
} else { |
|
102 |
String v = parameters.get("columns").toString(); |
|
103 |
if ("*".equals(v)) { |
|
104 |
this.pColumns = new ArrayList<>(getCorpus().getStructuralUnit("text").getUserDefinedOrderedProperties()); |
|
105 |
} else { |
|
106 |
this.pColumns = new ArrayList(Property.stringToProperties(getCorpus(), v)); |
|
107 |
} |
|
108 |
} |
|
109 |
return true; |
|
110 |
} |
|
111 |
return false; |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 |
public String getName() { |
|
116 |
|
|
117 |
return "Texts ("+pColumns+")"; |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
public String getSimpleName() { |
|
122 |
|
|
123 |
return "Texts"; |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public String getDetails() { |
|
128 |
|
|
129 |
return getName(); |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public void clean() { |
|
134 |
|
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public boolean canCompute() throws Exception { |
|
139 |
|
|
140 |
return pColumns != null; |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
protected boolean _compute(TXMProgressMonitor monitor) throws Exception { |
|
145 |
|
|
146 |
result = new LinkedHashMap<String, ArrayList<String>>(); |
|
147 |
|
|
148 |
// preset arrays |
|
149 |
String[] texts = getCorpus().getCorpusTextIdsList(); |
|
150 |
for (String t : texts) { |
|
151 |
|
|
152 |
ArrayList<String> values = new ArrayList<String>(); |
|
153 |
result.put(t, values); |
|
154 |
|
|
155 |
if (getCorpus().getProject().getText(t) == null) { |
|
156 |
Log.warning(NLS.bind("The {0} Corpus has no text named ''{1}''.", getCorpus(), t)); |
|
157 |
return false; |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
// optimization: get values property per property then set the Text property value arrays |
|
162 |
int positions [] = new int[texts.length]; |
|
163 |
for (int i = 0 ; i < texts.length ; i++) { |
|
164 |
positions[i] = i; |
|
165 |
} |
|
166 |
for (int icol = 0 ; icol < pColumns.size() ; icol++) { |
|
167 |
StructuralUnitProperty col = pColumns.get(icol); |
|
168 |
|
|
169 |
String[] values = CQPSearchEngine.getCqiClient().struc2Str(col.getQualifiedName(), positions); |
|
170 |
|
|
171 |
for (int i = 0 ; i < texts.length ; i++) { |
|
172 |
result.get(texts[i]).add( values[i]); |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
if (negativeFilters.length() > 0 && pColumns.size() > 0) { |
|
177 |
|
|
178 |
ArrayList<String> columnNames = new ArrayList<>(pColumns.size()); |
|
179 |
for (StructuralUnitProperty p : pColumns) columnNames.add(p.getName()); |
|
180 |
|
|
181 |
String[] filters = negativeFilters.split(";"); |
|
182 |
|
|
183 |
ArrayList<String> keys = new ArrayList<>(result.keySet()); |
|
184 |
for (String text : keys) { |
|
185 |
|
|
186 |
for (String negativeFilter : filters) { |
|
187 |
String[] split = negativeFilter.split("=", 2); |
|
188 |
if (split.length == 2 |
|
189 |
&& columnNames.contains(split[0]) |
|
190 |
&& result.get(text).get(columnNames.indexOf(split[0])).matches(split[1])) { |
|
191 |
// remove this line |
|
192 |
result.remove(text); |
|
193 |
break; |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
return true; |
|
200 |
} |
|
201 |
|
|
202 |
@Override |
|
203 |
protected boolean _toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception { |
|
204 |
|
|
205 |
PrintWriter writer = org.txm.utils.io.IOUtils.getWriter(outfile, encoding); |
|
206 |
|
|
207 |
writer.println("text"+colseparator+StringUtils.join(pColumns, colseparator)); |
|
208 |
|
|
209 |
for (String text : result.keySet()) { |
|
210 |
writer.println(text+colseparator+StringUtils.join(result.get(text), colseparator)); |
|
211 |
} |
|
212 |
|
|
213 |
writer.close(); |
|
214 |
return false; |
|
215 |
} |
|
216 |
|
|
217 |
@Override |
|
218 |
public String getResultType() { |
|
219 |
return "TextView"; |
|
220 |
} |
|
221 |
|
|
222 |
public LinkedHashMap<String, ArrayList<String>> getLines() { |
|
223 |
return result; |
|
224 |
} |
|
225 |
|
|
226 |
public List<StructuralUnitProperty> getColumns() { |
|
227 |
|
|
228 |
return pColumns; |
|
229 |
} |
|
230 |
|
|
231 |
} |
|
0 | 232 |
TXM/trunk/org.txm.texts.core/src/org/txm/texts/core/TextsViewPreferences.java (revision 3566) | ||
---|---|---|
1 |
package org.txm.texts.core; |
|
2 |
|
|
3 |
import org.osgi.service.prefs.Preferences; |
|
4 |
import org.txm.core.preferences.TXMPreferences; |
|
5 |
|
|
6 |
public class TextsViewPreferences extends TXMPreferences { |
|
7 |
|
|
8 |
public static final String CRITERII = "criterii"; |
|
9 |
|
|
10 |
public static final String ALLMUSTMATCH = "allmustmatch"; |
|
11 |
|
|
12 |
public static final String ALLPROPERTIESMUSTMATCH = "allmustmatch"; |
|
13 |
|
|
14 |
/** |
|
15 |
* Gets the instance. |
|
16 |
* |
|
17 |
* @return the instance |
|
18 |
*/ |
|
19 |
public static TXMPreferences getInstance() { |
|
20 |
if (!TXMPreferences.instances.containsKey(TextsViewPreferences.class)) { |
|
21 |
new TextsViewPreferences(); |
|
22 |
} |
|
23 |
return TXMPreferences.instances.get(TextsViewPreferences.class); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public void initializeDefaultPreferences() { |
|
28 |
super.initializeDefaultPreferences(); |
|
29 |
|
|
30 |
Preferences preferences = this.getDefaultPreferencesNode(); |
|
31 |
|
|
32 |
preferences.put("columns", "*"); |
|
33 |
} |
|
34 |
} |
|
0 | 35 |
TXM/trunk/org.txm.texts.core/src/org/txm/texts/core/TextsSelection.java (revision 3566) | ||
---|---|---|
1 |
package org.txm.texts.core; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.HashMap; |
|
5 |
|
|
6 |
import org.apache.commons.lang.StringUtils; |
|
7 |
import org.txm.core.results.Parameter; |
|
8 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
9 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
10 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
|
11 |
import org.txm.utils.TXMProgressMonitor; |
|
12 |
|
|
13 |
public class TextsSelection extends Subcorpus { |
|
14 |
|
|
15 |
@Parameter(key = TextsViewPreferences.CRITERII) |
|
16 |
HashMap<String, ArrayList<String>> criterii; |
|
17 |
|
|
18 |
@Parameter(key = TextsViewPreferences.ALLPROPERTIESMUSTMATCH) |
|
19 |
Boolean allPropertiesMustMatch; |
|
20 |
|
|
21 |
@Parameter(key = TextsViewPreferences.ALLMUSTMATCH) |
|
22 |
HashMap<String, Boolean> allMustMatch; |
|
23 |
|
|
24 |
public TextsSelection(CQPCorpus corpus) { |
|
25 |
|
|
26 |
super(corpus); |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @param parametersNodePath |
|
32 |
*/ |
|
33 |
public TextsSelection(String parametersNodePath) { |
|
34 |
super(parametersNodePath); |
|
35 |
} |
|
36 |
|
|
37 |
public boolean canCompute() { |
|
38 |
return criterii.size() > 0; |
|
39 |
} |
|
40 |
|
|
41 |
public boolean __compute(TXMProgressMonitor monitor) throws Exception { |
|
42 |
|
|
43 |
StringBuilder buffer = new StringBuilder(); |
|
44 |
buffer.append("<text> ["); |
|
45 |
int n = 0; |
|
46 |
for (String textprop : criterii.keySet()) { |
|
47 |
|
|
48 |
String operator = " && "; |
|
49 |
if (allPropertiesMustMatch) operator = " || "; |
|
50 |
|
|
51 |
if (n > 0) buffer.append(operator); |
|
52 |
|
|
53 |
String matchOperator = "&"; |
|
54 |
if (!allMustMatch.get(textprop)) matchOperator = "|"; |
|
55 |
|
|
56 |
buffer.append("_.text_"+textprop+"=\""+StringUtils.join(criterii.get(textprop), matchOperator)+"\""); |
|
57 |
} |
|
58 |
buffer.append("] expand to text"); |
|
59 |
|
|
60 |
this.pQuery = new CQLQuery(buffer.toString()); |
|
61 |
|
|
62 |
return super.__compute(monitor); |
|
63 |
} |
|
64 |
} |
|
0 | 65 |
TXM/trunk/org.txm.texts.rcp/.project (revision 3566) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.txm.texts.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 |
TXM/trunk/org.txm.texts.rcp/src/org/txm/texts/rcp/TextViewColumnLabelProvider.java (revision 3566) | ||
---|---|---|
1 |
package org.txm.texts.rcp; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.eclipse.jface.viewers.ColumnLabelProvider; |
|
7 |
import org.txm.objects.Text; |
|
8 |
|
|
9 |
|
|
10 |
public class TextViewColumnLabelProvider extends ColumnLabelProvider { |
|
11 |
|
|
12 |
int n; |
|
13 |
TextsViewEditor editor; |
|
14 |
|
|
15 |
public TextViewColumnLabelProvider(TextsViewEditor editor, int n) { |
|
16 |
this.n = n; |
|
17 |
this.editor = editor; |
|
18 |
} |
|
19 |
|
|
20 |
@Override |
|
21 |
public String getText(Object element) { |
|
22 |
|
|
23 |
Text text = (Text)element; |
|
24 |
return editor.getResult().getLines().get(text.getName()).get(n); |
|
25 |
} |
|
26 |
} |
|
0 | 27 |
TXM/trunk/org.txm.texts.rcp/src/org/txm/texts/rcp/TextsViewEditor.java (revision 3566) | ||
---|---|---|
1 |
package org.txm.texts.rcp; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.LinkedHashMap; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
|
|
8 |
import org.eclipse.jface.viewers.ColumnLabelProvider; |
|
9 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
|
10 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
|
11 |
import org.eclipse.jface.viewers.ISelection; |
|
12 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
|
13 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
14 |
import org.eclipse.jface.viewers.TableViewer; |
|
15 |
import org.eclipse.jface.viewers.TableViewerColumn; |
|
16 |
import org.eclipse.jface.viewers.ViewerComparator; |
|
17 |
import org.eclipse.swt.SWT; |
|
18 |
import org.eclipse.swt.graphics.Image; |
|
19 |
import org.eclipse.swt.layout.GridData; |
|
20 |
import org.eclipse.swt.layout.GridLayout; |
|
21 |
import org.eclipse.swt.widgets.Label; |
|
22 |
import org.eclipse.swt.widgets.TableColumn; |
|
23 |
import org.txm.core.results.Parameter; |
|
24 |
import org.txm.edition.rcp.handlers.OpenEdition; |
|
25 |
import org.txm.objects.Text; |
|
26 |
import org.txm.rcp.IImageKeys; |
|
27 |
import org.txm.rcp.editors.TXMEditor; |
|
28 |
import org.txm.rcp.editors.TableKeyListener; |
|
29 |
import org.txm.rcp.editors.listeners.ComputeSelectionListener; |
|
30 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
|
31 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
32 |
import org.txm.texts.core.TextsView; |
|
33 |
|
|
34 |
|
|
35 |
public class TextsViewEditor extends TXMEditor<TextsView> { |
|
36 |
|
|
37 |
@Parameter(key = "columns") |
|
38 |
PropertiesSelector<StructuralUnitProperty> propertiesSelector; |
|
39 |
|
|
40 |
@Parameter(key = "negativeFilters") |
|
41 |
org.eclipse.swt.widgets.Text negativeFiltersText; |
|
42 |
|
|
43 |
TableViewer viewer; |
|
44 |
// HashMap<String, TableViewerColumn> columns = new HashMap<String, TableViewerColumn>(); |
|
45 |
|
|
46 |
@Override |
|
47 |
public void _createPartControl() throws Exception { |
|
48 |
|
|
49 |
this.getParent().setLayout(new GridLayout(1, true)); |
|
50 |
|
|
51 |
this.getMainParametersComposite().getLayout().numColumns = 10; |
|
52 |
|
|
53 |
propertiesSelector = new PropertiesSelector<>(this.getMainParametersComposite()); |
|
54 |
ArrayList<StructuralUnitProperty> properties = new ArrayList<>(getResult().getCorpus().getStructuralUnitProperties("text")); |
|
55 |
for (int i = 0 ; i < properties.size() ; i++) { |
|
56 |
if (properties.get(i).getName().equals("id")) { |
|
57 |
properties.remove(i); |
|
58 |
break; |
|
59 |
} |
|
60 |
} |
|
61 |
propertiesSelector.setProperties(properties); |
|
62 |
ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this); |
|
63 |
propertiesSelector.addSelectionListener(computeSelectionListener); |
|
64 |
|
|
65 |
new Label(this.getMainParametersComposite(), SWT.NONE).setText("Negative filters (p1=v1;p2=v2)"); |
|
66 |
|
|
67 |
negativeFiltersText = new org.eclipse.swt.widgets.Text(this.getMainParametersComposite(), SWT.BORDER); |
|
68 |
negativeFiltersText.addSelectionListener(computeSelectionListener); |
|
69 |
GridData gdata = new GridData(GridData.FILL, GridData.CENTER, true, false); |
|
70 |
gdata.minimumWidth = 300; |
|
71 |
negativeFiltersText.setLayoutData(gdata); |
|
72 |
|
|
73 |
viewer = new TableViewer(this.getResultArea(), SWT.NONE); |
|
74 |
viewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
75 |
viewer.getTable().setHeaderVisible(true); |
|
76 |
viewer.getTable().setLinesVisible(true); |
|
77 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
|
78 |
|
|
79 |
viewer.setContentProvider(new IStructuredContentProvider() { |
|
80 |
|
|
81 |
@SuppressWarnings("rawtypes") |
|
82 |
@Override |
|
83 |
public Object[] getElements(Object inputElement) { |
|
84 |
|
|
85 |
if (inputElement instanceof List) { |
|
86 |
return ((List)inputElement).toArray(); |
|
87 |
} |
|
88 |
|
|
89 |
return null; |
|
90 |
} |
|
91 |
|
|
92 |
}); |
|
93 |
|
|
94 |
viewer.setComparator(new ViewerComparator()); |
|
95 |
|
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public void updateResultFromEditor() { |
|
100 |
|
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public void updateEditorFromResult(boolean update) throws Exception { |
|
105 |
|
|
106 |
|
|
107 |
TextsView tv = getResult(); |
|
108 |
int currentDisplayedColumns = viewer.getTable().getColumns().length; |
|
109 |
int numberOfColumnsToDisplay = (tv.getColumns().size() + 3); |
|
110 |
if ( currentDisplayedColumns == 0 || |
|
111 |
currentDisplayedColumns != numberOfColumnsToDisplay) { |
|
112 |
|
|
113 |
if (viewer.getTable().getColumns().length > 0) { // get rid of current columns |
|
114 |
for (TableColumn column : viewer.getTable().getColumns()) { |
|
115 |
column.dispose(); |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
TableViewerColumn c = new TableViewerColumn(viewer, SWT.NONE); |
|
120 |
TableColumn textColumn = c.getColumn(); |
|
121 |
textColumn.setText("Text"); |
|
122 |
textColumn.setToolTipText("Text"); |
|
123 |
textColumn.setWidth(200); |
|
124 |
c.setLabelProvider(new ColumnLabelProvider() { |
|
125 |
@Override |
|
126 |
public String getText(Object element) { |
|
127 |
Text text = (Text)element; |
|
128 |
return text.getName(); |
|
129 |
} |
|
130 |
}); |
|
131 |
|
|
132 |
c = new TableViewerColumn(viewer, SWT.NONE); |
|
133 |
TableColumn editionColumn = c.getColumn(); |
|
134 |
editionColumn.setText("Edition"); |
|
135 |
editionColumn.setToolTipText("Edition"); |
|
136 |
editionColumn.setWidth(65); |
|
137 |
c.setLabelProvider(new ColumnLabelProvider() { |
|
138 |
@Override |
|
139 |
public Image getImage(Object element) { |
|
140 |
Text text = (Text)element; |
|
141 |
TextsViewEditor.this.getResult().getLines().get(text.getName()); |
|
142 |
if (text.getEditions().size() > 0) { |
|
143 |
return IImageKeys.getImage(IImageKeys.EDITION); |
|
144 |
} else { |
|
145 |
return null; |
|
146 |
} |
|
147 |
} |
|
148 |
@Override |
|
149 |
public String getText(Object element) { |
|
150 |
return null; |
|
151 |
} |
|
152 |
}); |
|
153 |
|
|
154 |
c = new TableViewerColumn(viewer, SWT.NONE); |
|
155 |
TableColumn separatorColumn = c.getColumn(); |
|
156 |
separatorColumn.setText(" "); |
|
157 |
separatorColumn.setWidth(2); |
|
158 |
c.getColumn().setResizable(false); |
|
159 |
c.setLabelProvider(new ColumnLabelProvider() { |
|
160 |
@Override |
|
161 |
public String getText(Object element) { |
|
162 |
return ""; |
|
163 |
} |
|
164 |
}); |
|
165 |
|
|
166 |
int nColumn = 0; |
|
167 |
for (StructuralUnitProperty col : this.getResult().getColumns()) { |
|
168 |
c = new TableViewerColumn(viewer, SWT.NONE); |
|
169 |
TableColumn newColumn = c.getColumn(); |
|
170 |
newColumn.setText(col.getName()); |
|
171 |
newColumn.setData(nColumn); |
|
172 |
newColumn.setToolTipText(col.getFullName()); |
|
173 |
newColumn.setWidth(100); |
|
174 |
c.setLabelProvider(new TextViewColumnLabelProvider(this, nColumn)); |
|
175 |
nColumn++; |
|
176 |
} |
|
177 |
|
|
178 |
} |
|
179 |
// |
|
180 |
ArrayList<Text> texts = new ArrayList<>(); |
|
181 |
for (Text text : getResult().getCorpus().getProject().getTexts()) { |
|
182 |
if (this.getResult().getLines().containsKey(text.getName())) { |
|
183 |
texts.add(text); |
|
184 |
} |
|
185 |
} |
|
186 |
viewer.setInput(texts); |
|
187 |
|
|
188 |
viewer.addDoubleClickListener(new IDoubleClickListener() { |
|
189 |
|
|
190 |
@Override |
|
191 |
public void doubleClick(DoubleClickEvent event) { |
|
192 |
ISelection sel = viewer.getSelection(); |
|
193 |
StructuredSelection ssel = (StructuredSelection)sel; |
|
194 |
Object o = ssel.getFirstElement(); |
|
195 |
if (o != null && o instanceof Text) { |
|
196 |
OpenEdition.openEdition(getResult().getCorpus(), new String[] {getResult().getProject().getDefaultEditionName()}, ((Text)o).getName()); |
|
197 |
} |
|
198 |
} |
|
199 |
}); |
|
200 |
} |
|
201 |
} |
|
0 | 202 |
TXM/trunk/org.txm.texts.rcp/src/org/txm/texts/rcp/TextsViewAdapterFactory.java (revision 3566) | ||
---|---|---|
1 |
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté |
|
2 |
package org.txm.texts.rcp; |
|
3 |
|
|
4 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
5 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
6 |
import org.osgi.framework.FrameworkUtil; |
|
7 |
import org.txm.rcp.adapters.TXMResultAdapter; |
|
8 |
import org.txm.rcp.adapters.TXMResultAdapterFactory; |
|
9 |
import org.txm.texts.core.TextsView; |
|
10 |
|
|
11 |
|
|
12 |
/** |
|
13 |
* A factory for creating Adapter objects. |
|
14 |
* |
|
15 |
* @author mdecorde |
|
16 |
*/ |
|
17 |
public class TextsViewAdapterFactory extends TXMResultAdapterFactory { |
|
18 |
|
|
19 |
|
|
20 |
public static final ImageDescriptor ICON = AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(TextsViewAdapterFactory.class).getSymbolicName(), |
|
21 |
"platform:/plugin/org.txm.rcp/icons/objects/books.png"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
22 |
|
|
23 |
@Override |
|
24 |
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { |
|
25 |
if (this.canAdapt(adapterType) && adaptableObject instanceof TextsView) { |
|
26 |
return adapterType.cast(new TXMResultAdapter() { |
|
27 |
|
|
28 |
@Override |
|
29 |
public ImageDescriptor getImageDescriptor(Object object) { |
|
30 |
return ICON; |
|
31 |
} |
|
32 |
}); |
|
33 |
} |
|
34 |
return null; |
|
35 |
} |
|
36 |
} |
|
0 | 37 |
TXM/trunk/org.txm.texts.rcp/src/org/txm/texts/rcp/ComputeTextView.java (revision 3566) | ||
---|---|---|
1 |
package org.txm.texts.rcp; |
|
2 |
|
|
3 |
import org.eclipse.core.commands.ExecutionEvent; |
|
4 |
import org.eclipse.core.commands.ExecutionException; |
|
5 |
import org.txm.core.preferences.TXMPreferences; |
|
6 |
import org.txm.rcp.editors.TXMEditor; |
|
7 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
8 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
9 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
10 |
import org.txm.texts.core.TextsView; |
|
11 |
|
|
12 |
public class ComputeTextView extends BaseAbstractHandler { |
|
13 |
|
|
14 |
@Override |
|
15 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
16 |
|
|
17 |
if (!this.checkCorpusEngine()) { |
|
18 |
return false; |
|
19 |
} |
|
20 |
|
|
21 |
TextsView concordance = null; |
|
22 |
|
|
23 |
// From link: creating from parameter node |
|
24 |
String parametersNodePath = event.getParameter(TXMPreferences.RESULT_PARAMETERS_NODE_PATH); |
|
25 |
if (parametersNodePath != null && !parametersNodePath.isEmpty()) { |
|
26 |
concordance = new TextsView(parametersNodePath); |
|
27 |
} |
|
28 |
// From view result node |
|
29 |
else { |
|
30 |
Object selection = this.getCorporaViewSelectedObject(event); |
|
31 |
|
|
32 |
// Creating from Corpus |
|
33 |
if (selection instanceof CQPCorpus) { |
|
34 |
CQPCorpus corpus = (CQPCorpus) selection; |
|
35 |
concordance = new TextsView(corpus); |
|
36 |
} |
|
37 |
// Reopening existing result |
|
38 |
else if (selection instanceof TextsView) { |
|
39 |
concordance = (TextsView) selection; |
|
40 |
} |
|
41 |
// Error |
|
42 |
else { |
|
43 |
return this.logCanNotExecuteCommand(selection); |
|
44 |
} |
|
45 |
} |
|
46 |
|
|
47 |
openEditor(concordance); |
|
48 |
return null; |
|
49 |
} |
|
50 |
|
|
51 |
public static TXMEditor<TextsView> openEditor(TextsView view) { |
|
52 |
return TXMEditor.openEditor(view, TextsViewEditor.class.getName()); |
|
53 |
} |
|
54 |
|
|
55 |
} |
|
0 | 56 |
TXM/trunk/org.txm.texts.rcp/build.properties (revision 3566) | ||
---|---|---|
1 |
source.. = src/ |
|
2 |
output.. = bin/ |
|
3 |
bin.includes = META-INF/,\ |
|
4 |
.,\ |
|
5 |
plugin.xml,\ |
|
6 |
OSGI-INF/l10n/bundle.properties |
|
0 | 7 |
TXM/trunk/org.txm.texts.rcp/OSGI-INF/l10n/bundle.properties (revision 3566) | ||
---|---|---|
1 |
#Properties file for org.txm.texts.rcp |
|
2 |
command.name = Texts |
|
3 |
editor.name = Texts |
|
0 | 4 |
TXM/trunk/org.txm.texts.rcp/plugin.xml (revision 3566) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<?eclipse version="3.4"?> |
|
3 |
<plugin> |
|
4 |
<extension |
|
5 |
point="org.eclipse.ui.commands"> |
|
6 |
<command |
|
7 |
defaultHandler="org.txm.texts.rcp.ComputeTextView" |
|
8 |
id="org.txm.texts.rcp.ComputeTextView" |
|
9 |
name="%command.name" |
|
10 |
returnTypeId="org.txm.texts.core.TextsView"> |
|
11 |
</command> |
|
12 |
</extension> |
|
13 |
<extension |
|
14 |
point="org.eclipse.ui.menus"> |
|
15 |
<menuContribution |
|
16 |
locationURI="menu:menu.corpus"> |
|
17 |
<command |
|
18 |
commandId="org.txm.texts.rcp.ComputeTextView" |
|
19 |
icon="platform:/plugin/org.txm.rcp/icons/objects/books.png" |
|
20 |
style="push" |
|
21 |
tooltip="%command.name"> |
|
22 |
<visibleWhen |
|
23 |
checkEnabled="false"> |
|
24 |
<or> |
|
25 |
<reference |
|
26 |
definitionId="OneCorpusSelected"> |
|
27 |
</reference> |
|
28 |
</or> |
|
29 |
</visibleWhen> |
|
30 |
</command> |
|
31 |
</menuContribution> |
|
32 |
<menuContribution |
|
33 |
allPopups="false" |
|
34 |
locationURI="toolbar:org.txm.rcp.toolbarcorpus"> |
|
35 |
<command |
|
36 |
commandId="org.txm.texts.rcp.ComputeTextView" |
|
37 |
icon="platform:/plugin/org.txm.rcp/icons/objects/books.png" |
|
38 |
style="push" |
|
39 |
tooltip="%command.name"> |
|
40 |
<visibleWhen |
|
41 |
checkEnabled="false"> |
|
42 |
<or> |
|
43 |
<reference |
|
44 |
definitionId="OneCorpusSelected"> |
|
45 |
</reference> |
|
46 |
</or> |
|
47 |
</visibleWhen> |
|
48 |
</command> |
|
49 |
</menuContribution> |
|
50 |
<menuContribution |
|
51 |
allPopups="false" |
|
52 |
locationURI="popup:org.txm.rcp.views.corpora.CorporaView"> |
|
53 |
<command |
|
54 |
commandId="org.txm.texts.rcp.ComputeTextView" |
|
55 |
icon="platform:/plugin/org.txm.rcp/icons/objects/books.png" |
|
56 |
style="push" |
|
57 |
tooltip="%command.name"> |
|
58 |
<visibleWhen |
|
59 |
checkEnabled="false"> |
|
60 |
<or> |
|
61 |
<reference |
|
62 |
definitionId="OneCorpusSelected"> |
|
63 |
</reference> |
|
64 |
</or> |
|
65 |
</visibleWhen> |
|
66 |
</command> |
|
67 |
</menuContribution> |
|
68 |
</extension> |
|
69 |
<extension |
|
70 |
point="org.eclipse.ui.editors"> |
|
71 |
<editor |
|
72 |
class="org.txm.texts.rcp.TextsViewEditor" |
|
73 |
default="false" |
|
74 |
icon="platform:/plugin/org.txm.rcp/icons/objects/books.png" |
|
75 |
id="org.txm.texts.rcp.TextsViewEditor" |
|
76 |
name="%editor.name"> |
|
77 |
</editor> |
|
78 |
</extension> |
|
79 |
<extension |
|
80 |
point="org.eclipse.core.runtime.adapters"> |
|
81 |
<factory |
|
82 |
adaptableType="org.txm.texts.core.TextsView" |
|
83 |
class="org.txm.texts.rcp.TextsViewAdapterFactory"> |
|
84 |
<adapter |
|
85 |
type="org.eclipse.ui.model.IWorkbenchAdapter"> |
|
86 |
</adapter> |
|
87 |
</factory> |
|
88 |
</extension> |
|
89 |
|
|
90 |
</plugin> |
|
0 | 91 |
TXM/trunk/org.txm.texts.rcp/.settings/org.eclipse.jdt.core.prefs (revision 3566) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
|
3 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 |
|
4 |
org.eclipse.jdt.core.compiler.compliance=1.8 |
|
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.8 |
|
0 | 8 |
TXM/trunk/org.txm.texts.rcp/.classpath (revision 3566) | ||
---|---|---|
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.8"/> |
|
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 |
TXM/trunk/org.txm.texts.rcp/META-INF/MANIFEST.MF (revision 3566) | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Bundle-ManifestVersion: 2 |
|
3 |
Bundle-Name: org.txm.texts.rcp |
|
4 |
Bundle-SymbolicName: org.txm.texts.rcp;singleton:=true |
|
5 |
Bundle-Version: 1.0.0.qualifier |
|
6 |
Automatic-Module-Name: org.txm.texts.rcp |
|
7 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 |
|
8 |
Require-Bundle: org.txm.rcp;bundle-version="0.8.2", |
|
9 |
org.txm.texts.core;bundle-version="1.0.0", |
|
10 |
org.txm.edition.rcp;bundle-version="1.0.0" |
|
11 |
Export-Package: org.txm.texts.rcp |
|
0 | 12 |
Formats disponibles : Unified diff