Révision 75

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

  
150
</plugin>
0 151

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

  
tmp/org.txm.specificities.rcp/.settings/org.eclipse.core.resources.prefs (revision 75)
1
eclipse.preferences.version=1
2
encoding//OSGI-INF/l10n/bundle_ru_utf-8.properties=UTF-8
0 3

  
tmp/org.txm.specificities.rcp/.classpath (revision 75)
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="src" path="OSGI-INF"/>
7
	<classpathentry kind="output" path="bin"/>
8
</classpath>
0 9

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

  
tmp/org.txm.specificities.rcp/.project (revision 75)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.specificities.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.specificities.rcp/src/org/txm/specificities/rcp/messages/RCPSpecificitiesMessages.java (revision 75)
1
package org.txm.specificities.rcp.messages;
2

  
3
import org.eclipse.osgi.util.NLS;
4

  
5
public class RCPSpecificitiesMessages extends NLS {
6
	
7

  
8
	//private static final String BUNDLE_NAME = "org.txm.rcp.wordcloud.messages.messages"; //$NON-NLS-1$
9
	// FIXME: use the same properties file than the bundle	
10
	private static final String BUNDLE_NAME = "l10n.bundle"; //$NON-NLS-1$
11
	
12
	
13
	
14
	public static String SpecificitiesPreferencePage_0;
15
	public static String SpecificitiesPreferencePage_1;
16
	public static String SpecificitiesPreferencePage_2;
17
	public static String SpecificitiesPreferencePage_3;
18
	public static String SpecificitiesPreferencePage_4;
19
	public static String SpecificitiesPreferencePage_5;
20
	public static String SpecificitiesPreferencePage_6;
21
	public static String SpecificitiesPreferencePage_7;
22

  
23
	public static String SpecificitiesPreferencePage_8;
24
	public static String SpecificitiesResultEditorInput_0;
25
	public static String SpecificitiesResultEditorInput_1;
26
	public static String SpecificitiesResultEditorInput_11;
27
	public static String SpecificitiesResultEditorInput_2;
28
	public static String SpecificitiesResultEditorInput_5;
29
	public static String SpecificitiesResultEditorInput_6;
30
	public static String SpecificitiesResultEditorInput_7;
31
	public static String SpecificitiesTableEditor_0;
32
	public static String SpecificitiesTableEditor_1;
33
	public static String SpecificitiesTableEditor_11;
34
	public static String SpecificitiesTableEditor_16;
35
	public static String SpecificitiesTableEditor_17;
36
	public static String SpecificitiesTableEditor_5;
37
	public static String SpecificitiesTableEditor_8;
38
	
39
	
40
	static {
41
		// initialize resource bundle
42
		NLS.initializeMessages(BUNDLE_NAME, RCPSpecificitiesMessages.class);
43
	}
44

  
45
	private RCPSpecificitiesMessages() {
46
	}
47
}
0 48

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesTableLabelProvider.java (revision 75)
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.specificities.rcp.editors;
29

  
30
import org.eclipse.jface.viewers.ILabelProviderListener;
31
import org.eclipse.jface.viewers.ITableLabelProvider;
32
import org.eclipse.jface.viewers.LabelProvider;
33
import org.eclipse.swt.graphics.Image;
34
import org.txm.core.preferences.TXMPreferences;
35
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
36

  
37
// TODO: Auto-generated Javadoc
38
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39
// create the specificites table (as many columns as parts)
40
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41

  
42
/**
43
 * The Class SpecificitesTableLabelProvider.
44
 */
45
class SpecificitiesTableLabelProvider extends LabelProvider implements ITableLabelProvider {
46

  
47
	/** The partindexes. */
48
	//int[] partindexes;
49

  
50
	private boolean showPValues;
51
	private String format;
52

  
53
	/**
54
	 * Instantiates a new specificites table label provider.
55
	 *
56
	 * @param partindexes the partindexes
57
	 */
58
	public SpecificitiesTableLabelProvider() {
59
		//this.partindexes = partindexes;
60
		//showPValues = "true".equals(Toolbox.getParam(SpecificitiesPreferencePage.SPECIF_PVALUES)); //$NON-NLS-1$
61
		this.format = TXMPreferences.getString(SpecificitiesPreferences.PREFERENCES_NODE, SpecificitiesPreferences.FORMAT);
62
		if (format == null || format.trim().length() == 0) format = "%,.1f"; //$NON-NLS-1$
63
	}
64

  
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
67
	 */
68
	@Override
69
	public Image getColumnImage(Object element, int columnIndex) {
70
		return null;
71
	}
72

  
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
75
	 */
76
	@Override
77
	public String getColumnText(Object element, int columnIndex) {
78

  
79
		Object[] line = (Object[]) element;
80
		//line content : {unit, freq, freqs[], scores[]}
81

  
82
		if (columnIndex < 2) {
83
			Object cell = line[columnIndex];
84
			return cell.toString();
85
		} else if (columnIndex == 2) { // separator column
86
			return ""; //$NON-NLS-1$
87
		} else {
88
			columnIndex = columnIndex - 3 ;//this.partindexes[columnIndex - 3];
89
			if (columnIndex%2 == 0) { // FREQ COLUMN
90
				columnIndex = columnIndex/2; // because there is 2 col per part
91
				int[] freqs = (int[])line[2];// get the freqs
92
				return String.valueOf(freqs[columnIndex]);
93
			} else { // SCORE COLUMN
94
				columnIndex = columnIndex/2; // because there is 2 cols per part
95
				Object specif = line[3]; // get the scores
96
				double[] specifs = (double[]) specif ;
97

  
98
				double s = specifs[columnIndex];
99
				//if (-2 < s && s < 2) return "";
100
				return String.format(format, s);
101
//				if (showPValues) {
102
//					return String.valueOf();
103
//				} else {
104
//					return String.valueOf((int) specifs[columnIndex]);
105
//				}
106
			}
107
		}
108
	}
109

  
110
	/* (non-Javadoc)
111
	 * @see org.eclipse.jface.viewers.BaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
112
	 */
113
	@Override
114
	public void addListener(ILabelProviderListener listener) {
115

  
116
	}
117

  
118
	/* (non-Javadoc)
119
	 * @see org.eclipse.jface.viewers.BaseLabelProvider#dispose()
120
	 */
121
	@Override
122
	public void dispose() {
123

  
124
	}
125

  
126
	/* (non-Javadoc)
127
	 * @see org.eclipse.jface.viewers.BaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
128
	 */
129
	@Override
130
	public boolean isLabelProperty(Object element, String property) {
131
		return false;
132
	}
133

  
134
	/* (non-Javadoc)
135
	 * @see org.eclipse.jface.viewers.BaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
136
	 */
137
	@Override
138
	public void removeListener(ILabelProviderListener listener) {
139

  
140
	}
141
}
0 142

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesTableLines.java (revision 75)
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.specificities.rcp.editors;
29

  
30
import java.util.Arrays;
31
import java.util.Comparator;
32

  
33
/**
34
 * The Class SpecificitesTableLines : input object of the TableViewer of the SpecificitiesTableEditor
35
 */
36
public class SpecificitiesTableLines {
37

  
38
	/** The lines. */
39
	private Object[] lines;
40

  
41
	/**
42
	 * Instantiates a new specificites table lines.
43
	 *
44
	 * @param lines the lines
45
	 */
46
	public SpecificitiesTableLines(Object[] lines) {
47
		this.lines = lines;
48
	}
49

  
50
	/**
51
	 * Gets the lines.
52
	 *
53
	 * @return the lines
54
	 */
55
	public Object[] getLines() {
56
		return lines;
57
	}
58

  
59
	/**
60
	 * Gets the lines.
61
	 *
62
	 * @param start the start
63
	 * @param end the end
64
	 * @return the lines
65
	 */
66
	public Object[] getLines(int start, int end) {
67
		Object[] ret = new Object[end - start];
68
		int c = 0;
69
		for (int i = start; i < end; i++) {
70
			ret[c] = lines[i];
71
			c++;
72
		}
73
		return ret;
74
	}
75

  
76
	/**
77
	 * Sort.
78
	 *
79
	 * @param comparator the comparator
80
	 */
81
	public void sort(Comparator comparator) {
82
		Arrays.sort(lines, comparator);
83
	}
84

  
85
}
0 86

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesResultEditorInput.java (revision 75)
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.specificities.rcp.editors;
29

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

  
34
import org.eclipse.jface.resource.ImageDescriptor;
35
import org.eclipse.jface.viewers.IStructuredContentProvider;
36
import org.eclipse.jface.viewers.ITableLabelProvider;
37
import org.eclipse.jface.viewers.LabelProvider;
38
import org.eclipse.jface.viewers.Viewer;
39
import org.eclipse.swt.graphics.Image;
40
import org.eclipse.ui.IEditorInput;
41
import org.eclipse.ui.IPersistableElement;
42
import org.eclipse.ui.part.EditorPart;
43
import org.eclipse.ui.plugin.AbstractUIPlugin;
44
import org.txm.rcpapplication.Application;
45
import org.txm.rcpapplication.IImageKeys;
46
import org.txm.rcpapplication.Messages;
47
import org.txm.rcpapplication.editors.Tablable;
48
import org.txm.rcpapplication.editors.TableEditor;
49
import org.txm.rcpapplication.editors.input.AbstractTablable;
50
import org.txm.rcpapplication.editors.input.IProvidingMultiPageEditorInput;
51
import org.txm.searchengine.cqp.corpus.Corpus;
52
import org.txm.searchengine.cqp.corpus.Partition;
53
import org.txm.specificities.core.functions.SpecificitesResult;
54
import org.txm.specificities.rcp.messages.RCPSpecificitiesMessages;
55
import org.txm.stat.StatException;
56
// TODO: Auto-generated Javadoc
57
/**
58
 * The Class SpecificitiesResultEditorInput.
59
 * 
60
 * TODO : simplif ier toute la partie haut niveau de Specificities :
61
 * SpecificitiesResult doit être identique (un vecteur d'indice de spécif icités)
62
 * que ce soit des spécif icities de formes ou de parties. SL
63
 * 
64
 * @author jmague, Sylvain Loiseau
65
 */
66
public class SpecificitiesResultEditorInput implements IEditorInput, IProvidingMultiPageEditorInput {
67

  
68
	/** The specificities result. */
69
	private SpecificitesResult specificitiesResult;
70
	
71
	/** The editors. */
72
	private List<EditorPart> editors;
73
	
74
	/** The inputs. */
75
	private List<IEditorInput> inputs;
76
	
77
	/** The names. */
78
	private List<String> names = Arrays.asList(new String[] {
79
			RCPSpecificitiesMessages.SpecificitiesResultEditorInput_0,
80
			RCPSpecificitiesMessages.SpecificitiesResultEditorInput_1 });
81
	
82
	/** The subcorpus. */
83
	private Corpus subcorpus;
84
	
85
	/** The partition. */
86
	private Partition partition;
87

  
88
	/**
89
	 * The Class SpecificitiesResultLabelProvider.
90
	 */
91
	private class SpecificitiesResultLabelProvider extends LabelProvider implements ITableLabelProvider {
92

  
93
		/* (non-Javadoc)
94
		 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
95
		 */
96
		@Override
97
		public Image getColumnImage(Object element, int columnIndex) {
98
			// TODO Auto-generated method stub
99
			return null;
100
		}
101

  
102
		/* (non-Javadoc)
103
		 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
104
		 */
105
		@Override
106
		@SuppressWarnings("unchecked") //$NON-NLS-1$
107
		public String getColumnText(Object element, int columnIndex) {
108
			return ((List<Object>) element).get(columnIndex).toString();
109
		}
110
	}
111

  
112
	/**
113
	 * The Class SpecificitiesContentProvider.
114
	 */
115
	private class SpecificitiesContentProvider implements IStructuredContentProvider {
116

  
117
		/* (non-Javadoc)
118
		 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
119
		 */
120
		@Override
121
		public Object[] getElements(Object inputElement) {
122
			SpecificitesResult res = (SpecificitesResult) inputElement;
123
			int[][] freq = null;
124
			double[][] specificitiesIndex = null;
125
			String[] names = null;
126
			try {
127
				freq = res.getFrequency();
128
				specificitiesIndex = res.getSpecificitesIndex();
129
				names = res.getTypeNames();
130
			} catch (StatException e) {
131
				org.txm.rcpapplication.utils.Logger.printStackTrace(e);
132
			}
133

  
134
			List<List<Object>> specif = new ArrayList<List<Object>>();
135

  
136
			if (freq.length > 1) {
137
				int[] formFreq = null;
138
				try {
139
					formFreq = res.getFormFrequencies();
140
				} catch (StatException e) {
141
					org.txm.rcpapplication.utils.Logger.printStackTrace(e);
142
				}
143
				if (freq[0].length > 1)
144
					throw new IllegalStateException(RCPSpecificitiesMessages.SpecificitiesResultEditorInput_2);
145
				for (int i = 0; i < freq.length; i++) {
146
					List<Object> node = new ArrayList<Object>();
147
					node.add(names[i]);
148
					node.add(formFreq[i]);
149
					node.add(freq[i][0]);
150
					node.add(specificitiesIndex[i][0]);
151
					specif.add(node);
152
				}
153
			} else {
154
				int[] partSize = null;
155
				try {
156
					partSize = res.getPartSize();
157
				} catch (StatException e) {
158
					org.txm.rcpapplication.utils.Logger.printStackTrace(e);
159
				}
160
				if (freq.length != 1)
161
					throw new IllegalStateException(
162
							RCPSpecificitiesMessages.SpecificitiesResultEditorInput_2);
163
				for (int i = 0; i < freq[0].length; i++) {
164
					List<Object> node = new ArrayList<Object>();
165
					node.add(names[i]);
166
					node.add(partSize[i]);
167
					node.add(freq[0][i]);
168
					node.add(specificitiesIndex[0][i]);
169
					specif.add(node);
170
				}
171
				// throw new
172
				// UnsupportedOperationException("Not implemented yet.");
173
			}
174
			return specif.toArray();
175
		}
176

  
177
		/* (non-Javadoc)
178
		 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
179
		 */
180
		@Override
181
		public void dispose() {
182
			// TODO Auto-generated method stub
183

  
184
		}
185

  
186
		/* (non-Javadoc)
187
		 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
188
		 */
189
		@Override
190
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
191
			// TODO Auto-generated method stub
192

  
193
		}
194

  
195
	};
196

  
197
	/**
198
	 * Instantiates a new specificities result editor input.
199
	 *
200
	 * @param specificitiesResult the specificities result
201
	 * @param subcorpus the subcorpus
202
	 */
203
	public SpecificitiesResultEditorInput(final SpecificitesResult specificitiesResult, Corpus subcorpus) {
204
		this.specificitiesResult = specificitiesResult;
205
		this.subcorpus = subcorpus;
206
		init();
207
	}
208

  
209
	/**
210
	 * Instantiates a new specificities result editor input.
211
	 *
212
	 * @param specificitiesResult the specificities result
213
	 * @param partition the partition
214
	 */
215
	public SpecificitiesResultEditorInput(final SpecificitesResult specificitiesResult, Partition partition) {
216
		this.specificitiesResult = specificitiesResult;
217
		this.partition = partition;
218
		specificitiesResult.getLexicalTable().getPartition();
219
		specificitiesResult.getLexicalTable().getProperty();
220
		specificitiesResult.getTypeFocus();
221
		specificitiesResult.getPartFocus();
222
		init();
223
	}
224

  
225
	/**
226
	 * Gets the specificites result.
227
	 *
228
	 * @return the specificites result
229
	 */
230
	public SpecificitesResult getSpecificitesResult() {
231
		return specificitiesResult;
232
	}
233

  
234
	/**
235
	 * Inits the.
236
	 */
237
	private void init() {
238
		editors = new ArrayList<EditorPart>();
239
		editors.add(new TableEditor());
240

  
241
		inputs = new ArrayList<IEditorInput>();
242

  
243
		Tablable asTable = new AbstractTablable() {
244

  
245
			@Override
246
			public String[] getColumnTitles() {
247
				return new String[] {
248
						Messages.FrequencyListEditorInput_3,
249
						RCPSpecificitiesMessages.SpecificitiesResultEditorInput_5,
250
						RCPSpecificitiesMessages.SpecificitiesResultEditorInput_6,
251
						RCPSpecificitiesMessages.SpecificitiesResultEditorInput_7 };
252
			}
253

  
254
			@Override
255
			public String[] getColumnTypes() {
256
				return new String[] {
257
						Messages.FrequencyListEditorInput_5,
258
						Messages.FrequencyListEditorInput_6,
259
						Messages.FrequencyListEditorInput_6,
260
						RCPSpecificitiesMessages.SpecificitiesResultEditorInput_11 };
261
			}
262

  
263
			@Override
264
			public IStructuredContentProvider getContentProvider() {
265
				return new SpecificitiesContentProvider();
266
			}
267

  
268
			@Override
269
			public Object getInput() {
270
				return specificitiesResult;
271
			}
272

  
273
			@Override
274
			public LabelProvider getLabelProvider() {
275
				return new SpecificitiesResultLabelProvider();
276
			}
277

  
278
		};
279
		inputs.add(asTable);
280

  
281
	}
282

  
283
	/**
284
	 * Exists.
285
	 *
286
	 * @return true, if successful
287
	 * @see org.eclipse.ui.IEditorInput#exists()
288
	 */
289
	@Override
290
	public boolean exists() {
291
		return false;
292
	}
293

  
294
	/**
295
	 * Gets the image descriptor.
296
	 *
297
	 * @return the image descriptor
298
	 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
299
	 */
300
	@Override
301
	public ImageDescriptor getImageDescriptor() {
302
		return AbstractUIPlugin.imageDescriptorFromPlugin(
303
				Application.PLUGIN_ID, IImageKeys.ACTION_SPECIFICITIES);
304
	}
305

  
306
	/**
307
	 * Gets the name.
308
	 *
309
	 * @return the name
310
	 * @see org.eclipse.ui.IEditorInput#getName()
311
	 */
312
	@Override
313
	public String getName() {
314
		return ""; //$NON-NLS-1$
315
	}
316

  
317
	/**
318
	 * Gets the persistable.
319
	 *
320
	 * @return the persistable
321
	 * @see org.eclipse.ui.IEditorInput#getPersistable()
322
	 */
323
	@Override
324
	public IPersistableElement getPersistable() {
325
		return null;
326
	}
327

  
328
	/**
329
	 * Gets the tool tip text.
330
	 *
331
	 * @return the tool tip text
332
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
333
	 */
334
	@Override
335
	public String getToolTipText() {
336
		return getName();
337
	}
338

  
339
	/**
340
	 * Gets the adapter.
341
	 *
342
	 * @param arg0 the arg0
343
	 * @return the adapter
344
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
345
	 */
346
	@Override
347
	public Object getAdapter(Class arg0) {
348
		return null;
349
	}
350

  
351
	/**
352
	 * Gets the specificities result.
353
	 *
354
	 * @return the specificitiesResult
355
	 */
356
	public SpecificitesResult getSpecificitiesResult() {
357
		return specificitiesResult;
358
	}
359

  
360
	/* (non-Javadoc)
361
	 * @see org.txm.rcpapplication.editors.input.IProvidingMultiPageEditorInput#getEditorInputs()
362
	 */
363
	@Override
364
	public List<IEditorInput> getEditorInputs() {
365
		return inputs;
366
	}
367

  
368
	/* (non-Javadoc)
369
	 * @see org.txm.rcpapplication.editors.input.IProvidingMultiPageEditorInput#getEditors()
370
	 */
371
	@Override
372
	public List<EditorPart> getEditors() {
373
		return editors;
374
	}
375

  
376
	/* (non-Javadoc)
377
	 * @see org.txm.rcpapplication.editors.input.IProvidingMultiPageEditorInput#getNames()
378
	 */
379
	@Override
380
	public List<String> getNames() {
381
		// TODO Auto-generated method stub
382
		return names;
383
	}
384
	
385
	/**
386
	 * Gets the partition.
387
	 *
388
	 * @return the partition
389
	 */
390
	public Partition getPartition() {
391
		return partition;
392
	}
393

  
394
	/**
395
	 * Gets the subcorpus.
396
	 *
397
	 * @return the subcorpus
398
	 */
399
	public Corpus getSubcorpus() {
400
		return subcorpus;
401
	}
402
	
403
	/**
404
	 * Sets the subcorpus.
405
	 *
406
	 * @param subcorpus the new subcorpus
407
	 */
408
	public void setSubcorpus(Corpus subcorpus) {
409
		this.subcorpus = subcorpus;
410
	}
411

  
412
}
0 413

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecifForm.java (revision 75)
1
package org.txm.specificities.rcp.editors;
2
import org.eclipse.swt.SWT;
3
import org.eclipse.swt.custom.SashForm;
4
import org.eclipse.swt.custom.ScrolledComposite;
5
import org.eclipse.swt.layout.GridData;
6
import org.eclipse.swt.layout.GridLayout;
7
import org.eclipse.swt.widgets.Button;
8
import org.eclipse.swt.widgets.Combo;
9
import org.eclipse.swt.widgets.Composite;
10
import org.eclipse.swt.widgets.Label;
11
import org.eclipse.swt.widgets.Table;
12
import org.txm.rcpapplication.Messages;
13

  
14

  
15
public class SpecifForm extends Composite {
16
	SashForm sashForm;
17
	private Table table;
18
	Combo propCombo;
19
	Button okButton;
20
	
21
	/**
22
	 * Create the composite.
23
	 * @param parent
24
	 * @param style
25
	 */
26
	public SpecifForm(Composite parent, int style) {
27
		super(parent, style);
28
		setLayout(new GridLayout(1, true));
29
		
30
		sashForm = new SashForm(this, SWT.VERTICAL);
31
		sashForm.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
32
		
33
		ScrolledComposite scrolledComposite_1 = new ScrolledComposite(sashForm, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
34
		scrolledComposite_1.setExpandHorizontal(true);
35
		scrolledComposite_1.setExpandVertical(true);
36
		
37
		Composite composite = new Composite(scrolledComposite_1, SWT.NONE);
38
		composite.setLayout(new GridLayout(3, false));
39
		
40
		Label lblProprit = new Label(composite, SWT.NONE);
41
		lblProprit.setText(Messages.ProgressionForm_7);
42
		
43
		propCombo = new Combo(composite, SWT.NONE);
44
		
45
		okButton = new Button(composite, SWT.NONE);
46
		okButton.setText(Messages.InternalViewEditor_11);
47
		scrolledComposite_1.setContent(composite);
48
		scrolledComposite_1.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
49
		
50
//		table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
51
//		table.setHeaderVisible(true);
52
//		table.setLinesVisible(true);
53
//		sashForm.setWeights(new int[] {47, 545});
54
	}
55
	
56
	public void setTable(Table table) {
57
		//table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
58
		table.setHeaderVisible(true);
59
		table.setLinesVisible(true);
60
		sashForm.setWeights(new int[] {215, 334});
61
	}
62
	
63
	@Override
64
	protected void checkSubclass() {
65
		// Disable the check that prevents subclassing of SWT components
66
	}
67

  
68
	public SashForm getSash() {
69
		return sashForm;
70
	}
71
	
72
	/**
73
	 * @return the table
74
	 */
75
	public Table getTable() {
76
		return table;
77
	}
78
	
79
	public Button getOkButton() {
80
		return okButton;
81
	}
82
	
83
	public Combo getPropCombo() {
84
		return propCombo;
85
	}
86
}
0 87

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/package.html (revision 75)
1
<html>
2
<body>
3
	<p>specificites editor</p>
4
</body>
5
</html>
0 6

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesTableEditor.java (revision 75)
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.specificities.rcp.editors;
29

  
30
import java.lang.reflect.InvocationTargetException;
31
import java.text.Collator;
32
import java.util.ArrayList;
33
import java.util.Comparator;
34
import java.util.List;
35
import java.util.Locale;
36

  
37
import org.eclipse.core.runtime.IProgressMonitor;
38
import org.eclipse.jface.action.MenuManager;
39
import org.eclipse.jface.operation.IRunnableWithProgress;
40
import org.eclipse.jface.viewers.IStructuredContentProvider;
41
import org.eclipse.jface.viewers.TableViewer;
42
import org.eclipse.jface.viewers.Viewer;
43
import org.eclipse.osgi.util.NLS;
44
import org.eclipse.swt.SWT;
45
import org.eclipse.swt.events.SelectionEvent;
46
import org.eclipse.swt.events.SelectionListener;
47
import org.eclipse.swt.graphics.Image;
48
import org.eclipse.swt.layout.GridData;
49
import org.eclipse.swt.layout.GridLayout;
50
import org.eclipse.swt.widgets.Composite;
51
import org.eclipse.swt.widgets.Label;
52
import org.eclipse.swt.widgets.Menu;
53
import org.eclipse.swt.widgets.ScrollBar;
54
import org.eclipse.swt.widgets.Table;
55
import org.eclipse.swt.widgets.TableColumn;
56
import org.eclipse.ui.IEditorInput;
57
import org.eclipse.ui.IEditorSite;
58
import org.eclipse.ui.PartInitException;
59
import org.eclipse.ui.PlatformUI;
60
import org.eclipse.ui.part.EditorPart;
61
import org.txm.objects.TxmObject;
62
import org.txm.rcpapplication.Messages;
63
import org.txm.rcpapplication.StatusLine;
64
import org.txm.rcpapplication.commands.editor.CustomizableEditor;
65
import org.txm.rcpapplication.editors.TableKeyListener;
66
import org.txm.searchengine.cqp.corpus.Corpus;
67
import org.txm.specificities.core.functions.SpecificitesResult;
68
import org.txm.specificities.rcp.messages.RCPSpecificitiesMessages;
69
import org.txm.stat.StatException;
70
// TODO: Auto-generated Javadoc
71
/**
72
 * Display a table editor with specificites index.
73
 * 
74
 * @author sloiseau
75
 * 
76
 */
77
public class SpecificitiesTableEditor extends EditorPart implements CustomizableEditor{
78

  
79
	public static String ID = "org.txm.specificities.editors.SpecificitiesTableEditor";
80
	
81
	
82

  
83
	/** The specificities table. */
84
	private Table specificitesTable;
85
	private TableViewer viewer;
86
	
87
	/** Column for table typeNameTable. */
88
	private TableColumn typeNameColumn;
89

  
90
	/** Column for table typeFrequencyColumn. */
91
	private TableColumn typeFrequencyColumn;
92

  
93
	/** The current comparator: updated when user click on a column header */
94
	protected Comparator currentComparator;
95

  
96
	/** All columns for the table specificitesTable. */
97
	private List<TableColumn> specificitesTableColumn = new ArrayList<TableColumn>();
98

  
99
	/** The result of specificites*/
100
	private SpecificitesResult specificitiesResult;
101

  
102
	/** The table lines : table input */
103
	private SpecificitiesTableLines tableLines;
104

  
105
	/** The source. */
106
	private Object source;
107

  
108
	/* (non-Javadoc)
109
	 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
110
	 */
111
	@Override
112
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
113
		setSite(site);
114
		setInput(input);
115

  
116
		SpecificitiesResultEditorInput spinput = (SpecificitiesResultEditorInput) getEditorInput();
117
		this.specificitiesResult = ((SpecificitiesResultEditorInput) getEditorInput()).getSpecificitesResult();
118
		if (this.specificitiesResult.getLexicalTable()!= null && this.specificitiesResult.getLexicalTable().getPartition() != null)	{
119
			setPartName(this.specificitiesResult.getLexicalTable().getPartition().getName()+": "+specificitiesResult.getName()); //$NON-NLS-1$
120
		} else if (spinput.getSubcorpus() != null) {
121
			setPartName(spinput.getSubcorpus().getName()+": "+specificitiesResult.getName()); //$NON-NLS-1$
122
		} else {
123
			setPartName(specificitiesResult.getName());
124
		}
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
		Composite displayArea = new Composite(parent, SWT.BORDER);
133
		displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
134
		try {
135
			composeDisplayArea(displayArea);
136
		} catch (StatException e) {
137
			System.err.println(NLS.bind(RCPSpecificitiesMessages.SpecificitiesTableEditor_0, e.getMessage()));
138
		}
139
	}
140

  
141
	/** Sort. */
142
	protected void sort() {
143
		if (currentComparator != null) {
144
			try {
145
				PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
146
						new IRunnableWithProgress() {
147
							@Override
148
							public void run(IProgressMonitor monitor)
149
							throws InvocationTargetException,
150
							InterruptedException {
151
								tableLines.sort(currentComparator);
152
							}
153
						});
154
				StatusLine.setMessage(Messages.IndexEditor_37);
155
				fillDisplay();
156
			} catch (Exception e) {
157
				System.err.println(NLS.bind(RCPSpecificitiesMessages.SpecificitiesTableEditor_1, e)); 
158
			}
159
		}
160
	}
161

  
162
	/**
163
	 * Compose display area.
164
	 *
165
	 * @param parent the parent
166
	 * @throws StatException the stat exception
167
	 */
168
	private void composeDisplayArea(final Composite parent) throws StatException {
169

  
170
		GridLayout layout = new GridLayout(2, false);
171
		layout.marginWidth = layout.marginHeight = layout.horizontalSpacing = 0;
172
		parent.setLayout(layout);
173

  
174
		final SpecificitesResult specificitiesResult = this.specificitiesResult;
175
		// units
176
		final String[] typeNames = specificitiesResult.getTypeNames();
177
		// units' total freq
178
		final int[] typeFreq = specificitiesResult.getFormFrequencies();
179
		// units' index fr each part
180
		final double[][] specIndex = specificitiesResult.getSpecificitesIndex();
181
		final int[][] specFreqs = specificitiesResult.getFrequency();
182
		// units' total in parts
183
		//final int[] sortedPartIndexes = specificitesResult.getSortedPartIndexes();
184

  
185
		// Create an array of lines to fill the tables
186
//		System.out.println("len types: "+typeNames.length);
187
//		System.out.println("len freq: "+typeFreq.length);
188
//		System.out.println("len spec: "+specFreqs.length);
189
//		System.out.println("len specidx: "+specIndex.length);
190
		Object[] lines = new Object[typeNames.length];
191
		for (int j = 0; j < lines.length; j++)
192
			lines[j] = new Object[] { typeNames[j], new Integer(typeFreq[j]), specFreqs[j], specIndex[j] };
193

  
194
		// final SpecificitesTableLines
195
		tableLines = new SpecificitiesTableLines(lines);
196

  
197
		// create table viewer
198
		viewer = new TableViewer(parent, SWT.VIRTUAL | SWT.MULTI | SWT.FULL_SELECTION);
199
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
200
		viewer.getTable().setLinesVisible(true);
201
		viewer.getTable().setHeaderVisible(true);
202
		viewer.setLabelProvider(new SpecificitiesTableLabelProvider());
203
		viewer.setContentProvider(new IStructuredContentProvider() {
204
			@Override
205
			public Object[] getElements(Object inputElement) {
206
				return ((SpecificitiesTableLines) inputElement).getLines();
207
			}
208

  
209
			@Override
210
			public void dispose() { }
211

  
212
			@Override
213
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
214
			}
215
		});
216

  
217
		specificitesTable = viewer.getTable();
218
		GridData table2Data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
219
		specificitesTable.setLayoutData(table2Data);
220

  
221
		// create 1st column
222
		typeNameColumn = new TableColumn(specificitesTable,
223
				SWT.NONE);
224
		typeNameColumn.setText(Messages.ReferencerEditor_9);
225
		typeNameColumn.setToolTipText(Messages.ReferencerEditor_9);
226
		typeNameColumn.setAlignment(SWT.RIGHT);
227
		typeNameColumn.pack();
228
		typeNameColumn.setWidth((int) (typeNameColumn.getWidth()*1.5));
229

  
230
		Object oparent = specificitiesResult.getParent();
231
		Locale locale = Locale.getDefault();
232
		if (oparent instanceof TxmObject) {
233
			String lang = (String) ((TxmObject) oparent).getAttribute("lang"); //$NON-NLS-1$
234
			if (lang != null)
235
				locale = new Locale(lang);
236
		}
237
		final Collator collator = Collator.getInstance(locale);
238
		collator.setStrength(Collator.TERTIARY);
239
		typeNameColumn.addSelectionListener(new SelectionListener() {
240
			@Override
241
			public void widgetSelected(SelectionEvent e) {
242
				StatusLine.setMessage(Messages.IndexEditor_36);
243
				Comparator column_comparator = new Comparator() {
244
					@Override
245
					public int compare(Object o1, Object o2) {
246
						Object[] line1 = (Object[]) o1;
247
						Object[] line2 = (Object[]) o2;
248
						return collator.compare(line1[0], line2[0]);
249
					}
250
				};
251
				if (specificitesTable.getSortColumn() != typeNameColumn) {
252
					specificitesTable.setSortColumn(
253
							typeNameColumn);
254
					specificitesTable.setSortDirection(SWT.UP);
255
				} else if (specificitesTable
256
						.getSortDirection() == SWT.UP) {
257
					specificitesTable.setSortDirection(
258
							SWT.DOWN);
259
					column_comparator = new ReverseComparator(column_comparator);
260
				} else {
261
					specificitesTable.setSortDirection(SWT.UP);
262
				}
263
				currentComparator = column_comparator;
264
				sort();
265
				StatusLine.setMessage(""); //$NON-NLS-1$
266
			}
267

  
268
			@Override
269
			public void widgetDefaultSelected(SelectionEvent e) {
270
			}
271
		});
272

  
273
		// create 2nd column
274
		typeFrequencyColumn = new TableColumn(viewer
275
				.getTable(), SWT.NONE);
276
		typeFrequencyColumn.setText(Messages.FrequencyListEditorInput_4
277
				+ " "+RCPSpecificitiesMessages.SpecificitiesTableEditor_11+" "
278
				+ specificitiesResult.getCorpusSize()); 
279
		typeFrequencyColumn.setToolTipText(Messages.FrequencyListEditorInput_4
280
				+ RCPSpecificitiesMessages.SpecificitiesTableEditor_11
281
				+ specificitiesResult.getCorpusSize()); 
282
		typeFrequencyColumn.setAlignment(SWT.RIGHT);
283
		typeFrequencyColumn.pack();
284
		typeFrequencyColumn.addSelectionListener(new SelectionListener() {
285
			@Override
286
			public void widgetSelected(SelectionEvent e) {
287
				StatusLine.setMessage(Messages.IndexEditor_36);
288
				Comparator<Object[]> column_comparator = new Comparator<Object[]>() {
289
					@Override
290
					public int compare(Object[] line1, Object[] line2) { // Compare two
291
						return ((Integer) line1[1]).compareTo(((Integer) line2[1]));
292
					}
293
				};
294
				if (specificitesTable.getSortColumn() != typeFrequencyColumn) {
295
					specificitesTable.setSortColumn(
296
							typeFrequencyColumn);
297
					specificitesTable.setSortDirection(SWT.UP);
298
				} else if (specificitesTable
299
						.getSortDirection() == SWT.UP) {
300
					specificitesTable.setSortDirection(
301
							SWT.DOWN);
302
					column_comparator = new ReverseComparator(column_comparator);
303
				} else {
304
					specificitesTable.setSortDirection(SWT.UP);
305
				}
306
				currentComparator = column_comparator;
307
				sort();
308
				StatusLine.setMessage(""); //$NON-NLS-1$
309
			}
310

  
311
			@Override
312
			public void widgetDefaultSelected(SelectionEvent e) {
313
			}
314
		});
315

  
316
		// add a separator column
317
		TableColumn separatorColumn = new TableColumn(specificitesTable, SWT.NONE);
318
		separatorColumn.setResizable(false);
319
		specificitesTableColumn.add(separatorColumn);
320

  
321
		String[] partNames = null;
322
		int[] partSize = null;
323
		try {
324
			partNames = specificitiesResult.getPartShortNames();
325
			partSize = specificitiesResult.getPartSize();
326
		} catch (StatException e) {
327
			System.err.println(NLS.bind(RCPSpecificitiesMessages.SpecificitiesTableEditor_5, e));
328
			return;
329
		}
330
		// System.out.println("partnames: "+Arrays.toString(partNames));
331
		// for (int i = 0; i <
332
		// specificitesResult.getSpecificitesIndex()[0].length; i++)
333
		for (int i = 0; i < partNames.length ; i++) { // for each part
334
			final int columnIndex = i;
335

  
336
			//FREQ COLUMN
337
			final TableColumn freqpartTableColumn = new TableColumn(
338
					specificitesTable, SWT.NONE);
339
			freqpartTableColumn.setText(partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ 
340
			freqpartTableColumn.setToolTipText(partNames[i] + " t=" + partSize[i]); //$NON-NLS-1$ 
341
			// System.out.println("create column "+partNames[i]);
342
			freqpartTableColumn.setAlignment(SWT.RIGHT);
343
			freqpartTableColumn.pack();
344
			freqpartTableColumn.addSelectionListener(new SelectionListener() {
345
				@Override
346
				public void widgetSelected(SelectionEvent e) {
347
					StatusLine.setMessage(Messages.IndexEditor_36);
348
					Comparator<Object> column_comparator = new Comparator<Object>() {
349
						@Override
350
						public int compare(Object o1, Object o2) { // Compare
351
							// two Integer
352
							Object[] line1 = (Object[]) o1;
353
							Object[] line2 = (Object[]) o2;
354
							return new Integer(
355
									((int[]) line1[2])[columnIndex])
356
							.compareTo(new Integer(
357
									((int[]) line2[2])[columnIndex]));
358
						}
359
					};
360
					
361
					if (specificitesTable.getSortColumn() != freqpartTableColumn) {
362
						specificitesTable.setSortColumn(freqpartTableColumn);
363
						specificitesTable.setSortDirection(SWT.DOWN);
364
						column_comparator = new ReverseComparator(column_comparator);
365
					} else if (specificitesTable.getSortDirection() == SWT.UP) {
366
						specificitesTable.setSortDirection(SWT.DOWN);
367
						column_comparator = new ReverseComparator(column_comparator);
368
					} else {
369
						specificitesTable.setSortDirection(SWT.UP);
370
					}
371
					currentComparator = column_comparator;
372
					sort();
373
					StatusLine.setMessage(""); //$NON-NLS-1$
374
				}
375

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

Formats disponibles : Unified diff