Révision 204

tmp/org.txm.cooccurrence.rcp/.classpath (revision 204)
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.cooccurrence.rcp/META-INF/MANIFEST.MF (revision 204)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Cooccurence RCP
4
Bundle-SymbolicName: org.txm.cooccurrence.rcp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
7
Export-Package: org.txm.cooccurrence.rcp.editors
8
Require-Bundle: org.txm.cooccurrence.core;bundle-version="1.0.0",
9
 org.eclipse.core.commands,
10
 org.txm.core,
11
 org.txm.rcp,
12
 org.eclipse.ui;bundle-version="3.106.1",
13
 org.eclipse.core.runtime;bundle-version="3.10.0"
0 14

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

  
30
import java.util.List;
31

  
32
import org.eclipse.jface.viewers.IStructuredContentProvider;
33
import org.eclipse.jface.viewers.Viewer;
34
import org.txm.functions.cooccurrence.*;
35

  
36
// TODO: Auto-generated Javadoc
37
/**
38
 * The Class LineContentProvider.
39
 *
40
 * @ author mdecorde
41
 */
42
public class LineContentProvider implements IStructuredContentProvider {
43

  
44
	/*
45
	 * (non-Javadoc)
46
	 * 
47
	 * @see
48
	 * org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java
49
	 * .lang.Object)
50
	 */
51
	@Override
52
	public Object[] getElements(Object inputElement) {
53
		@SuppressWarnings("unchecked") //$NON-NLS-1$
54
		List<Cooccurrence.CLine> lines = (List<Cooccurrence.CLine>) inputElement;
55
		// System.out.println("input lines size "+ lines.size());
56
		return lines.toArray();
57
	}
58

  
59
	/*
60
	 * (non-Javadoc)
61
	 * 
62
	 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
63
	 */
64
	@Override
65
	public void dispose() {
66
		// TODO Auto-generated method stub
67

  
68
	}
69

  
70
	/*
71
	 * (non-Javadoc)
72
	 * 
73
	 * @see
74
	 * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface
75
	 * .viewers.Viewer, java.lang.Object, java.lang.Object)
76
	 */
77
	@Override
78
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
79
		// TODO Auto-generated method stub
80
	}
81

  
82
}
0 83

  
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/CooccurrenceEditorInput.java (revision 204)
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.cooccurrence.rcp.editors;
29

  
30
import org.eclipse.jface.resource.ImageDescriptor;
31
import org.eclipse.ui.IEditorInput;
32
import org.eclipse.ui.IPersistableElement;
33
import org.eclipse.ui.plugin.AbstractUIPlugin;
34
import org.txm.functions.cooccurrence.Cooccurrence;
35
import org.txm.rcpapplication.Application;
36
import org.txm.rcpapplication.IImageKeys;
37
import org.txm.rcpapplication.Messages;
38
import org.txm.searchengine.cqp.corpus.Corpus;
39
// TODO: Auto-generated Javadoc
40
/**
41
 * The Class CooccurrenceEditorInput.
42
 */
43
public class CooccurrenceEditorInput implements IEditorInput {
44

  
45
	/** The cooc. */
46
	private Cooccurrence cooc;
47
	
48
	/** The corpus. */
49
	private Corpus corpus;
50

  
51
	/**
52
	 * Instantiates a new cooccurrence editor input.
53
	 *
54
	 * @param cooc the cooc
55
	 */
56
	public CooccurrenceEditorInput(Cooccurrence cooc) {
57
		this.cooc = cooc;
58
		this.corpus = cooc.getCorpus();
59
	}
60

  
61
	/**
62
	 * Instantiates a new cooccurrence editor input.
63
	 *
64
	 * @param corpus the corpus
65
	 */
66
	public CooccurrenceEditorInput(Corpus corpus) {
67
		this.corpus = corpus;
68
	}
69

  
70
	/* (non-Javadoc)
71
	 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
72
	 */
73
	@Override
74
	public ImageDescriptor getImageDescriptor() {
75
		return AbstractUIPlugin.imageDescriptorFromPlugin(
76
				Application.PLUGIN_ID, IImageKeys.ACTION_COOCCURRENCE);
77
	}
78

  
79
	/* (non-Javadoc)
80
	 * @see org.eclipse.ui.IEditorInput#getName()
81
	 */
82
	@Override
83
	public String getName() {
84
		if (cooc != null)
85
			return cooc.getQuery().toString(); 
86
		else
87
			return Messages.CoocPreferencePage_5;
88
	}
89

  
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.ui.IEditorInput#getPersistable()
92
	 */
93
	@Override
94
	public IPersistableElement getPersistable() {
95
		return null;
96
	}
97

  
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
100
	 */
101
	@Override
102
	public String getToolTipText() {
103
		if (cooc != null)
104
			return cooc.toInfos();
105
		else
106
			return ""; //$NON-NLS-1$
107
	}
108

  
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
111
	 */
112
	@Override
113
	public Object getAdapter(Class adapter) {
114
		return null;
115
	}
116

  
117
	/**
118
	 * Gets the cooc.
119
	 *
120
	 * @return the cooc
121
	 */
122
	public Cooccurrence getCooc() {
123
		return cooc;
124
	}
125

  
126
	/* (non-Javadoc)
127
	 * @see org.eclipse.ui.IEditorInput#exists()
128
	 */
129
	@Override
130
	public boolean exists() {
131
		return false;
132
	}
133

  
134
	/**
135
	 * Gets the corpus.
136
	 *
137
	 * @return the corpus
138
	 */
139
	public Corpus getCorpus() {
140
		return corpus;
141
	}
142
}
0 143

  
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/LineLabelProvider.java (revision 204)
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.cooccurrence.rcp.editors;
29

  
30
import java.text.DecimalFormat;
31

  
32
import org.eclipse.jface.viewers.ILabelProviderListener;
33
import org.eclipse.jface.viewers.ITableLabelProvider;
34
import org.eclipse.swt.graphics.Image;
35
import org.txm.cooccurrence.core.preferences.CooccurrencePreferences;
36
import org.txm.core.preferences.TXMPreferences;
37
import org.txm.functions.cooccurrence.Cooccurrence;
38

  
39
// TODO: Auto-generated Javadoc
40
/**
41
 * The Class LineLabelProvider.
42
 *
43
 * @author mdecorde
44
 */
45
public class LineLabelProvider implements ITableLabelProvider {
46

  
47
	/** The format. */
48
	String format = TXMPreferences.getString(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.SCORE_FORMAT);
49

  
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
52
	 */
53
	@Override
54
	public Image getColumnImage(Object element, int columnIndex) {
55
		return null;
56
	}
57

  
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
60
	 */
61
	@Override
62
	public String getColumnText(Object element, int columnIndex) {
63
		// System.out.println("getColumnText "+columnIndex+" >>> "+((Cooccurence.CLine)
64
		// element).resume());
65
		Cooccurrence.CLine line = (Cooccurrence.CLine) element;
66
		switch (columnIndex) {
67
		case 0:
68
			return ""; //$NON-NLS-1$
69
		case 1:
70
			return line.occ;
71
		case 2:
72
			return "" + line.freq; //$NON-NLS-1$
73
		case 3:
74
			return "" + line.nbocc; //$NON-NLS-1$
75
		case 4:
76
			//String signe = "+"; //$NON-NLS-1$
77
			/*
78
			 * DecimalFormat f = new DecimalFormat("0.0000E00"); //$NON-NLS-1$
79
			 * try { //if (line.mode > line.nbocc) // signe="-"; //$NON-NLS-1$
80
			 * 
81
			 * f = new DecimalFormat(format); return f.format(line.score);
82
			 * }catch(Exception e){ } String d = f.format(line.score);
83
			 * 
84
			 * return d.substring(d.length()-2, d.length());
85
			 */
86
			return String.valueOf((int) line.score);
87
			//return ""+(line.score*100.0)+"%"; //$NON-NLS-1$
88
		case 5:
89
			DecimalFormat f = new DecimalFormat("#.0"); //$NON-NLS-1$
90
			return f.format(line.distmoyenne);
91
			//return ""+line.distmoyenne; //$NON-NLS-1$
92
		case 6:
93
			return ""; //$NON-NLS-1$
94
		}
95
		return "null" + columnIndex; //$NON-NLS-1$
96
	}
97

  
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
100
	 */
101
	@Override
102
	public void addListener(ILabelProviderListener listener) {
103
		// TODO Auto-generated method stub
104
	}
105

  
106
	/* (non-Javadoc)
107
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
108
	 */
109
	@Override
110
	public void dispose() {
111
		// TODO Auto-generated method stub
112
	}
113

  
114
	/* (non-Javadoc)
115
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
116
	 */
117
	@Override
118
	public boolean isLabelProperty(Object element, String property) {
119
		// TODO Auto-generated method stub
120
		return false;
121
	}
122

  
123
	/* (non-Javadoc)
124
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
125
	 */
126
	@Override
127
	public void removeListener(ILabelProviderListener listener) {
128
		// TODO Auto-generated method stub
129
	}
130
}
0 131

  
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/CooccurrencesEditor.java (revision 204)
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.cooccurrence.rcp.editors;
29

  
30
import java.lang.reflect.InvocationTargetException;
31
import java.util.ArrayList;
32
import java.util.List;
33

  
34
import org.eclipse.core.runtime.IProgressMonitor;
35
import org.eclipse.core.runtime.IStatus;
36
import org.eclipse.core.runtime.Status;
37
import org.eclipse.jface.action.MenuManager;
38
import org.eclipse.jface.operation.IRunnableWithProgress;
39
import org.eclipse.jface.viewers.IStructuredSelection;
40
import org.eclipse.jface.viewers.TableViewer;
41
import org.eclipse.osgi.util.NLS;
42
import org.eclipse.swt.SWT;
43
import org.eclipse.swt.custom.ScrolledComposite;
44
import org.eclipse.swt.events.ControlAdapter;
45
import org.eclipse.swt.events.ControlEvent;
46
import org.eclipse.swt.events.KeyEvent;
47
import org.eclipse.swt.events.KeyListener;
48
import org.eclipse.swt.events.MouseAdapter;
49
import org.eclipse.swt.events.MouseEvent;
50
import org.eclipse.swt.events.SelectionEvent;
51
import org.eclipse.swt.events.SelectionListener;
52
import org.eclipse.swt.graphics.Font;
53
import org.eclipse.swt.graphics.FontData;
54
import org.eclipse.swt.graphics.Image;
55
import org.eclipse.swt.graphics.Point;
56
import org.eclipse.swt.graphics.Rectangle;
57
import org.eclipse.swt.layout.FormAttachment;
58
import org.eclipse.swt.layout.FormData;
59
import org.eclipse.swt.layout.FormLayout;
60
import org.eclipse.swt.layout.GridData;
61
import org.eclipse.swt.layout.GridLayout;
62
import org.eclipse.swt.layout.RowLayout;
63
import org.eclipse.swt.widgets.Button;
64
import org.eclipse.swt.widgets.Composite;
65
import org.eclipse.swt.widgets.Display;
66
import org.eclipse.swt.widgets.Event;
67
import org.eclipse.swt.widgets.Label;
68
import org.eclipse.swt.widgets.Listener;
69
import org.eclipse.swt.widgets.Menu;
70
import org.eclipse.swt.widgets.Spinner;
71
import org.eclipse.swt.widgets.TableColumn;
72
import org.eclipse.swt.widgets.Text;
73
import org.eclipse.ui.IEditorInput;
74
import org.eclipse.ui.IEditorSite;
75
import org.eclipse.ui.PartInitException;
76
import org.eclipse.ui.PlatformUI;
77
import org.eclipse.ui.part.EditorPart;
78
import org.txm.Toolbox;
79
import org.txm.cooccurrence.core.preferences.CooccurrencePreferences;
80
import org.txm.core.preferences.TXMPreferences;
81
import org.txm.functions.cooccurrence.Cooccurrence;
82
import org.txm.functions.cooccurrence.comparators.CLineComparator;
83
import org.txm.functions.cooccurrence.comparators.DistComparator;
84
import org.txm.functions.cooccurrence.comparators.FreqComparator;
85
import org.txm.functions.cooccurrence.comparators.NbOccComparator;
86
import org.txm.functions.cooccurrence.comparators.OccComparator;
87
import org.txm.functions.cooccurrence.comparators.ReverseComparator;
88
import org.txm.functions.cooccurrence.comparators.ScoreComparator;
89
import org.txm.rcpapplication.JobsTimer;
90
import org.txm.rcpapplication.Messages;
91
import org.txm.rcpapplication.StatusLine;
92
import org.txm.rcpapplication.TxmPreferences;
93
import org.txm.rcpapplication.commands.editor.CustomizableEditor;
94
import org.txm.rcpapplication.commands.link.CooccurrencesToConcordances;
95
import org.txm.rcpapplication.editors.TableKeyListener;
96
import org.txm.rcpapplication.preferences.UserPreferencePage;
97
import org.txm.rcpapplication.swt.widget.AssistedQueryWidget;
98
import org.txm.rcpapplication.swt.widget.EmpantWidget;
99
import org.txm.rcpapplication.swt.widget.PropertiesSelector;
100
import org.txm.rcpapplication.utils.JobHandler;
101
import org.txm.rcpapplication.utils.Logger;
102
import org.txm.rcpapplication.views.CorporaView;
103
import org.txm.rcpapplication.views.QueriesView;
104
import org.txm.rcpapplication.views.RVariablesView;
105
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
106
import org.txm.searchengine.cqp.corpus.Corpus;
107
import org.txm.searchengine.cqp.corpus.Property;
108
import org.txm.searchengine.cqp.corpus.StructuralUnit;
109
import org.txm.searchengine.cqp.corpus.query.Query;
110
import org.txm.utils.logger.Log;
111

  
112
// TODO: Auto-generated Javadoc
113
/**
114
 * display the cooc parameters and result @ author mdecorde.
115
 */
116
public class CooccurrencesEditor extends EditorPart implements CustomizableEditor{
117
	
118
	/** The Constant ID. */
119
	public static final String ID = "CooccurrencesEditor"; //$NON-NLS-1$
120

  
121
	/** The cooc. */
122
	Cooccurrence cooc;
123
	
124
	/** The self. */
125
	CooccurrencesEditor self;
126
	// params
127
	/** The query widget. */
128
	AssistedQueryWidget queryWidget;
129
	
130
	/** The props area. */
131
	PropertiesSelector propsArea;
132
	
133
	/** The empant panel. */
134
	EmpantWidget empantPanel;
135
	
136
	/** The T score. */
137
	Text TScore;
138
	
139
	/** The T count. */
140
	Spinner TCount;
141
	
142
	/** The T freq. */
143
	Spinner TFreq;
144

  
145
	/** The line table viewer. */
146
	TableViewer viewer;
147
	
148
	/** The n column. */
149
	TableColumn nColumn;
150
	
151
	/** The occ column. */
152
	TableColumn occColumn;
153
	
154
	/** The freq column. */
155
	TableColumn freqColumn;
156
	
157
	/** The nbocc column. */
158
	TableColumn nboccColumn;
159
	
160
	/** The score column. */
161
	TableColumn scoreColumn;
162
	
163
	/** The dist column. */
164
	TableColumn distColumn;
165

  
166
	/** The current comparator. */
167
	CLineComparator currentComparator;
168

  
169
	/** The corpus. */
170
	private Corpus corpus;
171
	
172
	/** The query. */
173
	private Query query;
174
	
175
	/** The properties. */
176
	private List<Property> properties;
177
	
178
	/** The structure. */
179
	private StructuralUnit structure;
180
	
181
	/** The leftmin. */
182
	private int leftmin;
183
	
184
	/** The leftmax. */
185
	private int leftmax;
186
	
187
	/** The rightmin. */
188
	private int rightmin;
189
	
190
	/** The rightmax. */
191
	private int rightmax;
192
	
193
	/** The minfreq. */
194
	private int minfreq;
195
	
196
	/** The mincount. */
197
	private int mincount;
198
	
199
	/** The minscore. */
200
	private double minscore;
201

  
202
	/** The scroll composite. */
203
	private ScrolledComposite scrollComposite;
204

  
205
	/** The include xpivot. */
206
	private boolean includeXpivot;
207
	
208
	private boolean buildLexicalTableWithCooccurrents;
209

  
210
	/** The source. */
211
	private Object source;
212

  
213
	/**
214
	 * Instantiates a new cooccurrences editor.
215
	 */
216
	public CooccurrencesEditor() {
217
		super();
218
		self = this;
219
	}
220

  
221
	/**
222
	 * Do save.
223
	 *
224
	 * @param arg0 the arg0
225
	 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
226
	 */
227
	@Override
228
	public void doSave(IProgressMonitor arg0) {
229

  
230
	}
231

  
232
	/**
233
	 * Do save as.
234
	 *
235
	 * @see org.eclipse.lyon gournd zeroui.part.EditorPart#doSaveAs()
236
	 */
237
	@Override
238
	public void doSaveAs() {
239

  
240
	}
241

  
242
	/**
243
	 * Inits the.
244
	 *
245
	 * @param site the site
246
	 * @param input the input
247
	 * @throws PartInitException the part init exception
248
	 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
249
	 * org.eclipse.ui.IEditorInput)
250
	 */
251
	@Override
252
	public void init(IEditorSite site, IEditorInput input)
253
	throws PartInitException {
254
		setSite(site);
255
		setInput(input);
256

  
257
		this.cooc = ((CooccurrenceEditorInput) input).getCooc();
258
		if (cooc != null)
259
		{
260
			this.corpus = cooc.getCorpus();
261
			setPartName(cooc.getCorpus().getName()+": "+cooc.getName()); //$NON-NLS-1$
262
		}
263
		else
264
			this.corpus = ((CooccurrenceEditorInput) input).getCorpus();
265
	}
266

  
267
	/**
268
	 * Checks if is dirty.
269
	 *
270
	 * @return true, if is dirty
271
	 * @see org.eclipse.ui.part.EditorPart#isDirty()
272
	 */
273
	@Override
274
	public boolean isDirty() {
275
		return false;
276
	}
277

  
278
	/**
279
	 * Checks if is save as allowed.
280
	 *
281
	 * @return true, if is save as allowed
282
	 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
283
	 */
284
	@Override
285
	public boolean isSaveAsAllowed() {
286
		return false;
287
	}
288

  
289
	/**
290
	 * Sort.
291
	 */
292
	public void sort() {
293
		if (cooc != null && currentComparator != null) {
294

  
295
			try {
296
				Log.info(NLS.bind(Messages.CooccurrencesEditor_0, currentComparator.getName()));
297

  
298
				PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
299
						new IRunnableWithProgress() {
300
							@Override
301
							public void run(IProgressMonitor monitor)
302
							throws InvocationTargetException,
303
							InterruptedException {
304
								try {
305
									cooc.sort(currentComparator);
306
								} catch (CqiClientException e) {
307
									System.err.println(NLS.bind(
308
										Messages.ERROR_WHILE_LOADING_CONCORDANCE_LINE, e));
309
								}
310
							}
311
						});
312
			} catch (Exception e) {
313
				System.err.println(NLS.bind(
314
						Messages.ERROR_WHILE_LOADING_CONCORDANCE_LINE, e));
315
				org.txm.rcpapplication.utils.Logger.printStackTrace(e);
316
			}
317
			viewer.refresh();
318
		}
319
	}
320

  
321
	/**
322
	 * Creates the part control.
323
	 *
324
	 * @param parent the parent
325
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
326
	 */
327
	@Override
328
	public void createPartControl(final Composite parent) {
329
		FormLayout parentLayout = new FormLayout();
330
		parent.setLayout(parentLayout);
331

  
332
		scrollComposite = new ScrolledComposite(parent, SWT.H_SCROLL
333
				| SWT.BORDER);
334
		FormData paramLayoutData = new FormData();
335
		paramLayoutData.top = new FormAttachment(0);
336
		paramLayoutData.left = new FormAttachment(0);
337
		paramLayoutData.right = new FormAttachment(100);
338
		scrollComposite.setLayoutData(paramLayoutData);
339

  
340
		final Composite paramArea = new Composite(scrollComposite, SWT.NONE);
341
		FormLayout paramLayout = new FormLayout();
342
		paramArea.setLayout(paramLayout);
343

  
344
		scrollComposite.setContent(paramArea);
345
		scrollComposite.setExpandVertical(true);
346
		scrollComposite.setExpandHorizontal(true);
347
		scrollComposite.addControlListener(new ControlAdapter() {
348
			@Override
349
			public void controlResized(ControlEvent e) {
350
				Rectangle r = scrollComposite.getClientArea();
351
				scrollComposite.setMinSize(paramArea.computeSize(SWT.DEFAULT,
352
						SWT.DEFAULT));
353
			}
354
		});
355

  
356
		// Label infos = new Label(paramArea, SWT.NONE);
357
		// infos.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
358
		// true));
359

  
360
		Composite queryArea = new Composite(paramArea, SWT.NONE);
361

  
362
		FormData queryLayoutData = new FormData();
363
		queryLayoutData.top = new FormAttachment(0);
364
		queryLayoutData.left = new FormAttachment(0);
365
		queryLayoutData.right = new FormAttachment(100);
366
		queryArea.setLayoutData(queryLayoutData);
367

  
368
		queryArea.setLayout(new GridLayout(3, false));
369

  
370
		Label queryLabel = new Label(queryArea, SWT.NONE);
371
		queryLabel.setText(Messages.IndexEditor_3);
372
		queryLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
373
				true));
374

  
375
		// [ (v)]
376
		queryWidget = new AssistedQueryWidget(queryArea, SWT.DROP_DOWN,
377
				this.corpus);
378
		GridData layoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
379
		layoutData.horizontalAlignment = GridData.FILL;
380
		layoutData.grabExcessHorizontalSpace = true;
381
		queryWidget.setLayoutData(layoutData);
382
		queryWidget.addKeyListener(new KeyListener() {
383
			@Override
384
			public void keyPressed(KeyEvent e) {
385
				// System.out.println("key pressed : "+e.keyCode);
386
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
387
					compute();
388
				}
389
			}
390

  
391
			@Override
392
			public void keyReleased(KeyEvent e) {
393
			}
394

  
395
		});
396

  
397
		final Button go = new Button(queryArea, SWT.BOLD);
398
		go.setText(Messages.CooccurrencesEditor_2);
399

  
400
		Font f = go.getFont();
401
		FontData defaultFont = f.getFontData()[0];
402
		defaultFont.setStyle(SWT.BOLD);
403
		Font newf = new Font(go.getDisplay(), defaultFont);
404
		go.setFont(newf);
405

  
406
		layoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
407
		layoutData.horizontalAlignment = GridData.FILL;
408
		layoutData.grabExcessHorizontalSpace = false;
409
		go.setLayoutData(layoutData);
410

  
411
		go.addSelectionListener(new SelectionListener() {
412
			@Override
413
			public void widgetSelected(SelectionEvent e) {
414
				compute();
415
			}
416

  
417
			@Override
418
			public void widgetDefaultSelected(SelectionEvent e) {
419
			}
420
		});
421

  
422
		// Filters
423
		Composite filtercontrols = new Composite(paramArea, SWT.NONE);
424
		FormData filtersLayoutData = new FormData();
425
		filtersLayoutData.top = new FormAttachment(queryArea, 0);
426
		// filtersLayoutData.bottom = new FormAttachment (100);
427
		filtersLayoutData.left = new FormAttachment(0);
428
		filtersLayoutData.right = new FormAttachment(100);
429
		filtercontrols.setLayoutData(filtersLayoutData);
430
		RowLayout layout = new RowLayout();
431
		layout.wrap = true;
432
		layout.center = true;
433
		filtercontrols.setLayout(layout);
434

  
435
		// | Properties: word_pos [Edit] |
436
		propsArea = new PropertiesSelector(filtercontrols, SWT.NONE);
437
		propsArea.setLayout(new GridLayout(4, false));
438
		propsArea.setCorpus(this.getCorpus());
439
		propsArea.setText(Messages.CooccurrencesEditor_3);
440
		propsArea.addValueChangeListener(new Listener() {
441
			@Override
442
			public void handleEvent(Event event) {
443
				if (TxmPreferences.getBoolean(UserPreferencePage.AUTO_UPDATE_EDITOR))
444
					compute();
445
			}
446
		});
447
		/*
448
		 * FormData propsLayoutData = new FormData(); propsLayoutData.top = new
449
		 * FormAttachment (queryArea, 0); propsLayoutData.left = new
450
		 * FormAttachment (0); propsLayoutData.right = new FormAttachment (100);
451
		 * propsArea.setLayoutData(propsLayoutData);
452
		 */
453

  
454
		/*
455
		 * GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 9;
456
		 * gridLayout.makeColumnsEqualWidth = false;
457
		 * filtercontrols.setLayout(gridLayout);
458
		 */
459

  
460
		Label seuilLabel = new Label(filtercontrols, SWT.NONE);
461
		seuilLabel.setText(Messages.CooccurrencesEditor_4);
462

  
463
		TFreq = new Spinner(filtercontrols, SWT.BORDER);
464
		TFreq.setMinimum(1);
465
		TFreq.setMaximum(99999);
466
		TFreq.setIncrement(1);
467
		TFreq.setPageIncrement(100);
468
		int defaultFmin = TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_FREQ);
469
		TFreq.setSelection(defaultFmin);
470

  
471
		seuilLabel = new Label(filtercontrols, SWT.NONE);
472
		seuilLabel.setText(Messages.CooccurrencesEditor_5);
473
		TCount = new Spinner(filtercontrols, SWT.BORDER);
474
		TCount.setMinimum(1);
475
		TCount.setMaximum(99999);
476
		TCount.setIncrement(1);
477
		TCount.setPageIncrement(100);
478
		int defaultCountmin = TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_COUNT);
479
		TCount.setSelection(defaultCountmin);
480

  
481
		seuilLabel = new Label(filtercontrols, SWT.NONE);
482
		seuilLabel.setText(Messages.CooccurrencesEditor_6);
483
		TScore = new Text(filtercontrols, SWT.BORDER);
484
		TScore.setText("0.0"); //$NON-NLS-1$
485
		String defaultScoremin = TXMPreferences.getString(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_SCORE);
486
		TScore.setText(defaultScoremin);
487

  
488
		// empant
489
		empantPanel = new EmpantWidget(paramArea, SWT.NONE, this.getCorpus());
490
		
491
		FormData empantLayoutData = new FormData();
492
		empantLayoutData.top = new FormAttachment(filtercontrols, 0);
493
		empantLayoutData.bottom = new FormAttachment(100);
494
		empantLayoutData.left = new FormAttachment(0);
495
		empantLayoutData.right = new FormAttachment(100);
496
		empantPanel.setLayoutData(empantLayoutData);
497
		empantPanel.setMinLeft(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_LEFT));
498
		empantPanel.setMaxLeft(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MAX_LEFT));
499
		empantPanel.setMinRight(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_RIGHT));
500
		empantPanel.setMaxRight(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MAX_RIGHT));
501
		
502
		// result
503
		Composite resultArea = new Composite(parent, SWT.NONE);
504
		FormData resultLayoutData = new FormData();
505
		resultLayoutData.top = new FormAttachment(scrollComposite, 0);
506
		resultLayoutData.left = new FormAttachment(0);
507
		resultLayoutData.right = new FormAttachment(100);
508
		resultLayoutData.bottom = new FormAttachment(100);
509
		resultArea.setLayoutData(resultLayoutData);
510

  
511
		FormLayout resultLayout = new FormLayout();
512
		resultArea.setLayout(resultLayout);
513

  
514
		viewer = new TableViewer(resultArea, SWT.MULTI
515
				| SWT.FULL_SELECTION | SWT.BORDER);
516
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
517
		viewer.getTable().setLinesVisible(true);
518
		viewer.getTable().setHeaderVisible(true);
519
		
520
		if (corpus != null && corpus.getFont() != null && corpus.getFont().length() > 0) {
521
			Font old = viewer.getTable().getFont();
522
			FontData fD = old.getFontData()[0];
523
			//Font f = new Font(old.getDevice(), corpus.getFont(), fD.getHeight(), fD.getStyle());
524
			Font font = new Font(Display.getCurrent(), corpus.getFont(), fD.getHeight(), fD.getStyle()); 
525
			viewer.getTable().setFont(font);
526
		}
527

  
528
		viewer.getTable().addMouseListener(new MouseAdapter() {
529
			@Override
530
			public void mouseDoubleClick(MouseEvent e) {
531
				Point mouseposition = new Point(e.x
532
						+ viewer.getTable().getHorizontalBar()
533
						.getSelection(), e.y);
534
				int col = getPointedColumn(mouseposition);
535
				//System.out.println("col "+col);
536
				switch(col)
537
				{
538
				default:
539
					IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
540
					CooccurrencesToConcordances.link(CooccurrencesEditor.this, selection);
541
				}
542
			}
543
		});
544

  
545
		FormData tableLayoutData = new FormData();
546
		tableLayoutData.top = new FormAttachment(0);
547
		tableLayoutData.bottom = new FormAttachment(100);
548
		tableLayoutData.left = new FormAttachment(0);
549
		tableLayoutData.right = new FormAttachment(100);
550
		viewer.getTable().setLayoutData(tableLayoutData);
551

  
552
		viewer.setLabelProvider(new LineLabelProvider());
553
		viewer.setContentProvider(new LineContentProvider());
554
		if (cooc != null)
555
			viewer.setInput(cooc.getLines());
556

  
557
		nColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
558
		nColumn.setText(" "); //$NON-NLS-1$
559
		nColumn.pack();
560

  
561
		occColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
562
		occColumn.setText(Messages.CooccurrencesEditor_8);
563
		occColumn.setToolTipText(Messages.CooccurrencesEditor_8);
564
		occColumn.setWidth(200);
565
		occColumn.addSelectionListener(new SelectionListener() {
566
			@Override
567
			public void widgetSelected(SelectionEvent e) {
568
				setColComparator(new OccComparator(), occColumn);
569
				sort();
570
			}
571

  
572
			@Override
573
			public void widgetDefaultSelected(SelectionEvent e) {
574
			}
575
		});
576

  
577
		freqColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
578
		freqColumn.setText(Messages.FrequencyListEditorInput_4);
579
		freqColumn.setToolTipText(Messages.FrequencyListEditorInput_4);
580
		freqColumn.setWidth(100);
581
		freqColumn.addSelectionListener(new SelectionListener() {
582
			@Override
583
			public void widgetSelected(SelectionEvent e) {
584
				setColComparator(new FreqComparator(), freqColumn);
585
				sort();
586
			}
587

  
588
			@Override
589
			public void widgetDefaultSelected(SelectionEvent e) {
590
			}
591
		});
592

  
593
		nboccColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
594
		nboccColumn.setText(Messages.CooccurrencesEditor_10);
595
		nboccColumn.setToolTipText(Messages.CooccurrencesEditor_10);
596
		nboccColumn.setWidth(130);
597
		nboccColumn.addSelectionListener(new SelectionListener() {
598
			@Override
599
			public void widgetSelected(SelectionEvent e) {
600
				setColComparator(new NbOccComparator(), nboccColumn);
601
				sort();
602
			}
603

  
604
			@Override
605
			public void widgetDefaultSelected(SelectionEvent e) {
606
			}
607
		});
608

  
609
		scoreColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
610
		scoreColumn.setText(Messages.CooccurrencesEditor_17);
611
		scoreColumn.setToolTipText(Messages.CooccurrencesEditor_17);
612
		scoreColumn.setWidth(100);
613
		scoreColumn.addSelectionListener(new SelectionListener() {
614
			@Override
615
			public void widgetSelected(SelectionEvent e) {
616
				setColComparator(new ScoreComparator(), scoreColumn);
617
				sort();
618
			}
619

  
620
			@Override
621
			public void widgetDefaultSelected(SelectionEvent e) {
622
			}
623
		});
624

  
625
		distColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
626
		distColumn.setText(Messages.CooccurrencesEditor_9);
627
		distColumn.setToolTipText(Messages.CooccurrencesEditor_9);
628
		distColumn.setWidth(130);
629
		distColumn.addSelectionListener(new SelectionListener() {
630
			@Override
631
			public void widgetSelected(SelectionEvent e) {
632
				setColComparator(new DistComparator(), distColumn);
633
				sort();
634
			}
635

  
636
			@Override
637
			public void widgetDefaultSelected(SelectionEvent e) {
638
			}
639
		});
640

  
641
		TableColumn n2Column = new TableColumn(viewer.getTable(),
642
				SWT.RIGHT);
643
		n2Column.setText(""); //$NON-NLS-1$
644
		n2Column.pack();
645

  
646
		viewer.refresh();
647
		currentComparator = new ScoreComparator();
648
		setColComparator(new ScoreComparator(), scoreColumn);
649
		sort();
650
		setColComparator(new ScoreComparator(), scoreColumn);
651
		sort();
652
		createContextMenu(viewer);
653
		setParametersFromCooc();
654

  
655
		for (TableColumn col : viewer.getTable().getColumns())
656
			col.pack();
657
	}
658

  
659
	/**
660
	 * Gets the pointed column.
661
	 *
662
	 * @param mouseposition the mouseposition
663
	 * @return the pointed column
664
	 */
665
	public int getPointedColumn(Point mouseposition) {
666
		int x = mouseposition.x; // + lineTableViewer.getTable().get;
667
		int sumWidthColumn = this.nColumn.getWidth();
668
		if (x < sumWidthColumn)
669
			return 0;
670

  
671
		sumWidthColumn += this.occColumn.getWidth();
672
		if (x < sumWidthColumn)
673
			return 1;
674

  
675
		sumWidthColumn += this.freqColumn.getWidth();
676
		if (x < sumWidthColumn)
677
			return 2;
678

  
679
		sumWidthColumn += this.nboccColumn.getWidth();
680
		if (x < sumWidthColumn)
681
			return 3;
682

  
683
		sumWidthColumn += this.scoreColumn.getWidth();
684
		if (x < sumWidthColumn)
685
			return 4;
686

  
687
		sumWidthColumn += this.distColumn.getWidth();
688
		if (x < sumWidthColumn)
689
			return 5;
690

  
691
		return 5;
692
	}
693

  
694
	/**
695
	 * Compute.
696
	 */
697
	public void compute() {
698
		StatusLine.setMessage(Messages.CooccurrencesEditor_33);
699
		if (this.queryWidget.getQueryString().trim().length() == 0
700
				|| this.queryWidget.getQueryString().trim().equals("\"\"")) //$NON-NLS-1$
701
			return;
702
		this.query = new Query(this.queryWidget.getQueryString());
703
		queryWidget.memorize();
704
		
705
		if (this.empantPanel.getMinLeft() == -1 && this.empantPanel.getMinRight() == -1)
706
		{
707
			if (this.empantPanel.getStruct() == null) {
708
				System.out.println(Messages.CooccurrencesEditor_16);
709
				return;
710
			} else if (!this.empantPanel.getXPivot()) {
711
				System.out.println(Messages.CooccurrencesEditor_16);
712
				return;
713
			}
714
		}
715
		this.properties = this.propsArea.getProperties();
716
		this.structure = this.empantPanel.getStruct();
717
		this.leftmin = this.empantPanel.getMinLeft() + 1;
718
		this.leftmax = this.empantPanel.getMaxLeft() + 1;
719
		this.rightmin = this.empantPanel.getMinRight() + 1;
720
		this.rightmax = this.empantPanel.getMaxRight() + 1;
721
		this.minfreq = this.TFreq.getSelection();
722
		this.mincount = this.TCount.getSelection();
723
		this.includeXpivot = this.empantPanel.getXPivot();
724
		/*if (!this.empantPanel.getXPivot() && this.structure != null) {
725
			if (this.leftmin == 1) {
726
				this.leftmin = 2;
727
				if (this.leftmax == 1)
728
					this.leftmax = 2;
729
			}
730
			if (this.rightmin == 1) {
731
				this.rightmin = 2;
732
				if (this.rightmax == 1)
733
					this.rightmax = 2;
734
			}
735
		}*/
736

  
737
		try {
738
			Double d = Double.parseDouble(TScore.getText());
739
			this.minscore = d;
740
		} catch (Exception e) {
741
			System.out.println(NLS.bind(Messages.CooccurrencesEditor_18, TScore.getText()));
742
			this.minscore = 0.0;
743
		}
744
		
745
		buildLexicalTableWithCooccurrents = TXMPreferences.getBoolean(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.PARTIAL_LEXICAL_TABLE);
746

  
747
		JobHandler jobhandler = new JobHandler(NLS.bind(Messages.CooccurrencesEditor_12, corpus)) {
748
			@Override
749
			protected IStatus run(IProgressMonitor monitor) {
750
				this.runInit(monitor);
751
				JobsTimer.start();
752
				monitor.beginTask(Messages.CooccurrencesEditor_13, 100);
753
				try {
754
					System.out.println(NLS.bind(Messages.CooccurrencesEditor_20, query.getQueryString(), corpus.getName()));
755
					cooc = new Cooccurrence(corpus, query, properties,
756
							structure, leftmax, leftmin, rightmin, rightmax,
757
							minfreq, mincount, minscore, includeXpivot, buildLexicalTableWithCooccurrents);
758
					//System.out.println("cooc: "+corpus+" "+query+" "+properties+" "+structure+" "+leftmax+" "+leftmin+" "+rightmin+" "+rightmax+" "+minfreq+" "+mincount+" "+minscore+" "+includeXpivot);
759
					monitor.worked(5);
760
					
761
					monitor.subTask(Messages.CooccurrencesEditor_27);
762
					if (!cooc.stepQueryLimits()) {
763
						return Status.CANCEL_STATUS;
764
					}	
765
					
766
					monitor.subTask(Messages.CooccurrencesEditor_28);
767
					if (!cooc.stepGetMatches()) {
768
						return Status.CANCEL_STATUS;
769
					}
770
					monitor.worked(10);
771
					
772
					monitor.subTask(Messages.CooccurrencesEditor_29);
773
					if (!cooc.stepBuildSignatures())
774
						return Status.CANCEL_STATUS;
775
					monitor.worked(10);
776
					
777
					monitor.subTask(Messages.CooccurrencesEditor_30);
778
					if (!cooc.stepCount())
779
						return Status.CANCEL_STATUS;
780
					monitor.worked(10);
781
					
782
					monitor.subTask(Messages.CooccurrencesEditor_31);
783
					this.acquireSemaphore();
784
					if (!cooc.stepBuildLexicalTable())
785
						return Status.CANCEL_STATUS;
786
					monitor.worked(10);
787
					this.releaseSemaphore();
788
					
789
					monitor.subTask(Messages.CooccurrencesEditor_32);
790
					this.acquireSemaphore();
791
					if (!cooc.stepGetScores())
792
						return Status.CANCEL_STATUS;
793
					monitor.worked(10);
794
					this.releaseSemaphore();
795
					
796
					if (cooc != null) cooc.clearMemory();
797
					
798
					
799
					
800
					final String message;
801
					if (cooc.getLines().size() == 0) {
802
						message = (Messages.CooccurrencesEditor_23);
803
					} else if (cooc.getLines().size() == 1) {
804
						message = (Messages.CooccurrencesEditor_24);
805
					} else {
806
						message = (Messages.bind(Messages.CooccurrencesEditor_34, cooc.getNumberOfKeyword(), cooc.getNumberOfDifferentCooccurrents()));
807
					}
808
					
809
					System.out.println(message);
810
					this.syncExec(new Runnable() {
811
						@Override
812
						public void run() {
813
							String txt = "tp "+cooc.getNumberOfKeyword()+", vc "+cooc.getNumberOfDifferentCooccurrents()+", tc "+cooc.getNumberOfCooccurrents(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
814
							try { txt += ", T "+cooc.getCorpus().getSize();} //$NON-NLS-1$
815
							catch(Exception e) {System.out.println(Messages.CooccurrencesEditor_25);}
816
							String tooltip = "- " + txt.replaceAll(", ", "\n- "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
817
							
818
							empantPanel.setInfo(txt, tooltip);
819
							StatusLine.setMessage(message);
820
						}
821
					});
822

  
823
					corpus.storeResult(cooc);
824
				} catch(ThreadDeath e) {
825
					if (cooc != null) cooc.clearMemory();
826
					return Status.CANCEL_STATUS;
827
				} catch (Exception e) {
828
					if (cooc != null) cooc.clearMemory();
829
					Logger.severe(Messages.CooccurrencesEditor_1 
830
					+ " " + Logger.toString(e)); //$NON-NLS-1$
831
					
832
					try {
833
						Logger.info(Messages.LastCQPError+Toolbox.getCqiClient().getLastCQPError());
834
					} catch (Exception e2) {
835
						Logger.severe(Messages.ConcordancesEditor_7+e2);
836
						org.txm.rcpapplication.utils.Logger.printStackTrace(e);
837
					}
838
					
839
					return Status.CANCEL_STATUS;
840
				}
841
				if (cooc != null) cooc.clearMemory();
842
				monitor.worked(5);
843
				// System.out.println(cooc.toInfos());
844

  
845
				monitor.subTask(Messages.CooccurrencesEditor_14);
846

  
847
				if (monitor.isCanceled())
848
					return Status.CANCEL_STATUS;
849

  
850
				monitor.subTask(Messages.CooccurrencesEditor_15);
851
				syncExec(new Runnable() {
852
					@Override
853
					public void run() {
854
						viewer.setInput(cooc.getLines());
855
						sort();
856
						viewer.refresh();
857
						for (TableColumn col : viewer.getTable().getColumns())
858
							col.pack();
859
						setTitleToolTip(cooc.toInfos());
860
						CorporaView.refresh();
861
						CorporaView.expand(corpus);
862
						QueriesView.refresh();
863
						RVariablesView.refresh();
864
						
865
						viewer.getTable().setFocus();
866
						setPartName(cooc.getCorpus().getName()+": "+cooc.getName()); //$NON-NLS-1$
867
					}
868
				});
869

  
870
				monitor.worked(35);
871
				monitor.done();
872
				JobsTimer.stopAndPrint();
873
				return Status.OK_STATUS;
874
			}
875
		};
876
		jobhandler.startJob();
877
	}
878

  
879
	/**
880
	 * Sets the parameters from cooc.
881
	 */
882
	private void setParametersFromCooc() {
883
		if (this.cooc != null) {
884
			this.queryWidget.setText(cooc.getQuery().getQueryString());
885
			List<Property> available;
886
			try {
887
				available = new ArrayList<Property>(this.cooc.getCorpus().getProperties());
888
				available.removeAll(cooc.getProperties());
889
				this.propsArea.setProperties(available, cooc.getProperties());
890
			} catch (CqiClientException e) {
891
				// TODO Auto-generated catch block
892
				org.txm.rcpapplication.utils.Logger.printStackTrace(e);
893
			}
894
			this.empantPanel.setStructure(cooc.getStructure());
895
			this.empantPanel.setMinLeft(cooc.getMinLeft()-1);
896
			this.empantPanel.setMaxLeft(cooc.getMaxLeft()-1);
897
			this.empantPanel.setMinRight(cooc.getMinRight()-1);
898
			this.empantPanel.setMaxRight(cooc.getMaxRight()-1);
899

  
900
		}
901
	}
902

  
903
	/**
904
	 * Sets the col comparator.
905
	 *
906
	 * @param comp the comp
907
	 * @param col the col
908
	 */
909
	private void setColComparator(CLineComparator comp, TableColumn col) {
910
		currentComparator = comp;
911
		if (viewer.getTable().getSortColumn() != col) {
912
			viewer.getTable().setSortColumn(col);
913
			viewer.getTable().setSortDirection(SWT.UP);
914
		} else if (viewer.getTable().getSortDirection() == SWT.UP) {
915
			viewer.getTable().setSortDirection(SWT.DOWN);
916
			currentComparator = new ReverseComparator(currentComparator);
917
		} else {
918
			viewer.getTable().setSortDirection(SWT.UP);
919
		}
920
		if (cooc != null)
921
			currentComparator.initialize(cooc.getCorpus());
922
	}
923

  
924
	/**
925
	 * Creates the context menu.
926
	 *
927
	 * @param tableViewer the table viewer
928
	 */
929
	private void createContextMenu(TableViewer tableViewer) {
930

  
931
		MenuManager menuManager = new MenuManager();
932
		Menu menu = menuManager.createContextMenu(tableViewer.getTable());
933

  
934
		// Set the MenuManager
935
		tableViewer.getTable().setMenu(menu);
936
		getSite().registerContextMenu(menuManager, tableViewer);
937
		// Make the selection available
938
		getSite().setSelectionProvider(tableViewer);
939
	}
940

  
941
	/* (non-Javadoc)
942
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
943
	 */
944
	@Override
945
	public void setFocus() {
946

  
947
	}
948

  
949
	/**
950
	 * Gets the corpus.
951
	 *
952
	 * @return the corpus
953
	 */
954
	public Corpus getCorpus() {
955
		return corpus;
956
	}
957

  
958
	/**
959
	 * Gets the cooc.
960
	 *
961
	 * @return the cooc
962
	 */
963
	public Cooccurrence getCooc() {
964
		return this.cooc;
965
	}
966
	
967
	/* (non-Javadoc)
968
	 * @see org.txm.rcpapplication.commands.editor.CustomizableEditor#setName(java.lang.String)
969
	 */
970
	@Override
971
	public void setName(String name) {
972
		this.setPartName(name);
973
	}
974

  
975
	/* (non-Javadoc)
976
	 * @see org.txm.rcpapplication.commands.editor.CustomizableEditor#setIcon(org.eclipse.swt.graphics.Image)
977
	 */
978
	@Override
979
	public void setIcon(Image image) {
980
		this.setTitleImage(image);
981
	}
982
	
983
	/* (non-Javadoc)
984
	 * @see org.txm.rcpapplication.commands.editor.CustomizableEditor#setSource(java.lang.Object)
985
	 */
986
	@Override
987
	public void setSource(Object source)
988
	{
989
		this.source = source;
990
	}
991

  
992
	/* (non-Javadoc)
993
	 * @see org.txm.rcpapplication.commands.editor.CustomizableEditor#getSource()
994
	 */
995
	@Override
996
	public Object getSource() {
997
		return cooc;
998
	}
999

  
1000
	public void setFocus(String query2) {
1001
		this.queryWidget.setText(query2);
1002
	}
1003
	
1004
	@Override
1005
	public Object toConcordance() { return null;}
1006
	@Override
1007
	public Object toIndex() { return null;}
1008
	@Override
1009
	public Object toProgression() { return null;}
1010
	
1011
	@Override
1012
	public boolean usingCorpus(Corpus corpus) {
1013
		return this.corpus.getName().equals(corpus.getName());
1014
	}
1015

  
1016
	@Override
1017
	public boolean updateCorpus(Corpus corpus) {
1018
		// TODO Auto-generated method stub
1019
		return false;
1020
	}
1021
}
0 1022

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

Formats disponibles : Unified diff