Révision 538
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 538) | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package org.txm.chartsengine.core.results; |
5 | 5 |
|
6 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
6 | 7 |
import org.txm.chartsengine.core.ChartCreator; |
7 | 8 |
import org.txm.chartsengine.core.ChartsEngine; |
8 | 9 |
import org.txm.core.results.TXMResult; |
... | ... | |
29 | 30 |
*/ |
30 | 31 |
protected boolean chartDirty; |
31 | 32 |
|
33 |
|
|
34 |
protected boolean needsToResetView; |
|
35 |
|
|
36 |
protected boolean needsToClearItemsSelection; |
|
37 |
|
|
38 |
|
|
32 | 39 |
/** |
33 | 40 |
* |
34 | 41 |
* @param parent |
... | ... | |
44 | 51 |
} |
45 | 52 |
|
46 | 53 |
|
47 |
public boolean computeChart(boolean update) throws Exception { |
|
54 |
@Override |
|
55 |
public boolean compute(boolean update, IProgressMonitor monitor) throws Exception { |
|
48 | 56 |
|
57 |
this.monitor = monitor; |
|
58 |
|
|
59 |
// FIXME: Debug |
|
60 |
System.err.println("ChartResult.compute(): computing result of type " + this.getClass() + "..."); |
|
61 |
|
|
62 |
if(!this.isDirty()) { |
|
63 |
|
|
64 |
// FIXME: Debug |
|
65 |
System.err.println("ChartResult.compute(): result is not dirty, computing skipped."); |
|
66 |
|
|
67 |
// return true; |
|
68 |
} |
|
69 |
else { |
|
70 |
|
|
71 |
if(!hasBeenConstructorCalled()) { |
|
72 |
return false; |
|
73 |
} |
|
74 |
|
|
75 |
if (!canCompute()) { |
|
76 |
// FIXME: Debug |
|
77 |
System.err.println("ChartResult.compute(): missing or wrong parameters, computing aborted."); |
|
78 |
|
|
79 |
return false; |
|
80 |
} |
|
81 |
|
|
82 |
if (!_compute(update)) { |
|
83 |
|
|
84 |
// FIXME: Debug |
|
85 |
System.err.println("ChartResult.compute(): computing failed."); |
|
86 |
|
|
87 |
return false; |
|
88 |
} |
|
89 |
|
|
90 |
if (!saveParameters()) { |
|
91 |
return false; |
|
92 |
} |
|
93 |
|
|
94 |
this.dirty = false; // the _compute was successful the result is no more dirty |
|
95 |
|
|
96 |
// FIXME: Debug |
|
97 |
System.err.println("ChartResult.compute(): computing done."); |
|
98 |
} |
|
99 |
|
|
100 |
return computeChart(update); |
|
101 |
|
|
102 |
//return true; |
|
103 |
} |
|
104 |
|
|
105 |
protected boolean computeChart(boolean update) throws Exception { |
|
106 |
|
|
49 | 107 |
this.subTask("computing chart"); |
50 | 108 |
|
51 | 109 |
// FIXME: Debug |
... | ... | |
144 | 202 |
public void setChartDirty() { |
145 | 203 |
this.chartDirty = true; |
146 | 204 |
} |
205 |
|
|
206 |
|
|
207 |
/** |
|
208 |
* @return the needsToResetView |
|
209 |
*/ |
|
210 |
public boolean needsToResetView() { |
|
211 |
return needsToResetView; |
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
/** |
|
216 |
* @param needsToResetView the needsToResetView to set |
|
217 |
*/ |
|
218 |
public void setNeedsToResetView(boolean needsToResetView) { |
|
219 |
this.needsToResetView = needsToResetView; |
|
220 |
} |
|
221 |
|
|
222 |
|
|
223 |
/** |
|
224 |
* @return the needsClearItemsSelection |
|
225 |
*/ |
|
226 |
public boolean needsToClearItemsSelection() { |
|
227 |
return needsToClearItemsSelection; |
|
228 |
} |
|
229 |
|
|
230 |
|
|
231 |
/** |
|
232 |
* @param needsToClearItemsSelection the needsClearItemsSelection to set |
|
233 |
*/ |
|
234 |
public void setNeedsToClearItemsSelection(boolean needsToClearItemsSelection) { |
|
235 |
this.needsToClearItemsSelection = needsToClearItemsSelection; |
|
236 |
} |
|
147 | 237 |
|
148 | 238 |
|
149 | 239 |
|
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java (revision 538) | ||
---|---|---|
30 | 30 |
import org.txm.core.messages.TXMCoreMessages; |
31 | 31 |
import org.txm.progression.core.functions.Progression; |
32 | 32 |
import org.txm.progression.core.preferences.ProgressionPreferences; |
33 |
import org.txm.progression.rcp.dialogs.ProgressionDialog; |
|
33 |
import org.txm.progression.rcp.dialogs.___ProgressionDialog;
|
|
34 | 34 |
import org.txm.rcp.RCPMessages; |
35 | 35 |
import org.txm.rcp.StatusLine; |
36 | 36 |
import org.txm.rcp.swt.widget.AssistedQueryWidget; |
... | ... | |
121 | 121 |
String[] colors = DefaultTheme.colors; |
122 | 122 |
|
123 | 123 |
/** The self. */ |
124 |
ProgressionDialog self; |
|
124 |
___ProgressionDialog self;
|
|
125 | 125 |
|
126 | 126 |
/** The parent. */ |
127 | 127 |
private Composite parent; |
... | ... | |
247 | 247 |
getSite().getShell().getDisplay().syncExec(new Runnable() { |
248 | 248 |
@Override |
249 | 249 |
public void run() { |
250 |
|
|
251 |
StructuralUnit su = null; |
|
252 |
if(structuralUnitsCombo.getSelectionIndex() != 0) { |
|
253 |
su = structuralUnits.get(structuralUnitsCombo.getSelectionIndex() - 1); |
|
254 |
} |
|
255 |
|
|
256 |
// skip if no change |
|
257 |
if(su == getResultData().getStructure()) { |
|
258 |
return; |
|
259 |
} |
|
260 |
|
|
250 | 261 |
reloadSUProperties(); |
251 |
getResultData().setStructuralUnit(structuralUnits.get(structuralUnitsCombo.getSelectionIndex() - 1));
|
|
262 |
getResultData().setStructuralUnit(su);
|
|
252 | 263 |
getResultData().setDirty(); |
253 |
computeChart(true);
|
|
264 |
compute(true); |
|
254 | 265 |
} |
255 | 266 |
}); |
256 | 267 |
} |
... | ... | |
290 | 301 |
|
291 | 302 |
@Override |
292 | 303 |
public void widgetSelected(SelectionEvent event) { |
293 |
getSite().getShell().getDisplay().syncExec(new Runnable() {
|
|
294 |
@Override
|
|
295 |
public void run() {
|
|
296 |
getResultData().setStructuralUnitProperty(structuralUnitsProperties.get(propertyCombo.getSelectionIndex() - 1));
|
|
297 |
getResultData().setDirty();
|
|
298 |
computeChart(true); |
|
299 |
}
|
|
300 |
});
|
|
304 |
StructuralUnitProperty sup = null;
|
|
305 |
if(propertyCombo.getSelectionIndex() != 0) {
|
|
306 |
sup = structuralUnitsProperties.get(propertyCombo.getSelectionIndex() - 1);
|
|
307 |
}
|
|
308 |
getResultData().setStructuralUnitProperty(sup);
|
|
309 |
|
|
310 |
getResultData().setDirty();
|
|
311 |
compute(true);
|
|
301 | 312 |
} |
302 | 313 |
}); |
303 | 314 |
|
... | ... | |
460 | 471 |
} |
461 | 472 |
|
462 | 473 |
((Progression)getResultData()).setParameters(queries, selectedStructuralUnit, selectedStructuralUnitProperty, regexpropertyValue, cumulative, linewidth, repeatvalues, bandemultiplier); |
463 |
computeChart(false);
|
|
474 |
compute(false); |
|
464 | 475 |
|
465 | 476 |
} |
466 | 477 |
|
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/handlers/ComputeProgression.java (revision 538) | ||
---|---|---|
37 | 37 |
import org.txm.progression.core.functions.Progression; |
38 | 38 |
import org.txm.progression.core.messages.ProgressionCoreMessages; |
39 | 39 |
import org.txm.progression.core.preferences.ProgressionPreferences; |
40 |
import org.txm.progression.rcp.dialogs.ProgressionDialog; |
|
40 |
import org.txm.progression.rcp.dialogs.___ProgressionDialog;
|
|
41 | 41 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
42 | 42 |
import org.txm.rcp.views.corpora.CorporaView; |
43 | 43 |
import org.txm.searchengine.cqp.corpus.Corpus; |
... | ... | |
83 | 83 |
// La fonctionnalité Progression n'est pas encore disponible pour les sous-corpus discontinus. |
84 | 84 |
return null; |
85 | 85 |
} |
86 |
|
|
87 |
// FIXME: old code with Dialog box parameters |
|
88 |
// Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
|
89 |
// ProgressionDialog d = new ProgressionDialog(shell, corpus); |
|
90 |
// |
|
91 |
// int code = d.open(); |
|
92 |
// if (code == Window.OK) { |
|
93 |
// //computeProgression(d); |
|
94 |
// |
|
95 |
// progression = new Progression(d.getCorpus(), d.getQueries(), d.getStructuralUnit(), d.getStructuralProperty(), d.getPropertyregex(), |
|
96 |
// d.isCumulativeType(), d.getLineWidth(), d.isRepeatvalues(), d.getBandeMultiplier()); |
|
97 |
// |
|
98 |
// |
|
99 |
// progression = new Progression(d.getCorpus()); |
|
100 |
// |
|
101 |
// } |
|
102 |
|
|
103 | 86 |
progression = new Progression(corpus); |
104 |
|
|
105 |
|
|
106 | 87 |
} |
107 | 88 |
// Reopens a progression result with default preferences |
108 | 89 |
else if(selection instanceof Progression) { |
... | ... | |
117 | 98 |
tmpSWTComponentsProvider.setChartsEngine(tmpChartsEngine); |
118 | 99 |
|
119 | 100 |
// Create and open the chart editor |
120 |
ChartEditorPart.compute(progression, tmpSWTComponentsProvider); |
|
101 |
//ChartEditorPart.compute(progression, tmpSWTComponentsProvider);
|
|
121 | 102 |
|
122 | 103 |
} |
123 | 104 |
else { |
... | ... | |
125 | 106 |
ChartEditorPart.compute(progression); |
126 | 107 |
} |
127 | 108 |
|
109 |
ChartEditorPart.openEditor(progression); |
|
128 | 110 |
|
129 | 111 |
return null; |
130 | 112 |
} |
131 | 113 |
|
132 |
|
|
133 |
/** |
|
134 |
* Computes progression and open the result editor. |
|
135 |
* |
|
136 |
* @param dialog the dialog box |
|
137 |
*/ |
|
138 |
@Deprecated |
|
139 |
public Object computeProgression(final ProgressionDialog dialog) { |
|
140 |
// if (!this.checkCorpusEngine()) { |
|
141 |
// return false; |
|
142 |
// } |
|
143 |
// |
|
144 |
// |
|
145 |
// |
|
146 |
// |
|
147 |
// JobHandler job = new JobHandler(NLS.bind(ProgressionCoreMessages.ComputeProgression_2, dialog.getQueries(), dialog.getCorpus().getName())) { |
|
148 |
// @Override |
|
149 |
// protected IStatus run(IProgressMonitor monitor) { |
|
150 |
// |
|
151 |
// final Progression progression = new Progression(dialog.getCorpus(), dialog.getQueries(), dialog.getStructuralUnit(), dialog.getStructuralProperty(), dialog.getPropertyregex(), |
|
152 |
// dialog.isCumulativeType(), dialog.getLineWidth(), dialog.isRepeatvalues(), dialog.getBandeMultiplier()); |
|
153 |
// |
|
154 |
// monitor = progression; |
|
155 |
// |
|
156 |
// this.runInit(monitor); |
|
157 |
// JobsTimer.start(); |
|
158 |
// try { |
|
159 |
// final Corpus corpus = dialog.getCorpus(); |
|
160 |
// if (dialog.getQueries().size() == 0) { |
|
161 |
// Log.severe(ProgressionCoreMessages.ComputeProgression_6); |
|
162 |
// return Status.CANCEL_STATUS; |
|
163 |
// } |
|
164 |
// |
|
165 |
// |
|
166 |
// |
|
167 |
// |
|
168 |
// // persistence |
|
169 |
// if(dialog.isBlackAndWhite()) { |
|
170 |
// TXMPreferences.putLocal(progression, ChartsEnginePreferences.RENDERING_COLORS_MODE, ChartsEngine.RENDERING_BLACK_AND_WHITE_MODE); |
|
171 |
// } |
|
172 |
// TXMPreferences.putLocal(progression, ProgressionPreferences.CHART_MONO_STYLE, dialog.isMonoStyle()); |
|
173 |
// TXMPreferences.putLocal(progression, ProgressionPreferences.CHART_CUMULATIVE, dialog.isCumulativeType()); |
|
174 |
// |
|
175 |
// |
|
176 |
// |
|
177 |
// Log.info(NLS.bind(ProgressionCoreMessages.ComputeProgression_4, |
|
178 |
// new Object[]{dialog.getCorpus(), dialog.getQueries(), dialog.getStructuralUnit(), dialog.getStructuralProperty(), dialog.isCumulativeType()})); |
|
179 |
// |
|
180 |
// monitor.worked(50); |
|
181 |
// |
|
182 |
// |
|
183 |
// if (monitor.isCanceled()) { |
|
184 |
// return Status.CANCEL_STATUS; |
|
185 |
// } |
|
186 |
// |
|
187 |
// boolean success = progression.compute(false, monitor); |
|
188 |
// |
|
189 |
// |
|
190 |
// |
|
191 |
// |
|
192 |
// |
|
193 |
// // System.out.println("success : "+success); |
|
194 |
// if (success) { |
|
195 |
// syncExec(new Runnable() { |
|
196 |
// @Override |
|
197 |
// public void run() { |
|
198 |
// |
|
199 |
// openEditor(progression); |
|
200 |
// |
|
201 |
// StatusLine.setMessage(ProgressionCoreMessages.ComputeProgression_10); |
|
202 |
// |
|
203 |
// } |
|
204 |
// }); |
|
205 |
// } |
|
206 |
// monitor.worked(45); |
|
207 |
// |
|
208 |
// monitor.subTask(RCPMessages.RefreshingCorporaView); |
|
209 |
// //CorporaView.storeResult(corpus, progression); |
|
210 |
// |
|
211 |
// monitor.worked(5); |
|
212 |
// System.out.println(NLS.bind(ProgressionCoreMessages.ComputeProgression_12, progression.getPositionsCounts())); |
|
213 |
// } catch (ThreadDeath td) { |
|
214 |
// return Status.CANCEL_STATUS; |
|
215 |
// } catch (Exception e) { |
|
216 |
// e.printStackTrace(); |
|
217 |
// System.out.println(NLS.bind(ProgressionCoreMessages.ComputeProgression_13, e)); |
|
218 |
// Log.severe(ProgressionCoreMessages.ComputeProgression_13 + Log.toString(e)); |
|
219 |
// try { |
|
220 |
// System.out.println(RCPMessages.LastCQPError + CQPEngine.getCqiClient().getLastCQPError()); |
|
221 |
// } catch (Exception e1) { |
|
222 |
// System.out.println(ProgressionCoreMessages.ComputeProgression_1 + e1); |
|
223 |
// Log.printStackTrace(e1); |
|
224 |
// } |
|
225 |
// } finally { |
|
226 |
// monitor.done(); |
|
227 |
// JobsTimer.stopAndPrint(); |
|
228 |
// } |
|
229 |
// return Status.OK_STATUS; |
|
230 |
// } |
|
231 |
// }; |
|
232 |
// //jobhandler.setCurrentMonitor(progression); |
|
233 |
// //jobhandler.startJob(); |
|
234 |
// job.setPriority(Job.DECORATE); |
|
235 |
// job.setUser(true); |
|
236 |
// job.schedule(); |
|
237 |
return null; |
|
238 |
} |
|
239 | 114 |
} |
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/dialogs/ProgressionDialog.java (revision 538) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.progression.rcp.dialogs; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
import java.util.regex.Pattern; |
|
33 |
import java.util.regex.PatternSyntaxException; |
|
34 |
|
|
35 |
import org.eclipse.jface.dialogs.Dialog; |
|
36 |
import org.eclipse.swt.SWT; |
|
37 |
import org.eclipse.swt.custom.ScrolledComposite; |
|
38 |
import org.eclipse.swt.events.SelectionEvent; |
|
39 |
import org.eclipse.swt.events.SelectionListener; |
|
40 |
import org.eclipse.swt.layout.FormAttachment; |
|
41 |
import org.eclipse.swt.layout.FormData; |
|
42 |
import org.eclipse.swt.layout.FormLayout; |
|
43 |
import org.eclipse.swt.layout.GridData; |
|
44 |
import org.eclipse.swt.layout.GridLayout; |
|
45 |
import org.eclipse.swt.widgets.Button; |
|
46 |
import org.eclipse.swt.widgets.Combo; |
|
47 |
import org.eclipse.swt.widgets.Composite; |
|
48 |
import org.eclipse.swt.widgets.Control; |
|
49 |
import org.eclipse.swt.widgets.Event; |
|
50 |
import org.eclipse.swt.widgets.Group; |
|
51 |
import org.eclipse.swt.widgets.Label; |
|
52 |
import org.eclipse.swt.widgets.Listener; |
|
53 |
import org.eclipse.swt.widgets.Shell; |
|
54 |
import org.eclipse.swt.widgets.Text; |
|
55 |
import org.txm.chartsengine.core.ChartsEngine; |
|
56 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
|
57 |
import org.txm.chartsengine.r.core.themes.DefaultTheme; |
|
58 |
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages; |
|
59 |
import org.txm.core.messages.TXMCoreMessages; |
|
60 |
import org.txm.core.preferences.TXMPreferences; |
|
61 |
import org.txm.progression.core.preferences.ProgressionPreferences; |
|
62 |
import org.txm.rcp.preferences.TXMPreferenceStore; |
|
63 |
import org.txm.rcp.RCPMessages; |
|
64 |
import org.txm.rcp.StatusLine; |
|
65 |
import org.txm.rcp.swt.widget.AssistedQueryWidget; |
|
66 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
67 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
|
68 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
69 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
70 |
import org.txm.utils.logger.Log; |
|
71 |
|
|
72 |
/** |
|
73 |
* Allow the user to choose : the type of the graphic the structural units, |
|
74 |
* property and values to be shown the queries of each curves. |
|
75 |
* |
|
76 |
* @author mdecorde |
|
77 |
* @author sjacquot |
|
78 |
*/ |
|
79 |
public class ProgressionDialog extends Dialog { |
|
80 |
|
|
81 |
/** The query widgets. */ |
|
82 |
protected List<AssistedQueryWidget> queryWidgets = new ArrayList<AssistedQueryWidget>(); |
|
83 |
|
|
84 |
/** The queries. */ |
|
85 |
List<Query> queries; |
|
86 |
|
|
87 |
/** The corpus. */ |
|
88 |
private Corpus corpus; |
|
89 |
|
|
90 |
/** The selected structural unit. */ |
|
91 |
private StructuralUnit selectedStructuralUnit; |
|
92 |
|
|
93 |
/** The selected structural unit property. */ |
|
94 |
private StructuralUnitProperty selectedStructuralUnitProperty; |
|
95 |
|
|
96 |
/** The regexproperty value. */ |
|
97 |
private String regexpropertyValue; |
|
98 |
|
|
99 |
/** The graphtype. */ |
|
100 |
private boolean cumulative = true; |
|
101 |
|
|
102 |
private boolean blackAndWhite = true; |
|
103 |
|
|
104 |
/** The monostyle. */ |
|
105 |
private boolean monostyle = true; |
|
106 |
|
|
107 |
/** The repeatvalues. */ |
|
108 |
private boolean repeatvalues = false; |
|
109 |
|
|
110 |
/** The linewidth. */ |
|
111 |
private int linewidth = 2; |
|
112 |
|
|
113 |
/** The bandemultiplier. */ |
|
114 |
private float bandemultiplier = 2; |
|
115 |
|
|
116 |
/** The structural units combo. */ |
|
117 |
Combo structuralUnitsCombo; |
|
118 |
|
|
119 |
/** The structural units. */ |
|
120 |
List<StructuralUnit> structuralUnits; |
|
121 |
|
|
122 |
/** The structural units properties. */ |
|
123 |
List<StructuralUnitProperty> structuralUnitsProperties; |
|
124 |
|
|
125 |
/** The property combo. */ |
|
126 |
private Combo propertyCombo; |
|
127 |
|
|
128 |
/** The regex value. */ |
|
129 |
private Text regexValue; |
|
130 |
|
|
131 |
/** The focus composite. */ |
|
132 |
Composite focusComposite; |
|
133 |
|
|
134 |
/** The main panel. */ |
|
135 |
Composite mainPanel; |
|
136 |
|
|
137 |
/** The bande field. */ |
|
138 |
Text bandeField; |
|
139 |
|
|
140 |
/** The cumu button. */ |
|
141 |
Button cumuButton; |
|
142 |
|
|
143 |
/** The repeat button. */ |
|
144 |
Button repeatButton; |
|
145 |
|
|
146 |
/** The color button. */ |
|
147 |
Button colorButton; |
|
148 |
|
|
149 |
/** The style button. */ |
|
150 |
Button styleButton; |
|
151 |
|
|
152 |
/** The colors. */ |
|
153 |
String[] colors = DefaultTheme.colors; |
|
154 |
|
|
155 |
/** The self. */ |
|
156 |
ProgressionDialog self; |
|
157 |
|
|
158 |
/** The parent. */ |
|
159 |
private Composite parent; |
|
160 |
|
|
161 |
private ScrolledComposite sc1; |
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
/** |
|
166 |
* Instantiates a new progression dialog. |
|
167 |
* |
|
168 |
* @param parentShell the parent shell |
|
169 |
* @param corpus the corpus |
|
170 |
*/ |
|
171 |
public ProgressionDialog(Shell parentShell, Corpus corpus) { |
|
172 |
super(parentShell); |
|
173 |
this.corpus = corpus; |
|
174 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Instantiates a new progression dialog. |
|
179 |
* |
|
180 |
* @param parentShell the parent shell |
|
181 |
* @param corpus the corpus |
|
182 |
* @param queries the queries |
|
183 |
*/ |
|
184 |
public ProgressionDialog(Shell parentShell, Corpus corpus, |
|
185 |
List<Query> queries) { |
|
186 |
super(parentShell); |
|
187 |
this.corpus = corpus; |
|
188 |
this.queries = queries; |
|
189 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
190 |
} |
|
191 |
|
|
192 |
/* (non-Javadoc) |
|
193 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
|
194 |
*/ |
|
195 |
@Override |
|
196 |
protected void configureShell(Shell newShell) { |
|
197 |
super.configureShell(newShell); |
|
198 |
newShell.setText(RCPMessages.ProgressionDialog_0); |
|
199 |
newShell.setMinimumSize(300, 460); |
|
200 |
|
|
201 |
} |
|
202 |
|
|
203 |
/* (non-Javadoc) |
|
204 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
205 |
*/ |
|
206 |
@Override |
|
207 |
protected Control createDialogArea(Composite p) { |
|
208 |
try { |
|
209 |
this.self = this; |
|
210 |
this.parent = p; |
|
211 |
|
|
212 |
// get preferences values |
|
213 |
TXMPreferenceStore store = new TXMPreferenceStore(ProgressionPreferences.PREFERENCES_NODE); |
|
214 |
|
|
215 |
this.blackAndWhite = (TXMPreferences.getInt(ChartsEnginePreferences.RENDERING_COLORS_MODE, ProgressionPreferences.PREFERENCES_NODE) == ChartsEngine.RENDERING_BLACK_AND_WHITE_MODE); |
|
216 |
|
|
217 |
this.monostyle = store.getBoolean(ProgressionPreferences.CHART_MONO_STYLE); |
|
218 |
this.cumulative = store.getBoolean(ProgressionPreferences.CHART_CUMULATIVE); |
|
219 |
this.repeatvalues = store.getBoolean(ProgressionPreferences.CHART_REPEAT_VALUES); |
|
220 |
this.bandemultiplier = store.getFloat(ProgressionPreferences.CHART_BANDE_MULTIPLIER); |
|
221 |
|
|
222 |
// System.out.println(parent.getLayout()); |
|
223 |
FormLayout mainlayout = new FormLayout(); |
|
224 |
mainPanel = new Composite(parent, SWT.NONE); |
|
225 |
mainPanel.setLayout(mainlayout); |
|
226 |
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true); |
|
227 |
mainPanel.setLayoutData(gridData); |
|
228 |
|
|
229 |
Composite paramPanel = new Composite(mainPanel, SWT.NONE); |
|
230 |
// set the QueryWidget's tab |
|
231 |
|
|
232 |
sc1 = new ScrolledComposite(mainPanel, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); |
|
233 |
sc1.setLayout(new GridLayout(1, true)); |
|
234 |
sc1.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
235 |
sc1.setExpandHorizontal( true ); |
|
236 |
sc1.setExpandVertical( true ); |
|
237 |
sc1.setMinSize( 0, 250 ); |
|
238 |
|
|
239 |
focusComposite = new Composite(sc1, SWT.NONE); |
|
240 |
focusComposite.setLayout(new GridLayout(1, true)); |
|
241 |
sc1.setContent(focusComposite); |
|
242 |
|
|
243 |
FormData paramPanelData = new FormData(); |
|
244 |
paramPanelData.top = new FormAttachment(0); |
|
245 |
paramPanelData.left = new FormAttachment(0); |
|
246 |
paramPanelData.right = new FormAttachment(100); |
|
247 |
paramPanel.setLayoutData(paramPanelData); |
|
248 |
|
|
249 |
FormData queriesPanelData = new FormData(); |
|
250 |
queriesPanelData.top = new FormAttachment(paramPanel); |
|
251 |
queriesPanelData.left = new FormAttachment(0); |
|
252 |
queriesPanelData.right = new FormAttachment(100); |
|
253 |
queriesPanelData.bottom = new FormAttachment(100); |
|
254 |
sc1.setLayoutData(queriesPanelData); |
|
255 |
|
|
256 |
paramPanel.setLayout(new GridLayout(3, true)); |
|
257 |
|
|
258 |
// controls |
|
259 |
// graph param |
|
260 |
Label typeLabel = new Label(paramPanel, SWT.NONE); |
|
261 |
typeLabel.setText(RCPMessages.ProgressionDialog_1); |
|
262 |
typeLabel.setAlignment(SWT.CENTER); |
|
263 |
|
|
264 |
cumuButton = new Button(paramPanel, SWT.RADIO); |
|
265 |
cumuButton.setText(RCPMessages.ProgressionDialog_2); |
|
266 |
cumuButton.setSelection(cumulative); |
|
267 |
|
|
268 |
Button densityButton = new Button(paramPanel, SWT.RADIO); |
|
269 |
densityButton.setText(RCPMessages.ProgressionDialog_3); |
|
270 |
densityButton.setSelection(!cumulative); |
|
271 |
|
|
272 |
//Bande size |
|
273 |
typeLabel = new Label(paramPanel, SWT.NONE); |
|
274 |
typeLabel.setText(RCPMessages.ProgressionDialog_11); |
|
275 |
typeLabel.setAlignment(SWT.CENTER); |
|
276 |
|
|
277 |
bandeField = new Text(paramPanel, SWT.BORDER); |
|
278 |
bandeField.setText(""+bandemultiplier); //$NON-NLS-1$ |
|
279 |
bandeField.setLayoutData(new GridData(GridData.FILL, |
|
280 |
GridData.FILL, true, true, 2, 1)); |
|
281 |
// Structural units param |
|
282 |
Group displayParam = new Group(paramPanel, SWT.BORDER); |
|
283 |
displayParam.setText(RCPMessages.ProgressionDialog_13); |
|
284 |
displayParam.setLayout(new GridLayout(3, true)); |
|
285 |
displayParam.setLayoutData(new GridData(GridData.FILL, |
|
286 |
GridData.FILL, true, true, 3, 1)); |
|
287 |
|
|
288 |
Label structLabel = new Label(displayParam, SWT.NONE); |
|
289 |
structLabel.setText(RCPMessages.ProgressionDialog_4); |
|
290 |
structLabel.setAlignment(SWT.CENTER); |
|
291 |
|
|
292 |
structuralUnitsCombo = new Combo(displayParam, SWT.READ_ONLY); |
|
293 |
structuralUnitsCombo.setLayoutData(new GridData(GridData.FILL, |
|
294 |
GridData.FILL, true, true, 2, 1)); |
|
295 |
|
|
296 |
structuralUnitsCombo.addSelectionListener(new SelectionListener() { |
|
297 |
@Override |
|
298 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
299 |
} |
|
300 |
|
|
301 |
@Override |
|
302 |
public void widgetSelected(SelectionEvent event) { |
|
303 |
reloadProperties(); |
|
304 |
} |
|
305 |
}); |
|
306 |
|
|
307 |
try {// get |
|
308 |
structuralUnitsCombo.add(" "); //$NON-NLS-1$ |
|
309 |
structuralUnits = corpus.getOrderedStructuralUnits(); |
|
310 |
for (StructuralUnit unit : structuralUnits) { |
|
311 |
structuralUnitsCombo.add(unit.getName()); |
|
312 |
} |
|
313 |
} catch (Exception e) { |
|
314 |
Log.severe(RCPMessages.ObjectExplorer_9 |
|
315 |
+ Log.toString(e)); |
|
316 |
return null; |
|
317 |
} |
|
318 |
structuralUnitsCombo.select(0); |
|
319 |
|
|
320 |
// if (structuralUnitsCombo.getItemCount() == 0) { |
|
321 |
// this.getButton(IDialogConstants.OK_ID).setEnabled(false); |
|
322 |
// } else { |
|
323 |
// selectedStructuralUnit = structuralUnits.get(0); |
|
324 |
// } |
|
325 |
|
|
326 |
// properties combo |
|
327 |
Label propLabel = new Label(displayParam, SWT.NONE); |
|
328 |
propLabel.setText(TXMCoreMessages.PROPERTY_1); |
|
329 |
propLabel.setAlignment(SWT.CENTER); |
|
330 |
|
|
331 |
propertyCombo = new Combo(displayParam, SWT.READ_ONLY); |
|
332 |
propertyCombo.setLayoutData(new GridData(GridData.FILL, |
|
333 |
GridData.FILL, true, true, 2, 1)); |
|
334 |
reloadProperties(); |
|
335 |
|
|
336 |
// property value field |
|
337 |
Label regexLabel = new Label(displayParam, SWT.NONE); |
|
338 |
regexLabel.setText(RCPMessages.ProgressionDialog_7); |
|
339 |
regexLabel.setAlignment(SWT.CENTER); |
|
340 |
|
|
341 |
regexValue = new Text(displayParam, SWT.SINGLE | SWT.BORDER); |
|
342 |
regexValue.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
343 |
true, true, 2, 1)); |
|
344 |
|
|
345 |
//spacer |
|
346 |
styleButton = new Button(displayParam, SWT.CHECK); |
|
347 |
styleButton.setText(RCPMessages.ProgressionDialog_14); |
|
348 |
styleButton.setSelection(monostyle); |
|
349 |
|
|
350 |
//Repeat options |
|
351 |
repeatButton = new Button(displayParam, SWT.CHECK); |
|
352 |
repeatButton.setText(RCPMessages.ProgressionDialog_15); |
|
353 |
repeatButton.setSelection(repeatvalues); |
|
354 |
|
|
355 |
//Color options |
|
356 |
colorButton = new Button(displayParam, SWT.CHECK); |
|
357 |
colorButton.setText(SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeBlackAndWhite); |
|
358 |
colorButton.setSelection(blackAndWhite); |
|
359 |
|
|
360 |
// queries param |
|
361 |
Label focusLabel = new Label(paramPanel, SWT.NONE); |
|
362 |
focusLabel.setText(RCPMessages.ProgressionDialog_8); |
|
363 |
focusLabel.setAlignment(SWT.CENTER); |
|
364 |
|
|
365 |
Button plusButton = new Button(paramPanel, SWT.NONE); |
|
366 |
plusButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
367 |
true, true)); |
|
368 |
plusButton.setText(RCPMessages.ProgressionDialog_9); |
|
369 |
plusButton.addListener(SWT.Selection, new Listener() { |
|
370 |
@Override |
|
371 |
public void handleEvent(Event event) { |
|
372 |
if (colors.length > queryWidgets.size()) { |
|
373 |
Log.info("add query field"); |
|
374 |
createTypeFocusField(); |
|
375 |
sc1.layout(true); |
|
376 |
focusComposite.layout(true); |
|
377 |
sc1.setMinSize(focusComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
|
378 |
} |
|
379 |
} |
|
380 |
}); |
|
381 |
|
|
382 |
Button minusButton = new Button(paramPanel, SWT.NONE); |
|
383 |
minusButton.setLayoutData(new GridData(GridData.FILL, |
|
384 |
GridData.FILL, true, true)); |
|
385 |
minusButton.setText(RCPMessages.ProgressionDialog_5); |
|
386 |
minusButton.addListener(SWT.Selection, new Listener() { |
|
387 |
@Override |
|
388 |
public void handleEvent(Event event) { |
|
389 |
if (queryWidgets.size() > 0) { |
|
390 |
// System.out.println("remove field"); |
|
391 |
AssistedQueryWidget lastwidget = queryWidgets |
|
392 |
.get(queryWidgets.size() - 1); |
|
393 |
lastwidget.setSize(200, 30); |
|
394 |
queryWidgets.remove(queryWidgets.size() - 1); |
|
395 |
lastwidget.dispose(); |
|
396 |
sc1.layout(true); |
|
397 |
focusComposite.layout(true); |
|
398 |
sc1.setMinSize(focusComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
|
399 |
} |
|
400 |
} |
|
401 |
}); |
|
402 |
|
|
403 |
if (queries == null) { |
|
404 |
createTypeFocusField(); |
|
405 |
} else { |
|
406 |
for (Query q : queries) { |
|
407 |
createTypeFocusField().setText(q.getQueryString()); |
|
408 |
} |
|
409 |
} |
|
410 |
return mainPanel; |
|
411 |
} catch (Exception e) { |
|
412 |
Log.printStackTrace(e); |
|
413 |
} |
|
414 |
return null; |
|
415 |
} |
|
416 |
|
|
417 |
/** |
|
418 |
* Creates the type focus field. |
|
419 |
* |
|
420 |
* @return the assisted query widget |
|
421 |
*/ |
|
422 |
private AssistedQueryWidget createTypeFocusField() { |
|
423 |
AssistedQueryWidget focusTextBox = new AssistedQueryWidget( |
|
424 |
focusComposite, SWT.BORDER, this.corpus); |
|
425 |
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, |
|
426 |
false); |
|
427 |
focusTextBox.setLayoutData(gridData); |
|
428 |
focusTextBox.setFocus(); |
|
429 |
queryWidgets.add(focusTextBox); |
|
430 |
return focusTextBox; |
|
431 |
} |
|
432 |
|
|
433 |
/* (non-Javadoc) |
|
434 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
435 |
*/ |
|
436 |
@Override |
|
437 |
protected void okPressed() { |
|
438 |
|
|
439 |
queries = new ArrayList<Query>(); |
|
440 |
for (AssistedQueryWidget wid : queryWidgets) { |
|
441 |
if (!wid.getQueryString().equals("\"\"")) //$NON-NLS-1$ |
|
442 |
{ |
|
443 |
queries.add(new Query(wid.getQueryString())); |
|
444 |
wid.memorize(); |
|
445 |
} |
|
446 |
} |
|
447 |
|
|
448 |
if (propertyCombo.getSelectionIndex() > 0) |
|
449 |
selectedStructuralUnitProperty = structuralUnitsProperties |
|
450 |
.get(propertyCombo.getSelectionIndex() - 1); |
|
451 |
else |
|
452 |
selectedStructuralUnitProperty = null; |
|
453 |
|
|
454 |
if (structuralUnitsCombo.getSelectionIndex() > 0) |
|
455 |
selectedStructuralUnit = structuralUnits.get(structuralUnitsCombo |
|
456 |
.getSelectionIndex() - 1); |
|
457 |
else { |
|
458 |
selectedStructuralUnit = null; |
|
459 |
selectedStructuralUnitProperty = null;// need a structuralunit |
|
460 |
} |
|
461 |
|
|
462 |
try { |
|
463 |
Pattern.compile(regexValue.getText()); |
|
464 |
regexpropertyValue = regexValue.getText(); |
|
465 |
|
|
466 |
if (regexpropertyValue.length() == 0) |
|
467 |
regexpropertyValue = null; |
|
468 |
} catch (PatternSyntaxException e) { |
|
469 |
System.out.println(RCPMessages.ProgressionDialog_10 + e); |
|
470 |
} |
|
471 |
|
|
472 |
cumulative = cumuButton.getSelection(); |
|
473 |
blackAndWhite = colorButton.getSelection(); |
|
474 |
monostyle = styleButton.getSelection(); |
|
475 |
repeatvalues = repeatButton.getSelection(); |
|
476 |
String smultibande = bandeField.getText(); |
|
477 |
if (smultibande != null && smultibande.length() > 0) |
|
478 |
{ |
|
479 |
try |
|
480 |
{ bandemultiplier = Float.parseFloat(smultibande); |
|
481 |
|
|
482 |
}catch(Exception e){ |
|
483 |
bandemultiplier = 1.0f; |
|
484 |
System.out.println(RCPMessages.ProgressionDialog_17+e); |
|
485 |
StatusLine.error(RCPMessages.ProgressionDialog_17+e); |
|
486 |
} |
|
487 |
} |
|
488 |
else |
|
489 |
bandemultiplier = 1.0f; |
|
490 |
|
|
491 |
super.okPressed(); |
|
492 |
} |
|
493 |
|
|
494 |
/** |
|
495 |
* Reload properties. |
|
496 |
*/ |
|
497 |
private void reloadProperties() { |
|
498 |
propertyCombo.removeAll(); |
|
499 |
propertyCombo.add(" "); //$NON-NLS-1$ |
|
500 |
|
|
501 |
if (structuralUnitsCombo.getSelectionIndex() > 0) { |
|
502 |
selectedStructuralUnit = structuralUnits.get(structuralUnitsCombo |
|
503 |
.getSelectionIndex() - 1); |
|
504 |
structuralUnitsProperties = selectedStructuralUnit.getOrderedProperties(); |
|
505 |
for (StructuralUnitProperty property : structuralUnitsProperties) { |
|
506 |
propertyCombo.add(property.getName()); |
|
507 |
} |
|
508 |
} |
|
509 |
if (propertyCombo.getItemCount() > 0) { |
|
510 |
propertyCombo.select(0); |
|
511 |
} |
|
512 |
} |
|
513 |
|
|
514 |
/** |
|
515 |
* Gets the corpus. |
|
516 |
* |
|
517 |
* @return the corpus |
|
518 |
*/ |
|
519 |
public Corpus getCorpus() { |
|
520 |
return corpus; |
|
521 |
} |
|
522 |
|
|
523 |
/** |
|
524 |
* Gets the queries. |
|
525 |
* |
|
526 |
* @return the queries |
|
527 |
*/ |
|
528 |
public List<Query> getQueries() { |
|
529 |
return queries; |
|
530 |
} |
|
531 |
|
|
532 |
/** |
|
533 |
* Gets the colors. |
|
534 |
* |
|
535 |
* @return the colors |
|
536 |
*/ |
|
537 |
public List<String> getColors() { |
|
538 |
return null; |
|
539 |
} |
|
540 |
|
|
541 |
/** |
|
542 |
* Gets the structural unit. |
|
543 |
* |
|
544 |
* @return the structural unit |
|
545 |
*/ |
|
546 |
public StructuralUnit getStructuralUnit() { |
|
547 |
return selectedStructuralUnit; |
|
548 |
} |
|
549 |
|
|
550 |
/** |
|
551 |
* Gets the graph type. |
|
552 |
* |
|
553 |
* @return the graph type |
|
554 |
*/ |
|
555 |
public boolean isCumulativeType() { |
|
556 |
return cumulative; |
|
557 |
} |
|
558 |
|
|
559 |
/** |
|
560 |
* Gets the bande multiplier. |
|
561 |
* |
|
562 |
* @return the bande multiplier |
|
563 |
*/ |
|
564 |
public float getBandeMultiplier() |
|
565 |
{ |
|
566 |
return bandemultiplier; |
|
567 |
} |
|
568 |
|
|
569 |
/** |
|
570 |
* Checks if is monochrome. |
|
571 |
* |
|
572 |
* @return true, if is monochrome |
|
573 |
*/ |
|
574 |
public boolean isBlackAndWhite() { |
|
575 |
return blackAndWhite; |
|
576 |
} |
|
577 |
|
|
578 |
/** |
|
579 |
* Checks if is repeatvalues. |
|
580 |
* |
|
581 |
* @return true, if is repeatvalues |
|
582 |
*/ |
|
583 |
public boolean isRepeatvalues() { |
|
584 |
return repeatvalues; |
|
585 |
} |
|
586 |
|
|
587 |
/** |
|
588 |
* Gets the structural property. |
|
589 |
* |
|
590 |
* @return the structural property |
|
591 |
*/ |
|
592 |
public StructuralUnitProperty getStructuralProperty() { |
|
593 |
return selectedStructuralUnitProperty; |
|
594 |
} |
|
595 |
|
|
596 |
/** |
|
597 |
* Gets the propertyregex. |
|
598 |
* |
|
599 |
* @return the propertyregex |
|
600 |
*/ |
|
601 |
public String getPropertyregex() { |
|
602 |
return regexpropertyValue; |
|
603 |
} |
|
604 |
|
|
605 |
/** |
|
606 |
* Checks if is mono style. |
|
607 |
* |
|
608 |
* @return true, if is mono style |
|
609 |
*/ |
|
610 |
public boolean isMonoStyle() { |
|
611 |
|
|
612 |
return monostyle; |
|
613 |
} |
|
614 |
|
|
615 |
/** |
|
616 |
* Gets the line width. |
|
617 |
* |
|
618 |
* @return the line width |
|
619 |
*/ |
|
620 |
public int getLineWidth() |
|
621 |
{ |
|
622 |
return linewidth; |
|
623 |
} |
|
624 |
} |
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/dialogs/___ProgressionDialog.java (revision 538) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.progression.rcp.dialogs; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
import java.util.regex.Pattern; |
|
33 |
import java.util.regex.PatternSyntaxException; |
|
34 |
|
|
35 |
import org.eclipse.jface.dialogs.Dialog; |
|
36 |
import org.eclipse.swt.SWT; |
|
37 |
import org.eclipse.swt.custom.ScrolledComposite; |
|
38 |
import org.eclipse.swt.events.SelectionEvent; |
|
39 |
import org.eclipse.swt.events.SelectionListener; |
|
40 |
import org.eclipse.swt.layout.FormAttachment; |
|
41 |
import org.eclipse.swt.layout.FormData; |
|
42 |
import org.eclipse.swt.layout.FormLayout; |
|
43 |
import org.eclipse.swt.layout.GridData; |
|
44 |
import org.eclipse.swt.layout.GridLayout; |
|
45 |
import org.eclipse.swt.widgets.Button; |
|
46 |
import org.eclipse.swt.widgets.Combo; |
|
47 |
import org.eclipse.swt.widgets.Composite; |
|
48 |
import org.eclipse.swt.widgets.Control; |
|
49 |
import org.eclipse.swt.widgets.Event; |
|
50 |
import org.eclipse.swt.widgets.Group; |
|
51 |
import org.eclipse.swt.widgets.Label; |
|
52 |
import org.eclipse.swt.widgets.Listener; |
|
53 |
import org.eclipse.swt.widgets.Shell; |
|
54 |
import org.eclipse.swt.widgets.Text; |
|
55 |
import org.txm.chartsengine.core.ChartsEngine; |
|
56 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
|
57 |
import org.txm.chartsengine.r.core.themes.DefaultTheme; |
|
58 |
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages; |
|
59 |
import org.txm.core.messages.TXMCoreMessages; |
|
60 |
import org.txm.core.preferences.TXMPreferences; |
|
61 |
import org.txm.progression.core.preferences.ProgressionPreferences; |
|
62 |
import org.txm.rcp.preferences.TXMPreferenceStore; |
|
63 |
import org.txm.rcp.RCPMessages; |
|
64 |
import org.txm.rcp.StatusLine; |
|
65 |
import org.txm.rcp.swt.widget.AssistedQueryWidget; |
|
66 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
67 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
|
68 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
69 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
70 |
import org.txm.utils.logger.Log; |
|
71 |
|
|
72 |
/** |
|
73 |
* Allow the user to choose : the type of the graphic the structural units, |
|
74 |
* property and values to be shown the queries of each curves. |
|
75 |
* |
|
76 |
* @author mdecorde |
|
77 |
* @author sjacquot |
|
78 |
*/ |
|
79 |
public class ___ProgressionDialog extends Dialog { |
|
80 |
|
|
81 |
/** The query widgets. */ |
|
82 |
protected List<AssistedQueryWidget> queryWidgets = new ArrayList<AssistedQueryWidget>(); |
|
83 |
|
|
84 |
/** The queries. */ |
|
85 |
List<Query> queries; |
|
86 |
|
|
87 |
/** The corpus. */ |
|
88 |
private Corpus corpus; |
|
89 |
|
|
90 |
/** The selected structural unit. */ |
|
91 |
private StructuralUnit selectedStructuralUnit; |
|
92 |
|
|
93 |
/** The selected structural unit property. */ |
|
94 |
private StructuralUnitProperty selectedStructuralUnitProperty; |
|
95 |
|
|
96 |
/** The regexproperty value. */ |
|
97 |
private String regexpropertyValue; |
|
98 |
|
|
99 |
/** The graphtype. */ |
|
100 |
private boolean cumulative = true; |
|
101 |
|
|
102 |
private boolean blackAndWhite = true; |
|
103 |
|
|
104 |
/** The monostyle. */ |
|
105 |
private boolean monostyle = true; |
|
106 |
|
|
107 |
/** The repeatvalues. */ |
|
108 |
private boolean repeatvalues = false; |
|
109 |
|
|
110 |
/** The linewidth. */ |
|
111 |
private int linewidth = 2; |
|
112 |
|
|
113 |
/** The bandemultiplier. */ |
|
114 |
private float bandemultiplier = 2; |
|
115 |
|
|
116 |
/** The structural units combo. */ |
|
117 |
Combo structuralUnitsCombo; |
|
118 |
|
|
119 |
/** The structural units. */ |
|
120 |
List<StructuralUnit> structuralUnits; |
|
121 |
|
|
122 |
/** The structural units properties. */ |
|
123 |
List<StructuralUnitProperty> structuralUnitsProperties; |
|
124 |
|
|
125 |
/** The property combo. */ |
|
126 |
private Combo propertyCombo; |
|
127 |
|
|
128 |
/** The regex value. */ |
|
129 |
private Text regexValue; |
|
130 |
|
|
131 |
/** The focus composite. */ |
|
132 |
Composite focusComposite; |
|
133 |
|
|
134 |
/** The main panel. */ |
|
135 |
Composite mainPanel; |
|
136 |
|
|
137 |
/** The bande field. */ |
|
138 |
Text bandeField; |
|
139 |
|
|
140 |
/** The cumu button. */ |
|
141 |
Button cumuButton; |
|
142 |
|
|
143 |
/** The repeat button. */ |
|
144 |
Button repeatButton; |
|
145 |
|
|
146 |
/** The color button. */ |
|
147 |
Button colorButton; |
|
148 |
|
|
149 |
/** The style button. */ |
|
150 |
Button styleButton; |
|
151 |
|
|
152 |
/** The colors. */ |
|
153 |
String[] colors = DefaultTheme.colors; |
|
154 |
|
|
155 |
/** The self. */ |
|
156 |
___ProgressionDialog self; |
|
157 |
|
|
158 |
/** The parent. */ |
|
159 |
private Composite parent; |
|
160 |
|
|
161 |
private ScrolledComposite sc1; |
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
/** |
|
166 |
* Instantiates a new progression dialog. |
|
167 |
* |
|
168 |
* @param parentShell the parent shell |
|
169 |
* @param corpus the corpus |
|
170 |
*/ |
|
171 |
public ___ProgressionDialog(Shell parentShell, Corpus corpus) { |
|
172 |
super(parentShell); |
|
173 |
this.corpus = corpus; |
|
174 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Instantiates a new progression dialog. |
|
179 |
* |
|
180 |
* @param parentShell the parent shell |
|
181 |
* @param corpus the corpus |
|
182 |
* @param queries the queries |
|
183 |
*/ |
|
184 |
public ___ProgressionDialog(Shell parentShell, Corpus corpus, |
|
185 |
List<Query> queries) { |
|
186 |
super(parentShell); |
|
187 |
this.corpus = corpus; |
|
188 |
this.queries = queries; |
|
189 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
190 |
} |
|
191 |
|
|
192 |
/* (non-Javadoc) |
|
193 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
|
194 |
*/ |
|
195 |
@Override |
|
196 |
protected void configureShell(Shell newShell) { |
|
197 |
super.configureShell(newShell); |
|
198 |
newShell.setText(RCPMessages.ProgressionDialog_0); |
|
199 |
newShell.setMinimumSize(300, 460); |
|
200 |
|
|
201 |
} |
|
202 |
|
|
203 |
/* (non-Javadoc) |
|
204 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
205 |
*/ |
|
206 |
@Override |
|
207 |
protected Control createDialogArea(Composite p) { |
|
208 |
try { |
|
209 |
this.self = this; |
|
210 |
this.parent = p; |
|
211 |
|
|
212 |
// get preferences values |
|
213 |
TXMPreferenceStore store = new TXMPreferenceStore(ProgressionPreferences.PREFERENCES_NODE); |
|
214 |
|
|
215 |
this.blackAndWhite = (TXMPreferences.getInt(ChartsEnginePreferences.RENDERING_COLORS_MODE, ProgressionPreferences.PREFERENCES_NODE) == ChartsEngine.RENDERING_BLACK_AND_WHITE_MODE); |
|
216 |
|
|
217 |
this.monostyle = store.getBoolean(ProgressionPreferences.CHART_MONO_STYLE); |
|
218 |
this.cumulative = store.getBoolean(ProgressionPreferences.CHART_CUMULATIVE); |
|
219 |
this.repeatvalues = store.getBoolean(ProgressionPreferences.CHART_REPEAT_VALUES); |
|
220 |
this.bandemultiplier = store.getFloat(ProgressionPreferences.CHART_BANDE_MULTIPLIER); |
|
221 |
|
|
222 |
// System.out.println(parent.getLayout()); |
|
223 |
FormLayout mainlayout = new FormLayout(); |
|
224 |
mainPanel = new Composite(parent, SWT.NONE); |
|
225 |
mainPanel.setLayout(mainlayout); |
|
226 |
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true); |
|
227 |
mainPanel.setLayoutData(gridData); |
|
228 |
|
|
229 |
Composite paramPanel = new Composite(mainPanel, SWT.NONE); |
|
230 |
// set the QueryWidget's tab |
|
231 |
|
|
232 |
sc1 = new ScrolledComposite(mainPanel, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); |
|
233 |
sc1.setLayout(new GridLayout(1, true)); |
|
234 |
sc1.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
235 |
sc1.setExpandHorizontal( true ); |
|
236 |
sc1.setExpandVertical( true ); |
|
237 |
sc1.setMinSize( 0, 250 ); |
|
238 |
|
|
239 |
focusComposite = new Composite(sc1, SWT.NONE); |
|
240 |
focusComposite.setLayout(new GridLayout(1, true)); |
|
241 |
sc1.setContent(focusComposite); |
|
242 |
|
|
243 |
FormData paramPanelData = new FormData(); |
|
244 |
paramPanelData.top = new FormAttachment(0); |
|
245 |
paramPanelData.left = new FormAttachment(0); |
|
246 |
paramPanelData.right = new FormAttachment(100); |
|
247 |
paramPanel.setLayoutData(paramPanelData); |
|
248 |
|
|
249 |
FormData queriesPanelData = new FormData(); |
|
250 |
queriesPanelData.top = new FormAttachment(paramPanel); |
|
251 |
queriesPanelData.left = new FormAttachment(0); |
|
252 |
queriesPanelData.right = new FormAttachment(100); |
|
253 |
queriesPanelData.bottom = new FormAttachment(100); |
|
254 |
sc1.setLayoutData(queriesPanelData); |
|
255 |
|
|
256 |
paramPanel.setLayout(new GridLayout(3, true)); |
|
257 |
|
|
258 |
// controls |
|
259 |
// graph param |
|
260 |
Label typeLabel = new Label(paramPanel, SWT.NONE); |
|
261 |
typeLabel.setText(RCPMessages.ProgressionDialog_1); |
|
262 |
typeLabel.setAlignment(SWT.CENTER); |
|
263 |
|
|
264 |
cumuButton = new Button(paramPanel, SWT.RADIO); |
|
265 |
cumuButton.setText(RCPMessages.ProgressionDialog_2); |
|
266 |
cumuButton.setSelection(cumulative); |
|
267 |
|
|
268 |
Button densityButton = new Button(paramPanel, SWT.RADIO); |
|
269 |
densityButton.setText(RCPMessages.ProgressionDialog_3); |
|
270 |
densityButton.setSelection(!cumulative); |
|
271 |
|
|
272 |
//Bande size |
|
273 |
typeLabel = new Label(paramPanel, SWT.NONE); |
|
274 |
typeLabel.setText(RCPMessages.ProgressionDialog_11); |
|
275 |
typeLabel.setAlignment(SWT.CENTER); |
|
276 |
|
|
277 |
bandeField = new Text(paramPanel, SWT.BORDER); |
|
278 |
bandeField.setText(""+bandemultiplier); //$NON-NLS-1$ |
|
279 |
bandeField.setLayoutData(new GridData(GridData.FILL, |
|
280 |
GridData.FILL, true, true, 2, 1)); |
|
281 |
// Structural units param |
|
282 |
Group displayParam = new Group(paramPanel, SWT.BORDER); |
|
283 |
displayParam.setText(RCPMessages.ProgressionDialog_13); |
|
284 |
displayParam.setLayout(new GridLayout(3, true)); |
|
285 |
displayParam.setLayoutData(new GridData(GridData.FILL, |
|
286 |
GridData.FILL, true, true, 3, 1)); |
|
287 |
|
|
288 |
Label structLabel = new Label(displayParam, SWT.NONE); |
|
289 |
structLabel.setText(RCPMessages.ProgressionDialog_4); |
|
290 |
structLabel.setAlignment(SWT.CENTER); |
|
291 |
|
|
292 |
structuralUnitsCombo = new Combo(displayParam, SWT.READ_ONLY); |
|
293 |
structuralUnitsCombo.setLayoutData(new GridData(GridData.FILL, |
|
294 |
GridData.FILL, true, true, 2, 1)); |
|
295 |
|
|
296 |
structuralUnitsCombo.addSelectionListener(new SelectionListener() { |
|
297 |
@Override |
|
298 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
299 |
} |
|
300 |
|
|
301 |
@Override |
|
302 |
public void widgetSelected(SelectionEvent event) { |
|
303 |
reloadProperties(); |
|
304 |
} |
|
305 |
}); |
|
306 |
|
|
307 |
try {// get |
|
308 |
structuralUnitsCombo.add(" "); //$NON-NLS-1$ |
|
309 |
structuralUnits = corpus.getOrderedStructuralUnits(); |
|
310 |
for (StructuralUnit unit : structuralUnits) { |
|
311 |
structuralUnitsCombo.add(unit.getName()); |
|
312 |
} |
|
313 |
} catch (Exception e) { |
|
314 |
Log.severe(RCPMessages.ObjectExplorer_9 |
|
315 |
+ Log.toString(e)); |
|
316 |
return null; |
|
317 |
} |
|
318 |
structuralUnitsCombo.select(0); |
|
319 |
|
|
320 |
// if (structuralUnitsCombo.getItemCount() == 0) { |
|
321 |
// this.getButton(IDialogConstants.OK_ID).setEnabled(false); |
|
322 |
// } else { |
|
323 |
// selectedStructuralUnit = structuralUnits.get(0); |
|
324 |
// } |
|
325 |
|
|
326 |
// properties combo |
|
327 |
Label propLabel = new Label(displayParam, SWT.NONE); |
|
328 |
propLabel.setText(TXMCoreMessages.PROPERTY_1); |
|
329 |
propLabel.setAlignment(SWT.CENTER); |
|
330 |
|
|
331 |
propertyCombo = new Combo(displayParam, SWT.READ_ONLY); |
|
332 |
propertyCombo.setLayoutData(new GridData(GridData.FILL, |
|
333 |
GridData.FILL, true, true, 2, 1)); |
|
334 |
reloadProperties(); |
|
335 |
|
|
336 |
// property value field |
|
337 |
Label regexLabel = new Label(displayParam, SWT.NONE); |
|
338 |
regexLabel.setText(RCPMessages.ProgressionDialog_7); |
|
339 |
regexLabel.setAlignment(SWT.CENTER); |
|
340 |
|
|
341 |
regexValue = new Text(displayParam, SWT.SINGLE | SWT.BORDER); |
|
342 |
regexValue.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
343 |
true, true, 2, 1)); |
|
344 |
|
|
345 |
//spacer |
|
346 |
styleButton = new Button(displayParam, SWT.CHECK); |
|
347 |
styleButton.setText(RCPMessages.ProgressionDialog_14); |
|
348 |
styleButton.setSelection(monostyle); |
|
349 |
|
|
350 |
//Repeat options |
|
351 |
repeatButton = new Button(displayParam, SWT.CHECK); |
|
352 |
repeatButton.setText(RCPMessages.ProgressionDialog_15); |
|
353 |
repeatButton.setSelection(repeatvalues); |
|
354 |
|
|
355 |
//Color options |
|
356 |
colorButton = new Button(displayParam, SWT.CHECK); |
|
357 |
colorButton.setText(SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeBlackAndWhite); |
|
358 |
colorButton.setSelection(blackAndWhite); |
|
359 |
|
|
360 |
// queries param |
|
361 |
Label focusLabel = new Label(paramPanel, SWT.NONE); |
|
362 |
focusLabel.setText(RCPMessages.ProgressionDialog_8); |
|
363 |
focusLabel.setAlignment(SWT.CENTER); |
|
364 |
|
|
365 |
Button plusButton = new Button(paramPanel, SWT.NONE); |
|
366 |
plusButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
367 |
true, true)); |
|
368 |
plusButton.setText(RCPMessages.ProgressionDialog_9); |
|
369 |
plusButton.addListener(SWT.Selection, new Listener() { |
|
370 |
@Override |
|
371 |
public void handleEvent(Event event) { |
|
372 |
if (colors.length > queryWidgets.size()) { |
|
373 |
Log.info("add query field"); |
|
374 |
createTypeFocusField(); |
|
375 |
sc1.layout(true); |
|
376 |
focusComposite.layout(true); |
|
377 |
sc1.setMinSize(focusComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
|
378 |
} |
|
379 |
} |
|
380 |
}); |
|
381 |
|
|
382 |
Button minusButton = new Button(paramPanel, SWT.NONE); |
|
383 |
minusButton.setLayoutData(new GridData(GridData.FILL, |
|
384 |
GridData.FILL, true, true)); |
|
385 |
minusButton.setText(RCPMessages.ProgressionDialog_5); |
|
386 |
minusButton.addListener(SWT.Selection, new Listener() { |
|
387 |
@Override |
|
388 |
public void handleEvent(Event event) { |
|
389 |
if (queryWidgets.size() > 0) { |
|
390 |
// System.out.println("remove field"); |
|
391 |
AssistedQueryWidget lastwidget = queryWidgets |
|
392 |
.get(queryWidgets.size() - 1); |
|
393 |
lastwidget.setSize(200, 30); |
|
394 |
queryWidgets.remove(queryWidgets.size() - 1); |
|
395 |
lastwidget.dispose(); |
|
396 |
sc1.layout(true); |
|
397 |
focusComposite.layout(true); |
|
398 |
sc1.setMinSize(focusComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
|
399 |
} |
|
400 |
} |
|
401 |
}); |
|
402 |
|
|
403 |
if (queries == null) { |
|
404 |
createTypeFocusField(); |
|
405 |
} else { |
|
406 |
for (Query q : queries) { |
|
407 |
createTypeFocusField().setText(q.getQueryString()); |
|
408 |
} |
|
409 |
} |
|
410 |
return mainPanel; |
|
411 |
} catch (Exception e) { |
|
412 |
Log.printStackTrace(e); |
|
413 |
} |
|
414 |
return null; |
|
415 |
} |
|
416 |
|
|
417 |
/** |
|
418 |
* Creates the type focus field. |
|
419 |
* |
|
420 |
* @return the assisted query widget |
|
421 |
*/ |
|
422 |
private AssistedQueryWidget createTypeFocusField() { |
|
423 |
AssistedQueryWidget focusTextBox = new AssistedQueryWidget( |
|
424 |
focusComposite, SWT.BORDER, this.corpus); |
|
425 |
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, |
|
426 |
false); |
|
427 |
focusTextBox.setLayoutData(gridData); |
|
428 |
focusTextBox.setFocus(); |
|
429 |
queryWidgets.add(focusTextBox); |
|
430 |
return focusTextBox; |
|
431 |
} |
|
432 |
|
|
433 |
/* (non-Javadoc) |
|
434 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
435 |
*/ |
|
436 |
@Override |
|
437 |
protected void okPressed() { |
|
438 |
|
|
439 |
queries = new ArrayList<Query>(); |
|
440 |
for (AssistedQueryWidget wid : queryWidgets) { |
|
441 |
if (!wid.getQueryString().equals("\"\"")) //$NON-NLS-1$ |
|
442 |
{ |
|
443 |
queries.add(new Query(wid.getQueryString())); |
|
444 |
wid.memorize(); |
|
445 |
} |
|
446 |
} |
|
447 |
|
|
448 |
if (propertyCombo.getSelectionIndex() > 0) |
|
449 |
selectedStructuralUnitProperty = structuralUnitsProperties |
|
450 |
.get(propertyCombo.getSelectionIndex() - 1); |
|
451 |
else |
|
452 |
selectedStructuralUnitProperty = null; |
|
453 |
|
|
454 |
if (structuralUnitsCombo.getSelectionIndex() > 0) |
|
455 |
selectedStructuralUnit = structuralUnits.get(structuralUnitsCombo |
|
456 |
.getSelectionIndex() - 1); |
|
457 |
else { |
|
458 |
selectedStructuralUnit = null; |
|
459 |
selectedStructuralUnitProperty = null;// need a structuralunit |
|
460 |
} |
|
461 |
|
|
462 |
try { |
|
463 |
Pattern.compile(regexValue.getText()); |
|
464 |
regexpropertyValue = regexValue.getText(); |
|
465 |
|
|
466 |
if (regexpropertyValue.length() == 0) |
|
467 |
regexpropertyValue = null; |
|
468 |
} catch (PatternSyntaxException e) { |
|
469 |
System.out.println(RCPMessages.ProgressionDialog_10 + e); |
|
470 |
} |
|
471 |
|
|
472 |
cumulative = cumuButton.getSelection(); |
|
473 |
blackAndWhite = colorButton.getSelection(); |
|
474 |
monostyle = styleButton.getSelection(); |
|
475 |
repeatvalues = repeatButton.getSelection(); |
|
476 |
String smultibande = bandeField.getText(); |
|
477 |
if (smultibande != null && smultibande.length() > 0) |
|
478 |
{ |
|
479 |
try |
|
480 |
{ bandemultiplier = Float.parseFloat(smultibande); |
|
481 |
|
|
482 |
}catch(Exception e){ |
|
483 |
bandemultiplier = 1.0f; |
|
484 |
System.out.println(RCPMessages.ProgressionDialog_17+e); |
|
485 |
StatusLine.error(RCPMessages.ProgressionDialog_17+e); |
|
486 |
} |
|
487 |
} |
|
488 |
else |
|
489 |
bandemultiplier = 1.0f; |
|
490 |
|
|
491 |
super.okPressed(); |
|
492 |
} |
|
493 |
|
|
494 |
/** |
|
495 |
* Reload properties. |
|
496 |
*/ |
|
497 |
private void reloadProperties() { |
|
498 |
propertyCombo.removeAll(); |
Formats disponibles : Unified diff