Révision 2602
| tmp/org.txm.progression.core/src/org/txm/progression/core/functions/Progression.java (revision 2602) | ||
|---|---|---|
| 329 | 329 |
this.structurePositions = new int[0]; |
| 330 | 330 |
this.structureNames = new String[0]; |
| 331 | 331 |
|
| 332 |
this.subTask("Processing queries...");
|
|
| 332 |
this.setTask("Processing queries...");
|
|
| 333 | 333 |
if (!this.stepQueries()) {
|
| 334 | 334 |
return true; |
| 335 | 335 |
} |
| ... | ... | |
| 341 | 341 |
} |
| 342 | 342 |
|
| 343 | 343 |
// Structural units |
| 344 |
this.subTask("Processing structural units...");
|
|
| 344 |
this.setTask("Processing structural units...");
|
|
| 345 | 345 |
if (!this.stepStructuralUnits()) {
|
| 346 | 346 |
return false; |
| 347 | 347 |
} |
| ... | ... | |
| 350 | 350 |
|
| 351 | 351 |
// Finalization steps |
| 352 | 352 |
if (this.hasParameterChanged(ProgressionPreferences.QUERIES)) {
|
| 353 |
this.subTask("Finalizing...");
|
|
| 353 |
this.setTask("Finalizing...");
|
|
| 354 | 354 |
if (!stepFinalize()) {
|
| 355 | 355 |
return false; |
| 356 | 356 |
} |
| tmp/org.txm.querycooccurrences.rcp/src/org/txm/functions/coocmatrix/QueryAutoCooccurrence.java (revision 2602) | ||
|---|---|---|
| 28 | 28 |
public class QueryAutoCooccurrence extends TXMResult implements ICAComputable, IAdaptable {
|
| 29 | 29 |
|
| 30 | 30 |
protected CQPCorpus corpus; |
| 31 |
|
|
| 31 | 32 |
protected int[][] coocs; |
| 33 |
|
|
| 32 | 34 |
protected ArrayList<CQLQuery> queries; |
| 35 |
|
|
| 33 | 36 |
protected ArrayList<String> names; |
| 34 |
|
|
| 37 |
|
|
| 35 | 38 |
protected int dist; |
| 39 |
|
|
| 36 | 40 |
protected String struct = ""; |
| 41 |
|
|
| 37 | 42 |
protected String symbol; |
| 43 |
|
|
| 38 | 44 |
protected static int noCoocMatrix = 1; |
| 39 |
|
|
| 45 |
|
|
| 40 | 46 |
protected static String prefixR = "CoocMatrix"; |
| 41 |
|
|
| 47 |
|
|
| 42 | 48 |
protected int nNodes = 0; |
| 49 |
|
|
| 43 | 50 |
protected int nEdges = 0; |
| 51 |
|
|
| 44 | 52 |
protected int minCooc; |
| 53 |
|
|
| 45 | 54 |
protected boolean oriented = false; |
| 46 |
|
|
| 55 |
|
|
| 47 | 56 |
public QueryAutoCooccurrence(CQPCorpus corpus) {
|
| 48 | 57 |
super(corpus); |
| 49 | 58 |
} |
| 50 | 59 |
|
| 51 |
public void setParameters(ArrayList<CQLQuery> queries,
|
|
| 60 |
public void setParameters(ArrayList<CQLQuery> queries, |
|
| 52 | 61 |
ArrayList<String> names, int dist, int minCooc, String struct, boolean oriented, IProgressMonitor monitor) throws CqiClientException, RWorkspaceException {
|
| 53 | 62 |
this.queries = queries; |
| 54 | 63 |
this.names = names; |
| ... | ... | |
| 56 | 65 |
this.minCooc = minCooc; |
| 57 | 66 |
this.oriented = oriented; |
| 58 | 67 |
if (struct != null) |
| 59 |
this.struct = "within "+struct;
|
|
| 68 |
this.struct = "within " + struct;
|
|
| 60 | 69 |
else |
| 61 | 70 |
this.struct = "within text"; |
| 62 |
|
|
| 71 |
|
|
| 63 | 72 |
nNodes = queries.size(); |
| 64 | 73 |
} |
| 65 |
|
|
| 74 |
|
|
| 66 | 75 |
@Override |
| 67 | 76 |
public boolean _compute() throws Exception {
|
| 68 | 77 |
coocs = new int[queries.size()][queries.size()]; |
| 69 | 78 |
|
| 70 |
this.beginTask("Querying cooccurrences...", nNodes);
|
|
| 79 |
this.setTask("Querying cooccurrences...");
|
|
| 80 |
this.setWorkRemaining(nNodes); |
|
| 71 | 81 |
|
| 72 |
for (int i = 0 ; i < queries.size() ; i++) {
|
|
| 82 |
for (int i = 0; i < queries.size(); i++) {
|
|
| 73 | 83 |
int j = i; |
| 74 | 84 |
if (oriented) j = 0; // if the graph is not oriented, we don't need to evaluate all queries |
| 75 |
for (; j < queries.size() ; j++) {
|
|
| 85 |
for (; j < queries.size(); j++) {
|
|
| 76 | 86 |
this.worked(1); |
| 77 | 87 |
String query = null; |
| 78 | 88 |
if (oriented) {
|
| 79 |
query = "("+queries.get(i)+"[]{0,"+dist+"}"+queries.get(j)+") "+this.struct;
|
|
| 89 |
query = "(" + queries.get(i) + "[]{0," + dist + "}" + queries.get(j) + ") " + this.struct;
|
|
| 80 | 90 |
} |
| 81 | 91 |
else {
|
| 82 |
query = "("+queries.get(i)+"[]{0,"+dist+"}"+queries.get(j)+")|("+queries.get(j)+"[]{0,"+dist+"}"+queries.get(i)+") "+this.struct;
|
|
| 92 |
query = "(" + queries.get(i) + "[]{0," + dist + "}" + queries.get(j) + ")|(" + queries.get(j) + "[]{0," + dist + "}" + queries.get(i) + ") " + this.struct;
|
|
| 83 | 93 |
} |
| 84 |
|
|
| 85 |
Log.info("ListCooc: query "+query);
|
|
| 94 |
|
|
| 95 |
Log.info("ListCooc: query " + query);
|
|
| 86 | 96 |
QueryResult result = corpus.query(new CQLQuery(query), "tmp", false); |
| 87 | 97 |
coocs[i][j] = result.getNMatch(); |
| 88 | 98 |
if (coocs[i][j] >= minCooc) {
|
| 89 | 99 |
nEdges++; |
| 90 |
} else {
|
|
| 100 |
} |
|
| 101 |
else {
|
|
| 91 | 102 |
coocs[i][j] = 0; |
| 92 | 103 |
} |
| 93 | 104 |
result.drop(); |
| 94 | 105 |
} |
| 95 | 106 |
} |
| 96 |
|
|
| 107 |
|
|
| 97 | 108 |
if (!oriented) //// if the graph is not oriented, copy upper triangle values to lower triangle values |
| 98 |
for (int i = 0 ; i < queries.size() ; i++) {
|
|
| 99 |
for (int j = i ; j < queries.size() ; j++) {
|
|
| 100 |
coocs[j][i] = coocs[i][j]; |
|
| 101 |
} |
|
| 109 |
for (int i = 0; i < queries.size(); i++) {
|
|
| 110 |
for (int j = i; j < queries.size(); j++) {
|
|
| 111 |
coocs[j][i] = coocs[i][j]; |
|
| 102 | 112 |
} |
| 113 |
} |
|
| 103 | 114 |
this.done(); |
| 104 | 115 |
|
| 105 | 116 |
return true; |
| 106 | 117 |
} |
| 107 |
|
|
| 118 |
|
|
| 119 |
@Override |
|
| 108 | 120 |
public String getName() {
|
| 109 |
return corpus.getName()+ " d="+dist+ " min="+minCooc;
|
|
| 121 |
return corpus.getName() + " d=" + dist + " min=" + minCooc;
|
|
| 110 | 122 |
} |
| 111 |
|
|
| 123 |
|
|
| 124 |
@Override |
|
| 112 | 125 |
public CQPCorpus getParent() {
|
| 113 | 126 |
return corpus; |
| 114 | 127 |
} |
| 115 |
|
|
| 128 |
|
|
| 116 | 129 |
public String getSymbol() {
|
| 117 | 130 |
return symbol; |
| 118 | 131 |
} |
| 119 |
|
|
| 132 |
|
|
| 120 | 133 |
public int getNNodes() {
|
| 121 | 134 |
return nNodes; |
| 122 | 135 |
} |
| 123 |
|
|
| 136 |
|
|
| 124 | 137 |
public int getNEdges() {
|
| 125 | 138 |
return nEdges; |
| 126 | 139 |
} |
| 127 |
|
|
| 140 |
|
|
| 128 | 141 |
private void sendToR() throws RWorkspaceException {
|
| 129 | 142 |
if (symbol != null) return; |
| 130 |
|
|
| 131 |
this.symbol = prefixR+(QueryCooccurrence.noCoocMatrix ++);
|
|
| 143 |
|
|
| 144 |
this.symbol = prefixR + (QueryCooccurrence.noCoocMatrix++);
|
|
| 132 | 145 |
RWorkspace rw = RWorkspace.getRWorkspaceInstance(); |
| 133 |
rw.eval("rm("+symbol+")");
|
|
| 146 |
rw.eval("rm(" + symbol + ")");
|
|
| 134 | 147 |
rw.addMatrixToWorkspace(symbol, coocs); |
| 135 | 148 |
rw.addVectorToWorkspace("cooclabels", names.toArray(new String[names.size()]));
|
| 136 |
rw.eval("rownames("+symbol+") <- cooclabels");
|
|
| 137 |
rw.eval("colnames("+symbol+") <- cooclabels");
|
|
| 149 |
rw.eval("rownames(" + symbol + ") <- cooclabels");
|
|
| 150 |
rw.eval("colnames(" + symbol + ") <- cooclabels");
|
|
| 138 | 151 |
} |
| 139 |
|
|
| 140 |
|
|
| 152 |
|
|
| 153 |
|
|
| 141 | 154 |
public LexicalTable toLexicalTable() throws Exception {
|
| 142 | 155 |
sendToR(); |
| 143 | 156 |
RWorkspace rw = RWorkspace.getRWorkspaceInstance(); |
| 144 |
rw.eval("LT<-"+this.getSymbol());
|
|
| 157 |
rw.eval("LT<-" + this.getSymbol());
|
|
| 145 | 158 |
rw.eval("LT<-LT[rowSums(LT) != 0, ]");
|
| 146 | 159 |
rw.eval("LT<-LT[, colSums(LT) != 0]");
|
| 147 |
rw.eval(this.getSymbol()+"LT<-LT");
|
|
| 160 |
rw.eval(this.getSymbol() + "LT<-LT");
|
|
| 148 | 161 |
rw.eval("rm(LT)");
|
| 149 |
//TODO: use Table fmin preference |
|
| 162 |
// TODO: use Table fmin preference
|
|
| 150 | 163 |
LexicalTable table = new LexicalTable(corpus); |
| 151 | 164 |
table.setUnitProperty(corpus.getProperty("word"));
|
| 152 |
table.setData(new LexicalTableImpl(this.getSymbol()+"LT"));
|
|
| 165 |
table.setData(new LexicalTableImpl(this.getSymbol() + "LT"));
|
|
| 153 | 166 |
return table; |
| 154 | 167 |
} |
| 155 |
|
|
| 168 |
|
|
| 156 | 169 |
public boolean toGraphml(File outfile) throws RWorkspaceException {
|
| 157 |
|
|
| 170 |
|
|
| 158 | 171 |
RWorkspace rw = null; |
| 159 | 172 |
try {
|
| 160 | 173 |
rw = RWorkspace.getRWorkspaceInstance(); |
| 161 | 174 |
rw.eval("library(\"igraph\")");
|
| 162 | 175 |
Log.info("Package 'igraph' installed. Now running CoocMatrix");
|
| 163 |
} catch (Exception e) {
|
|
| 176 |
} |
|
| 177 |
catch (Exception e) {
|
|
| 164 | 178 |
Log.printStackTrace(e); |
| 165 |
Log.warning("The 'igraph' package is not installed: "+e);
|
|
| 179 |
Log.warning("The 'igraph' package is not installed: " + e);
|
|
| 166 | 180 |
boolean install = true; |
| 167 | 181 |
if (install) {
|
| 168 | 182 |
Log.warning("Installing 'igraph'");
|
| 169 | 183 |
try {
|
| 170 | 184 |
rw.eval("install.packages(\"igraph\", dependencies=TRUE, repos=\"http://cran.rstudio.com\");");
|
| 171 |
} catch(Exception e2) {
|
|
| 185 |
} |
|
| 186 |
catch (Exception e2) {
|
|
| 172 | 187 |
Log.severe("Could not install the 'igraph' package");
|
| 173 | 188 |
Log.printStackTrace(e2); |
| 174 | 189 |
return false; |
| 175 | 190 |
} |
| 176 |
} else {
|
|
| 191 |
} |
|
| 192 |
else {
|
|
| 177 | 193 |
System.out.println("Operation canceled by user");
|
| 178 | 194 |
return false; |
| 179 | 195 |
} |
| 180 | 196 |
} |
| 181 |
|
|
| 197 |
|
|
| 182 | 198 |
sendToR(); |
| 183 |
|
|
| 199 |
|
|
| 184 | 200 |
outfile.delete(); |
| 185 |
|
|
| 201 |
|
|
| 186 | 202 |
String orientationMode = "undirected"; |
| 187 |
//if (oriented) orientationMode = "directed"; |
|
| 188 |
|
|
| 203 |
// if (oriented) orientationMode = "directed";
|
|
| 204 |
|
|
| 189 | 205 |
rw.eval("library(igraph)");
|
| 190 |
rw.eval("g <- graph.adjacency("+symbol+", weighted=T, mode = \""+orientationMode+"\", diag=FALSE)"); // create graph from matrix
|
|
| 206 |
rw.eval("g <- graph.adjacency(" + symbol + ", weighted=T, mode = \"" + orientationMode + "\", diag=FALSE)"); // create graph from matrix
|
|
| 191 | 207 |
rw.eval("V(g)$label <- V(g)$name"); // copy names in labels
|
| 192 |
//rw.eval("g <- set.vertex.attribute(g, \"label\", colnames("+symbol+"))");
|
|
| 193 |
//rw.eval("g <- set.vertex.attribute(g, \"color\", value=colors)");
|
|
| 194 |
|
|
| 195 |
String path = outfile.getAbsolutePath();//.replaceAll("\\\\", "\\\\")
|
|
| 208 |
// rw.eval("g <- set.vertex.attribute(g, \"label\", colnames("+symbol+"))");
|
|
| 209 |
// rw.eval("g <- set.vertex.attribute(g, \"color\", value=colors)");
|
|
| 210 |
|
|
| 211 |
String path = outfile.getAbsolutePath();// .replaceAll("\\\\", "\\\\")
|
|
| 196 | 212 |
path = path.replace('\\', '/');
|
| 197 |
rw.eval("write.graph(g, \""+path+"\", format = 'graphml')");
|
|
| 198 |
|
|
| 213 |
rw.eval("write.graph(g, \"" + path + "\", format = 'graphml')");
|
|
| 214 |
|
|
| 199 | 215 |
return outfile.exists(); |
| 200 | 216 |
} |
| 201 |
|
|
| 217 |
|
|
| 218 |
@Override |
|
| 202 | 219 |
public CQPCorpus getCorpus() {
|
| 203 | 220 |
return corpus; |
| 204 | 221 |
} |
| 205 |
|
|
| 222 |
|
|
| 206 | 223 |
public int[][] getCoocs() {
|
| 207 | 224 |
return coocs; |
| 208 | 225 |
} |
| 209 |
|
|
| 226 |
|
|
| 210 | 227 |
public ArrayList<CQLQuery> getQueries() {
|
| 211 | 228 |
return queries; |
| 212 | 229 |
} |
| 213 |
|
|
| 230 |
|
|
| 214 | 231 |
public java.util.ArrayList<String> getNames() {
|
| 215 | 232 |
return names; |
| 216 | 233 |
} |
| 217 |
|
|
| 234 |
|
|
| 218 | 235 |
public int getDist() {
|
| 219 | 236 |
return dist; |
| 220 | 237 |
} |
| 221 |
|
|
| 238 |
|
|
| 222 | 239 |
public void printCoocs() {
|
| 223 |
for (int i = 0 ; i < queries.size() ; i++) {
|
|
| 240 |
for (int i = 0; i < queries.size(); i++) {
|
|
| 224 | 241 |
System.out.print(names.get(i)); |
| 225 |
for (int j = 0 ; j < queries.size() ; j++) {
|
|
| 226 |
System.out.print("\t"+coocs[i][j]);
|
|
| 242 |
for (int j = 0; j < queries.size(); j++) {
|
|
| 243 |
System.out.print("\t" + coocs[i][j]);
|
|
| 227 | 244 |
} |
| 228 | 245 |
System.out.println(); |
| 229 | 246 |
} |
| 230 | 247 |
} |
| 231 |
|
|
| 248 |
|
|
| 232 | 249 |
@Override |
| 233 | 250 |
public void clean() {
|
| 234 | 251 |
// TODO Auto-generated method stub |
| 235 | 252 |
} |
| 236 |
|
|
| 253 |
|
|
| 254 |
@Override |
|
| 237 | 255 |
public boolean toTxt(File outfile, String encoding, String colseparator, |
| 238 | 256 |
String txtseparator) throws Exception {
|
| 239 | 257 |
return toGraphml(outfile); |
| 240 | 258 |
} |
| 241 |
|
|
| 259 |
|
|
| 260 |
@Override |
|
| 242 | 261 |
public String toString() {
|
| 243 | 262 |
return getName(); |
| 244 | 263 |
} |
| 245 |
|
|
| 264 |
|
|
| 246 | 265 |
@Override |
| 247 | 266 |
public CA toCA() throws Exception {
|
| 248 | 267 |
CQPCorpus corpus = this.getCorpus(); |
| 249 | 268 |
Property analysisProperty = null; |
| 250 | 269 |
try {
|
| 251 | 270 |
analysisProperty = this.getCorpus().getProperty("word"); //$NON-NLS-1$
|
| 252 |
} catch (CqiClientException e) {
|
|
| 271 |
} |
|
| 272 |
catch (CqiClientException e) {
|
|
| 253 | 273 |
// TODO Auto-generated catch block |
| 254 | 274 |
org.txm.utils.logger.Log.printStackTrace(e); |
| 255 | 275 |
} |
| 256 | 276 |
LexicalTable table = this.toLexicalTable(); |
| 257 | 277 |
int fmin = table.getFMin(); |
| 258 |
|
|
| 278 |
|
|
| 259 | 279 |
CA ca = new CA(table); |
| 260 |
|
|
| 280 |
|
|
| 261 | 281 |
return ca; |
| 262 | 282 |
} |
| 263 |
|
|
| 283 |
|
|
| 264 | 284 |
@Override |
| 265 | 285 |
public Partition getPartition() {
|
| 266 | 286 |
return null; |
| 267 | 287 |
} |
| 268 |
|
|
| 288 |
|
|
| 269 | 289 |
/** The WordCloud adapter. */ |
| 270 | 290 |
private static IWorkbenchAdapter coocMatrixAdapter = new IWorkbenchAdapter() {
|
| 271 |
|
|
| 291 |
|
|
| 272 | 292 |
@Override |
| 273 | 293 |
public Object[] getChildren(Object o) {
|
| 274 | 294 |
return new Object[0]; |
| 275 | 295 |
} |
| 276 |
|
|
| 296 |
|
|
| 277 | 297 |
@Override |
| 278 | 298 |
public ImageDescriptor getImageDescriptor(Object object) {
|
| 279 | 299 |
return IImageKeys.getImageDescriptor(IImageKeys.COOCMATRIX); |
| 280 | 300 |
} |
| 281 |
|
|
| 301 |
|
|
| 282 | 302 |
@Override |
| 283 | 303 |
public String getLabel(Object o) {
|
| 284 | 304 |
return ((QueryAutoCooccurrence) o).getName(); |
| 285 | 305 |
} |
| 286 |
|
|
| 306 |
|
|
| 287 | 307 |
@Override |
| 288 | 308 |
public Object getParent(Object o) {
|
| 289 | 309 |
if (((QueryAutoCooccurrence) o).getPartition() != null) {
|
| 290 | 310 |
return ((QueryAutoCooccurrence) o).getPartition(); |
| 291 |
} else {
|
|
| 311 |
} |
|
| 312 |
else {
|
|
| 292 | 313 |
return ((QueryAutoCooccurrence) o).getCorpus(); |
| 293 | 314 |
} |
| 294 | 315 |
} |
| 295 | 316 |
}; |
| 296 |
|
|
| 317 |
|
|
| 297 | 318 |
@Override |
| 298 | 319 |
public Object getAdapter(Class adapter) {
|
| 299 | 320 |
return coocMatrixAdapter; |
| 300 | 321 |
} |
| 301 |
|
|
| 322 |
|
|
| 302 | 323 |
@Override |
| 303 | 324 |
public String getSimpleName() {
|
| 304 | 325 |
return "QueryCooccurrence"; |
| 305 | 326 |
} |
| 306 |
|
|
| 327 |
|
|
| 307 | 328 |
@Override |
| 308 | 329 |
public String getDetails() {
|
| 309 | 330 |
return queries.toString(); |
| 310 | 331 |
} |
| 311 |
|
|
| 332 |
|
|
| 312 | 333 |
@Override |
| 313 | 334 |
public boolean canCompute() {
|
| 314 | 335 |
return corpus != null; |
| 315 | 336 |
} |
| 316 |
|
|
| 337 |
|
|
| 317 | 338 |
@Override |
| 318 | 339 |
public boolean setParameters(TXMParameters parameters) {
|
| 319 |
//FIXME: not yet implemented. |
|
| 340 |
// FIXME: not yet implemented.
|
|
| 320 | 341 |
System.err.println("QueryAutoCooccurrence.setParameters(): not yet implemented.");
|
| 321 | 342 |
return false; |
| 322 | 343 |
} |
| 323 |
|
|
| 344 |
|
|
| 324 | 345 |
@Override |
| 325 | 346 |
public boolean saveParameters() throws Exception {
|
| 326 |
//FIXME: not yet implemented. |
|
| 347 |
// FIXME: not yet implemented.
|
|
| 327 | 348 |
System.err.println("QueryAutoCooccurrence.saveParameters(): not yet implemented.");
|
| 328 | 349 |
return false; |
| 329 | 350 |
} |
| 330 |
|
|
| 351 |
|
|
| 331 | 352 |
@Override |
| 332 | 353 |
public boolean loadParameters() throws Exception {
|
| 333 |
//FIXME: not yet implemented. |
|
| 354 |
// FIXME: not yet implemented.
|
|
| 334 | 355 |
System.err.println("QueryAutoCooccurrence.loadParameters(): not yet implemented.");
|
| 335 | 356 |
return false; |
| 336 | 357 |
} |
| 337 |
|
|
| 358 |
|
|
| 338 | 359 |
@Override |
| 339 | 360 |
public String getResultType() {
|
| 340 | 361 |
return "Query auto cooccurrence"; |
| 341 | 362 |
} |
| 342 |
|
|
| 363 |
|
|
| 343 | 364 |
} |
| tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/OpenEdition.java (revision 2602) | ||
|---|---|---|
| 63 | 63 |
* choose one of the text used in the partition @ author mdecorde. |
| 64 | 64 |
*/ |
| 65 | 65 |
public class OpenEdition extends AbstractHandler {
|
| 66 |
|
|
| 66 |
|
|
| 67 | 67 |
/** The Constant ID. */ |
| 68 | 68 |
public final static String ID = "org.txm.synopticedition.rcp.handlers.OpenEdition"; //$NON-NLS-1$ |
| 69 |
|
|
| 69 |
|
|
| 70 | 70 |
/** The lastopenedfile. */ |
| 71 | 71 |
public static String lastopenedfile; |
| 72 |
|
|
| 73 |
/* (non-Javadoc) |
|
| 72 |
|
|
| 73 |
/* |
|
| 74 |
* (non-Javadoc) |
|
| 74 | 75 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
| 75 | 76 |
*/ |
| 76 | 77 |
@Override |
| 77 | 78 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 78 |
|
|
| 79 |
|
|
| 79 | 80 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
| 80 | 81 |
if (selection.getFirstElement() instanceof CQPCorpus) {
|
| 81 | 82 |
try {
|
| 82 | 83 |
CQPCorpus c = (CQPCorpus) selection.getFirstElement(); |
| 83 |
// Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
|
|
| 84 |
|
|
| 85 |
//EditionSelectorDialog d = new EditionSelectorDialog(shell, c, null); |
|
| 84 |
// Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
|
|
| 85 |
|
|
| 86 |
// EditionSelectorDialog d = new EditionSelectorDialog(shell, c, null);
|
|
| 86 | 87 |
SynopticEditionEditor editor = null; |
| 87 |
// if (c.getEditionNames().size() > 1 && d.open() == Window.OK) {
|
|
| 88 |
// Object[] rez = d.getResult();
|
|
| 89 |
// String[] rezS = new String[rez.length];
|
|
| 90 |
// for (int i =0 ; i < rez.length ; i++) rezS[i] = rez[i].toString();
|
|
| 91 |
// editor = openEdition(c, rezS);
|
|
| 92 |
// } else
|
|
| 88 |
// if (c.getEditionNames().size() > 1 && d.open() == Window.OK) {
|
|
| 89 |
// Object[] rez = d.getResult();
|
|
| 90 |
// String[] rezS = new String[rez.length];
|
|
| 91 |
// for (int i =0 ; i < rez.length ; i++) rezS[i] = rez[i].toString();
|
|
| 92 |
// editor = openEdition(c, rezS);
|
|
| 93 |
// } else
|
|
| 93 | 94 |
String[] editionsToOpen = getDefaultEditions(c); |
| 94 |
|
|
| 95 |
|
|
| 95 | 96 |
if (editionsToOpen.length == 0) { // the defaultEdition parameter is not set
|
| 96 | 97 |
List<String> editionNames = c.getProject().getEditionNames(); |
| 97 | 98 |
if (editionNames.size() > 0) { // use the first edition declared
|
| 98 | 99 |
editionsToOpen = new String[1]; |
| 99 | 100 |
editionsToOpen[0] = editionNames.get(0); |
| 100 | 101 |
Log.info(NLS.bind(EditionUIMessages.openingWithFirstEditionNoDefaultEditionSetColonP0, editionNames.get(0))); |
| 101 |
} else { // no edition in the corpus
|
|
| 102 |
} |
|
| 103 |
else { // no edition in the corpus
|
|
| 102 | 104 |
Log.warning(EditionUIMessages.noEditionToOpen); |
| 103 | 105 |
editionsToOpen = new String[0]; |
| 104 | 106 |
return false; |
| 105 | 107 |
} |
| 106 |
} else {
|
|
| 108 |
} |
|
| 109 |
else {
|
|
| 107 | 110 |
Log.info(NLS.bind(EditionUIMessages.openingDefaultEditionsColonP0, StringUtils.join(editionsToOpen, ", "))); |
| 108 | 111 |
} |
| 109 |
|
|
| 112 |
|
|
| 110 | 113 |
editor = openEdition(c, editionsToOpen); |
| 111 |
|
|
| 112 |
// if (editor != null) |
|
| 113 |
// editor.firstPage(); |
|
| 114 |
} catch (Exception e) {
|
|
| 114 |
|
|
| 115 |
// if (editor != null) |
|
| 116 |
// editor.firstPage(); |
|
| 117 |
} |
|
| 118 |
catch (Exception e) {
|
|
| 115 | 119 |
Log.severe(NLS.bind(EditionUIMessages.errorWhileOpeningEditionColonP0, e)); |
| 116 | 120 |
org.txm.utils.logger.Log.printStackTrace(e); |
| 117 | 121 |
} |
| 118 |
} else {
|
|
| 122 |
} |
|
| 123 |
else {
|
|
| 119 | 124 |
Log.warning(EditionUIMessages.abortingColonSelectionIsNotACorpus); |
| 120 | 125 |
} |
| 121 | 126 |
return null; |
| 122 | 127 |
} |
| 123 |
|
|
| 128 |
|
|
| 124 | 129 |
public static String[] getDefaultEditions(Project p) {
|
| 125 |
return p.getDefaultEdition().split(","); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 130 |
return p.getDefaultEdition().split(","); //$NON-NLS-1$
|
|
| 126 | 131 |
} |
| 127 |
|
|
| 132 |
|
|
| 128 | 133 |
public static String[] getDefaultEditions(CQPCorpus c) {
|
| 129 | 134 |
return getDefaultEditions(c.getProject()); |
| 130 | 135 |
} |
| 131 |
|
|
| 136 |
|
|
| 132 | 137 |
/** |
| 133 |
* Open edition, but don't show a page
|
|
| 138 |
* Open edition, but don't show a page |
|
| 134 | 139 |
* |
| 135 | 140 |
* @param corpus the corpus |
| 136 | 141 |
* @return the object |
| ... | ... | |
| 140 | 145 |
} |
| 141 | 146 |
|
| 142 | 147 |
/** |
| 143 |
* Open edition, but don't show a page
|
|
| 148 |
* Open edition, but don't show a page |
|
| 144 | 149 |
* |
| 145 | 150 |
* @param corpus the corpus |
| 146 | 151 |
* @return the object |
| 147 | 152 |
*/ |
| 148 | 153 |
public static SynopticEditionEditor openEdition(CQPCorpus corpus, List<String> editions) {
|
| 149 | 154 |
String textid = null; |
| 150 |
|
|
| 151 |
Log.fine("Opening edition of "+corpus); //$NON-NLS-1$
|
|
| 155 |
|
|
| 156 |
Log.fine("Opening edition of " + corpus); //$NON-NLS-1$
|
|
| 152 | 157 |
try {
|
| 153 | 158 |
Text text = null; |
| 154 | 159 |
if (corpus instanceof Subcorpus) {
|
| 155 |
Subcorpus sub = (Subcorpus)corpus; |
|
| 160 |
Subcorpus sub = (Subcorpus) corpus;
|
|
| 156 | 161 |
sub.compute(false); |
| 157 | 162 |
List<Match> matches = sub.getMatches(); |
| 158 | 163 |
if (matches.size() > 0) {
|
| 159 | 164 |
StructuralUnit text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$
|
| 160 | 165 |
Property text_id = text_su.getProperty("id"); //$NON-NLS-1$
|
| 161 |
|
|
| 166 |
|
|
| 162 | 167 |
textid = matches.get(0).getValueForProperty(text_id); |
| 163 | 168 |
if (textid != null) text = corpus.getProject().getText(textid); |
| 164 | 169 |
} |
| 165 | 170 |
} |
| 166 |
// QueryResult result = corpus.query(new Query("<text> []"), "get_edition", false); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 167 |
// StructuralUnit text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$
|
|
| 168 |
// Property text_id = text_su.getProperty("id"); //$NON-NLS-1$
|
|
| 169 |
|
|
| 170 |
// if (result.getNMatch() > 0) textid = result.getMatches(0, 1).get(0).getValueForProperty(text_id);
|
|
| 171 |
// QueryResult result = corpus.query(new Query("<text> []"), "get_edition", false); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 172 |
// StructuralUnit text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$
|
|
| 173 |
// Property text_id = text_su.getProperty("id"); //$NON-NLS-1$
|
|
| 174 |
|
|
| 175 |
// if (result.getNMatch() > 0) textid = result.getMatches(0, 1).get(0).getValueForProperty(text_id); |
|
| 171 | 176 |
MainCorpus maincorpus = corpus.getMainCorpus(); |
| 172 |
|
|
| 173 |
// if (textid != null) text = maincorpus.getText(textid);
|
|
| 174 |
|
|
| 177 |
|
|
| 178 |
// if (textid != null) text = maincorpus.getText(textid);
|
|
| 179 |
|
|
| 175 | 180 |
if (text == null) {
|
| 176 | 181 |
text = maincorpus.getProject().getFirstText(); |
| 177 |
|
|
| 182 |
|
|
| 178 | 183 |
if (text == null) {
|
| 179 | 184 |
System.out.println(NLS.bind(EditionUIMessages.couldNotFindFirstTextOfP0IDInTheCorpus, textid)); |
| 180 | 185 |
return null; |
| 181 | 186 |
} |
| 182 |
|
|
| 187 |
|
|
| 183 | 188 |
textid = text.getName(); |
| 184 | 189 |
} |
| 185 |
|
|
| 186 |
//String[] editions = {maincorpus.getDefaultEdition()};
|
|
| 190 |
|
|
| 191 |
// String[] editions = {maincorpus.getDefaultEdition()};
|
|
| 187 | 192 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
| 188 | 193 |
IWorkbenchPage page = window.getActivePage(); |
| 189 |
|
|
| 194 |
|
|
| 190 | 195 |
SynopticEditorInput editorInput = new SynopticEditorInput(text, corpus, editions); |
| 191 | 196 |
SynopticEditionEditor editor = (SynopticEditionEditor) page.openEditor(editorInput, SynopticEditionEditor.ID, true); |
| 192 |
|
|
| 197 |
|
|
| 193 | 198 |
return editor; |
| 194 |
|
|
| 195 |
} catch (Exception e) {
|
|
| 199 |
|
|
| 200 |
} |
|
| 201 |
catch (Exception e) {
|
|
| 196 | 202 |
Log.printStackTrace(e); |
| 197 | 203 |
System.out.println(NLS.bind(EditionUIMessages.errorWhileOpeningEditorColonP0, e)); |
| 198 | 204 |
return null; |
| 199 | 205 |
} |
| 200 | 206 |
} |
| 201 |
} |
|
| 207 |
} |
|
| tmp/org.txm.index.core/src/org/txm/index/core/functions/___Lexicon2.java (revision 2602) | ||
|---|---|---|
| 173 | 173 |
@Override |
| 174 | 174 |
protected boolean _computeLines() throws Exception {
|
| 175 | 175 |
if (this.getParent() instanceof MainCorpus) {
|
| 176 |
return computeWithMainCorpus((MainCorpus) this.getParent(), pProperty, monitor);
|
|
| 176 |
return computeWithMainCorpus((MainCorpus) this.getParent(), pProperty, this.splitMonitor(70));
|
|
| 177 | 177 |
} |
| 178 | 178 |
else if (this.getParent() instanceof Subcorpus) {
|
| 179 |
return computewithSubCorpus((Subcorpus) this.getParent(), pProperty, monitor);
|
|
| 179 |
return computewithSubCorpus((Subcorpus) this.getParent(), pProperty, this.splitMonitor(70));
|
|
| 180 | 180 |
} |
| 181 | 181 |
else {
|
| 182 | 182 |
Log.severe("Error: Lexicon parent is neither a Maincorpus nor a Subcorpus."); //$NON-NLS-1$
|
| ... | ... | |
| 198 | 198 |
protected boolean computeWithMainCorpus(MainCorpus corpus, Property property, IProgressMonitor monitor) throws CqiClientException {
|
| 199 | 199 |
// System.out.println("in "+this.getCqpId()+" look for cached lexicon "+property);
|
| 200 | 200 |
// System.out.println("not found");
|
| 201 |
this.subTask("Computing lexicon size...");
|
|
| 201 |
this.setTask("Computing lexicon size...");
|
|
| 202 | 202 |
Log.finest(IndexCoreMessages.lexicon + corpus.getID()); |
| 203 | 203 |
int lexiconSize; |
| 204 | 204 |
try {
|
| ... | ... | |
| 215 | 215 |
|
| 216 | 216 |
int[] freqs; |
| 217 | 217 |
try {
|
| 218 |
this.subTask("Computing lexicon frequencies...");
|
|
| 218 |
this.setTask("Computing lexicon frequencies...");
|
|
| 219 | 219 |
freqs = CorpusManager.getCorpusManager().getCqiClient().id2Freq(property.getQualifiedName(), ids); |
| 220 | 220 |
} |
| 221 | 221 |
catch (Exception e) {
|
| ... | ... | |
| 248 | 248 |
int[][] fdist = null; |
| 249 | 249 |
Subcorpus tmp = null; |
| 250 | 250 |
try {
|
| 251 |
this.subTask("Computing lexicon frequencies...");
|
|
| 251 |
this.setTask("Computing lexicon frequencies...");
|
|
| 252 | 252 |
tmp = corpus.createSubcorpus(new CQLQuery("[]"), "S" + corpus.getNextSubcorpusCounter(), true); //$NON-NLS-1$
|
| 253 | 253 |
if (tmp != null) {
|
| 254 | 254 |
fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(tmp.getQualifiedCqpId(), 0, ICqiClient.CQI_CONST_FIELD_MATCH, property.getName()); |
| ... | ... | |
| 343 | 343 |
|
| 344 | 344 |
|
| 345 | 345 |
|
| 346 |
@Override |
|
| 346 | 347 |
public String getDetails() {
|
| 347 | 348 |
try {
|
| 348 | 349 |
return this.getParent().getName() + " " + this.pProperty.getName(); //$NON-NLS-1$ |
| ... | ... | |
| 602 | 603 |
* @param txtseparator the txtseparator |
| 603 | 604 |
* @return true, if successful |
| 604 | 605 |
*/ |
| 606 |
@Override |
|
| 605 | 607 |
@Deprecated |
| 606 | 608 |
public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) {
|
| 607 | 609 |
// NK: writer declared as class attribute to perform a clean if the operation is interrupted |
| tmp/org.txm.index.core/src/org/txm/index/core/functions/Lexicon.java (revision 2602) | ||
|---|---|---|
| 82 | 82 |
// this.query = new Query("[]"); //$NON-NLS-1$
|
| 83 | 83 |
// this.props = new ArrayList<Property>(); |
| 84 | 84 |
// this.props.add(property); |
| 85 |
Property property = pProperties.get(0); |
|
| 85 |
Property property = this.pProperties.get(0);
|
|
| 86 | 86 |
|
| 87 |
CQPLexicon lexicon = CQPLexicon.getLexicon(this.getCorpus(), property, monitor);
|
|
| 87 |
CQPLexicon lexicon = CQPLexicon.getLexicon(this.getCorpus(), property, this.splitMonitor(20));
|
|
| 88 | 88 |
lexicon.setProperty(property); |
| 89 | 89 |
lexicon._compute(); |
| 90 | 90 |
|
| tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java (revision 2602) | ||
|---|---|---|
| 108 | 108 |
currentpartid++; |
| 109 | 109 |
} |
| 110 | 110 |
|
| 111 |
this.worked(30); |
|
| 112 |
|
|
| 111 | 113 |
setLineCounts(); |
| 112 | 114 |
|
| 113 | 115 |
getAllLines(); |
| 114 | 116 |
|
| 115 | 117 |
this.filterLines(); |
| 116 | 118 |
|
| 117 |
this.subTask("Sorting...");
|
|
| 118 | 119 |
|
| 120 |
this.worked(30); |
|
| 121 |
|
|
| 122 |
this.setTask("Sorting...");
|
|
| 123 |
|
|
| 119 | 124 |
this.sortLines(SortMode.FREQUNIT, true); |
| 120 | 125 |
|
| 121 | 126 |
this.cut(); |
| 122 | 127 |
|
| 128 |
this.worked(30); |
|
| 129 |
|
|
| 123 | 130 |
this.dirty = false; |
| 124 | 131 |
this.pTopIndex = 0; |
| 125 | 132 |
|
| 126 |
this.subTask("Index done.");
|
|
| 133 |
this.setTask("Index done.");
|
|
| 127 | 134 |
|
| 128 | 135 |
return true; |
| 129 | 136 |
} |
| tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 2602) | ||
|---|---|---|
| 188 | 188 |
return false; |
| 189 | 189 |
} |
| 190 | 190 |
// } |
| 191 |
|
|
| 192 | 191 |
this.filterLines(); |
| 192 |
this.worked(30); |
|
| 193 | 193 |
|
| 194 |
this.subTask("Sorting...");
|
|
| 195 |
|
|
| 194 |
this.setTask("Sorting...");
|
|
| 196 | 195 |
this.sortLines(SortMode.FREQUNIT, true); |
| 196 |
this.worked(30); |
|
| 197 | 197 |
|
| 198 | 198 |
this.cut(); |
| 199 | 199 |
|
| 200 | 200 |
this.dirty = false; |
| 201 | 201 |
this.pTopIndex = 0; |
| 202 | 202 |
|
| 203 |
this.subTask("Index done.");
|
|
| 203 |
this.setTask("Index done.");
|
|
| 204 | 204 |
|
| 205 | 205 |
return true; |
| 206 | 206 |
} |
| tmp/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java (revision 2602) | ||
|---|---|---|
| 259 | 259 |
// FIXME: debug |
| 260 | 260 |
// System.out.println("cooc: "+corpus+" "+query+" "+properties+" "+limit+" "+maxLeft+" "+minLeft+" "+minRight+" "+maxRight+" "+minFreq+" "+minCof+" "+minScore+" "+includeXpivot);
|
| 261 | 261 |
|
| 262 |
this.subTask(CooccurrenceCoreMessages.info_buildingQueries);
|
|
| 262 |
this.setTask(CooccurrenceCoreMessages.info_buildingQueries);
|
|
| 263 | 263 |
|
| 264 | 264 |
// clear data |
| 265 | 265 |
try {
|
| ... | ... | |
| 283 | 283 |
return false; |
| 284 | 284 |
} |
| 285 | 285 |
|
| 286 |
this.subTask(CooccurrenceCoreMessages.info_retreivingMatches);
|
|
| 286 |
this.setTask(CooccurrenceCoreMessages.info_retreivingMatches);
|
|
| 287 | 287 |
if (!this.stepGetMatches()) {
|
| 288 | 288 |
return false; |
| 289 | 289 |
} |
| 290 |
this.worked(10);
|
|
| 290 |
this.worked(20);
|
|
| 291 | 291 |
|
| 292 |
this.subTask(CooccurrenceCoreMessages.info_buildingLineSignatures);
|
|
| 292 |
this.setTask(CooccurrenceCoreMessages.info_buildingLineSignatures);
|
|
| 293 | 293 |
if (!this.stepBuildSignatures()) {
|
| 294 | 294 |
return false; |
| 295 | 295 |
} |
| 296 |
this.worked(10);
|
|
| 296 |
this.worked(20);
|
|
| 297 | 297 |
|
| 298 |
this.subTask(CooccurrenceCoreMessages.info_counting);
|
|
| 298 |
this.setTask(CooccurrenceCoreMessages.info_counting);
|
|
| 299 | 299 |
if (!this.stepCount()) {
|
| 300 | 300 |
return false; |
| 301 | 301 |
} |
| 302 |
this.worked(10);
|
|
| 302 |
this.worked(20);
|
|
| 303 | 303 |
|
| 304 |
this.subTask(CooccurrenceCoreMessages.info_buildingLexicalTable);
|
|
| 304 |
this.setTask(CooccurrenceCoreMessages.info_buildingLexicalTable);
|
|
| 305 | 305 |
if (!this.stepBuildLexicalTable()) {
|
| 306 | 306 |
return false; |
| 307 | 307 |
} |
| 308 | 308 |
this.worked(10); |
| 309 | 309 |
|
| 310 |
this.subTask(CooccurrenceCoreMessages.info_computingSpecificitiesScores);
|
|
| 310 |
this.setTask(CooccurrenceCoreMessages.info_computingSpecificitiesScores);
|
|
| 311 | 311 |
if (!this.stepGetScores()) {
|
| 312 | 312 |
return false; |
| 313 | 313 |
} |
| 314 | 314 |
|
| 315 | 315 |
this.clearMemory(); |
| 316 |
this.worked(10);
|
|
| 316 |
this.done();
|
|
| 317 | 317 |
|
| 318 |
|
|
| 319 | 318 |
return true; |
| 320 | 319 |
} |
| 321 | 320 |
|
| ... | ... | |
| 960 | 959 |
index = new Index(corpus); |
| 961 | 960 |
index.setVisible(false); |
| 962 | 961 |
index.setParameters(new CQLQuery(pCooccurentQueryFilter), pProperties, null, null, null, null); |
| 963 |
if (!index.compute(monitor)) {
|
|
| 962 |
if (!index.compute(this.splitMonitor(10))) {
|
|
| 964 | 963 |
Log.severe("Cooccurrence internal Index compute failed. Aborting.");
|
| 965 | 964 |
return false; |
| 966 | 965 |
} |
| tmp/org.txm.properties.core/src/org/txm/properties/core/functions/Properties.java (revision 2602) | ||
|---|---|---|
| 294 | 294 |
|
| 295 | 295 |
@Override |
| 296 | 296 |
protected boolean _compute() throws Exception {
|
| 297 |
if (computer._compute(monitor)) {
|
|
| 297 |
if (computer._compute(this.splitMonitor(100))) {
|
|
| 298 | 298 |
|
| 299 | 299 |
String txmhome = Toolbox.getTxmHomePath(); |
| 300 | 300 |
String filename = computer.getName(); |
| tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 2602) | ||
|---|---|---|
| 164 | 164 |
public void _createPartControl() {
|
| 165 | 165 |
|
| 166 | 166 |
|
| 167 |
this.index = (Index) this.getResult();
|
|
| 167 |
this.index = this.getResult(); |
|
| 168 | 168 |
|
| 169 | 169 |
// Computing listeners |
| 170 | 170 |
ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this); |
| ... | ... | |
| 214 | 214 |
queryWidget.getQueryWidget().addModifyListener(computeKeyListener); |
| 215 | 215 |
|
| 216 | 216 |
// Word properties selector |
| 217 |
propertiesSelector = new PropertiesSelector<WordProperty>(this.getMainParametersComposite(), SWT.NONE);
|
|
| 217 |
propertiesSelector = new PropertiesSelector<>(this.getMainParametersComposite(), SWT.NONE); |
|
| 218 | 218 |
propertiesSelector.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false)); |
| 219 | 219 |
propertiesSelector.setLayout(new GridLayout(3, false)); |
| 220 | 220 |
try {
|
| ... | ... | |
| 484 | 484 |
lines = index.getLines(from, to); |
| 485 | 485 |
} |
| 486 | 486 |
else {
|
| 487 |
lines = new ArrayList<Line>();
|
|
| 487 |
lines = new ArrayList<>(); |
|
| 488 | 488 |
} |
| 489 | 489 |
|
| 490 | 490 |
navigationArea.setInfoLineText("" + (from + 1), //$NON-NLS-1$
|
| ... | ... | |
| 527 | 527 |
*/ |
| 528 | 528 |
@Override |
| 529 | 529 |
public void setFocus() {
|
| 530 |
super.setFocus(); |
|
| 530 | 531 |
if (this.queryWidget != null && !this.queryWidget.isDisposed()) {
|
| 531 | 532 |
this.queryWidget.setFocus(); |
| 532 | 533 |
} |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 2602) | ||
|---|---|---|
| 136 | 136 |
Log.fine(NLS.bind(SearchEngineCoreMessages.info_creatingNewPartition, this.getParent(), this.userName)); |
| 137 | 137 |
long start = System.currentTimeMillis(); |
| 138 | 138 |
|
| 139 |
this.subTask("Building parts...");
|
|
| 139 |
this.setTask("Building parts...");
|
|
| 140 | 140 |
|
| 141 | 141 |
for (int i = 0; i < pQueries.size(); i++) {
|
| 142 | 142 |
String queryS = pQueries.get(i); |
| ... | ... | |
| 150 | 150 |
} |
| 151 | 151 |
new Part(this, partName, queryS); |
| 152 | 152 |
|
| 153 |
this.worked(1); |
|
| 154 | 153 |
} |
| 155 | 154 |
long end = System.currentTimeMillis(); |
| 156 | 155 |
Log.fine(NLS.bind(SearchEngineCoreMessages.info_partitionCreatedInXMs, this.userName, (end - start))); |
| tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 2602) | ||
|---|---|---|
| 188 | 188 |
// parts lexicons |
| 189 | 189 |
List<CQPLexicon> partsLexicons = new ArrayList<>(); |
| 190 | 190 |
for (int i = 0; i < partition.getPartsCount(); i++) {
|
| 191 |
partsLexicons.add(CQPLexicon.getLexicon(partition.getParts().get(i), this.property, this.monitor, false));
|
|
| 191 |
partsLexicons.add(CQPLexicon.getLexicon(partition.getParts().get(i), this.property, this.splitMonitor(1), false));
|
|
| 192 | 192 |
} |
| 193 | 193 |
|
| 194 | 194 |
// Corpus global lexicon |
| 195 |
CQPLexicon corpusLexicon = CQPLexicon.getLexicon(partition.getParent(), this.property, this.monitor, false);
|
|
| 195 |
CQPLexicon corpusLexicon = CQPLexicon.getLexicon(partition.getParent(), this.property, this.splitMonitor(1), false);
|
|
| 196 | 196 |
|
| 197 | 197 |
ArrayList<String> filteredForms = new ArrayList<>(); |
| 198 | 198 |
// create a copy and filter line with Fmin; |
| ... | ... | |
| 351 | 351 |
|
| 352 | 352 |
Subcorpus subcorpus = (Subcorpus) this.parent; |
| 353 | 353 |
CQPCorpus parentCorpus = subcorpus.getCorpusParent(); |
| 354 |
CQPLexicon l1 = CQPLexicon.getLexicon(parentCorpus, this.property, this.monitor, false);
|
|
| 355 |
CQPLexicon l2 = CQPLexicon.getLexicon(subcorpus, this.property, this.monitor, false);
|
|
| 354 |
CQPLexicon l1 = CQPLexicon.getLexicon(parentCorpus, this.property, this.splitMonitor(20), false);
|
|
| 355 |
CQPLexicon l2 = CQPLexicon.getLexicon(subcorpus, this.property, this.splitMonitor(20), false);
|
|
| 356 | 356 |
|
| 357 | 357 |
this.statsData = new LexicalTableImpl(getNextName(), l1, l2); |
| 358 | 358 |
} |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/export/ExportResult.java (revision 2602) | ||
|---|---|---|
| 36 | 36 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 37 | 37 |
import org.eclipse.core.runtime.IStatus; |
| 38 | 38 |
import org.eclipse.core.runtime.Status; |
| 39 |
import org.eclipse.core.runtime.SubMonitor; |
|
| 39 | 40 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 40 | 41 |
import org.eclipse.osgi.util.NLS; |
| 41 | 42 |
import org.eclipse.swt.SWT; |
| ... | ... | |
| 51 | 52 |
import org.txm.rcp.messages.TXMUIMessages; |
| 52 | 53 |
import org.txm.rcp.swt.dialog.LastOpened; |
| 53 | 54 |
import org.txm.rcp.utils.JobHandler; |
| 55 |
|
|
| 54 | 56 |
/** |
| 55 | 57 |
* Exports a result by calling the function toTxt(File f) then opens or not the result in the text editor according to the preferences. |
| 58 |
* |
|
| 56 | 59 |
* @author mdecorde, sjacquot |
| 57 | 60 |
*/ |
| 58 | 61 |
public class ExportResult extends AbstractHandler {
|
| 59 |
|
|
| 62 |
|
|
| 60 | 63 |
private static final String ID = "org.txm.rcp.commands.function.ExportResult"; //$NON-NLS-1$ |
| 64 |
|
|
| 61 | 65 |
/** The selection. */ |
| 62 | 66 |
private IStructuredSelection selection; |
| 63 |
|
|
| 67 |
|
|
| 64 | 68 |
/** The lastopenedfile. */ |
| 65 |
//private static String lastopenedfile; |
|
| 66 |
|
|
| 69 |
// private static String lastopenedfile;
|
|
| 70 |
|
|
| 67 | 71 |
/** |
| 68 | 72 |
* Export a TXM result in a CSV file. |
| 69 | 73 |
* |
| ... | ... | |
| 76 | 80 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
| 77 | 81 |
final Object s = selection.getFirstElement(); |
| 78 | 82 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
| 79 |
|
|
| 80 |
//String txmhome = Toolbox.getTxmHomePath(); |
|
| 83 |
|
|
| 84 |
// String txmhome = Toolbox.getTxmHomePath();
|
|
| 81 | 85 |
FileDialog dialog = new FileDialog(shell, SWT.SAVE); |
| 82 |
|
|
| 83 |
String extensions[] = {"*.csv"}; //$NON-NLS-1$
|
|
| 86 |
|
|
| 87 |
String extensions[] = { "*.csv" }; //$NON-NLS-1$
|
|
| 84 | 88 |
if (s instanceof TXMResult) {
|
| 85 |
extensions = ((TXMResult)s).getExportTXTExtensions(); //$NON-NLS-1$
|
|
| 86 |
dialog.setFileName(((TXMResult)s).getValidFileName()); |
|
| 89 |
extensions = ((TXMResult) s).getExportTXTExtensions();
|
|
| 90 |
dialog.setFileName(((TXMResult) s).getValidFileName());
|
|
| 87 | 91 |
} |
| 88 | 92 |
dialog.setFilterExtensions(extensions); |
| 89 |
|
|
| 93 |
|
|
| 90 | 94 |
if (LastOpened.getFile(ID) != null) {
|
| 91 | 95 |
dialog.setFilterPath(LastOpened.getFolder(ID)); |
| 92 | 96 |
} |
| 93 |
|
|
| 97 |
|
|
| 94 | 98 |
if (dialog.open() != null) {
|
| 95 | 99 |
StatusLine.setMessage(TXMUIMessages.exportingResults); |
| 96 | 100 |
String filepath = dialog.getFilterPath() + "/" + dialog.getFileName(); //$NON-NLS-1$ |
| 97 | 101 |
if (!(filepath.endsWith(extensions[0].substring(1)))) |
| 98 | 102 |
filepath += extensions[0].substring(1); |
| 99 |
|
|
| 103 |
|
|
| 100 | 104 |
final File outfile = new File(filepath); |
| 101 | 105 |
LastOpened.set(ID, outfile.getParent(), outfile.getName()); |
| 102 | 106 |
try {
|
| 103 | 107 |
outfile.createNewFile(); |
| 104 |
} catch (IOException e1) {
|
|
| 108 |
} |
|
| 109 |
catch (IOException e1) {
|
|
| 105 | 110 |
System.err.println(NLS.bind(TXMUIMessages.exportColonCantCreateFileP0ColonP1, outfile, e1)); |
| 106 | 111 |
} |
| 107 | 112 |
if (!outfile.canWrite()) {
|
| ... | ... | |
| 112 | 117 |
System.out.println("Error: " + outfile + " is not a file"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 113 | 118 |
return null; |
| 114 | 119 |
} |
| 115 |
|
|
| 120 |
|
|
| 116 | 121 |
final String encoding = TBXPreferences.getInstance().getString(TBXPreferences.EXPORT_ENCODING); |
| 117 | 122 |
String _colseparator = TBXPreferences.getInstance().getString(TBXPreferences.EXPORT_COL_SEPARATOR); |
| 118 | 123 |
final String colseparator = _colseparator; |
| 119 | 124 |
String _txtseparator = TBXPreferences.getInstance().getString(TBXPreferences.EXPORT_TXT_SEPARATOR); |
| 120 | 125 |
final String txtseparator = _txtseparator; |
| 121 |
|
|
| 126 |
|
|
| 122 | 127 |
JobHandler jobhandler = new JobHandler(TXMUIMessages.exportingResults) {
|
| 128 |
|
|
| 123 | 129 |
@Override |
| 124 | 130 |
protected IStatus run(IProgressMonitor monitor) {
|
| 131 |
|
|
| 132 |
// convert the monitor into sub-monitor |
|
| 133 |
SubMonitor subMonitor = SubMonitor.convert(monitor, TXMUIMessages.exporting, 100); |
|
| 134 |
|
|
| 125 | 135 |
try {
|
| 126 |
this.runInit(monitor); |
|
| 127 |
monitor.beginTask(TXMUIMessages.exporting, 100);
|
|
| 128 |
|
|
| 136 |
|
|
| 137 |
this.runInit(subMonitor);
|
|
| 138 |
|
|
| 129 | 139 |
if (s instanceof TXMResult) {
|
| 130 |
TXMResult r = (TXMResult)s; |
|
| 140 |
TXMResult r = (TXMResult) s;
|
|
| 131 | 141 |
|
| 132 | 142 |
// compute the result if needed |
| 133 | 143 |
if (!r.isAltered()) {
|
| 134 | 144 |
r.compute(this); |
| 135 | 145 |
} |
| 136 | 146 |
|
| 137 |
r.setCurrentMonitor(this); // Allows Functions to protect themselves from interruption
|
|
| 147 |
r.setCurrentMonitor(subMonitor); // Allows Functions to protect themselves from interruption
|
|
| 138 | 148 |
r.toTxt(outfile, encoding, colseparator, txtseparator); |
| 139 |
} else {
|
|
| 149 |
} |
|
| 150 |
else {
|
|
| 140 | 151 |
System.out.println("Exported object is not a TXMResult result");
|
| 141 | 152 |
return Status.CANCEL_STATUS; |
| 142 | 153 |
} |
| 143 |
|
|
| 154 |
|
|
| 144 | 155 |
if (outfile.exists()) {
|
| 145 | 156 |
// Open internal editor in the UI thread |
| 146 |
if(TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPORT_SHOW)) {
|
|
| 157 |
if (TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPORT_SHOW)) {
|
|
| 147 | 158 |
this.syncExec(new Runnable() {
|
| 159 |
|
|
| 148 | 160 |
@Override |
| 149 | 161 |
public void run() {
|
| 150 | 162 |
EditFile.openfile(outfile.getAbsolutePath()); |
| 151 | 163 |
} |
| 152 | 164 |
}); |
| 153 | 165 |
} |
| 154 |
|
|
| 166 |
|
|
| 155 | 167 |
System.out.println(NLS.bind("", outfile.getAbsolutePath())); //$NON-NLS-1$
|
| 156 |
} else {
|
|
| 168 |
} |
|
| 169 |
else {
|
|
| 157 | 170 |
System.out.println(NLS.bind(TXMUIMessages.failedToExportResultP0ColonP1, outfile.getAbsolutePath())); |
| 158 | 171 |
} |
| 159 |
} catch (ThreadDeath td) {
|
|
| 172 |
} |
|
| 173 |
catch (ThreadDeath td) {
|
|
| 160 | 174 |
return Status.CANCEL_STATUS; |
| 161 |
} catch (Exception e) {
|
|
| 175 |
} |
|
| 176 |
catch (Exception e) {
|
|
| 162 | 177 |
System.out.println(NLS.bind(TXMUIMessages.failedToExportResultP0ColonP1, s, e)); |
| 163 | 178 |
org.txm.utils.logger.Log.printStackTrace(e); |
| 164 | 179 |
return Status.CANCEL_STATUS; |
| 165 |
} finally {
|
|
| 166 |
if (s instanceof TXMResult) |
|
| 167 |
((TXMResult)s).setCurrentMonitor(null); |
|
| 168 |
monitor.done(); |
|
| 180 |
} |
|
| 181 |
finally {
|
|
| 182 |
if (s instanceof TXMResult) {
|
|
| 183 |
((TXMResult) s).setCurrentMonitor(null); |
|
| 184 |
} |
|
| 185 |
subMonitor.done(); |
|
| 169 | 186 |
JobsTimer.stopAndPrint(); |
| 170 | 187 |
} |
| 171 | 188 |
return Status.OK_STATUS; |
| 172 | 189 |
} |
| 173 | 190 |
}; |
| 174 |
|
|
| 191 |
|
|
| 175 | 192 |
jobhandler.startJob(); |
| 176 | 193 |
} |
| 177 | 194 |
return null; |
| 178 | 195 |
} |
| 179 |
} |
|
| 196 |
} |
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/export/ExportResultParameters.java (revision 2602) | ||
|---|---|---|
| 36 | 36 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 37 | 37 |
import org.eclipse.core.runtime.IStatus; |
| 38 | 38 |
import org.eclipse.core.runtime.Status; |
| 39 |
import org.eclipse.core.runtime.SubMonitor; |
|
| 39 | 40 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 40 | 41 |
import org.eclipse.osgi.util.NLS; |
| 41 | 42 |
import org.eclipse.swt.SWT; |
| ... | ... | |
| 51 | 52 |
import org.txm.rcp.messages.TXMUIMessages; |
| 52 | 53 |
import org.txm.rcp.swt.dialog.LastOpened; |
| 53 | 54 |
import org.txm.rcp.utils.JobHandler; |
| 55 |
|
|
| 54 | 56 |
// TODO: Auto-generated Javadoc |
| 55 | 57 |
/** |
| 56 | 58 |
* export a result of a result by calling the function toTxt(File f) then show |
| 57 | 59 |
* the result in the text editor @ author mdecorde. |
| 58 | 60 |
*/ |
| 59 | 61 |
public class ExportResultParameters extends AbstractHandler {
|
| 60 |
|
|
| 62 |
|
|
| 61 | 63 |
private static final String ID = ExportResultParameters.class.getName(); |
| 62 |
|
|
| 64 |
|
|
| 63 | 65 |
/** |
| 64 | 66 |
* Export a TXM result parameters in the preferences format |
| 65 | 67 |
* |
| ... | ... | |
| 75 | 77 |
return null; |
| 76 | 78 |
} |
| 77 | 79 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
| 78 |
|
|
| 79 |
//String txmhome = Toolbox.getTxmHomePath(); |
|
| 80 |
|
|
| 81 |
// String txmhome = Toolbox.getTxmHomePath();
|
|
| 80 | 82 |
FileDialog dialog = new FileDialog(shell, SWT.SAVE); |
| 81 |
|
|
| 82 |
String extensions[] = {"*.parameters"}; //$NON-NLS-1$
|
|
| 83 |
|
|
| 84 |
String extensions[] = { "*.parameters" }; //$NON-NLS-1$
|
|
| 83 | 85 |
dialog.setFilterExtensions(extensions); |
| 84 |
dialog.setFileName(((TXMResult)s).getValidFileName()+".parameters");
|
|
| 86 |
dialog.setFileName(((TXMResult) s).getValidFileName() + ".parameters");
|
|
| 85 | 87 |
if (LastOpened.getFile(ID) != null) {
|
| 86 | 88 |
dialog.setFilterPath(LastOpened.getFolder(ID)); |
| 87 | 89 |
} |
| 88 |
|
|
| 90 |
|
|
| 89 | 91 |
if (dialog.open() != null) {
|
| 90 | 92 |
StatusLine.setMessage(TXMUIMessages.exportingResults); |
| 91 | 93 |
String filepath = dialog.getFilterPath() |
| 92 | 94 |
+ "/" + dialog.getFileName(); //$NON-NLS-1$ |
| 93 | 95 |
if (!(filepath.endsWith(extensions[0].substring(1)))) |
| 94 | 96 |
filepath += extensions[0].substring(1); |
| 95 |
|
|
| 97 |
|
|
| 96 | 98 |
final File outfile = new File(filepath); |
| 97 | 99 |
LastOpened.set(ID, outfile.getParent(), outfile.getName()); |
| 98 | 100 |
try {
|
| 99 | 101 |
outfile.createNewFile(); |
| 100 |
} catch (IOException e1) {
|
|
| 102 |
} |
|
| 103 |
catch (IOException e1) {
|
|
| 101 | 104 |
System.err.println(NLS.bind(TXMUIMessages.exportColonCantCreateFileP0ColonP1, outfile, e1)); |
| 102 | 105 |
} |
| 103 | 106 |
if (!outfile.canWrite()) {
|
| ... | ... | |
| 108 | 111 |
System.out.println("Error: " + outfile + " is not a file"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 109 | 112 |
return null; |
| 110 | 113 |
} |
| 111 |
|
|
| 114 |
|
|
| 112 | 115 |
JobHandler jobhandler = new JobHandler(TXMUIMessages.exportingResults) {
|
| 116 |
|
|
| 113 | 117 |
@Override |
| 114 | 118 |
protected IStatus run(IProgressMonitor monitor) {
|
| 119 |
|
|
| 120 |
// convert the monitor into sub-monitor |
|
| 121 |
SubMonitor subMonitor = SubMonitor.convert(monitor, TXMUIMessages.exporting, 100); |
|
| 122 |
|
|
| 115 | 123 |
try {
|
| 116 |
this.runInit(monitor); |
|
| 117 |
monitor.beginTask(TXMUIMessages.exporting, 100); |
|
| 118 |
|
|
| 119 |
TXMResult r = (TXMResult)s; |
|
| 120 |
if (r.isAltered()) {
|
|
| 121 |
System.out.println("Warning: only parameters are exported, manual changes are not transfered.");
|
|
| 122 |
} else {
|
|
| 123 |
r.compute(this); // refresh result |
|
| 124 |
} |
|
| 125 |
r.setCurrentMonitor(this); // Allows Functions to protect themselves from interruption |
|
| 126 |
if (r.toParametersFile(outfile)) {
|
|
| 127 |
System.out.println(NLS.bind("Parameters exported to the {0} file.", outfile));
|
|
| 128 |
} |
|
| 129 |
|
|
| 124 |
|
|
| 125 |
this.runInit(subMonitor); |
|
| 126 |
|
|
| 127 |
TXMResult r = (TXMResult) s; |
|
| 128 |
if (r.isAltered()) {
|
|
| 129 |
System.out.println("Warning: only parameters are exported, manual changes are not transfered.");
|
|
| 130 |
} |
|
| 131 |
else {
|
|
| 132 |
r.compute(subMonitor); // refresh result |
|
| 133 |
} |
|
| 134 |
r.setCurrentMonitor(subMonitor); // Allows Functions to protect themselves from interruption |
|
| 135 |
if (r.toParametersFile(outfile)) {
|
|
| 136 |
System.out.println(NLS.bind("Parameters exported to the {0} file.", outfile));
|
|
| 137 |
} |
|
| 138 |
|
|
| 130 | 139 |
if (outfile.exists()) {
|
| 131 | 140 |
// Open internal editor in the UI thread |
| 132 |
if(TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPORT_SHOW)) {
|
|
| 141 |
if (TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPORT_SHOW)) {
|
|
| 133 | 142 |
this.syncExec(new Runnable() {
|
| 143 |
|
|
| 134 | 144 |
@Override |
| 135 | 145 |
public void run() {
|
| 136 | 146 |
EditFile.openfile(outfile.getAbsolutePath()); |
| 137 | 147 |
} |
| 138 | 148 |
}); |
| 139 | 149 |
} |
| 140 |
|
|
| 150 |
|
|
| 141 | 151 |
System.out.println(NLS.bind("", outfile.getAbsolutePath())); //$NON-NLS-1$
|
| 142 |
} else {
|
|
| 152 |
} |
|
| 153 |
else {
|
|
| 143 | 154 |
System.out.println(NLS.bind(TXMUIMessages.failedToExportResultP0ColonP1, outfile.getAbsolutePath())); |
| 144 | 155 |
} |
| 145 |
} catch (ThreadDeath td) {
|
|
| 146 |
if (s instanceof TXMResult) |
|
| 147 |
((TXMResult)s).clean(); |
|
| 156 |
} |
|
| 157 |
catch (ThreadDeath td) {
|
|
| 158 |
if (s instanceof TXMResult) {
|
|
| 159 |
((TXMResult) s).clean(); |
|
| 160 |
} |
|
| 148 | 161 |
return Status.CANCEL_STATUS; |
| 149 |
} catch (Exception e) {
|
|
| 162 |
} |
|
| 163 |
catch (Exception e) {
|
|
| 150 | 164 |
System.out.println(NLS.bind(TXMUIMessages.failedToExportResultP0ColonP1, s, e)); |
| 151 | 165 |
org.txm.utils.logger.Log.printStackTrace(e); |
| 152 | 166 |
return Status.CANCEL_STATUS; |
| 153 |
} finally {
|
|
| 154 |
if (s instanceof TXMResult) |
|
| 155 |
((TXMResult)s).setCurrentMonitor(null); |
|
| 156 |
monitor.done(); |
|
| 167 |
} |
|
| 168 |
finally {
|
|
| 169 |
if (s instanceof TXMResult) {
|
|
| 170 |
((TXMResult) s).setCurrentMonitor(null); |
|
| 171 |
} |
|
| 172 |
subMonitor.done(); |
|
| 157 | 173 |
JobsTimer.stopAndPrint(); |
| 158 | 174 |
} |
| 159 | 175 |
return Status.OK_STATUS; |
| 160 | 176 |
} |
| 161 | 177 |
}; |
| 162 |
|
|
| 178 |
|
|
| 163 | 179 |
jobhandler.startJob(); |
| 164 | 180 |
} |
| 165 | 181 |
return null; |
| 166 | 182 |
} |
| 167 |
} |
|
| 183 |
} |
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/UpdateCorpus.java (revision 2602) | ||
|---|---|---|
| 6 | 6 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 7 | 7 |
import org.eclipse.core.runtime.IStatus; |
| 8 | 8 |
import org.eclipse.core.runtime.Status; |
| 9 |
import org.eclipse.core.runtime.SubMonitor; |
|
| 9 | 10 |
import org.eclipse.jface.viewers.ISelection; |
| 10 | 11 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 11 | 12 |
import org.eclipse.osgi.util.NLS; |
| ... | ... | |
| 87 | 88 |
|
| 88 | 89 |
@Override |
| 89 | 90 |
protected IStatus run(IProgressMonitor monitor) {
|
| 90 |
project.setCurrentMonitor(monitor);
|
|
| 91 |
project.setCurrentMonitor(SubMonitor.convert(monitor));
|
|
| 91 | 92 |
try {
|
| 92 | 93 |
if (project.compute(true)) { // TODO children should be recomputed later when the user needs it
|
| 93 | 94 |
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 2602) | ||
|---|---|---|
| 17 | 17 |
import org.eclipse.core.runtime.Platform; |
| 18 | 18 |
import org.eclipse.core.runtime.SafeRunner; |
| 19 | 19 |
import org.eclipse.core.runtime.Status; |
| 20 |
import org.eclipse.core.runtime.SubMonitor; |
|
| 20 | 21 |
import org.eclipse.core.runtime.jobs.Job; |
| 21 | 22 |
import org.eclipse.jface.action.MenuManager; |
| 22 | 23 |
import org.eclipse.jface.dialogs.MessageDialog; |
| ... | ... | |
| 39 | 40 |
import org.eclipse.swt.widgets.Display; |
| 40 | 41 |
import org.eclipse.swt.widgets.Group; |
| 41 | 42 |
import org.eclipse.swt.widgets.Menu; |
| 42 |
import org.eclipse.swt.widgets.ProgressBar; |
|
| 43 | 43 |
import org.eclipse.swt.widgets.Shell; |
| 44 | 44 |
import org.eclipse.swt.widgets.Spinner; |
| 45 | 45 |
import org.eclipse.swt.widgets.Table; |
| ... | ... | |
| 758 | 758 |
@Override |
| 759 | 759 |
public void setFocus() {
|
| 760 | 760 |
|
| 761 |
this.parent.setFocus(); |
|
| 761 | 762 |
// this.resultArea.setFocus(); |
| 762 | 763 |
// FIXME SJ: this code leads to a bug, the focus must not be regiven to the main parameter after each computing of all result editors |
| 763 | 764 |
// if (mainParametersComposite != null && !mainParametersComposite.isDisposed()) {
|
| ... | ... | |
| 881 | 882 |
// FIXME: SJ: tests to hide/display the result area while computing |
| 882 | 883 |
// this.resultArea.setVisible(false); |
| 883 | 884 |
|
| 884 |
this.computingJob = new JobHandler(TXMCoreMessages.bind(TXMUIMessages.computing, this.getResult().getName())) {
|
|
| 885 |
this.computingJob = new JobHandler(this.getResult().getComputingStartMessage()) {
|
|
| 885 | 886 |
|
| 886 | 887 |
@Override |
| 887 | 888 |
protected IStatus run(IProgressMonitor monitor) {
|
| 888 | 889 |
|
| 889 |
// monitor.beginTask("long process simulation test", 10);
|
|
| 890 |
// for (int i = 0; i < 12; i++) {
|
|
| 891 |
// try {
|
|
| 892 |
// Thread.sleep(25); |
|
| 893 |
// } |
|
| 894 |
// catch (InterruptedException e) {
|
|
| 895 |
// // TODO Auto-generated catch block |
|
| 896 |
// e.printStackTrace(); |
|
| 897 |
// } |
|
| 898 |
// monitor.worked(1); |
|
| 899 |
// } |
|
| 890 |
// convert the monitor into sub-monitor |
|
| 891 |
SubMonitor subMonitor = SubMonitor.convert(monitor); |
|
| 900 | 892 |
|
| 901 |
this.runInit(monitor);
|
|
| 893 |
this.runInit(subMonitor);
|
|
| 902 | 894 |
|
| 903 | 895 |
if (isLocked()) {
|
| 904 | 896 |
return Status.CANCEL_STATUS; |
| ... | ... | |
| 907 | 899 |
try {
|
| 908 | 900 |
JobsTimer.start(); |
| 909 | 901 |
|
| 910 |
// FIXME: SJ: tests |
|
| 911 |
// showBusy(true); |
|
| 912 |
|
|
| 902 |
// update the TXMResult data from Editor fields |
|
| 913 | 903 |
this.syncExec(new Runnable() {
|
| 914 | 904 |
|
| 915 | 905 |
@Override |
| ... | ... | |
| 968 | 958 |
return Status.CANCEL_STATUS; |
| 969 | 959 |
} |
| 970 | 960 |
|
| 971 |
// computing result
|
|
| 972 |
monitor.beginTask(TXMEditor.this.getResult().getComputingStartMessage(), 100);
|
|
| 961 |
// compute result
|
|
| 962 |
subMonitor.beginTask(TXMEditor.this.getResult().getComputingStartMessage(), 100);
|
|
| 973 | 963 |
|
| 974 | 964 |
notifyExtensions("notifyStartOfCompute"); //$NON-NLS-1$
|
| 975 | 965 |
|
| 976 |
if (!TXMEditor.this.getResult().compute(monitor)) {
|
|
| 966 |
if (!TXMEditor.this.getResult().compute(subMonitor.split(50))) {
|
|
| 977 | 967 |
Log.fine("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": computing failed.");
|
| 978 | 968 |
} |
| 979 | 969 |
|
| 980 | 970 |
notifyExtensions("notifyEndOfCompute"); //$NON-NLS-1$
|
| 981 | 971 |
|
| 982 |
monitor.worked(50); |
|
| 972 |
// monitor.worked(50);
|
|
| 983 | 973 |
|
| 984 |
// refreshing the UI
|
|
| 974 |
// refresh the UI (especially update the Editor fields from the TXMResult data
|
|
| 985 | 975 |
this.syncExec(new Runnable() {
|
| 986 | 976 |
|
| 987 | 977 |
@Override |
| ... | ... | |
| 1018 | 1008 |
Log.printStackTrace(e); |
| 1019 | 1009 |
} |
| 1020 | 1010 |
finally {
|
| 1021 |
monitor.done();
|
|
| 1011 |
subMonitor.done();
|
|
| 1022 | 1012 |
JobsTimer.stopAndPrint(); |
| 1023 | 1013 |
} |
| 1024 | 1014 |
return Status.OK_STATUS; |
| ... | ... | |
| 1058 | 1048 |
IWorkbenchWindow window = TXMWindows.getActiveWindow(); |
| 1059 | 1049 |
IWorkbenchPage page = window.getActivePage(); |
| 1060 | 1050 |
try {
|
| 1051 |
|
|
| 1052 |
// boolean wasAlreadyOpened = true; |
|
| 1061 | 1053 |
boolean wasAlreadyOpened = SWTEditorsUtils.isOpenEditor(editorInput, editorId); |
| 1062 | 1054 |
// TODO pre-compute result ? |
| 1063 | 1055 |
// if (!wasAlreadyOpened && (RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_COMPUTE_ON_EDITOR_OPEN))) {
|
| ... | ... | |
| 1068 | 1060 |
// since some editor fields need some values of their parent, |
| 1069 | 1061 |
// ensure the parents branch is ready (e.g. Sub-corpus properties in Cooccurrence editor, etc.) |
| 1070 | 1062 |
// show modal blocking cancelable progression dialog |
| 1071 |
if (!wasAlreadyOpened) {
|
|
| 1063 |
if (!wasAlreadyOpened && !editorInput.getResult().getParent().hasBeenComputedOnce()) {
|
|
| 1072 | 1064 |
try {
|
| 1073 |
if (!editorInput.getResult().getParent().hasBeenComputedOnce()) {
|
|
| 1074 |
AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(window.getShell(), editorInput.getResult().getParent()); |
|
| 1075 |
dialog.runComputingProcess(true); |
|
| 1076 |
} |
|
| 1065 |
// AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(window.getShell(), editorInput.getResult().getParent()); |
|
| 1066 |
// FIXME: SJ: finally it may be better to call the current result computing? it will do the parents branch computing but |
|
| 1067 |
// the main task stays the compute of the result itself, not the parent |
|
| 1068 |
AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(window.getShell(), editorInput.getResult()); |
|
| 1069 |
dialog.runComputingProcess(true); |
|
| 1077 | 1070 |
} |
| 1078 |
// Canceling
|
|
| 1071 |
// user canceling case
|
|
| 1079 | 1072 |
catch (InterruptedException e) {
|
| 1080 |
|
|
| 1081 | 1073 |
CorporaView.refresh(); |
| 1082 |
|
|
| 1083 | 1074 |
return null; |
| 1084 | 1075 |
} |
| 1085 | 1076 |
} |
| 1086 | 1077 |
|
| 1087 | 1078 |
|
| 1088 | 1079 |
// opening the editor |
| 1089 |
IEditorPart e = page.openEditor(editorInput, editorId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID); |
|
| 1090 |
if (e instanceof TXMEditor) {
|
|
| 1091 |
editor = (TXMEditor<? extends TXMResult>) e; |
|
| 1080 |
IEditorPart tmpEditor = page.openEditor(editorInput, editorId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID); |
|
Formats disponibles : Unified diff