Révision 136

tmp/org.txm.ca.rcp/.project (revision 136)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.ca.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.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCorrespondanceAnalysis.java (revision 136)
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.ca.rcp.handlers;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.core.runtime.IProgressMonitor;
34
import org.eclipse.core.runtime.IStatus;
35
import org.eclipse.core.runtime.Status;
36
import org.eclipse.jface.dialogs.MessageDialog;
37
import org.eclipse.jface.viewers.IStructuredSelection;
38
import org.eclipse.jface.window.Window;
39
import org.eclipse.osgi.util.NLS;
40
import org.eclipse.ui.IEditorPart;
41
import org.eclipse.ui.IWorkbenchPage;
42
import org.eclipse.ui.IWorkbenchWindow;
43
import org.eclipse.ui.handlers.HandlerUtil;
44
import org.txm.Toolbox;
45
import org.txm.ca.core.functions.CA;
46
import org.txm.ca.core.functions.ICAComputable;
47
import org.txm.ca.core.preferences.CAPreferences;
48
import org.txm.ca.rcp.editors.CorrespondanceAnalysisEditorInput;
49
import org.txm.ca.rcp.messages.CAUIMessages;
50
import org.txm.core.preferences.TXMPreferences;
51
import org.txm.rcpapplication.JobsTimer;
52
import org.txm.rcpapplication.Messages;
53
import org.txm.rcpapplication.StatusLine;
54
import org.txm.rcpapplication.actions.LexicalTableDialog;
55
import org.txm.rcpapplication.utils.JobHandler;
56
import org.txm.rcpapplication.views.CorporaView;
57
import org.txm.searchengine.cqp.corpus.Corpus;
58
import org.txm.searchengine.cqp.corpus.Partition;
59
import org.txm.searchengine.cqp.corpus.Property;
60
import org.txm.stat.data.LexicalTable;
61
import org.txm.utils.logger.MessageBox;
62

  
63
/**
64
 * if the selection is a lexical table : computes the CA if the selection is a
65
 * partition : ask the user which property used and which threshold used then
66
 * open the CaEditor
67
 * 
68
 * @author mdecorde
69
 * @author sjacquot
70
 */
71
public class ComputeCorrespondanceAnalysis extends AbstractHandler {
72

  
73
	/** The window. */
74
	private IWorkbenchWindow window;
75

  
76
	/** The selection. */
77
	private IStructuredSelection selection;
78

  
79
	/** The ca. */
80
	private CA ca;
81

  
82
	/** The property. */
83
	private Property property;
84

  
85
	/** The fmin. */
86
	private int fmin;
87

  
88
	/** The vmax. */
89
	private int vmax;
90

  
91
	/** The partition. */
92
	private Partition partition;
93
	private Corpus corpus;
94

  
95
	/** The lexicaltable. */
96
	private LexicalTable lexicaltable;
97

  
98
	
99
	
100
	// FIXME: should be put in an Activator? or better in an extension point loaded by the corpora view? or in a method called here as initTreeDoubleClickListener(Class resultDataType, String commandId)?
101
	// adds a double click listener to the Corpus View
102
	static	{
103
		CorporaView.addDoubleClickListener(CA.class, "ComputeCorrespondanceAnalysis"); //$NON-NLS-1$
104
	}
105
	
106
	
107
	
108
	/* (non-Javadoc)
109
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
110
	 */
111
	@Override
112
	public Object execute(ExecutionEvent event) throws ExecutionException {
113
		
114
		if (!Toolbox.isStatEngineInitialized()) {
115
			System.out.println(CAUIMessages.ComputeCorrespondanceAnalysis_2);
116
			return null;
117
		}
118
		
119
		window = HandlerUtil.getActiveWorkbenchWindow(event);
120
		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
121
		int code = 0;
122
		if (selection.getFirstElement() instanceof Partition) {
123
			partition = (Partition) selection.getFirstElement();
124
			corpus = partition.getCorpus();
125
			//warning to few parts
126
			if (partition.getNPart() < 4) {
127
				MessageDialog d = new MessageDialog(
128
						window.getShell(),
129
						CAUIMessages.ComputeCorrespondanceAnalysis_3,
130
						null,
131
						NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_4, partition.getNPart()),
132
						0,
133
						new String[] { CAUIMessages.ComputeCorrespondanceAnalysis_6 },
134
						0);
135
				d.open();
136
				return null;
137
			}
138
			//ask property and Fmins and Vmax
139
			String title = Messages.bind(CAUIMessages.ComputeCorrespondanceAnalysisDialog_0, partition.getName());
140
			LexicalTableDialog d = new LexicalTableDialog(
141
					window.getShell(), partition.getCorpus(), title);
142
			code = d.open();
143
			if (code == Window.OK) {
144
				property = d.getProperty();
145
				fmin = d.getFmin();
146
				vmax = d.getMaxLines();
147
			}
148
		} else if (selection.getFirstElement() instanceof LexicalTable) {
149
			lexicaltable = (LexicalTable) selection.getFirstElement();
150
			property = lexicaltable.getProperty();
151
			partition = lexicaltable.getPartition();
152
			if (partition != null)
153
				corpus = partition.getCorpus();
154
			if (lexicaltable.getNColumns() < 4) {
155
				MessageBox.error(CAUIMessages.ComputeCorrespondanceAnalysis_13);
156
				return null;
157
			}
158
			if (lexicaltable.getNRows() < 4) {
159
				MessageBox.error(CAUIMessages.ComputeCorrespondanceAnalysis_1);
160
				return null;
161
			}
162
			code = Window.OK;
163
		} else  if (selection.getFirstElement() instanceof ICAComputable) {
164
			corpus = ((ICAComputable) selection.getFirstElement()).getCorpus();
165
			partition = ((ICAComputable) selection.getFirstElement()).getPartition();
166
		}
167

  
168
		if (code == Window.OK) {
169
			// final Property property = d.getProperty();
170
			String statusmessage;
171
			if (partition != null)
172
				statusmessage = NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_0, partition.getName(), property);
173
			else
174
				statusmessage = NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_0, selection, "<none>"); //$NON-NLS-1$
175
			
176
			System.out.println(statusmessage);
177
			JobHandler jobhandler = new JobHandler(statusmessage) {
178
				@Override
179
				protected IStatus run(IProgressMonitor monitor) {
180
					this.runInit(monitor);
181
					try {
182
						JobsTimer.start();
183
						monitor.beginTask("", 100); //$NON-NLS-1$
184
						monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_15);
185

  
186
						if (selection.getFirstElement() instanceof Partition)
187
							ca = new CA(partition, property, fmin, vmax);
188
						else if (selection.getFirstElement() instanceof LexicalTable)
189
							ca = new CA(lexicaltable);
190
						else if (selection.getFirstElement() instanceof ICAComputable)
191
							ca = ((ICAComputable) selection.getFirstElement()).toCA();
192

  
193

  
194
						if (selection.getFirstElement() instanceof Partition) {
195
							if (monitor.isCanceled()) return Status.CANCEL_STATUS;
196
							monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_16);
197
							
198
							this.acquireSemaphore();
199
							ca.stepLexicalTable();
200
							this.releaseSemaphore();
201
							
202
							this.acquireSemaphore();
203
							ca.stepSortTableLexical();
204
							this.releaseSemaphore();
205
						}
206

  
207
						monitor.worked(20);
208

  
209
						if (monitor.isCanceled()) return Status.CANCEL_STATUS;
210

  
211
						monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_17);
212
						this.acquireSemaphore();
213
						ca.stepCompute();
214
						this.releaseSemaphore();
215
						
216
						boolean variables = TXMPreferences.getBoolean(CAPreferences.PREFERENCES_NODE, CAPreferences.SHOW_VARIABLES);
217
						boolean individuals = TXMPreferences.getBoolean(CAPreferences.PREFERENCES_NODE, CAPreferences.SHOW_INDIVIDUALS);
218
						
219
						
220
						ca.setShown(individuals, variables);
221

  
222
						ca.getLexicalTable().storeResult(ca);
223
//						if (partition != null) {
224
//							partition.storeResult(ca);
225
//						} else {
226
//							corpus.storeResult(ca);
227
//						}
228
						
229
						monitor.worked(20);
230
						monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_8);
231

  
232
						syncExec(new Runnable() {
233
							@Override
234
							public void run() {
235
								if (ca == null) return;
236
								IWorkbenchPage page = window.getActivePage();
237
								CorrespondanceAnalysisEditorInput editorInput = new CorrespondanceAnalysisEditorInput(ca, partition, property);
238

  
239
								try {
240
									StatusLine.setMessage(CAUIMessages.ComputeCorrespondanceAnalysis_14);
241
									IEditorPart editor = page.openEditor(editorInput, "CAEditor"); //$NON-NLS-1$
242
									StatusLine.setMessage(CAUIMessages.ComputeCorrespondanceAnalysis_14);
243
								} catch (Exception e) {
244
									org.txm.rcpapplication.utils.Logger.printStackTrace(e);
245
								} 
246

  
247
							}
248
						});
249
						monitor.worked(50);
250

  
251
						monitor.subTask(Messages.CreatePartition_9);
252
						syncExec(new Runnable() {
253
							@Override
254
							public void run() {
255
								CorporaView.refresh();
256
								CorporaView.expand(ca.getParent());
257
							}
258
						});
259

  
260
						monitor.worked(100);
261
					} catch (ThreadDeath td) {
262
						return Status.CANCEL_STATUS;
263
					} catch (Exception e) {
264
						org.txm.rcpapplication.utils.Logger.printStackTrace(e);
265
					} finally {
266
						monitor.done();
267
						JobsTimer.stopAndPrint();
268
					}
269
					return Status.OK_STATUS;
270
				}
271
			};
272
			jobhandler.startJob();
273
		}
274
		return null;
275
	}
276
}
0 277

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/preferences/CAPreferencePage.java (revision 136)
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.ca.rcp.preferences;
29

  
30
import org.eclipse.jface.preference.BooleanFieldEditor;
31
import org.eclipse.jface.preference.IntegerFieldEditor;
32
import org.eclipse.jface.preference.StringFieldEditor;
33
import org.eclipse.swt.SWT;
34
import org.eclipse.swt.layout.GridData;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Group;
37
import org.eclipse.ui.IWorkbench;
38
import org.txm.ca.core.preferences.CAPreferences;
39
import org.txm.ca.rcp.adapters.CAAdapterFactory;
40
import org.txm.ca.rcp.messages.CAUIMessages;
41
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
42
import org.txm.rcp.preferences.TXMPreferencePage;
43
import org.txm.rcp.preferences.TXMPreferenceStore;
44
import org.txm.rcpapplication.Messages;
45
// TODO: Auto-generated Javadoc
46
/**
47
 * This class represents a preference page that is contributed to the
48
 * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we
49
 * can use the field support built into JFace that allows us to create a page
50
 * that is small and knows how to save, restore and apply itself.
51
 * <p>
52
 * This page is used to modif y preferences only. They are stored in the
53
 * preference store that belongs to the main plug-in class. That way,
54
 * preferences can be accessed directly via the preference store.
55
 */
56

  
57
public class CAPreferencePage extends TXMPreferencePage {
58

  
59

  
60

  
61
	/**
62
	 * Creates the field editors. Field editors are abstractions of the common
63
	 * GUI blocks needed to manipulate various types of preferences. Each field
64
	 * editor knows how to save and restore itself.
65
	 */
66
	@Override
67
	public void createFieldEditors() {
68

  
69
		Group ltGroup = new Group(getFieldEditorParent(), SWT.NONE);
70
		ltGroup.setText(CAUIMessages.CAPreferencePage_2);
71
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
72
		gridData.horizontalSpan = 2;
73
		gridData.verticalIndent = 10;
74
		ltGroup.setLayoutData(gridData);
75

  
76
		this.addField(new IntegerFieldEditor(CAPreferences.F_MIN, Messages.LexicalTablePreferencePage_1, ltGroup));
77
		this.addField(new IntegerFieldEditor(CAPreferences.V_MAX, Messages.LexicalTableEditor_8, ltGroup));
78
		this.addField(new StringFieldEditor(CAPreferences.QUALITY_DISPLAY_FORMAT, CAUIMessages.CAPreferencePage_0, this.getFieldEditorParent()));
79
		this.addField(new StringFieldEditor(CAPreferences.CONTRIB_DISPLAY_FORMAT, CAUIMessages.CAPreferencePage_1, this.getFieldEditorParent()));
80
		this.addField(new StringFieldEditor(CAPreferences.MASS_DISPLAY_FORMAT, CAUIMessages.CAPreferencePage_5, this.getFieldEditorParent()));
81
		this.addField(new StringFieldEditor(CAPreferences.DIST_DISPLAY_FORMAT, CAUIMessages.CAPreferencePage_6, this.getFieldEditorParent()));
82
		this.addField(new StringFieldEditor(CAPreferences.COS2_DISPLAY_FORMAT, CAUIMessages.CAPreferencePage_7, this.getFieldEditorParent()));
83
		this.addField(new StringFieldEditor(CAPreferences.COORD_DISPLAY_FORMAT, CAUIMessages.CAPreferencePage_8, this.getFieldEditorParent()));
84

  
85
		// Charts rendering
86
		Composite chartsTab = SWTChartsComponentsProvider.createChartsRenderingPreferencesTabFolderComposite(this.getFieldEditorParent());
87

  
88
		this.addField(new BooleanFieldEditor(CAPreferences.SHOW_INDIVIDUALS, CAUIMessages.CAPreferencePage_3, chartsTab));
89
		this.addField(new BooleanFieldEditor(CAPreferences.SHOW_VARIABLES, CAUIMessages.CAPreferencePage_4, chartsTab));
90
		
91
		// other shared preferences
92
		SWTChartsComponentsProvider.createChartsRenderingPreferencesFields(this, chartsTab);
93

  
94

  
95
	}
96

  
97
	
98
//	@Override
99
//	public void createFieldEditors() {
100
//
101
//		
102
//		// FIXME: tabbed preferences page test
103
//		
104
//		TabFolder tabFolder = new TabFolder(this.getFieldEditorParent(), SWT.TOP);
105
//		tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
106
//		
107
//		TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
108
//		tabItem.setText("Table lexicale");
109
//		Composite composite1 = new Composite(tabFolder, SWT.NULL);
110
//		tabItem.setControl(composite1);
111
//		fmin = new IntegerFieldEditor(FMIN, Messages.LexicalTablePreferencePage_1, composite1);
112
//		addField(fmin);
113
//		vmax = new IntegerFieldEditor(VMAX, Messages.LexicalTableEditor_8, composite1);
114
//		addField(vmax);
115
//
116
//		
117
//		TabItem tabItem2 = new TabItem(tabFolder, SWT.NULL);
118
//		tabItem2.setText("Calcul");
119
//		Composite composite2 = new Composite(tabFolder, SWT.NULL);
120
//		tabItem2.setControl(composite2);
121
//		qualityDisplay = new StringFieldEditor(QUALITYDISPLAY,
122
//				Messages.CAPreferencePage_0, composite2);
123
//		addField(qualityDisplay);
124
//
125
//		contribDisplay = new StringFieldEditor(CONTRIBDISPLAY,
126
//				Messages.CAPreferencePage_1, composite2);
127
//		addField(contribDisplay);
128
//
129
//		massDisplay = new StringFieldEditor(MASSDISPLAY,
130
//				Messages.CAPreferencePage_5, composite2);
131
//		addField(massDisplay);
132
//
133
//		distDisplay = new StringFieldEditor(DISTDISPLAY,
134
//				Messages.CAPreferencePage_6, composite2);
135
//		addField(distDisplay);
136
//
137
//		cos2Display = new StringFieldEditor(COS2DISPLAY,
138
//				Messages.CAPreferencePage_7, composite2);
139
//		addField(cos2Display);
140
//
141
//		coordDisplay = new StringFieldEditor(COORDDISPLAY,
142
//				Messages.CAPreferencePage_8, composite2);
143
//		addField(coordDisplay);
144
//
145
//
146
//		// Charts rendering
147
//		TabItem tabItem3 = new TabItem(tabFolder, SWT.NULL);
148
//		tabItem3.setText("Graphiques");
149
//		Composite composite3 = new Composite(tabFolder, SWT.NULL);
150
//		tabItem3.setControl(composite3);
151
//
152
//		// FIXME : these 2 preferences should be renamed and moved to charts engine preference level (associated messages too)
153
//		showIndividuals = new BooleanFieldEditor(SHOWINDIVIDUALS, Messages.CAPreferencePage_3, composite3);
154
//		addField(showIndividuals);
155
//
156
//		showVariables = new BooleanFieldEditor(SHOWVARIABLES, Messages.CAPreferencePage_4, composite3);
157
//		addField(showVariables);
158
//
159
//	}
160

  
161
	
162

  
163
	
164
	
165
	
166
	
167
	
168
	/*
169
	 * (non-Javadoc)
170
	 *
171
	 * @see
172
	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
173
	 */
174
	@Override
175
	public void init(IWorkbench workbench) {
176
		this.setPreferenceStore(new TXMPreferenceStore(CAPreferences.PREFERENCES_NODE));
177
		//this.setDescription(Messages.CorrespondanceAnalysisEditorInput_10);
178
		this.setTitle(CAUIMessages.CorrespondanceAnalysisEditorInput_10);
179
		this.setImageDescriptor(CAAdapterFactory.ICON);
180

  
181
		// FIXME: useless?
182
//		if (TxmPreferences.getInt(FMIN, -1) <= 0)
183
//			TxmPreferences.set(FMIN, 10);
184
//		if (TxmPreferences.getInt(VMAX, -1) <= 0)
185
//			TxmPreferences.set(VMAX,200);
186

  
187
	}
188

  
189
	
190
}
0 191

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/adapters/CAAdapterFactory.java (revision 136)
1
// Copyright © 2010-2013 ENS de Lyon.
2
package org.txm.ca.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.ca.core.functions.CA;
9
import org.txm.rcp.adapters.BaseAdapterFactory;
10

  
11

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

  
20
	
21
	public static final ImageDescriptor ICON =
22
			AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(CAAdapterFactory.class).getSymbolicName(),
23
					"platform:/plugin/"+ FrameworkUtil.getBundle(CAAdapterFactory.class).getSymbolicName() + "/icons/ca.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
		
36
		if(adapterType == IWorkbenchAdapter.class)	{
37
			if(adaptableObject instanceof CA)	{
38
				return new IWorkbenchAdapter() {
39
					@Override
40
					public Object[] getChildren(Object o) {
41
						return ((CA)o).getResults().toArray();
42
					}
43

  
44
					@Override
45
					public ImageDescriptor getImageDescriptor(Object object) {
46
						return ICON;
47
					}
48

  
49
					@Override
50
					public String getLabel(Object o) {
51
						return ""+((CA) o).getName(); //$NON-NLS-1$
52
					}
53

  
54
					@Override
55
					public Object getParent(Object o) {
56
						return ((CA) o).getParent();
57
					}
58
				};
59
			}
60
		}
61
		return null;
62
	}
63

  
64

  
65
}
0 66

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/messages/messages.properties (revision 136)
1
CAPreferencePage_0=Quality column format
2
CAPreferencePage_1=Contribution column format
3
CAPreferencePage_2=Lexical table created when called from a partition
4
CAPreferencePage_3=Show the columns
5
CAPreferencePage_4=Show the rows
6
CAPreferencePage_5=Mass column format
7
CAPreferencePage_6=Distance column format
8
CAPreferencePage_7=Cos² column format
9
CAPreferencePage_8=Coord column format
10
ComputeCorrespondanceAnalysis_0=Computing Correspondance analysis on {0} with property {1}
11
ComputeCorrespondanceAnalysis_13=Can't compute CA on lexical table with less than 4 columns
12
ComputeCorrespondanceAnalysis_14=Opening the Correspondance Analysis results
13
ComputeCorrespondanceAnalysis_15=Create CA
14
ComputeCorrespondanceAnalysis_16=Get LexicalTable CA
15
ComputeCorrespondanceAnalysis_17=Compute CA
16
ComputeCorrespondanceAnalysis_1=Cannot compute CA with less than 4 rows in the table
17
ComputeCorrespondanceAnalysis_2=StatEngine is not ready. Canceling command.
18
ComputeCorrespondanceAnalysis_3=** Error
19
ComputeCorrespondanceAnalysis_4=Cannot compute factorial analysis with only {0} parts (the minimum is 4 parts).
20
ComputeCorrespondanceAnalysis_6=OK
21
ComputeCorrespondanceAnalysis_8=Loading correspondances analysis results...
22
ComputeCorrespondanceAnalysisDialog_0=Correspondance analysis with {0}
23
ComputeCorrespondanceAnalysisDialog_1=Property\:
24
ComputeCorrespondanceAnalysisDialog_2=Number of lines\:
25
CorrespondanceAnalysisEditorInput_0=Eigenvalues
26
CorrespondanceAnalysisEditorInput_10=CA
27
CorrespondanceAnalysisEditorInput_11=\u2211
28
CorrespondanceAnalysisEditorInput_1=Fact. plan
29
CorrespondanceAnalysisEditorInput_26=Mass
30
CorrespondanceAnalysisEditorInput_27=Dist
31
CorrespondanceAnalysisEditorInput_29=Cont
32
CorrespondanceAnalysisEditorInput_2=Eigenvalues histogram
33
CorrespondanceAnalysisEditorInput_30=Cos²
34
CorrespondanceAnalysisEditorInput_3=Correspondance analysis result cannot be null
35
CorrespondanceAnalysisEditorInput_4=#
36
CorrespondanceAnalysisEditorInput_5=Eigenvalue
37
CorrespondanceAnalysisEditorInput_8=Rows infos
38
CorrespondanceAnalysisEditorInput_9=Cols infos
39
SWTChartsComponentProvider_CA_TOOLBAR_AXES_SELECTION_COMBO_BOX_LABEL=Axes: 
40
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL=Show columns
41
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_TOOLTIP=Show/hide the column points
42
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL=Show rows
43
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_TOOLTIP=Show/hide the row points
0 44

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/messages/messages_ru.properties (revision 136)
1
CAPreferencePage_0=Формат колонки Качество
2
CAPreferencePage_1=Формат колонки Вклад
3
CAPreferencePage_3=Показать колонки в графике факторного плана
4
CAPreferencePage_4=Показать строчки в графике факторного плана
5
CAPreferencePage_5=Формат колонки Масса
6
CAPreferencePage_6=Формат колонки Дистанция
7
CAPreferencePage_7=Формат колонки Cos²
8
CAPreferencePage_8=Формат колонки Coord
9
ComputeCorrespondanceAnalysis_0=Расчет факторного анализа соответствий
10
ComputeCorrespondanceAnalysis_13=** Невозможно провести факторный анализ соответствий при наличии менее 4-х колонок
11
ComputeCorrespondanceAnalysis_14=Открытие результатов факторного анализа соответствий
12
ComputeCorrespondanceAnalysis_15=Создание окна ФАС
13
ComputeCorrespondanceAnalysis_16=Создание словарной таблицы для ФАС
14
ComputeCorrespondanceAnalysis_17=Расчет ФАС
15
ComputeCorrespondanceAnalysis_1=** Невозможно провести факторный анализ соответствий при наличии менее 4-х колонок в таблице
16
ComputeCorrespondanceAnalysis_3=** Ошибка
17
ComputeCorrespondanceAnalysis_4=** Невозможно провести факторный анализ соответствий при наличии только 
18
ComputeCorrespondanceAnalysis_6=ОК
19
ComputeCorrespondanceAnalysis_8=Загрузка результатов факторного анализа
20
ComputeCorrespondanceAnalysisDialog_0=Факторный анализ соответствий {0}
21
ComputeCorrespondanceAnalysisDialog_1=Свойства: 
22
ComputeCorrespondanceAnalysisDialog_2=Число строк:
23
CorrespondanceAnalysisEditorInput_0=Собственные значения
24
CorrespondanceAnalysisEditorInput_10=ФАС
25
CorrespondanceAnalysisEditorInput_1=Факт. план
26
CorrespondanceAnalysisEditorInput_26=Масса
27
CorrespondanceAnalysisEditorInput_27=Дист
28
CorrespondanceAnalysisEditorInput_29=Конт
29
CorrespondanceAnalysisEditorInput_2=Гистограмма собственных значений propres
30
CorrespondanceAnalysisEditorInput_30=Cos²
31
CorrespondanceAnalysisEditorInput_3=Результат анализа соответствий не может быть пустым 
32
CorrespondanceAnalysisEditorInput_4=Фактор
33
CorrespondanceAnalysisEditorInput_8=Инф Строчки
34
CorrespondanceAnalysisEditorInput_9=Инф Колонки
0 35

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/messages/CAUIMessages.java (revision 136)
1
package org.txm.ca.rcp.messages;
2

  
3
import org.eclipse.osgi.util.NLS;
4
import org.txm.core.messages.TXMCoreMessages;
5

  
6
public class CAUIMessages extends NLS {
7

  
8
	private static final String BUNDLE_NAME = "org.txm.ca.rcp.messages.messages"; //$NON-NLS-1$
9

  
10

  
11
	public static String SWTChartsComponentProvider_CA_TOOLBAR_AXES_SELECTION_COMBO_BOX_LABEL;
12
	public static String SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL;
13
	public static String SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_TOOLTIP;
14
	public static String SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL;
15
	public static String SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_TOOLTIP;
16

  
17

  
18
	public static String CAPreferencePage_0;
19
	public static String CAPreferencePage_1;
20
	public static String CAPreferencePage_2;
21
	public static String CAPreferencePage_3;
22
	public static String CAPreferencePage_4;
23
	public static String CAPreferencePage_5;
24
	public static String CAPreferencePage_6;
25
	public static String CAPreferencePage_7;
26
	public static String CAPreferencePage_8;
27

  
28
	public static String ComputeCorrespondanceAnalysisDialog_0;
29
	public static String ComputeCorrespondanceAnalysisDialog_1;
30
	public static String ComputeCorrespondanceAnalysisDialog_2;
31

  
32
	public static String ComputeCorrespondanceAnalysis_0;
33
	public static String ComputeCorrespondanceAnalysis_1;
34
	public static String ComputeCorrespondanceAnalysis_13;
35
	public static String ComputeCorrespondanceAnalysis_14;
36
	public static String ComputeCorrespondanceAnalysis_15;
37
	public static String ComputeCorrespondanceAnalysis_16;
38
	public static String ComputeCorrespondanceAnalysis_17;
39
	public static String ComputeCorrespondanceAnalysis_2;
40
	public static String ComputeCorrespondanceAnalysis_3;
41
	public static String ComputeCorrespondanceAnalysis_4;
42
	public static String ComputeCorrespondanceAnalysis_6;
43
	public static String ComputeCorrespondanceAnalysis_8;
44

  
45
	public static String CorrespondanceAnalysisEditorInput_0;
46
	public static String CorrespondanceAnalysisEditorInput_1;
47
	public static String CorrespondanceAnalysisEditorInput_11;
48
	public static String CorrespondanceAnalysisEditorInput_10;
49
	public static String CorrespondanceAnalysisEditorInput_2;
50
	public static String CorrespondanceAnalysisEditorInput_26;
51
	public static String CorrespondanceAnalysisEditorInput_27;
52
	public static String CorrespondanceAnalysisEditorInput_29;
53
	public static String CorrespondanceAnalysisEditorInput_3;
54
	public static String CorrespondanceAnalysisEditorInput_30;
55
	public static String CorrespondanceAnalysisEditorInput_4;
56
	public static String CorrespondanceAnalysisEditorInput_5;
57
	public static String CorrespondanceAnalysisEditorInput_8;
58
	public static String CorrespondanceAnalysisEditorInput_9;
59

  
60
	
61
	
62
	static {
63
		// initialize resource bundle
64
		TXMCoreMessages.initializeMessages(BUNDLE_NAME, CAUIMessages.class);
65
	}
66

  
67
	private CAUIMessages() {
68
	}
69
}
0 70

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/messages/messages_fr.properties (revision 136)
1
CAPreferencePage_0=Format de la colonne Qualité
2
CAPreferencePage_1=Format de la colonne Contribution
3
CAPreferencePage_3=Afficher les colonnes
4
CAPreferencePage_4=Afficher les lignes
5
CAPreferencePage_5=Format de la colonne Masse
6
CAPreferencePage_6=Format de la colonne Distance
7
CAPreferencePage_7=Format de la colonne Cos²
8
CAPreferencePage_8=Format de la colonne Coord
9
ComputeCorrespondanceAnalysis_0=Calcul de l'analyse factorielle des correspondances
10
ComputeCorrespondanceAnalysis_13=** Impossible de calculer l'analyse factorielle des correspondances avec moins de 4 colonnes 
11
ComputeCorrespondanceAnalysis_14=Ouverture des résultats de l'analyse factorielle des correspondances
12
ComputeCorrespondanceAnalysis_15=Création de la fen\u00EAtre de l'AFC
13
ComputeCorrespondanceAnalysis_16=Création de la table lexicale pour l'AFC
14
ComputeCorrespondanceAnalysis_17=Calcul de l'AFC
15
ComputeCorrespondanceAnalysis_1=** Impossible de calculer l'analyse factorielle des correspondances avec moins de 4 colonnes dans la table
16
ComputeCorrespondanceAnalysis_3=** Erreur
17
ComputeCorrespondanceAnalysis_4=** Impossible de calculer l''analyse factorielle avec seulement {0} parties (minimum=4).
18
ComputeCorrespondanceAnalysis_6=OK
19
ComputeCorrespondanceAnalysis_8=Chargement des résultats de l'analyse factorielle
20
ComputeCorrespondanceAnalysisDialog_0=Analyse factorielle des correspondances avec {0}
21
ComputeCorrespondanceAnalysisDialog_1=Propriétés \: 
22
ComputeCorrespondanceAnalysisDialog_2=Nombre de lignes \: 
23
CorrespondanceAnalysisEditorInput_0=Valeurs propres
24
CorrespondanceAnalysisEditorInput_10=AFC
25
CorrespondanceAnalysisEditorInput_1=Plan fact.
26
CorrespondanceAnalysisEditorInput_26=Mass
27
CorrespondanceAnalysisEditorInput_27=Dist
28
CorrespondanceAnalysisEditorInput_29=Cont
29
CorrespondanceAnalysisEditorInput_2=Histogramme des valeurs propres
30
CorrespondanceAnalysisEditorInput_30=Cos²
31
CorrespondanceAnalysisEditorInput_3=Le résultat de l'analyse des correspondances ne peut \u00EAtre nul 
32
CorrespondanceAnalysisEditorInput_4=#
33
CorrespondanceAnalysisEditorInput_5=Valeur propre
34
CorrespondanceAnalysisEditorInput_8=Info lignes
35
CorrespondanceAnalysisEditorInput_9=Info colonnes
36
SWTChartsComponentProvider_CA_TOOLBAR_AXES_SELECTION_COMBO_BOX_LABEL=Axes : 
37
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL=Afficher les colonnes
38
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_TOOLTIP=Afficher/masquer les points-colonnes
39
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL=Afficher les lignes
40
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_TOOLTIP=Afficher/masquer les points-lignes
0 41

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/SingularValuesEditor.java (revision 136)
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.ca.rcp.editors;
29

  
30
import java.util.ArrayList;
31
import java.util.List;
32

  
33
import org.eclipse.core.runtime.IProgressMonitor;
34
import org.eclipse.jface.action.MenuManager;
35
import org.eclipse.jface.viewers.TableViewer;
36
import org.eclipse.jface.viewers.TableViewerColumn;
37
import org.eclipse.swt.SWT;
38
import org.eclipse.swt.events.SelectionAdapter;
39
import org.eclipse.swt.events.SelectionEvent;
40
import org.eclipse.swt.layout.FillLayout;
41
import org.eclipse.swt.widgets.Composite;
42
import org.eclipse.swt.widgets.Event;
43
import org.eclipse.swt.widgets.Listener;
44
import org.eclipse.swt.widgets.Menu;
45
import org.eclipse.swt.widgets.Table;
46
import org.eclipse.swt.widgets.TableItem;
47
import org.eclipse.ui.IEditorInput;
48
import org.eclipse.ui.IEditorSite;
49
import org.eclipse.ui.PartInitException;
50
import org.eclipse.ui.part.EditorPart;
51
import org.txm.rcpapplication.Messages;
52
import org.txm.rcpapplication.StatusLine;
53
import org.txm.rcpapplication.editors.Tablable;
54
import org.txm.rcpapplication.editors.TableKeyListener;
55
import org.txm.rcpapplication.editors.TableSorter;
56
// TODO: Auto-generated Javadoc
57
/**
58
 * show the singular values and compute some stats.
59
 *
60
 * @author mdecorde
61
 */
62
public class SingularValuesEditor extends EditorPart {
63

  
64
	/** The ID. */
65
	static public String ID = "org.txm.rcpapplication.editors.TableEditor"; //$NON-NLS-1$
66

  
67
	/** The viewer. */
68
	private TableViewer viewer;
69

  
70
	/** The i editor input. */
71
	private IEditorInput iEditorInput;
72

  
73
	/** The table input. */
74
	private Tablable tableInput;
75

  
76
	/** The columns. */
77
	List<TableViewerColumn> columns = new ArrayList<TableViewerColumn>();
78

  
79
	/** The table sorter. */
80
	private TableSorter tableSorter;
81

  
82
	/* (non-Javadoc)
83
	 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
84
	 */
85
	@Override
86
	public void doSave(IProgressMonitor monitor) {
87
		// TODO Auto-generated method stub
88
	}
89

  
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.ui.part.EditorPart#doSaveAs()
92
	 */
93
	@Override
94
	public void doSaveAs() {
95
		// TODO Auto-generated method stub
96
	}
97

  
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
100
	 */
101
	@Override
102
	public void init(IEditorSite site, IEditorInput input)
103
			throws PartInitException {
104
		setSite(site);
105
		setInput(input);
106
		this.iEditorInput = input;
107
	}
108

  
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.ui.part.EditorPart#isDirty()
111
	 */
112
	@Override
113
	public boolean isDirty() {
114
		// TODO Auto-generated method stub
115
		return false;
116
	}
117

  
118
	/* (non-Javadoc)
119
	 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
120
	 */
121
	@Override
122
	public boolean isSaveAsAllowed() {
123
		// TODO Auto-generated method stub
124
		return false;
125
	}
126

  
127
	/* (non-Javadoc)
128
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
129
	 */
130
	@Override
131
	public void createPartControl(Composite parent) {
132
		parent.setLayout(new FillLayout());
133

  
134
		if (!(iEditorInput instanceof Tablable)) {
135
			throw new IllegalArgumentException(Messages.SingularValuesEditor_0);
136
		}
137
		tableInput = (Tablable) iEditorInput;
138

  
139
		viewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL
140
				| SWT.MULTI | SWT.FULL_SELECTION);
141
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
142

  
143
		Table table = viewer.getTable();
144
		table.setHeaderVisible(true);
145
		table.setLinesVisible(true);
146

  
147
		String[] titles = tableInput.getColumnTitles();
148

  
149
		for (int i = 0; i < titles.length; i++) {
150
			final int index = i;
151
			final TableViewerColumn column;
152

  
153
			int alignment = SWT.RIGHT;
154
			// Align the bar plot to the left
155
			if(i == 4)	{
156
				alignment = SWT.LEFT;
157
			}
158

  
159
			column = new TableViewerColumn(viewer, alignment);
160

  
161
			column.getColumn().setText(titles[i]);
162
			column.getColumn().setWidth(100);
163
			column.getColumn().setResizable(true);
164
			column.getColumn().setMoveable(true);
165
			columns.add(column);
166

  
167
			column.getColumn().addSelectionListener(new SelectionAdapter() {
168
				@Override
169
				public void widgetSelected(SelectionEvent e)
170
				{
171
					StatusLine.setMessage(Messages.IndexEditor_36);
172
					tableSorter.setColumn(index);
173
					int dir = viewer.getTable().getSortDirection();
174
					if (viewer.getTable().getSortColumn() == column.getColumn()) {
175
						dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
176
					} else {
177
						dir = SWT.DOWN;
178
					}
179
					viewer.getTable().setSortDirection(dir);
180
					viewer.getTable().setSortColumn(column.getColumn());
181
					viewer.refresh();
182
					StatusLine.setMessage(Messages.IndexEditor_37);
183
				}
184
			});
185
		}
186

  
187

  
188
		// To draw the bar plot column
189
		viewer.getTable().addListener(SWT.EraseItem, new Listener() {
190
		      public void handleEvent(Event event) {
191

  
192
		    	   if(event.index == 4)	{
193
		    		   int itemIndex = viewer.getTable().indexOf((TableItem)event.item);
194
		    		   double percent = Double.parseDouble(((ArrayList)viewer.getElementAt(itemIndex)).get(2).toString().replaceAll(",",".")); // comma replacement according to the locale //$NON-NLS-1$ //$NON-NLS-2$
195

  
196
		    		   int maxPercentItemIndex = 0;
197
		    		   double maxPercent = Double.parseDouble(viewer.getTable().getItem(0).getText(2).replaceAll(",",".")); //$NON-NLS-1$ //$NON-NLS-2$
198
		    		   double tmpMaxPercent;
199

  
200
		    		   // Get the max percent despite of the current row sorting
201
		    		   for(int i = 0; i < viewer.getTable().getItemCount(); i++) {
202
		    			   tmpMaxPercent =  Double.parseDouble(viewer.getTable().getItem(i).getText(2).replaceAll(",",".")); //$NON-NLS-1$ //$NON-NLS-2$
203
		    			   if(tmpMaxPercent > maxPercent)	{
204
		    				   maxPercent = tmpMaxPercent;
205
		    				   maxPercentItemIndex = i;
206
		    			   }
207
		    		   }
208

  
209
		    		   event.gc.setBackground(viewer.getTable().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
210
		    		   event.gc.fillRectangle(event.x, event.y, (int) (event.width * percent / Double.parseDouble(viewer.getTable().getItem(maxPercentItemIndex).getText(2).replaceAll(",","."))), event.height); //$NON-NLS-1$ //$NON-NLS-2$
211
		    	   }
212
		      }
213
		    });
214

  
215

  
216

  
217
		viewer.setContentProvider(tableInput.getContentProvider());
218
		viewer.setLabelProvider(tableInput.getLabelProvider());
219
		viewer.setInput(tableInput.getInput());
220

  
221
		tableSorter = new TableSorter();
222
		tableSorter.setColumnTypes(tableInput.getColumnTypes());
223
		viewer.setSorter(tableSorter);
224

  
225
		viewer.refresh();
226
		createContextMenu(viewer);
227

  
228
		tableSorter.setColumn(0);
229
		int dir = viewer.getTable().getSortDirection();
230
		if (viewer.getTable().getSortColumn() == columns.get(0).getColumn()) {
231
			dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
232
		} else {
233
			dir = SWT.DOWN;
234
		}
235
		viewer.getTable().setSortDirection(dir);
236
		viewer.getTable().setSortColumn(columns.get(0).getColumn());
237
		viewer.refresh();
238

  
239
		// Pack the columns except the bar plot column
240
		for(int i = 0; i < viewer.getTable().getColumnCount(); i++)	{
241
			if(i != 4)	{
242
				viewer.getTable().getColumn(i).pack();
243
			}
244
		}
245
	}
246

  
247
	/**
248
	 * Creates the context menu.
249
	 *
250
	 * @param tableViewer the table viewer
251
	 */
252
	private void createContextMenu(TableViewer tableViewer) {
253

  
254
		MenuManager menuManager = new MenuManager();
255
		Menu menu = menuManager.createContextMenu(tableViewer.getTable());
256

  
257
		// Set the MenuManager
258
		tableViewer.getTable().setMenu(menu);
259
		getSite().registerContextMenu(menuManager, tableViewer);
260
		// Make the selection available
261
		getSite().setSelectionProvider(tableViewer);
262
	}
263

  
264
	/* (non-Javadoc)
265
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
266
	 */
267
	@Override
268
	public void setFocus() {
269
		viewer.getControl().setFocus();
270
	}
271
}
0 272

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 136)
1
package org.txm.ca.rcp.editors;
2

  
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.custom.CLabel;
5
import org.eclipse.swt.widgets.Combo;
6
import org.eclipse.swt.widgets.Composite;
7
import org.eclipse.swt.widgets.ToolItem;
8
import org.txm.ca.core.functions.CA;
9
import org.txm.ca.rcp.chartsengine.events.CAPointSelectionCallBack;
10
import org.txm.ca.rcp.chartsengine.events.CASelectionListener;
11
import org.txm.ca.rcp.messages.CAUIMessages;
12
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
13
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
14
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
15
import org.txm.chartsengine.rcp.events.EventCallBackHandler;
16
import org.txm.rcpapplication.IImageKeys;
17
import org.txm.searchengine.cqp.corpus.Partition;
18

  
19
/**
20
 * Correspondence analysis factorial map chart editor.
21
 * @author sjacquot
22
 *
23
 */
24
public class CAFactorialMapChartEditor extends ChartEditorPart {
25

  
26

  
27
	/**
28
	 * The show/hide columns button.
29
	 */
30
	protected ToolItem showColumns;
31

  
32

  
33
	/**
34
	 * The show/hide rows button.
35
	 */
36
	protected ToolItem showRows;
37

  
38
	/**
39
	 * The factors selection combo box.
40
	 */
41
	protected Combo plans;
42

  
43
	
44
	public CAFactorialMapChartEditor() {
45
		super();
46
	}
47
	
48
	/**
49
	 *
50
	 * @param chartEditorInput
51
	 */
52
	public CAFactorialMapChartEditor(SWTChartsComponentsProvider swtComponentsProvider, ChartEditorInput chartEditorInput) {
53
		super(swtComponentsProvider, chartEditorInput);
54
		// Override the editor input name
55
		Partition partition = this.getResultData().getPartition();
56
		if (partition != null)
57
			chartEditorInput.setName(partition.getName() + ":" + this.getResultData().getAnalysisProperty()); //$NON-NLS-1$
58
		else {
59
			chartEditorInput.setName(""+this.getResultData().getCorpus() + ":" + this.getResultData().getAnalysisProperty()); //$NON-NLS-1$ //$NON-NLS-2$
60
		}
61
	}
62

  
63

  
64
	@Override
65
	public void createPartControl(Composite parent) {
66

  
67
		super.createPartControl(parent);
68

  
69
		// Extend the chart editor tool bar
70
		ToolItem separator = new ToolItem(this.toolBar, SWT.SEPARATOR);
71

  
72
		// Show/hide columns
73
		this.showColumns = new ToolItem(this.toolBar, SWT.CHECK);
74
		// FIXME: keep this for offering an option "large icons" with text in buttons ?
75
		//this.showColumns.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL);
76
		this.showColumns.setToolTipText(CAUIMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_TOOLTIP);
77
		this.showColumns.setImage(IImageKeys.getImage(IImageKeys.CHARTS_CA_SHOW_COLUMNS));
78
		// FIXME: this code should be restored when the charts rendering prefs will be moved outside of the CA object
79
		//this.showColumns.setSelection(TxmPreferences.getBoolean(CAPreferencePage.SHOWINDIVIDUALS));
80
		this.showColumns.setSelection(this.getResultData().isShowIndividuals());
81
		this.showColumns.addSelectionListener(new CASelectionListener(this, CASelectionListener.SHOW_HIDE_COLUMNS));
82

  
83
		// Show/hide rows
84
		this.showRows = new ToolItem(this.toolBar, SWT.CHECK);
85
		// FIXME: keep this for offering an option "large icons" with text in buttons ?
86
		//this.showRows.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL);
87
		this.showRows.setToolTipText(CAUIMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_TOOLTIP);
88
		this.showRows.setImage(IImageKeys.getImage(IImageKeys.CHARTS_CA_SHOW_ROWS));
89
		// FIXME: this code should be restored when the charts rendering prefs will be moved outside of the CA object
90
		//this.showRows.setSelection(TxmPreferences.getBoolean(CAPreferencePage.SHOWVARIABLES));
91
		this.showRows.setSelection(this.getResultData().isShowVariables());
92
		this.showRows.addSelectionListener(new CASelectionListener(this, CASelectionListener.SHOW_HIDE_ROWS));
93

  
94
//
95
		// Factors selection
96
		ToolItem itemSeparator = new ToolItem(this.toolBar, SWT.SEPARATOR);
97
		CLabel factorsLabel = new CLabel(this.toolBar, SWT.CENTER);
98
		factorsLabel.setText(CAUIMessages.SWTChartsComponentProvider_CA_TOOLBAR_AXES_SELECTION_COMBO_BOX_LABEL);
99
		factorsLabel.pack();
100
		itemSeparator.setWidth(factorsLabel.getBounds().width);
101
	    itemSeparator.setControl(factorsLabel);
102

  
103
		this.plans = new Combo(this.toolBar, SWT.READ_ONLY);
104

  
105
		// FIXME: commented because the infos panel is not ready to manage more axes
106
//		ArrayList<String> planes = null;
107
//		try {
108
//			int nbsv = ((CA) editorPart.getResultData()).getSingularValues().length;
109
//			planes = new ArrayList<String>();
110
//			for(int i = 1 ; i < nbsv ; i ++)	{
111
//				for(int j = i ; j < nbsv ; j++)	{
112
//					if(i != j)	{
113
//						planes.add("("+i+","+j+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
114
//					}
115
//				}
116
//			}
117
//		}
118
//		catch (StatException e1) {
119
//			// TODO Auto-generated catch block
120
//			org.txm.rcpapplication.utils.Logger.printStackTrace(e1);
121
//		}
122
//		String [] items = planes.toArray(new String[planes.size()]);
123

  
124
		String items[] = { "(1,2)", "(1,3)", "(2,3)" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
125

  
126
		// TODO : commented because the infos panel is not ready to manage more axes
127
		//		if(couples != null && couples.size() > 3)	{
128
		//			items = couples.toArray(new String[couples.size()]);
129
		//}
130

  
131

  
132
		this.plans.setItems(items);
133

  
134
		// Preselect the plan from the CA data
135
		if(this.getResultData().getFirstDimension() == 2)	{
136
			this.plans.select(2);
137
		}
138
		else if(this.getResultData().getSecondDimension() == 3)	{
139
			this.plans.select(1);
140
		}
141
		else	{
142
			this.plans.select(0);
143
		}
144

  
145

  
146
		ToolItem comboItem = new ToolItem(this.toolBar, SWT.SEPARATOR);
147
		comboItem.setControl(this.plans);
148
		this.plans.pack();
149
		comboItem.setWidth(this.plans.getBounds().width);
150
		this.plans.addSelectionListener(new CASelectionListener(this, CASelectionListener.CHANGE_FACTORS));
151
		
152
		
153
		// Initialize the default chart items selection order on descendant label order
154
//		Utils.getChartCreator(this.getChartEditor().getChartsEngine()).updateChartCAFactorialMapSetLabelItemsSelectionOrder(this.getChartEditor().getChart(),
155
//				this.getRowsInfosEditor().getOrdererLabels(), this.getColsInfosEditor().getOrdererLabels());
156
		
157
		
158
//		// Registers mouse handling call backs
159
//		EventCallBackHandler mouseHandler = this.getComposite().getMouseCallBackHandler();
160
//		if(mouseHandler != null)	 {
161
//			// Register mouse single click call back handler to manage the selection of SWT table rows from the charts engine TBX level
162
//			mouseHandler.registerEventCallBack(new CAPointSelectionCallBack(this, this.getRowsInfosEditor().getViewer(), this.getColsInfosEditor().getViewer()));
163
//		}
164
//		
165
//		// Registers keyboard handling call backs
166
//		EventCallBackHandler keyHandler = this.getComposite().getKeyCallBackHandler();
167
//		if(keyHandler != null)	 {
168
//			// Register mouse single click call back handler to manage the selection of SWT table rows from the charts engine TBX level
169
//			keyHandler.registerEventCallBack(new CAPointSelectionCallBack(this, this.getRowsInfosEditor().getViewer(), this.getColsInfosEditor().getViewer()));
170
//		}
171

  
172
		
173
		// initialize the default shared context menus as Export, etc.
174
		//SWTChartsComponentsProvider.initDefaultContextMenus(this.getComposite());
175
	}
176

  
177

  
178

  
179
	@Override
180
	public CA getResultData()	{
181
		return (CA) super.getResultData();
182
	}
183

  
184

  
185
	/**
186
	 * @return the showColumns
187
	 */
188
	public ToolItem getShowColumns() {
189
		return showColumns;
190
	}
191

  
192

  
193
	/**
194
	 * @return the showRows
195
	 */
196
	public ToolItem getShowRows() {
197
		return showRows;
198
	}
199

  
200

  
201
}
0 202

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/ColRowInfosLabelProvider.java (revision 136)
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.ca.rcp.editors;
29

  
30
import java.text.DecimalFormat;
31
import java.util.List;
32

  
33
import org.eclipse.jface.viewers.ITableLabelProvider;
34
import org.eclipse.jface.viewers.LabelProvider;
35
import org.eclipse.swt.graphics.Image;
36
import org.txm.ca.core.preferences.CAPreferences;
37
import org.txm.ca.rcp.messages.CAUIMessages;
38
import org.txm.core.preferences.TXMPreferences;
39
import org.txm.rcpapplication.Messages;
40
// TODO: Auto-generated Javadoc
41
/**
42
 * The Class ColRowInfosLabelProvider.
43
 */
44
public class ColRowInfosLabelProvider extends LabelProvider implements
45
		ITableLabelProvider {
46

  
47
	/** The names. */
48
	String[] names;
49

  
50
	/** The qualitypattern. */
51
	DecimalFormat qualitypattern = new DecimalFormat("0.00"); //$NON-NLS-1$
52

  
53
	/** The masspattern. */
54
	DecimalFormat masspattern = new DecimalFormat("0.00");//%% //$NON-NLS-1$
55

  
56
	/** The distpattern. */
57
	DecimalFormat distpattern = new DecimalFormat("0.00"); //$NON-NLS-1$
58

  
59
	/** The chipattern. */
60
	DecimalFormat chipattern = new DecimalFormat("0.00"); //$NON-NLS-1$
61

  
62
	/** The contribpattern. */
63
	DecimalFormat contribpattern = new DecimalFormat("0.00"); //$NON-NLS-1$
64

  
65
	/** The cos2pattern. */
66
	DecimalFormat cos2pattern = new DecimalFormat("0.00"); //$NON-NLS-1$
67

  
68
	/** The coordpattern. */
69
	DecimalFormat coordpattern = new DecimalFormat("0.00"); //$NON-NLS-1$
70

  
71
	/**
72
	 * Instantiates a new col row infos label provider.
73
	 *
74
	 * @param names the names
75
	 */
76
	public ColRowInfosLabelProvider(String[] names) {
77
		super();
78
		this.names = names;
79
		for (int i = 0; i < names.length; i++) {
80
			if (names[i].startsWith(CAUIMessages.CorrespondanceAnalysisEditorInput_26)) {
81
				String pattern = TXMPreferences.getString(CAPreferences.PREFERENCES_NODE, CAPreferences.MASS_DISPLAY_FORMAT);
82
			if (pattern != null && !pattern.trim().equals("")) //$NON-NLS-1$
83
					masspattern = new DecimalFormat(pattern);
84
			} else if (names[i].startsWith(Messages.ColRowInfosLabelProvider_9)) {
85
				String pattern = TXMPreferences.getString(CAPreferences.PREFERENCES_NODE, CAPreferences.CHI_DISPLAY_FORMAT);
86
				if (pattern != null && !pattern.trim().equals("")) //$NON-NLS-1$
87
					chipattern = new DecimalFormat(pattern);
88
			} else if (names[i].startsWith(CAUIMessages.CorrespondanceAnalysisEditorInput_27)) {
89
				String pattern = TXMPreferences.getString(CAPreferences.PREFERENCES_NODE, CAPreferences.DIST_DISPLAY_FORMAT);
90
				if (pattern != null && !pattern.trim().equals("")) //$NON-NLS-1$
91
					distpattern = new DecimalFormat(pattern);
92
			} else if (names[i].startsWith(CAUIMessages.CorrespondanceAnalysisEditorInput_30)) {
93
				String pattern = TXMPreferences.getString(CAPreferences.PREFERENCES_NODE, CAPreferences.COS2_DISPLAY_FORMAT);
94
				if (pattern != null && !pattern.trim().equals("")) //$NON-NLS-1$
95
					cos2pattern = new DecimalFormat(pattern);
96
			} else if (names[i].startsWith("c") && names[i].length() == 2) //$NON-NLS-1$
97
			{
98
				String pattern = TXMPreferences.getString(CAPreferences.PREFERENCES_NODE, CAPreferences.COORD_DISPLAY_FORMAT);
99
				if (pattern != null && !pattern.trim().equals("")) //$NON-NLS-1$
100
					coordpattern = new DecimalFormat(pattern);
101
			} else if (names[i].startsWith(CAUIMessages.CorrespondanceAnalysisEditorInput_29)) {
102
				String pattern = TXMPreferences.getString(CAPreferences.PREFERENCES_NODE, CAPreferences.CONTRIB_DISPLAY_FORMAT);
103
				if (pattern != null && !pattern.trim().equals("")) //$NON-NLS-1$
104
					contribpattern = new DecimalFormat(pattern);
105
			} else if (names[i].startsWith(Messages.ColRowInfosLabelProvider_19) && names[i].length() == 3) {
106
				String pattern = TXMPreferences.getString(CAPreferences.PREFERENCES_NODE, CAPreferences.QUALITY_DISPLAY_FORMAT);
107
				if (pattern != null && !pattern.trim().equals("")) //$NON-NLS-1$
108
					qualitypattern = new DecimalFormat(pattern);
109
			}
110
		}
111
	}
112

  
113
	/* (non-Javadoc)
114
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
115
	 */
116
	@Override
117
	public Image getColumnImage(Object element, int columnIndex) {
118
		// TODO Auto-generated method stub
119
		return null;
120
	}
121

  
122
	/* (non-Javadoc)
123
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
124
	 */
125
	@Override
126
	@SuppressWarnings("unchecked") //$NON-NLS-1$
127
	public String getColumnText(Object element, int columnIndex) {
128
		// names[columnIndex] = Rows,Q12,Q13,Q23,Mass,Chi²,Contrib,Cos²,c1,c2,c3
129

  
130
		Object o = ((List<Object>) element).get(columnIndex);
131
		if (o instanceof Double || o instanceof Float) {
132
			DecimalFormat f;
133
			String name = names[columnIndex];
134
			f = new DecimalFormat("###.00"); //$NON-NLS-1$
135
			if (name.startsWith(CAUIMessages.CorrespondanceAnalysisEditorInput_26)) {
136
				f = masspattern;
137
			} else if (name.startsWith(Messages.ColRowInfosLabelProvider_9)) {
138
				f = chipattern;
139
			} else if (name.startsWith(CAUIMessages.CorrespondanceAnalysisEditorInput_27)) {
140
				f = distpattern;
141
			} else if (name.startsWith(CAUIMessages.CorrespondanceAnalysisEditorInput_30)) {
142
				f = cos2pattern;
143
			} else if (name.startsWith("c") && name.length() == 2) //$NON-NLS-1$
144
			{
145
				f = coordpattern;
146
			} else if (name.startsWith(CAUIMessages.CorrespondanceAnalysisEditorInput_29)) {
147
				f = contribpattern;
148
			} else if (name.startsWith(Messages.ColRowInfosLabelProvider_19)
149
					&& name.length() == 3) {
150
				f = qualitypattern;
151
			}
152
			return f.format(o);
153
		} else
154
			return o.toString();
155
	}
156
}
0 157

  
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff