Révision 2567
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 2567) | ||
---|---|---|
2331 | 2331 |
|
2332 | 2332 |
// skip the process if the result is already in computing stage |
2333 | 2333 |
if (this.computing) { |
2334 |
|
|
2335 |
Log.finest(NLS.bind("TXMResult.compute(): {0}: The result is already computing, compute process aborted.", this.getClass().getSimpleName())); // $NON-NLS-1$ |
|
2336 |
|
|
2334 | 2337 |
return true; |
2335 | 2338 |
} |
2336 | 2339 |
|
... | ... | |
2339 | 2342 |
|
2340 | 2343 |
// no changes to do |
2341 | 2344 |
// FIXME: SJ: we need to do do some actions even if the object is locked, eg. updating parameters, saving parameters, etc. |
2342 |
// FIXME MD: nope the parameters must not move and will be saved in the current state |
|
2345 |
// FIXME: MD: nope the parameters must not move and will be saved in the current state
|
|
2343 | 2346 |
if (this.hasBeenComputedOnce && this.locked) { |
2344 | 2347 |
this.computing = false; |
2345 | 2348 |
return true; |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java (revision 2567) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.searchengine.cqp.rcp.handlers.base; |
29 | 29 |
|
30 |
import org.eclipse.core.commands.AbstractHandler; |
|
30 |
import java.lang.reflect.InvocationTargetException; |
|
31 |
|
|
31 | 32 |
import org.eclipse.core.commands.ExecutionEvent; |
32 | 33 |
import org.eclipse.core.commands.ExecutionException; |
33 | 34 |
import org.eclipse.core.runtime.IProgressMonitor; |
... | ... | |
41 | 42 |
import org.txm.rcp.JobsTimer; |
42 | 43 |
import org.txm.rcp.actions.CreateSubcorpusDialog; |
43 | 44 |
import org.txm.rcp.editors.TXMEditor; |
45 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
44 | 46 |
import org.txm.rcp.messages.TXMUIMessages; |
47 |
import org.txm.rcp.swt.dialog.AdvancedProgressMonitorDialog; |
|
45 | 48 |
import org.txm.rcp.utils.JobHandler; |
46 | 49 |
import org.txm.rcp.views.corpora.CorporaView; |
47 | 50 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
... | ... | |
55 | 58 |
import org.txm.utils.logger.Log; |
56 | 59 |
|
57 | 60 |
/** |
58 |
* Command which creates a subcorpus from a Corpus @ author mdecorde. |
|
61 |
* Command which creates a subcorpus from a Corpus |
|
62 |
* |
|
63 |
* @author mdecorde |
|
64 |
* @author sjacquot |
|
65 |
* |
|
59 | 66 |
*/ |
60 |
public class ComputeSubCorpus extends AbstractHandler { |
|
67 |
public class ComputeSubCorpus extends BaseAbstractHandler {
|
|
61 | 68 |
|
62 |
/** The selection. */ |
|
63 |
private IStructuredSelection selection; |
|
64 | 69 |
|
65 | 70 |
/* |
66 | 71 |
* (non-Javadoc) |
... | ... | |
68 | 73 |
*/ |
69 | 74 |
@Override |
70 | 75 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
76 |
|
|
77 |
// FIXME: SJ: tests of MD for using a TXMEditor rather than a dialog box to manage sub-corpus creation and edition |
|
71 | 78 |
if (SubcorpusPreferences.getInstance().getBoolean(SubcorpusPreferences.EDITORMODE)) { |
72 | 79 |
return execute_editor(event); |
73 |
} else { |
|
80 |
} |
|
81 |
// original code that uses a dialog box |
|
82 |
else { |
|
83 |
|
|
84 |
// since some widgets fields need some values of parents branch, |
|
85 |
// ensure the parents branch is ready |
|
86 |
// show modal blocking cancelable progression dialog |
|
87 |
try { |
|
88 |
|
|
89 |
Object selection = this.getCorporaViewSelectedObject(event); |
|
90 |
|
|
91 |
if (selection instanceof CQPCorpus) { |
|
92 |
CQPCorpus corpus = (CQPCorpus) selection; |
|
93 |
if (!corpus.hasBeenComputedOnce()) { |
|
94 |
|
|
95 |
AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), corpus); |
|
96 |
dialog.runComputingProcess(true); |
|
97 |
|
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
} |
|
102 |
// Canceling or error |
|
103 |
catch (InterruptedException | InvocationTargetException e) { |
|
104 |
CorporaView.refresh(); |
|
105 |
return null; |
|
106 |
} |
|
107 |
|
|
108 |
|
|
74 | 109 |
return execute_dialog(event); |
75 | 110 |
} |
76 | 111 |
} |
77 | 112 |
|
113 |
|
|
78 | 114 |
public Object execute_editor(ExecutionEvent event) throws ExecutionException { |
79 | 115 |
|
80 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
116 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
|
|
81 | 117 |
if (selection == null) { |
82 | 118 |
System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor()); |
83 | 119 |
return null; |
... | ... | |
90 | 126 |
if (firstElement instanceof CQPCorpus) { |
91 | 127 |
if (firstElement instanceof Subcorpus && "true".equals(edit)) { |
92 | 128 |
sub = (Subcorpus) firstElement; |
93 |
} else { |
|
94 |
sub = new Subcorpus((CQPCorpus)firstElement); |
|
95 | 129 |
} |
130 |
else { |
|
131 |
sub = new Subcorpus((CQPCorpus) firstElement); |
|
132 |
} |
|
96 | 133 |
} |
97 |
return TXMEditor.openEditor(sub , SubcorpusEditor.class.getName());
|
|
134 |
return TXMEditor.openEditor(sub, SubcorpusEditor.class.getName()); |
|
98 | 135 |
} |
99 | 136 |
|
100 | 137 |
/* |
... | ... | |
103 | 140 |
*/ |
104 | 141 |
public Object execute_dialog(ExecutionEvent event) throws ExecutionException { |
105 | 142 |
|
106 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
143 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
|
|
107 | 144 |
if (selection == null) { |
108 | 145 |
System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor()); |
109 | 146 |
return null; |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputePartition.java (revision 2567) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.searchengine.cqp.rcp.handlers.base; |
29 | 29 |
|
30 |
import java.lang.reflect.InvocationTargetException; |
|
30 | 31 |
import java.util.ArrayList; |
31 |
import java.util.List; |
|
32 | 32 |
|
33 |
import org.eclipse.core.commands.AbstractHandler; |
|
34 | 33 |
import org.eclipse.core.commands.ExecutionEvent; |
35 | 34 |
import org.eclipse.core.commands.ExecutionException; |
36 | 35 |
import org.eclipse.core.runtime.IProgressMonitor; |
... | ... | |
40 | 39 |
import org.eclipse.jface.window.Window; |
41 | 40 |
import org.eclipse.osgi.util.NLS; |
42 | 41 |
import org.eclipse.swt.widgets.Shell; |
43 |
import org.eclipse.ui.IWorkbenchWindow; |
|
44 | 42 |
import org.eclipse.ui.handlers.HandlerUtil; |
45 | 43 |
import org.txm.rcp.JobsTimer; |
46 | 44 |
import org.txm.rcp.actions.CreatePartitionDialog; |
47 | 45 |
import org.txm.rcp.editors.TXMEditor; |
46 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
48 | 47 |
import org.txm.rcp.messages.TXMUIMessages; |
48 |
import org.txm.rcp.swt.dialog.AdvancedProgressMonitorDialog; |
|
49 | 49 |
import org.txm.rcp.utils.JobHandler; |
50 | 50 |
import org.txm.rcp.views.corpora.CorporaView; |
51 | 51 |
import org.txm.searchengine.cqp.core.preferences.PartitionPreferences; |
52 | 52 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
53 | 53 |
import org.txm.searchengine.cqp.corpus.Part; |
54 | 54 |
import org.txm.searchengine.cqp.corpus.Partition; |
55 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
56 | 55 |
import org.txm.searchengine.cqp.rcp.editor.PartitionEditor; |
57 |
import org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor; |
|
58 | 56 |
import org.txm.utils.logger.Log; |
59 | 57 |
|
60 | 58 |
/** |
61 | 59 |
* Command which creates a Partition from a Corpus. |
62 | 60 |
* |
63 | 61 |
* @author mdecorde |
62 |
* @author sjacquot |
|
64 | 63 |
*/ |
65 |
public class ComputePartition extends AbstractHandler { |
|
64 |
public class ComputePartition extends BaseAbstractHandler {
|
|
66 | 65 |
|
67 |
/** The window. */ |
|
68 |
private IWorkbenchWindow window; |
|
69 | 66 |
|
70 |
/** The selection. */ |
|
71 |
private IStructuredSelection selection; |
|
72 |
|
|
73 | 67 |
/* |
74 | 68 |
* (non-Javadoc) |
75 | 69 |
* @see |
... | ... | |
78 | 72 |
*/ |
79 | 73 |
@Override |
80 | 74 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
75 |
|
|
76 |
// FIXME: SJ: tests of MD for using a TXMEditor rather than a dialog box to manage partitions creation and edition |
|
81 | 77 |
if (PartitionPreferences.getInstance().getBoolean(PartitionPreferences.EDITORMODE)) { |
82 | 78 |
return execute_editor(event); |
83 |
} else { |
|
79 |
} |
|
80 |
// original code that uses a dialog box |
|
81 |
else { |
|
82 |
// since some widgets fields need some values of parents branch, |
|
83 |
// ensure the parents branch is ready |
|
84 |
// show modal blocking cancelable progression dialog |
|
85 |
try { |
|
86 |
|
|
87 |
Object selection = this.getCorporaViewSelectedObject(event); |
|
88 |
|
|
89 |
if (selection instanceof CQPCorpus) { |
|
90 |
CQPCorpus corpus = (CQPCorpus) selection; |
|
91 |
if (!corpus.hasBeenComputedOnce()) { |
|
92 |
|
|
93 |
AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), corpus); |
|
94 |
dialog.runComputingProcess(true); |
|
95 |
|
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
} |
|
100 |
// Canceling or error |
|
101 |
catch (InterruptedException | InvocationTargetException e) { |
|
102 |
CorporaView.refresh(); |
|
103 |
return null; |
|
104 |
} |
|
105 |
|
|
84 | 106 |
return execute_dialog(event); |
85 | 107 |
} |
86 | 108 |
} |
87 | 109 |
|
88 |
/* |
|
89 |
* (non-Javadoc)
|
|
90 |
* @see
|
|
91 |
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
|
|
92 |
* .ExecutionEvent)
|
|
110 |
/**
|
|
111 |
* |
|
112 |
* @param event
|
|
113 |
* @return
|
|
114 |
* @throws ExecutionException
|
|
93 | 115 |
*/ |
94 | 116 |
public Object execute_editor(ExecutionEvent event) throws ExecutionException { |
95 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
117 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
|
|
96 | 118 |
if (selection == null) { |
97 | 119 |
System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor()); |
98 | 120 |
return null; |
... | ... | |
100 | 122 |
Object firstElement = selection.getFirstElement(); |
101 | 123 |
Partition part = null; |
102 | 124 |
if (firstElement instanceof CQPCorpus) { |
103 |
part = new Partition((CQPCorpus)firstElement); |
|
125 |
part = new Partition((CQPCorpus) firstElement);
|
|
104 | 126 |
part.setParameters("", new ArrayList<String>(), new ArrayList<String>()); |
105 |
} else if (firstElement instanceof Partition) { |
|
106 |
part = (Partition)firstElement; |
|
107 | 127 |
} |
108 |
return TXMEditor.openEditor(part , PartitionEditor.class.getName()); |
|
128 |
else if (firstElement instanceof Partition) { |
|
129 |
part = (Partition) firstElement; |
|
130 |
} |
|
131 |
return TXMEditor.openEditor(part, PartitionEditor.class.getName()); |
|
109 | 132 |
} |
110 |
/* |
|
111 |
* (non-Javadoc) |
|
112 |
* @see |
|
113 |
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands |
|
114 |
* .ExecutionEvent) |
|
133 |
|
|
134 |
/** |
|
135 |
* |
|
136 |
* @param event |
|
137 |
* @return |
|
138 |
* @throws ExecutionException |
|
115 | 139 |
*/ |
116 | 140 |
public Object execute_dialog(ExecutionEvent event) throws ExecutionException { |
117 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
141 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
|
|
118 | 142 |
|
119 | 143 |
final CQPCorpus corpus = (CQPCorpus) selection.getFirstElement(); |
120 | 144 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 2567) | ||
---|---|---|
394 | 394 |
try { |
395 | 395 |
|
396 | 396 |
// since some editor fields need some values of their parent, |
397 |
// ensure the parent is ready (e.g. Sub-corpus properties in Cooccurrence editor, etc.) |
|
397 |
// ensure the parents branch is ready (e.g. Sub-corpus properties in Cooccurrence editor, etc.)
|
|
398 | 398 |
// show modal blocking cancelable progression dialog |
399 | 399 |
try { |
400 | 400 |
if (!this.getResult().getParent().hasBeenComputedOnce()) { |
401 |
|
|
402 |
IRunnableWithProgress runnable = new IRunnableWithProgress() { |
|
403 |
|
|
404 |
@Override |
|
405 |
public void run(IProgressMonitor monitor) throws InterruptedException { |
|
406 |
TXMEditor.this.getResult().getParent().compute(monitor, false); |
|
407 |
} |
|
408 |
}; |
|
409 |
|
|
410 | 401 |
AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(this.getSite().getShell(), TXMEditor.this.getResult().getParent()); |
411 |
dialog.run(true, runnable); |
|
412 |
|
|
413 |
|
|
402 |
dialog.runComputingProcess(true); |
|
414 | 403 |
} |
415 | 404 |
} |
416 | 405 |
// Canceling |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/AdvancedProgressMonitorDialog.java (revision 2567) | ||
---|---|---|
4 | 4 |
import java.util.Timer; |
5 | 5 |
import java.util.TimerTask; |
6 | 6 |
|
7 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
7 | 8 |
import org.eclipse.jface.dialogs.ProgressMonitorDialog; |
8 | 9 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
9 | 10 |
import org.eclipse.swt.widgets.Display; |
10 | 11 |
import org.eclipse.swt.widgets.Shell; |
11 | 12 |
import org.txm.core.results.TXMResult; |
13 |
import org.txm.rcp.editors.TXMEditor; |
|
12 | 14 |
|
13 | 15 |
/** |
14 | 16 |
* An advanced progress monitor modal dialog managing delay before displaying and the force of cancel using Thread.stop(). |
... | ... | |
53 | 55 |
|
54 | 56 |
|
55 | 57 |
/** |
58 |
* Runs the computing process on the stored <code>TXMResult</code>. |
|
59 |
* |
|
60 |
* @param cancelable |
|
61 |
* @throws InvocationTargetException |
|
62 |
* @throws InterruptedException |
|
63 |
*/ |
|
64 |
public void runComputingProcess(boolean cancelable) throws InvocationTargetException, InterruptedException { |
|
65 |
|
|
66 |
IRunnableWithProgress runnable = new IRunnableWithProgress() { |
|
67 |
|
|
68 |
@Override |
|
69 |
public void run(IProgressMonitor monitor) throws InterruptedException { |
|
70 |
result.compute(monitor, false); |
|
71 |
} |
|
72 |
}; |
|
73 |
|
|
74 |
this.run(cancelable, runnable); |
|
75 |
} |
|
76 |
|
|
77 |
|
|
78 |
/** |
|
56 | 79 |
* Runs the given <code>IRunnableWithProgress</code>. |
57 | 80 |
* |
58 | 81 |
* @param cancelable |
Formats disponibles : Unified diff