Révision 2648
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 2648) | ||
---|---|---|
72 | 72 |
import org.txm.rcp.messages.TXMUIMessages; |
73 | 73 |
import org.txm.rcp.preferences.RCPPreferences; |
74 | 74 |
import org.txm.rcp.swt.GLComposite; |
75 |
import org.txm.rcp.swt.dialog.AdvancedProgressMonitorDialog;
|
|
75 |
import org.txm.rcp.swt.dialog.ComputeProgressMonitorDialog;
|
|
76 | 76 |
import org.txm.rcp.swt.widget.AssistedChoiceQueryWidget; |
77 | 77 |
import org.txm.rcp.swt.widget.AssistedQueryWidget; |
78 | 78 |
import org.txm.rcp.swt.widget.FloatSpinner; |
... | ... | |
1058 | 1058 |
|
1059 | 1059 |
// FIXME: SJ: Quick'n'dirty fix |
1060 | 1060 |
// without that the result is computed twice, one time when checking the branch is consistent |
1061 |
// and another time when calling ediot.compute().
|
|
1061 |
// and another time when calling editor.compute().
|
|
1062 | 1062 |
// See if we can do this directly in the editor ? |
1063 | 1063 |
// or pre-compute only the parents and not the result iself ? |
1064 |
boolean needComputing = true; |
|
1064 |
// boolean needComputing = true;
|
|
1065 | 1065 |
|
1066 | 1066 |
// since some editor fields need some values of their parent, |
1067 | 1067 |
// ensure the parents branch is ready (e.g. Sub-corpus properties in Cooccurrence editor, etc.) |
1068 | 1068 |
// show modal blocking cancelable progression dialog |
1069 |
if (!wasAlreadyOpened && !editorInput.getResult().getParent().hasBeenComputedOnce()) { |
|
1069 |
if (!wasAlreadyOpened |
|
1070 |
// && !editorInput.getResult().getParent().hasBeenComputedOnce() |
|
1071 |
) { |
|
1070 | 1072 |
try { |
1071 | 1073 |
// AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(window.getShell(), editorInput.getResult().getParent()); |
1072 | 1074 |
// FIXME: SJ: finally it may be better to call the current result computing? it will do the parents branch computing but |
1073 | 1075 |
// the main task stays the compute of the result itself, not the parent |
1074 |
AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(window.getShell(), editorInput.getResult());
|
|
1076 |
ComputeProgressMonitorDialog dialog = new ComputeProgressMonitorDialog(window.getShell(), editorInput.getResult());
|
|
1075 | 1077 |
dialog.runComputingProcess(true); |
1076 | 1078 |
|
1077 |
needComputing = false; |
|
1079 |
// needComputing = false;
|
|
1078 | 1080 |
} |
1079 | 1081 |
// user canceling case |
1080 | 1082 |
catch (InterruptedException e) { |
... | ... | |
1089 | 1091 |
if (tmpEditor instanceof TXMEditor) { |
1090 | 1092 |
editor = (TXMEditor<? extends TXMResult>) tmpEditor; |
1091 | 1093 |
} |
1094 |
else if (tmpEditor instanceof TXMMultiPageEditor) { |
|
1095 |
editor = (TXMEditor<? extends TXMResult>) ((TXMMultiPageEditor) tmpEditor).getMainEditorPart(); |
|
1096 |
} |
|
1092 | 1097 |
else { |
1098 |
Log.severe(NLS.bind("Failed to open editor {0}.", editorId)); // $NON-NLS-1$ |
|
1093 | 1099 |
return null; |
1094 | 1100 |
} |
1095 | 1101 |
|
1096 |
if (wasAlreadyOpened) { |
|
1102 |
if (!wasAlreadyOpened) {
|
|
1097 | 1103 |
|
1098 |
} |
|
1099 |
else { |
|
1104 |
// }
|
|
1105 |
// else {
|
|
1100 | 1106 |
// TODO until the TXMResult don't know if its parameters are set by the user or by the default preference value, we need to use the AUTO_COMPUTE_ON_EDITOR_OPEN preference |
1101 | 1107 |
// compute the result only if the editor wasn't already opened |
1102 |
if (needComputing && (RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_COMPUTE_ON_EDITOR_OPEN))) { |
|
1103 |
editor.compute(false); |
|
1104 |
} |
|
1105 |
else { |
|
1106 |
editor.refresh(false); |
|
1107 |
} |
|
1108 |
// if (//needComputing && |
|
1109 |
// (RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_COMPUTE_ON_EDITOR_OPEN))) { |
|
1110 |
// editor.compute(false); |
|
1111 |
// } |
|
1112 |
// else { |
|
1113 |
editor.refresh(false); |
|
1114 |
// } |
|
1108 | 1115 |
} |
1109 | 1116 |
} |
1110 | 1117 |
catch (Exception e) { |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/AdvancedProgressMonitorDialog.java (revision 2648) | ||
---|---|---|
1 |
package org.txm.rcp.swt.dialog; |
|
2 |
|
|
3 |
import java.lang.reflect.InvocationTargetException; |
|
4 |
import java.util.Timer; |
|
5 |
import java.util.TimerTask; |
|
6 |
|
|
7 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
8 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
|
9 |
import org.eclipse.swt.widgets.Composite; |
|
10 |
import org.eclipse.swt.widgets.Display; |
|
11 |
import org.eclipse.swt.widgets.Shell; |
|
12 |
import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog; |
|
13 |
import org.txm.core.results.TXMResult; |
|
14 |
|
|
15 |
/** |
|
16 |
* An advanced progress monitor modal dialog managing delay before displaying the window |
|
17 |
* and the forcing of cancel using Thread.stop(). |
|
18 |
* |
|
19 |
* @author sjacquot |
|
20 |
* |
|
21 |
*/ |
|
22 |
public class AdvancedProgressMonitorDialog extends ProgressMonitorJobsDialog { |
|
23 |
|
|
24 |
/** |
|
25 |
* Result. |
|
26 |
*/ |
|
27 |
protected TXMResult result; |
|
28 |
|
|
29 |
/** |
|
30 |
* Delay in ms before opening the dialog after starting runnable. |
|
31 |
*/ |
|
32 |
protected int delayBeforeOpen; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* Creates a modal progress monitor dialog. |
|
37 |
* |
|
38 |
* @param parent |
|
39 |
* @param result |
|
40 |
* @param delayBeforeOpen delay in ms before opening the dialog after starting runnable |
|
41 |
*/ |
|
42 |
public AdvancedProgressMonitorDialog(Shell parent, TXMResult result, int delayBeforeOpen) { |
|
43 |
super(parent); |
|
44 |
this.result = result; |
|
45 |
this.delayBeforeOpen = delayBeforeOpen; |
|
46 |
this.setOpenOnRun(false); |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* Creates a modal progress monitor dialog. |
|
51 |
* |
|
52 |
* @param parent |
|
53 |
* @param result |
|
54 |
*/ |
|
55 |
public AdvancedProgressMonitorDialog(Shell parent, TXMResult result) { |
|
56 |
this(parent, result, 1000); |
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
@Override |
|
61 |
protected void createDetailsButton(Composite parent) { |
|
62 |
// to not create the "Details" button |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
protected void configureShell(final Shell shell) { |
|
67 |
super.configureShell(shell); |
|
68 |
// set window title to result start computing message |
|
69 |
shell.setText(this.result.getComputingStartMessage()); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* Runs the computing process on the stored <code>TXMResult</code>. |
|
74 |
* |
|
75 |
* @param cancelable |
|
76 |
* @throws InvocationTargetException |
|
77 |
* @throws InterruptedException |
|
78 |
*/ |
|
79 |
public void runComputingProcess(boolean cancelable) throws InvocationTargetException, InterruptedException { |
|
80 |
|
|
81 |
IRunnableWithProgress runnable = new IRunnableWithProgress() { |
|
82 |
|
|
83 |
@Override |
|
84 |
public void run(IProgressMonitor monitor) throws InterruptedException { |
|
85 |
result.compute(monitor, false); |
|
86 |
} |
|
87 |
}; |
|
88 |
|
|
89 |
this.run(cancelable, runnable); |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
/** |
|
94 |
* Runs the given <code>IRunnableWithProgress</code>. |
|
95 |
* |
|
96 |
* @param cancelable |
|
97 |
* @param runnable |
|
98 |
* @throws InvocationTargetException |
|
99 |
* @throws InterruptedException |
|
100 |
*/ |
|
101 |
public void run(boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { |
|
102 |
this.run(true, cancelable, runnable); |
|
103 |
} |
|
104 |
|
|
105 |
|
|
106 |
@Override |
|
107 |
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { |
|
108 |
|
|
109 |
// manage the dialog open delay |
|
110 |
Timer timer = new Timer(); |
|
111 |
timer.schedule(new TimerTask() { |
|
112 |
|
|
113 |
protected int elapsedTime = 0; |
|
114 |
|
|
115 |
@Override |
|
116 |
public void run() { |
|
117 |
this.elapsedTime += 10; |
|
118 |
if (this.elapsedTime > delayBeforeOpen) { |
|
119 |
Display.getDefault().asyncExec(new Runnable() { |
|
120 |
|
|
121 |
@Override |
|
122 |
public void run() { |
|
123 |
open(); |
|
124 |
} |
|
125 |
}); |
|
126 |
this.cancel(); |
|
127 |
timer.purge(); |
|
128 |
timer.cancel(); |
|
129 |
} |
|
130 |
} |
|
131 |
}, 0, 10); |
|
132 |
|
|
133 |
super.run(fork, cancelable, runnable); |
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
@Override |
|
138 |
protected void cancelPressed() { |
|
139 |
this.result.getComputingThread().stop(); |
|
140 |
super.cancelPressed(); |
|
141 |
} |
|
142 |
|
|
143 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/ComputeProgressMonitorDialog.java (revision 2648) | ||
---|---|---|
1 |
package org.txm.rcp.swt.dialog; |
|
2 |
|
|
3 |
import java.lang.reflect.InvocationTargetException; |
|
4 |
import java.util.Timer; |
|
5 |
import java.util.TimerTask; |
|
6 |
|
|
7 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
8 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
|
9 |
import org.eclipse.swt.widgets.Composite; |
|
10 |
import org.eclipse.swt.widgets.Display; |
|
11 |
import org.eclipse.swt.widgets.Shell; |
|
12 |
import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog; |
|
13 |
import org.txm.core.results.TXMResult; |
|
14 |
|
|
15 |
/** |
|
16 |
* An advanced progress monitor modal dialog managing delay before displaying the window |
|
17 |
* and the forcing of cancel using Thread.stop(). |
|
18 |
* |
|
19 |
* @author sjacquot |
|
20 |
* |
|
21 |
*/ |
|
22 |
public class ComputeProgressMonitorDialog extends ProgressMonitorJobsDialog { |
|
23 |
|
|
24 |
/** |
|
25 |
* Result. |
|
26 |
*/ |
|
27 |
protected TXMResult result; |
|
28 |
|
|
29 |
/** |
|
30 |
* Delay in ms before opening the dialog after starting runnable. |
|
31 |
*/ |
|
32 |
protected int delayBeforeOpen; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* Creates a modal progress monitor dialog. |
|
37 |
* |
|
38 |
* @param parent |
|
39 |
* @param result |
|
40 |
* @param delayBeforeOpen delay in ms before opening the dialog after starting runnable |
|
41 |
*/ |
|
42 |
public ComputeProgressMonitorDialog(Shell parent, TXMResult result, int delayBeforeOpen) { |
|
43 |
super(parent); |
|
44 |
this.result = result; |
|
45 |
this.delayBeforeOpen = delayBeforeOpen; |
|
46 |
this.setOpenOnRun(false); |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* Creates a modal progress monitor dialog. |
|
51 |
* |
|
52 |
* @param parent |
|
53 |
* @param result |
|
54 |
*/ |
|
55 |
public ComputeProgressMonitorDialog(Shell parent, TXMResult result) { |
|
56 |
this(parent, result, 1000); |
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
@Override |
|
61 |
protected void createDetailsButton(Composite parent) { |
|
62 |
// to not create the "Details" button |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
protected void configureShell(final Shell shell) { |
|
67 |
super.configureShell(shell); |
|
68 |
// set window title to result start computing message |
|
69 |
shell.setText(this.result.getComputingStartMessage()); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* Runs the computing process on the stored <code>TXMResult</code>. |
|
74 |
* |
|
75 |
* @param cancelable |
|
76 |
* @throws InvocationTargetException |
|
77 |
* @throws InterruptedException |
|
78 |
*/ |
|
79 |
public void runComputingProcess(boolean cancelable) throws InvocationTargetException, InterruptedException { |
|
80 |
|
|
81 |
IRunnableWithProgress runnable = new IRunnableWithProgress() { |
|
82 |
|
|
83 |
@Override |
|
84 |
public void run(IProgressMonitor monitor) throws InterruptedException { |
|
85 |
result.compute(monitor, false); |
|
86 |
} |
|
87 |
}; |
|
88 |
|
|
89 |
this.run(cancelable, runnable); |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
/** |
|
94 |
* Runs the given <code>IRunnableWithProgress</code>. |
|
95 |
* |
|
96 |
* @param cancelable |
|
97 |
* @param runnable |
|
98 |
* @throws InvocationTargetException |
|
99 |
* @throws InterruptedException |
|
100 |
*/ |
|
101 |
public void run(boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { |
|
102 |
this.run(true, cancelable, runnable); |
|
103 |
} |
|
104 |
|
|
105 |
|
|
106 |
@Override |
|
107 |
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { |
|
108 |
|
|
109 |
// manage the dialog open delay |
|
110 |
Timer timer = new Timer(); |
|
111 |
timer.schedule(new TimerTask() { |
|
112 |
|
|
113 |
protected int elapsedTime = 0; |
|
114 |
|
|
115 |
@Override |
|
116 |
public void run() { |
|
117 |
this.elapsedTime += 10; |
|
118 |
if (this.elapsedTime > delayBeforeOpen) { |
|
119 |
Display.getDefault().asyncExec(new Runnable() { |
|
120 |
|
|
121 |
@Override |
|
122 |
public void run() { |
|
123 |
open(); |
|
124 |
} |
|
125 |
}); |
|
126 |
this.cancel(); |
|
127 |
timer.purge(); |
|
128 |
timer.cancel(); |
|
129 |
} |
|
130 |
} |
|
131 |
}, 0, 10); |
|
132 |
|
|
133 |
super.run(fork, cancelable, runnable); |
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
@Override |
|
138 |
protected void cancelPressed() { |
|
139 |
this.result.getComputingThread().stop(); |
|
140 |
super.cancelPressed(); |
|
141 |
} |
|
142 |
|
|
143 |
} |
|
0 | 144 |
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAEditor.java (revision 2648) | ||
---|---|---|
181 | 181 |
this.setPageText(editorIndex, this.names.get(i)); |
182 | 182 |
} |
183 | 183 |
|
184 |
caFactorialMapEditorPart.compute(false); |
|
184 |
// caFactorialMapEditorPart.compute(false); |
|
185 |
// caFactorialMapEditorPart.refresh(false); |
|
186 |
eigenvalues.compute(); |
|
185 | 187 |
|
186 | 188 |
} |
187 | 189 |
catch (Exception e1) { |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java (revision 2648) | ||
---|---|---|
44 | 44 |
import org.txm.rcp.editors.TXMEditor; |
45 | 45 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
46 | 46 |
import org.txm.rcp.messages.TXMUIMessages; |
47 |
import org.txm.rcp.swt.dialog.AdvancedProgressMonitorDialog;
|
|
47 |
import org.txm.rcp.swt.dialog.ComputeProgressMonitorDialog;
|
|
48 | 48 |
import org.txm.rcp.utils.JobHandler; |
49 | 49 |
import org.txm.rcp.views.corpora.CorporaView; |
50 | 50 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
... | ... | |
92 | 92 |
CQPCorpus corpus = (CQPCorpus) selection; |
93 | 93 |
if (!corpus.hasBeenComputedOnce()) { |
94 | 94 |
|
95 |
AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), corpus);
|
|
95 |
ComputeProgressMonitorDialog dialog = new ComputeProgressMonitorDialog(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), corpus);
|
|
96 | 96 |
dialog.runComputingProcess(true); |
97 | 97 |
|
98 | 98 |
} |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputePartition.java (revision 2648) | ||
---|---|---|
46 | 46 |
import org.txm.rcp.editors.TXMEditor; |
47 | 47 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
48 | 48 |
import org.txm.rcp.messages.TXMUIMessages; |
49 |
import org.txm.rcp.swt.dialog.AdvancedProgressMonitorDialog;
|
|
49 |
import org.txm.rcp.swt.dialog.ComputeProgressMonitorDialog;
|
|
50 | 50 |
import org.txm.rcp.utils.JobHandler; |
51 | 51 |
import org.txm.rcp.views.corpora.CorporaView; |
52 | 52 |
import org.txm.searchengine.cqp.core.preferences.PartitionPreferences; |
... | ... | |
97 | 97 |
CQPCorpus corpus = (CQPCorpus) selection; |
98 | 98 |
if (!corpus.hasBeenComputedOnce()) { |
99 | 99 |
|
100 |
AdvancedProgressMonitorDialog dialog = new AdvancedProgressMonitorDialog(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), corpus);
|
|
100 |
ComputeProgressMonitorDialog dialog = new ComputeProgressMonitorDialog(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), corpus);
|
|
101 | 101 |
dialog.runComputingProcess(true); |
102 | 102 |
|
103 | 103 |
} |
Formats disponibles : Unified diff