Révision 285

tmp/org.txm.cah.rcp/.settings/org.eclipse.core.resources.prefs (revision 285)
1
eclipse.preferences.version=1
2
encoding//src/org/txm/cah/rcp/messages/messages_ru.properties=UTF-8
0 3

  
tmp/org.txm.cah.rcp/.settings/org.eclipse.jdt.core.prefs (revision 285)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4
org.eclipse.jdt.core.compiler.compliance=1.6
5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7
org.eclipse.jdt.core.compiler.source=1.6
0 8

  
tmp/org.txm.cah.rcp/.classpath (revision 285)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
0 8

  
tmp/org.txm.cah.rcp/META-INF/MANIFEST.MF (revision 285)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: CAH RCP
4
Bundle-SymbolicName: org.txm.cah.rcp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
7
Export-Package: org.txm.cah.rcp.adapters,
8
 org.txm.cah.rcp.editors,
9
 org.txm.cah.rcp.handlers,
10
 org.txm.cah.rcp.messages,
11
 org.txm.cah.rcp.preferences
12
Require-Bundle: org.txm.cah.core;bundle-version="1.0.0",
13
 org.txm.chartsengine.rcp;bundle-version="1.0.0",
14
 org.txm.core;bundle-version="0.7.0",
15
 org.txm.rcp;bundle-version="0.7.8",
16
 org.eclipse.ui;bundle-version="3.106.1",
17
 org.eclipse.core.runtime;bundle-version="3.10.0",
18
 org.txm.ca.core,
19
 org.txm.lexicaltable.core;bundle-version="1.0.0",
20
 org.txm.lexicaltable.rcp;bundle-version="1.0.0",
21
 org.eclipse.core.expressions;bundle-version="3.4.600"
22
Bundle-Vendor: Textometrie.org
0 23

  
tmp/org.txm.cah.rcp/.project (revision 285)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.cah.rcp</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
0 29

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/handlers/package.html (revision 285)
1
<html>
2
<body>
3
	<p>Commands which call textometry functions</p>
4
</body>
5
</html>
0 6

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/handlers/ComputeCAH.java (revision 285)
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.cah.rcp.handlers;
29

  
30
import org.eclipse.core.commands.ExecutionEvent;
31
import org.eclipse.core.commands.ExecutionException;
32
import org.eclipse.jface.dialogs.Dialog;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.jface.window.Window;
35
import org.eclipse.swt.SWT;
36
import org.eclipse.swt.layout.GridLayout;
37
import org.eclipse.swt.widgets.Button;
38
import org.eclipse.swt.widgets.Composite;
39
import org.eclipse.swt.widgets.Control;
40
import org.eclipse.swt.widgets.Display;
41
import org.eclipse.swt.widgets.Label;
42
import org.eclipse.swt.widgets.Shell;
43
import org.eclipse.swt.widgets.Spinner;
44
import org.eclipse.ui.handlers.HandlerUtil;
45
import org.txm.ca.core.functions.CA;
46
import org.txm.ca.core.preferences.CAPreferences;
47
import org.txm.cah.core.functions.CAH;
48
import org.txm.cah.core.messages.CAHCoreMessages;
49
import org.txm.cah.core.preferences.CAHPreferences;
50
import org.txm.cah.rcp.messages.CAHUIMessages;
51
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
52
import org.txm.core.preferences.TXMPreferences;
53
import org.txm.lexicaltable.core.functions.LexicalTableFactory;
54
import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
55
import org.txm.lexicaltable.rcp.editors.LexicalTableDialog;
56
import org.txm.rcp.handlers.BaseAbstractHandler;
57
import org.txm.rcpapplication.TxmPreferences;
58
import org.txm.rcpapplication.views.corpora.CorporaView;
59
import org.txm.searchengine.cqp.corpus.Partition;
60
import org.txm.searchengine.cqp.corpus.Property;
61
import org.txm.statsengine.core.StatException;
62
import org.txm.utils.logger.Log;
63

  
64
/**
65
 * If the selection is a CA or a Lexical Table result computes the CAH.
66
 *
67
 * @author mdecorde
68
 * @author sjacquot
69
 */
70
public class ComputeCAH extends BaseAbstractHandler {
71

  
72

  
73
	// adds a double click listener to the Corpus View
74
	static	{
75
		CorporaView.addDoubleClickListener(CAH.class, ComputeCAH.class);
76
	}
77
	
78

  
79
	/* (non-Javadoc)
80
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
81
	 */
82
	@Override
83
	public Object execute(ExecutionEvent event) throws ExecutionException {
84

  
85

  
86
		if(!this.checkStatsEngine()) {
87
			return null;
88
		}
89

  
90

  
91
		CAH cah = null;
92
		CA ca = null;
93
		LexicalTable lexicaltable = null;
94
		Partition partition = null;
95
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
96

  
97
		
98
		// Build the CA or not depending on the selection
99
		if (selection.getFirstElement() instanceof CAH) {
100
			cah = (CAH) selection.getFirstElement();
101
		} else if (selection.getFirstElement() instanceof CA) {
102
			//System.out.println("Compute CAH with CA : "+((CA)selection.getFirstElement()).getName());
103
			ca = (CA) selection.getFirstElement();
104
		} else if (selection.getFirstElement() instanceof LexicalTable) {
105
			//System.out.println("Compute CAH with LT : "+((LexicalTable)selection.getFirstElement()).getName());
106
			lexicaltable = (LexicalTable) selection.getFirstElement();
107
			
108
			try {
109
				ca = new CA(lexicaltable);
110
			} catch (StatException e) {
111
				System.out.println("Failed to build the CA with lexical table " + lexicaltable + ": " + e);
112
				Log.printStackTrace(e);
113
			}
114
			lexicaltable.addResult(ca);
115
			
116
//			if (lexicaltable.getPartition() != null)
117
//				lexicaltable.getPartition().storeResult(ca);
118
//			else if (lexicaltable.getCorpus() != null)
119
//				lexicaltable.getCorpus().storeResult(ca);
120
		} else if (selection.getFirstElement() instanceof Partition) {
121
			//System.out.println("Compute CAH with Partition : "+((Partition)selection.getFirstElement()).getName());
122
			partition = (Partition)selection.getFirstElement();
123
			try {
124
				String title = CAHUIMessages.bind(CAHUIMessages.ComputeCAH_0, partition.getName());
125
				int vmax = TXMPreferences.getInt(CAPreferences.PREFERENCES_NODE, CAPreferences.V_MAX);
126
				int fmin = TXMPreferences.getInt(CAPreferences.PREFERENCES_NODE, CAPreferences.F_MIN);
127
				Shell shell = Display.getCurrent().getActiveShell();
128
				LexicalTableDialog d = new LexicalTableDialog(shell, partition.getCorpus(), title);
129
				d.setFminAndVMax(fmin, vmax);
130
				
131
				if (d.open() == Window.OK) {
132
					Property property = d.getProperty();
133
					fmin = d.getFmin();
134
					vmax = d.getMaxLines();
135
					
136
					lexicaltable = LexicalTableFactory.getLexicalTable(partition, property, fmin); // use the CAPreferencePage Fmin
137
					lexicaltable.cut(vmax);
138
					partition.addResult(lexicaltable);
139
					
140
					ca = new CA(lexicaltable);
141
					lexicaltable.addResult(ca);
142
				} else {
143
					// canceled
144
					return null;
145
				}
146
			} catch (Exception e) {
147
				System.out.println("Failed to build the lexical table of " + partition + ": " + e);
148
				Log.printStackTrace(e);
149
				return null;
150
			} 
151
		}
152

  
153
		// Use existent CAH (used when reopening an editor from a CAH result node)
154
		//FIXME: why we remove the result from the parent here? it shouldn't be necessary
155
		if (cah != null)	{
156
			if (cah.getParent() != null)	{
157
				cah.getParent().removeResult(cah);
158
			}
159
		} else {
160
//			if (ca == null) cah = new CAH(lexicaltable, computeColumns, method, metric, ncluster, display2D);
161
//			else 
162
				cah = new CAH(ca,
163
						TXMPreferences.getBoolean(CAHPreferences.PREFERENCES_NODE, CAHPreferences.COLUMNS_COMPUTING),
164
						TXMPreferences.getString(CAHPreferences.PREFERENCES_NODE, CAHPreferences.METHOD),
165
						TXMPreferences.getString(CAHPreferences.PREFERENCES_NODE, CAHPreferences.METRIC),
166
						TXMPreferences.getInt(CAHPreferences.PREFERENCES_NODE, CAHPreferences.N_CLUSTERS)
167
						);
168
		}
169
	
170
		//compute(cah, null);
171
		SWTChartsComponentsProvider.getCurrent().openEditor(cah, CAHPreferences.PREFERENCES_NODE);
172

  
173
		return null;
174
	}
175

  
176

  
177

  
178

  
179
	/**
180
	 * The Class CAHParamDialog.
181
	 */
182
	public class CAHParamDialog extends Dialog {
183

  
184
		//protected Combo methodsCombo;
185
		//protected Combo metricsCombo;
186
		/** The ncluster spinner. */
187
		protected Spinner nclusterSpinner;
188

  
189
		/** The docolumns button. */
190
		protected Button docolumnsButton;
191

  
192
		/** The title. */
193
		protected String title;
194

  
195
		/**
196
		 * Instantiates a new cAH param dialog.
197
		 *
198
		 * @param parentShell the parent shell
199
		 */
200
		public CAHParamDialog(Shell parentShell) {
201
			super(parentShell);
202
			this.title = CAHCoreMessages.RESULT_TYPE;
203
		}
204

  
205
		/* (non-Javadoc)
206
		 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
207
		 */
208
		@Override
209
		protected void configureShell(Shell newShell) {
210
			super.configureShell(newShell);
211

  
212
			if (title != null)
213
				newShell.setText(title);
214
			else
215
				newShell.setText(CAHCoreMessages.RESULT_TYPE);
216
		}
217

  
218
		/** The composite. */
219
		protected Composite composite;
220

  
221
		/** The method. */
222
		private String method;
223

  
224
		/** The metric. */
225
		private String metric;
226

  
227
		/** The Ncluster. */
228
		private int Ncluster;
229

  
230
		/** The doculumns. */
231
		private boolean doculumns;
232

  
233
		/* (non-Javadoc)
234
		 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
235
		 */
236
		@Override
237
		protected Control createDialogArea(Composite parent) {
238
			composite = new Composite(parent, SWT.NONE);
239
			GridLayout layout = new GridLayout(2, false);
240
			composite.setLayout(layout);
241

  
242
			// N CLUSTERS
243
			Label label = new Label(composite, SWT.NONE);
244
			label.setText(CAHUIMessages.CAHPreferencePage_2);
245

  
246
			nclusterSpinner = new Spinner(composite, SWT.BORDER);
247
			nclusterSpinner.setMinimum(2);
248
			nclusterSpinner.setIncrement(1);
249
			nclusterSpinner.setSelection(TxmPreferences.getInt(CAHPreferences.N_CLUSTERS, 2));
250
			nclusterSpinner.setMaximum(50);
251

  
252
			// ROWS OR COLS
253
			docolumnsButton = new Button(composite, SWT.RADIO);
254
			docolumnsButton.setText(CAHUIMessages.COMPUTE_COLUMNS);
255
			docolumnsButton.setSelection(true);
256

  
257
			Button dorowsButton = new Button(composite, SWT.RADIO);
258
			dorowsButton.setText(CAHUIMessages.COMPUTE_ROWS);
259

  
260
			/*
261
			// METHODS
262
			Label methodLabel = new Label(composite, SWT.NONE);
263
			methodLabel.setText("Methods");
264

  
265
			methodLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER,
266
					false, false));
267

  
268
			methodsCombo = new Combo(composite, SWT.READ_ONLY);
269
			methodsCombo.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
270
					true, false));
271
			methodsCombo.select(methodsCombo.indexOf(CAH.getDefaultMethod()));
272
			for(String method : CAH.getMethods())
273
				methodsCombo.add(method);
274

  
275
			// METRICS
276
			Label metricsLabel = new Label(composite, SWT.NONE);
277
			metricsLabel.setText("Methods");
278

  
279
			metricsLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER,
280
					false, false));
281

  
282
			metricsCombo = new Combo(composite, SWT.READ_ONLY);
283
			metricsCombo.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
284
					true, false));
285
			metricsCombo.select(metricsCombo.indexOf(CAH.getDefaultMetric()));
286
			for(String method : CAH.getMetrics())
287
				metricsCombo.add(method);
288
				*/
289

  
290
			return composite;
291
		}
292

  
293
		/* (non-Javadoc)
294
		 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
295
		 */
296
		@Override
297
		protected void okPressed() {
298
			/*int idx = methodsCombo.getSelectionIndex();
299
			method = methodsCombo.getItem(idx);
300

  
301
			idx = metricsCombo.getSelectionIndex();
302
			metric = metricsCombo.getItem(idx);
303
*/
304
			Ncluster = this.nclusterSpinner.getSelection();
305

  
306
			doculumns = this.docolumnsButton.getSelection();
307

  
308
			super.okPressed();
309
		}
310

  
311
		/**
312
		 * Gets the method.
313
		 *
314
		 * @return the method
315
		 */
316
		public String getMethod() {
317
			return method;
318
		}
319

  
320
		/**
321
		 * Gets the metric.
322
		 *
323
		 * @return the metric
324
		 */
325
		public String getMetric() {
326
			return metric;
327
		}
328

  
329
		/**
330
		 * Gets the ncluster.
331
		 *
332
		 * @return the ncluster
333
		 */
334
		public int getNcluster() {
335
			return Ncluster;
336
		}
337

  
338
		/**
339
		 * Checks if is doculumns.
340
		 *
341
		 * @return true, if is doculumns
342
		 */
343
		public boolean isDoculumns() {
344
			return doculumns;
345
		}
346
	}
347

  
348

  
349
}
0 350

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/preferences/CAHPreferencePage.java (revision 285)
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.cah.rcp.preferences;
29

  
30
import org.eclipse.jface.preference.ComboFieldEditor;
31
import org.eclipse.jface.preference.IntegerFieldEditor;
32
import org.eclipse.jface.preference.RadioGroupFieldEditor;
33
import org.eclipse.swt.widgets.Composite;
34
import org.eclipse.ui.IWorkbench;
35
import org.txm.cah.core.functions.CAH;
36
import org.txm.cah.core.messages.CAHCoreMessages;
37
import org.txm.cah.core.preferences.CAHPreferences;
38
import org.txm.cah.rcp.adapters.CAHAdapterFactory;
39
import org.txm.cah.rcp.messages.CAHUIMessages;
40
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
41
import org.txm.rcp.preferences.TXMPreferencePage;
42
import org.txm.rcp.preferences.TXMPreferenceStore;
43

  
44
/**
45
 * CAH preferences page.
46
 * 
47
 * @author mdecorde
48
 * @author sjacquot
49
 */
50
public class CAHPreferencePage extends TXMPreferencePage {
51

  
52

  
53

  
54
	@Override
55
	public void createFieldEditors() {
56

  
57
		
58
		IntegerFieldEditor nClusters = new IntegerFieldEditor(CAHPreferences.N_CLUSTERS, CAHUIMessages.CAHPreferencePage_2, getFieldEditorParent());
59
		addField(nClusters);
60

  
61
		String list[] = CAH.getMethods(); 
62
		String methods[][] = new String[list.length][2];
63
		for(int i = 0 ; i < list.length ; i++)
64
			methods[i][0] = methods[i][1] = list[i];
65
				
66
		ComboFieldEditor method = new ComboFieldEditor(CAHPreferences.METHOD, CAHUIMessages.CAHPreferencePage_3, methods, getFieldEditorParent());
67
		addField(method);
68

  
69
		list = CAH.getMetrics(); 
70
		String metrics[][] = new String[list.length][2];
71
		for(int i = 0 ; i < list.length ; i++)
72
			metrics[i][0] = metrics[i][1] = list[i];
73
		
74
		ComboFieldEditor metric = new ComboFieldEditor(CAHPreferences.METRIC, CAHUIMessages.CAHPreferencePage_4, metrics, getFieldEditorParent());
75
		addField(metric);
76
		
77
		
78
		// Charts
79
		Composite chartsTab = SWTChartsComponentsProvider.createChartsRenderingPreferencesTabFolderComposite(getFieldEditorParent());
80

  
81
		String[][] labelAndValues = {{"2D", "true"}, {"3D", "false"}}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
82
		RadioGroupFieldEditor default2D3Ddisplay = new RadioGroupFieldEditor(CAHPreferences.DISPLAY_2D, CAHUIMessages.CAHPreferencePage_0, 2, labelAndValues, chartsTab);
83
		addField(default2D3Ddisplay);
84
		
85
		
86
		// other shared preferences
87
		SWTChartsComponentsProvider.createChartsRenderingPreferencesFields(this, chartsTab);
88
	}
89

  
90
	@Override
91
	public void init(IWorkbench workbench) {
92
		this.setPreferenceStore(new TXMPreferenceStore(CAHPreferences.PREFERENCES_NODE));
93
		//setDescription("CAH");
94
		this.setTitle(CAHCoreMessages.RESULT_TYPE);
95
		this.setImageDescriptor(CAHAdapterFactory.ICON);
96
	}
97

  
98
}
0 99

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/adapters/CAHAdapterFactory.java (revision 285)
1
// Copyright © 2010-2013 ENS de Lyon.
2
package org.txm.cah.rcp.adapters;
3

  
4
import org.eclipse.jface.resource.ImageDescriptor;
5
import org.eclipse.ui.model.IWorkbenchAdapter;
6
import org.eclipse.ui.plugin.AbstractUIPlugin;
7
import org.osgi.framework.FrameworkUtil;
8
import org.txm.cah.core.functions.CAH;
9
import org.txm.rcp.adapters.TXMResultAdapter;
10
import org.txm.rcp.adapters.TXMResultAdapterFactory;
11

  
12
/**
13
 * A factory for creating Adapter objects.
14
 *  
15
 * @author mdecorde
16
 * @author sjacquot
17
 */
18
public class CAHAdapterFactory extends TXMResultAdapterFactory {
19

  
20
	
21
	public static final ImageDescriptor ICON =
22
			AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(CAHAdapterFactory.class).getSymbolicName(),
23
					"platform:/plugin/"+ FrameworkUtil.getBundle(CAHAdapterFactory.class).getSymbolicName() + "/icons/cah.png"); //$NON-NLS-1$
24
	
25
	/**
26
	 * Gets the adapter.
27
	 *
28
	 * @param adaptableObject the adaptable object
29
	 * @param adapterType the adapter type
30
	 * @return the adapter
31
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
32
	 */
33
	@Override
34
	public Object getAdapter(Object adaptableObject, Class adapterType) {
35
		if(adapterType == IWorkbenchAdapter.class && adaptableObject instanceof CAH)	{
36
			return new TXMResultAdapter() {
37
				@Override
38
				public ImageDescriptor getImageDescriptor(Object object) {
39
					return ICON;
40
				}
41
			};
42
		}
43
		return null;
44
	}
45

  
46

  
47
}
0 48

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/messages/messages_ru.properties (revision 285)
1

  
2
CAHPreferencePage_0 = Показывать графики в 2D
3
CAHPreferencePage_2 = Число кластеров
4
CAHPreferencePage_3 = Метод
5
CAHPreferencePage_4 = Метрика
6

  
7
COMPUTE_COLUMNS = Колонки
8
COMPUTE_ROWS    = Строчки
9

  
10
ComputeCAH_0 = Расчет Классификации {0}
11
ComputeCAH_1 = Показать график
12
ComputeCAH_2 = ** Не удается записать данные во временный файл
13
ComputeCAH_3 = Расчет классификации с 
0 14

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/messages/messages_fr.properties (revision 285)
1

  
2
CAHPreferencePage_0 = Afficher les graphiques en 2D
3

  
4
CAHPreferencePage_2 = Nombre de clusters
5

  
6
CAHPreferencePage_3 = Méthode
7

  
8
CAHPreferencePage_4 = Métrique
9

  
10
CHART_TOOLBAR_BUTTON_NUMBER_OF_CLUSTERS = Nombre de clusters :
11

  
12
COMPUTE_COLUMNS = Classer les colonnes
13

  
14
COMPUTE_ROWS = Classer les lignes
15

  
16
ComputeCAH_0 = Calcul de la Classification avec {0}
17

  
18
ComputeCAH_1 = Afficher le graphique
19

  
20
ComputeCAH_2 = ** Impossible d'écrire dans le fichier temporaire
21

  
22
ComputeCAH_3 = Calcul de la classification avec
23

  
24
ComputeCAH_5 = Ouverture de la fenêtre de Classification
25

  
26
ComputeCAH_6 = Erreur lors de l'ouverture de l'éditeur de Classification : {0}
0 27

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/messages/CAHUIMessages.java (revision 285)
1
package org.txm.cah.rcp.messages;
2

  
3
import org.eclipse.osgi.util.NLS;
4
import org.txm.utils.messages.Utf8NLS;
5

  
6
public class CAHUIMessages extends NLS {
7

  
8
	private static final String BUNDLE_NAME = "org.txm.cah.rcp.messages.messages"; //$NON-NLS-1$
9
	
10
	
11
	public static String CAHPreferencePage_0;
12
	public static String CAHPreferencePage_2;
13
	public static String CAHPreferencePage_3;
14
	public static String CAHPreferencePage_4;
15
	
16
	public static String ComputeCAH_0;
17
	
18
	//FIXME: these keys/values are not used, remove or use them?
19
	public static String ComputeCAH_1;
20
	public static String ComputeCAH_2;
21
	public static String ComputeCAH_3;
22
	public static String ComputeCAH_5;
23
	public static String ComputeCAH_6;
24
	// end of fixme
25
	
26
	public static String COMPUTE_COLUMNS;
27
	public static String COMPUTE_ROWS;
28
	
29
	public static String CHART_TOOLBAR_BUTTON_NUMBER_OF_CLUSTERS;
30
	
31
	static {
32
		// initializes resource bundle
33
		Utf8NLS.initializeMessages(BUNDLE_NAME, CAHUIMessages.class);
34
	}
35
	
36
	private CAHUIMessages() {
37
		//no instantiation
38
	}
39
}
0 40

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/messages/messages.properties (revision 285)
1

  
2
CAHPreferencePage_0 = Display chart in
3

  
4
CAHPreferencePage_2 = Number of clusters
5

  
6
CAHPreferencePage_3 = Method
7

  
8
CAHPreferencePage_4 = Metric
9

  
10
CHART_TOOLBAR_BUTTON_NUMBER_OF_CLUSTERS = Number of clusters:
11

  
12
COMPUTE_COLUMNS = Compute columns
13

  
14
COMPUTE_ROWS = Compute rows
15

  
16
ComputeCAH_0 = Compute Classification with {0}
17

  
18
ComputeCAH_1 = Show chart
19

  
20
ComputeCAH_2 = Error: temporary file created cannot be written:
21

  
22
ComputeCAH_3 = Computing CAH with
23

  
24
ComputeCAH_5 = Opening the Classification result
25

  
26
ComputeCAH_6 = Error while computing Classification: {0}
0 27

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/editors/CAHChartEditor.java (revision 285)
1
package org.txm.cah.rcp.editors;
2

  
3
import org.eclipse.core.runtime.IProgressMonitor;
4
import org.eclipse.core.runtime.IStatus;
5
import org.eclipse.core.runtime.Status;
6
import org.eclipse.swt.SWT;
7
import org.eclipse.swt.custom.CLabel;
8
import org.eclipse.swt.events.SelectionEvent;
9
import org.eclipse.swt.events.SelectionListener;
10
import org.eclipse.swt.graphics.Image;
11
import org.eclipse.swt.widgets.Combo;
12
import org.eclipse.swt.widgets.Composite;
13
import org.eclipse.swt.widgets.Spinner;
14
import org.eclipse.swt.widgets.ToolItem;
15
import org.txm.cah.core.functions.CAH;
16
import org.txm.cah.core.messages.CAHCoreMessages;
17
import org.txm.cah.core.preferences.CAHPreferences;
18
import org.txm.cah.rcp.messages.CAHUIMessages;
19
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
20
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages;
21
import org.txm.core.preferences.TXMPreferences;
22
import org.txm.core.results.ITXMResult;
23
import org.txm.rcpapplication.IImageKeys;
24
import org.txm.rcpapplication.JobsTimer;
25
import org.txm.rcpapplication.commands.editor.CustomizableEditor;
26
import org.txm.rcpapplication.utils.JobHandler;
27
import org.txm.rcpapplication.views.QueriesView;
28
import org.txm.rcpapplication.views.corpora.CorporaView;
29
import org.txm.searchengine.cqp.corpus.Corpus;
30
import org.txm.statsengine.r.rcp.views.RVariablesView;
31
import org.txm.utils.logger.Log;
32

  
33
/**
34
 * CAH chart editor.
35
 * 
36
 * @author mdecorde
37
 * @author sjacquot
38
 *
39
 */
40
public class CAHChartEditor extends ChartEditorPart implements CustomizableEditor {
41

  
42

  
43

  
44
	/**
45
	 * Numbers of clusters.
46
	 */
47
	protected Spinner numbersOfClusters;
48

  
49

  
50

  
51
	@Override
52
	public void createPartControl(Composite parent) {
53

  
54
		super.createPartControl(parent);
55

  
56

  
57
		// Extend the chart editor tool bar
58
		ToolItem separator = new ToolItem(this.toolBar, SWT.SEPARATOR);
59

  
60
		// Number of clusters
61
		ToolItem itemSeparator = new ToolItem(this.toolBar, SWT.SEPARATOR);
62
	    CLabel clustersLabel = new CLabel(this.toolBar, SWT.CENTER);
63
		clustersLabel.setText(CAHUIMessages.CHART_TOOLBAR_BUTTON_NUMBER_OF_CLUSTERS);
64
		clustersLabel.pack();
65
		itemSeparator.setWidth(clustersLabel.getBounds().width);
66
	    itemSeparator.setControl(clustersLabel);
67

  
68
	    itemSeparator = new ToolItem(this.toolBar, SWT.SEPARATOR);
69
	    this.numbersOfClusters = new Spinner(this.toolBar, SWT.BORDER);
70
	    this.numbersOfClusters.setMinimum(2);
71
	    this.numbersOfClusters.setIncrement(1);
72

  
73
		itemSeparator.setControl(this.numbersOfClusters);
74
		this.numbersOfClusters.pack();
75
		itemSeparator.setWidth(this.numbersOfClusters.getBounds().width);
76

  
77

  
78
		// Columns
79
		final ToolItem computeColumns = new ToolItem(this.toolBar, SWT.RADIO);
80
		computeColumns.setToolTipText(CAHUIMessages.COMPUTE_COLUMNS);
81
		computeColumns.setImage(IImageKeys.getImage(CAHChartEditor.class, "icons/compute_columns.png")); //$NON-NLS-1$
82
		// FIXME: keep this for offering an option "large icons" with text in buttons ?
83
		//computeColumns.setText(CAUIPMessages.ComputeClassification_5);
84
		computeColumns.setSelection(TXMPreferences.getBoolean(CAHPreferences.PREFERENCES_NODE, this.getResultData(), CAHPreferences.COLUMNS_COMPUTING));
85

  
86
		// Rows
87
		final ToolItem computeRows = new ToolItem(this.toolBar, SWT.RADIO);
88
		computeRows.setToolTipText(CAHUIMessages.COMPUTE_ROWS);
89
		computeRows.setImage(IImageKeys.getImage(CAHChartEditor.class, "icons/compute_rows.png")); //$NON-NLS-1$
90
		// FIXME: keep this for offering an option "large icons" with text in buttons ?
91
		//computeRows.setText(CAUIPMessages.ComputeClassification_6);
92
		computeRows.setSelection(!TXMPreferences.getBoolean(CAHPreferences.PREFERENCES_NODE, this.getResultData(), CAHPreferences.COLUMNS_COMPUTING));
93

  
94
		
95
		// 2D/3D
96
		final Combo displayCombo = new Combo(this.toolBar, SWT.READ_ONLY);
97
		String items[] = { "2D", "3D" }; //$NON-NLS-1$ //$NON-NLS-2$
98
		displayCombo.setItems(items);
99
		if(TXMPreferences.getBoolean(CAHPreferences.PREFERENCES_NODE, this.getResultData(), CAHPreferences.DISPLAY_2D))	{
100
			displayCombo.select(0);
101
		}
102
		else	{
103
			displayCombo.select(1);
104
		}
105
		
106
		ToolItem comboItem = new ToolItem(this.toolBar, SWT.SEPARATOR);
107
		comboItem.setControl(displayCombo);
108
		displayCombo.pack();
109
		comboItem.setWidth(displayCombo.getBounds().width);
110
		
111
		// Listeners
112
		SelectionListener listener = new SelectionListener() {
113
			
114
			@Override
115
			public void widgetSelected(SelectionEvent e) {
116
				CAH cah = getResultData();
117

  
118
				// Numbers of clusters
119
				if(e.getSource() == numbersOfClusters)	{
120
					
121
					TXMPreferences.putLocalInt(cah, CAHPreferences.N_CLUSTERS, ((Spinner)e.getSource()).getSelection());
122
					cah.setNCluster(((Spinner)e.getSource()).getSelection());
123
				}
124
				// Compute columns or rows
125
				else if(e.getSource() == computeColumns || e.getSource() == computeRows)	{
126
					
127
					// cancel the event if nothing has changed
128
//					if(e.getSource() == computeColumns && computeColumns.getSelection()
129
//							|| e.getSource() == computeRows && computeRows.getSelection())	{
130
//						return;
131
//					}
132
					
133
					
134
					TXMPreferences.putLocalBoolean(cah, CAHPreferences.COLUMNS_COMPUTING, computeColumns.getSelection());
135
					cah.setColumnsComputing(computeColumns.getSelection());
136
					
137
					// reset the number of clusters
138
					TXMPreferences.putLocalInt(cah, CAHPreferences.N_CLUSTERS, TXMPreferences.getInt(CAHPreferences.PREFERENCES_NODE, CAHPreferences.N_CLUSTERS));
139
					cah.setNCluster(TXMPreferences.getInt(CAHPreferences.PREFERENCES_NODE, CAHPreferences.N_CLUSTERS));
140

  
141
					updateNumbersOfClustersCurrentValue();
142
					// Update the maximum value of the number of clusters spinner according to the new CAH configuration 
143
					updateNumbersOfClustersMaxValue();
144
				}
145
				else if(e.getSource() == displayCombo)	{
146
					TXMPreferences.putLocalBoolean(cah, CAHPreferences.DISPLAY_2D, (displayCombo.getSelectionIndex() == 0));
147
				}
148
				
149
				
150
				// Recompute the CAH and the chart
151
				compute(true);
152
			}
153
			
154
			@Override
155
			public void widgetDefaultSelected(SelectionEvent e) {
156
				// TODO Auto-generated method stub
157
				
158
			}
159
		};
160
		
161
		this.numbersOfClusters.addSelectionListener(listener);
162
		computeColumns.addSelectionListener(listener);
163
		displayCombo.addSelectionListener(listener);
164
		
165
		this.compute(false);
166
		
167
		
168

  
169
	}
170

  
171

  
172
	/**
173
	 * Computes the result and the chart.
174
	 * @param update
175
	 */
176
	public void compute(final boolean update)	{
177
		
178
		JobHandler jobhandler = new JobHandler(CAHCoreMessages.LOG_COMPUTE_CAH) {
179
			@Override
180
			protected IStatus run(IProgressMonitor monitor) {
181
				this.runInit(monitor);
182
				try {
183

  
184
					this.acquireSemaphore();
185
					getResultData().stepCompute();
186
					this.releaseSemaphore();
187

  
188
					if(!update)	{
189

  
190
						getResultData().getCA().addResult(getResultData());
191
						
192
						// Refresh views
193
						this.syncExec(new Runnable() {
194
							@Override
195
							public void run() {
196
								
197
							    updateNumbersOfClustersMaxValue();
198
							    updateNumbersOfClustersCurrentValue();
199

  
200
								
201
								// Refresh UI
202
								CorporaView.refresh();
203
								CorporaView.expand(getResultData().getParent());
204
								QueriesView.refresh();
205
								RVariablesView.refresh();
206
							}
207
						});
208
					
209
						
210
					}
211
					
212
					computeChart(update);
213
					
214
				}
215
				catch (ThreadDeath td) {
216
					return Status.CANCEL_STATUS;
217
				}
218
				catch (Exception e) {
219
					System.out.println(e.getLocalizedMessage());
220
					org.txm.rcpapplication.utils.Logger.printStackTrace(e);
221
					Log.severe("Error while computing CAH: " + e.getLocalizedMessage());
222
				}
223
				finally {
224
					monitor.done();
225
					JobsTimer.stopAndPrint();
226
				}
227
				return Status.OK_STATUS;
228
			}
229
		};
230
		jobhandler.startJob();
231
	}
232
	
233
	
234
	
235
	
236
	/**
237
	 * Updates the maximum value of the number of clusters spinner according to the CAH configuration.
238
	 */
239
	public void updateNumbersOfClustersMaxValue()	{
240
		int max = this.getResultData().getMaxClustersCount();
241
		this.numbersOfClusters.setMaximum(max);
242
	}
243

  
244
	/**
245
	 * Updates the current value of the number of clusters spinner.
246
	 */
247
	public void updateNumbersOfClustersCurrentValue()	{
248
		this.numbersOfClusters.setSelection(TXMPreferences.getInt(CAHPreferences.PREFERENCES_NODE, this.getResultData(), CAHPreferences.N_CLUSTERS));
249
	}
250

  
251

  
252
	@Override
253
	public void setName(String name) {
254
		this.setPartName(name);
255
	}
256

  
257
	@Override
258
	public void setIcon(Image titleImage) {
259
		this.setTitleImage(titleImage);
260
	}
261

  
262
	@Override
263
	public void setSource(Object source) {
264
		if (source instanceof CAH)
265
			getEditorInput().setResult((ITXMResult) source);
266
	}
267

  
268
	@Override
269
	public Object getSource() {
270
		return getResultData();
271
	}
272

  
273
	@Override
274
	public Object toConcordance() {
275
		// TODO Auto-generated method stub
276
		return null;
277
	}
278
	@Override
279
	public Object toIndex() {
280
		// TODO Auto-generated method stub
281
		return null;
282
	}
283
	@Override
284
	public Object toProgression() {
285
		// TODO Auto-generated method stub
286
		return null;
287
	}
288

  
289

  
290

  
291
	@Override
292
	public CAH getResultData() {
293
		return (CAH) super.getResultData();
294
	}
295

  
296

  
297

  
298
	@Override
299
	public boolean usingCorpus(Corpus corpus) {
300
		CAH cah = getResultData();
301
		if (cah != null && cah.getCorpus() != null) 
302
			return cah.getCorpus().getName().equals(corpus.getName());
303
		return false;
304
	}
305

  
306

  
307
	@Override
308
	public boolean updateCorpus(Corpus corpus) {
309
		// TODO Auto-generated method stub
310
		return false;
311
	}
312
}
0 313

  
tmp/org.txm.cah.rcp/build.properties (revision 285)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .,\
5
               plugin.xml
0 6

  
tmp/org.txm.cah.rcp/OSGI-INF/l10n/bundle_ru_utf-8.properties (revision 285)
1
command.name=Классификация
2
command.tooltip=Классификация
3
page.name=Классификация
0 4

  
tmp/org.txm.cah.rcp/OSGI-INF/l10n/bundle.properties (revision 285)
1

  
2
command.name = Classification
3

  
4
command.tooltip = Compute classification
5

  
6
editor.name = Classification
7

  
8
page.name = Classification
0 9

  
tmp/org.txm.cah.rcp/OSGI-INF/l10n/bundle_ru.properties (revision 285)
1

  
2
command.name    = Классификация
3
command.tooltip = Классификация
4

  
5
page.name = Классификация
0 6

  
tmp/org.txm.cah.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 285)
1
command.name=Classification
2
command.tooltip=Calculer la classification
3
page.name=Classification
0 4

  
tmp/org.txm.cah.rcp/plugin.xml (revision 285)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.ui.commands">
6
      <command
7
            categoryId="org.txm.rcpapplication.category.txm"
8
            defaultHandler="org.txm.cah.rcp.handlers.ComputeCAH"
9
            id="ComputeCAH"
10
            name="%command.name">
11
      </command>
12
   </extension>
13
   <extension
14
         point="org.eclipse.ui.menus">
15
      <menuContribution
16
            allPopups="false"
17
            locationURI="toolbar:org.txm.rcpapplication.toolbartools">
18
         <command
19
               commandId="ComputeCAH"
20
               icon="icons/cah.png"
21
               style="push"
22
               tooltip="%command.tooltip">
23
            <visibleWhen
24
                  checkEnabled="false">
25
               <or>
26
                  <reference
27
                        definitionId="OneCASelected">
28
                  </reference>
29
                  <reference
30
                        definitionId="OneLexicalTableSelected">
31
                  </reference>
32
                  <reference
33
                        definitionId="OnePartitionSelected">
34
                  </reference>
35
               </or>
36
            </visibleWhen>
37
         </command>
38
      </menuContribution>
39
      <menuContribution
40
            allPopups="false"
41
            locationURI="popup:org.txm.rcpapplication.views.CorporaView">
42
         <command
43
               commandId="ComputeCAH"
44
               icon="icons/cah.png"
45
               style="push">
46
            <visibleWhen
47
                  checkEnabled="false">
48
               <or>
49
                  <reference
50
                        definitionId="OneCASelected">
51
                  </reference>
52
                  <reference
53
                        definitionId="OneLexicalTableSelected">
54
                  </reference>
55
                  <reference
56
                        definitionId="OnePartitionSelected">
57
                  </reference>
58
               </or>
59
            </visibleWhen>
60
         </command>
61
      </menuContribution>
62
      <menuContribution
63
            locationURI="menu:menu.tools">
64
         <command
65
               commandId="ComputeCAH"
66
               icon="icons/cah.png"
67
               style="push">
68
            <visibleWhen
69
                  checkEnabled="false">
70
               <or>
71
                  <reference
72
                        definitionId="OneCASelected">
73
                  </reference>
74
                  <reference
75
                        definitionId="OneLexicalTableSelected">
76
                  </reference>
77
                  <reference
78
                        definitionId="OnePartitionSelected">
79
                  </reference>
80
               </or>
81
            </visibleWhen>
82
         </command>
83
      </menuContribution>
84
   </extension>
85
   <extension
86
         point="org.eclipse.ui.editors">
87
      <editor
88
            class="org.txm.cah.rcp.editors.CAHChartEditor"
89
            default="false"
90
            icon="icons/cah.png"
91
            id="org.txm.cah.core.functions.CAH"
92
            name="%editor.name">
93
      </editor>
94
   </extension>
95
   <extension
96
         point="org.eclipse.core.runtime.adapters">
97
      <factory
98
            adaptableType="org.txm.cah.core.functions.CAH"
99
            class="org.txm.cah.rcp.adapters.CAHAdapterFactory">
100
         <adapter
101
               type="org.eclipse.ui.model.IWorkbenchAdapter">
102
         </adapter>
103
      </factory>
104
   </extension>
105
   <extension
106
         point="org.eclipse.ui.preferencePages">
107
      <page
108
            category="org.txm.rcpapplication.preferences.UserPreferencePage"
109
            class="org.txm.cah.rcp.preferences.CAHPreferencePage"
110
            id="org.txm.cah.rcp.preferences.CAHPreferencePage"
111
            name="%page.name">
112
      </page>
113
   </extension>
114
   <extension
115
         point="org.eclipse.core.expressions.definitions">
116
      <definition
117
            id="OneCAHSelected">
118
         <with
119
               variable="selection">
120
            <iterate
121
                  ifEmpty="false"
122
                  operator="and">
123
               <instanceof
124
                     value="org.txm.cah.core.functions.CAH">
125
               </instanceof>
126
            </iterate>
127
         </with>
128
      </definition>
129
   </extension>
130

  
131
</plugin>
0 132

  

Formats disponibles : Unified diff