Révision 225
tmp/org.txm.cah.rcp/.project (revision 225) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.txm.cah.rcp</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.pde.ManifestBuilder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
<buildCommand> |
|
19 |
<name>org.eclipse.pde.SchemaBuilder</name> |
|
20 |
<arguments> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
23 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.pde.PluginNature</nature> |
|
26 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
27 |
</natures> |
|
28 |
</projectDescription> |
|
0 | 29 |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/messages/CAUIPMessages.java (revision 225) | ||
---|---|---|
1 |
package org.txm.cah.rcp.messages; |
|
2 |
|
|
3 |
import org.eclipse.osgi.util.NLS; |
|
4 |
import org.txm.core.messages.TXMCoreMessages; |
|
5 |
|
|
6 |
public class CAUIPMessages extends NLS { |
|
7 |
|
|
8 |
// FIXME: use the same properties file than the bundle |
|
9 |
//private static final String BUNDLE_NAME = "l10n.bundle"; //$NON-NLS-1$ |
|
10 |
private static final String BUNDLE_NAME = "org.txm.cah.rcp.messages.messages"; //$NON-NLS-1$ |
|
11 |
|
|
12 |
|
|
13 |
public static String CAHPreferencePage_0; |
|
14 |
public static String CAHPreferencePage_2; |
|
15 |
public static String CAHPreferencePage_3; |
|
16 |
public static String CAHPreferencePage_4; |
|
17 |
|
|
18 |
public static String CAHEditor_0; |
|
19 |
|
|
20 |
public static String ComputeCAH_0; |
|
21 |
public static String ComputeCAH_1; |
|
22 |
public static String ComputeCAH_2; |
|
23 |
public static String ComputeCAH_3; |
|
24 |
public static String ComputeCAH_4; |
|
25 |
public static String ComputeCAH_5; |
|
26 |
public static String ComputeCAH_6; |
|
27 |
|
|
28 |
public static String ComputeClassification_5; |
|
29 |
public static String ComputeClassification_6; |
|
30 |
|
|
31 |
public static String CAHEditorTitle; |
|
32 |
|
|
33 |
static { |
|
34 |
// initializes resource bundle |
|
35 |
TXMCoreMessages.initializeMessages(BUNDLE_NAME, CAUIPMessages.class); |
|
36 |
} |
|
37 |
|
|
38 |
private CAUIPMessages() { |
|
39 |
} |
|
40 |
} |
|
0 | 41 |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/messages/messages_fr.properties (revision 225) | ||
---|---|---|
1 |
CAHPreferencePage_0=Afficher les graphiques en 2D |
|
2 |
CAHPreferencePage_1=Classification |
|
3 |
CAHPreferencePage_2=Nombre de clusters |
|
4 |
CAHPreferencePage_3=Méthode |
|
5 |
CAHPreferencePage_4=Métrique |
|
6 |
ComputeCAH_0=Calcul de la Classification avec {0} |
|
7 |
ComputeCAH_1=Afficher le graphique |
|
8 |
ComputeCAH_2=** Impossible d'écrire dans le fichier temporaire |
|
9 |
ComputeCAH_3=Calcul de la classification avec |
|
10 |
ComputeCAH_5=Ouverture de la fenêtre de Classification |
|
11 |
ComputeCAH_6=Erreur lors de l'ouverture de l'éditeur de Classification \: {0} |
|
12 |
ComputeClassification_5=Classer les colonnes |
|
13 |
ComputeClassification_6=Classer les lignes |
|
0 | 14 |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/messages/messages_ru_utf8.properties (revision 225) | ||
---|---|---|
1 |
ComputeCAH_0=Расчет Классификации {0} |
|
2 |
ComputeCAH_1=Показать график |
|
3 |
ComputeCAH_2=** Не удается записать данные во временный файл |
|
4 |
ComputeCAH_3=Расчет классификации с |
|
5 |
ComputeClassification_5=Колонки |
|
6 |
ComputeClassification_6=Строчки |
|
7 |
CAHPreferencePage_0=Показывать графики в 2D |
|
8 |
CAHPreferencePage_1=Классификация |
|
9 |
CAHPreferencePage_2=Число кластеров |
|
10 |
CAHPreferencePage_3=Метод |
|
11 |
CAHPreferencePage_4=Метрика |
|
0 | 12 |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/messages/messages.properties (revision 225) | ||
---|---|---|
1 |
CAHPreferencePage_0=Display graphics in |
|
2 |
CAHPreferencePage_1=Classification |
|
3 |
CAHPreferencePage_2=Number of clusters |
|
4 |
CAHPreferencePage_3=Method |
|
5 |
CAHPreferencePage_4=Metric |
|
6 |
ComputeCAH_0=Compute Classification with {0} |
|
7 |
ComputeCAH_1=Show graphic |
|
8 |
ComputeCAH_2=Error\: temporary file created cannot be written\: |
|
9 |
ComputeCAH_3=Computing CAH with |
|
10 |
ComputeCAH_4=Statistics Engine is not ready. Canceling command. |
|
11 |
ComputeCAH_5=Opening the Classification result |
|
12 |
ComputeCAH_6=Error while computing Classification\: {0} |
|
13 |
ComputeClassification_5=Compute columns |
|
14 |
ComputeClassification_6=Compute rows |
|
0 | 15 |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/editors/CAHChartEditor.java (revision 225) | ||
---|---|---|
1 |
package org.txm.cah.rcp.editors; |
|
2 |
|
|
3 |
import org.eclipse.swt.SWT; |
|
4 |
import org.eclipse.swt.custom.CLabel; |
|
5 |
import org.eclipse.swt.events.SelectionEvent; |
|
6 |
import org.eclipse.swt.events.SelectionListener; |
|
7 |
import org.eclipse.swt.graphics.Image; |
|
8 |
import org.eclipse.swt.widgets.Composite; |
|
9 |
import org.eclipse.swt.widgets.Spinner; |
|
10 |
import org.eclipse.swt.widgets.ToolItem; |
|
11 |
import org.txm.cah.core.functions.CAH; |
|
12 |
import org.txm.cah.core.preferences.CAHPreferences; |
|
13 |
import org.txm.cah.rcp.commands.ComputeCAH; |
|
14 |
import org.txm.cah.rcp.messages.CAUIPMessages; |
|
15 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
|
16 |
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages; |
|
17 |
import org.txm.functions.TXMResult; |
|
18 |
import org.txm.rcpapplication.IImageKeys; |
|
19 |
import org.txm.rcpapplication.TxmPreferences; |
|
20 |
import org.txm.rcpapplication.commands.editor.CustomizableEditor; |
|
21 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
22 |
import org.txm.stat.engine.r.RWorkspaceException; |
|
23 |
|
|
24 |
/** |
|
25 |
* CAH chart editor. |
|
26 |
* |
|
27 |
* @author mdecorde |
|
28 |
* @author sjacquot |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class CAHChartEditor extends ChartEditorPart implements CustomizableEditor { |
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* Numbers of clusters. |
|
37 |
*/ |
|
38 |
protected Spinner numbersOfClusters; |
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
@Override |
|
43 |
public void createPartControl(Composite parent) { |
|
44 |
|
|
45 |
super.createPartControl(parent); |
|
46 |
|
|
47 |
|
|
48 |
// Extend the chart editor tool bar |
|
49 |
ToolItem separator = new ToolItem(this.toolBar, SWT.SEPARATOR); |
|
50 |
|
|
51 |
// Number of clusters |
|
52 |
ToolItem itemSeparator = new ToolItem(this.toolBar, SWT.SEPARATOR); |
|
53 |
CLabel clustersLabel = new CLabel(this.toolBar, SWT.CENTER); |
|
54 |
clustersLabel.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CAH_TOOLBAR_BUTTON_NUMBER_OF_CLUSTERS); |
|
55 |
clustersLabel.pack(); |
|
56 |
itemSeparator.setWidth(clustersLabel.getBounds().width); |
|
57 |
itemSeparator.setControl(clustersLabel); |
|
58 |
|
|
59 |
itemSeparator = new ToolItem(this.toolBar, SWT.SEPARATOR); |
|
60 |
this.numbersOfClusters = new Spinner(this.toolBar, SWT.BORDER); |
|
61 |
this.numbersOfClusters.setMinimum(2); |
|
62 |
this.numbersOfClusters.setIncrement(1); |
|
63 |
this.updateNumbersOfClustersCurrentValue(); |
|
64 |
this.updateNumbersOfClustersMaxValue(); |
|
65 |
|
|
66 |
itemSeparator.setControl(this.numbersOfClusters); |
|
67 |
this.numbersOfClusters.pack(); |
|
68 |
itemSeparator.setWidth(this.numbersOfClusters.getBounds().width); |
|
69 |
|
|
70 |
|
|
71 |
// Columns |
|
72 |
final ToolItem computeColumns = new ToolItem(this.toolBar, SWT.RADIO); |
|
73 |
computeColumns.setToolTipText(CAUIPMessages.ComputeClassification_5); |
|
74 |
computeColumns.setImage(IImageKeys.getImage(this, "icons/compute_columns.png")); |
|
75 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
|
76 |
//computeColumns.setText(CAUIPMessages.ComputeClassification_5); |
|
77 |
computeColumns.setSelection(this.getResultData().isColumnsComputing()); |
|
78 |
|
|
79 |
// Rows |
|
80 |
final ToolItem computeRows = new ToolItem(this.toolBar, SWT.RADIO); |
|
81 |
computeRows.setToolTipText(CAUIPMessages.ComputeClassification_6); |
|
82 |
computeRows.setImage(IImageKeys.getImage(this, "icons/compute_rows.png")); |
|
83 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
|
84 |
//computeRows.setText(CAUIPMessages.ComputeClassification_6); |
|
85 |
computeRows.setSelection(!this.getResultData().isColumnsComputing()); |
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
// Listeners |
|
90 |
final ChartEditorPart self = this; |
|
91 |
|
|
92 |
SelectionListener listener = new SelectionListener() { |
|
93 |
|
|
94 |
@Override |
|
95 |
public void widgetSelected(SelectionEvent e) { |
|
96 |
try { |
|
97 |
CAH cah = getResultData(); |
|
98 |
|
|
99 |
// Numbers of clusters |
|
100 |
if(e.getSource() == numbersOfClusters) { |
|
101 |
cah.setNCluster(((Spinner)e.getSource()).getSelection()); |
|
102 |
} |
|
103 |
// Compute columns or rows |
|
104 |
else if(e.getSource() == computeColumns || e.getSource() == computeRows) { |
|
105 |
cah.setColumnsComputing(((ToolItem)e.getSource()).getSelection()); |
|
106 |
cah.setNCluster(TxmPreferences.getInt(CAHPreferences.NCLUSTER)); |
|
107 |
updateNumbersOfClustersCurrentValue(); |
|
108 |
} |
|
109 |
|
|
110 |
// Update the maximum value of the number of clusters spinner according to the new CAH configuration |
|
111 |
updateNumbersOfClustersMaxValue(); |
|
112 |
|
|
113 |
// Recompute the CAH |
|
114 |
ComputeCAH.compute(cah, self); |
|
115 |
|
|
116 |
} |
|
117 |
catch(RWorkspaceException e1) { |
|
118 |
// TODO Auto-generated catch block |
|
119 |
e1.printStackTrace(); |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
125 |
// TODO Auto-generated method stub |
|
126 |
|
|
127 |
} |
|
128 |
}; |
|
129 |
|
|
130 |
this.numbersOfClusters.addSelectionListener(listener); |
|
131 |
computeColumns.addSelectionListener(listener); |
|
132 |
computeRows.addSelectionListener(listener); |
|
133 |
|
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
/** |
|
138 |
* Updates the maximum value of the number of clusters spinner according to the CAH configuration. |
|
139 |
*/ |
|
140 |
public void updateNumbersOfClustersMaxValue() { |
|
141 |
this.numbersOfClusters.setMaximum(this.getResultData().getMaxClustersCount()); |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Updates the current value of the number of clusters spinner. |
|
146 |
*/ |
|
147 |
public void updateNumbersOfClustersCurrentValue() { |
|
148 |
this.numbersOfClusters.setSelection(this.getResultData().getNCluster()); |
|
149 |
} |
|
150 |
|
|
151 |
|
|
152 |
@Override |
|
153 |
public void setName(String name) { |
|
154 |
this.setPartName(name); |
|
155 |
} |
|
156 |
|
|
157 |
@Override |
|
158 |
public void setIcon(Image titleImage) { |
|
159 |
this.setTitleImage(titleImage); |
|
160 |
} |
|
161 |
|
|
162 |
@Override |
|
163 |
public void setSource(Object source) { |
|
164 |
if (source instanceof CAH) |
|
165 |
getEditorInput().setResultData((TXMResult) source); |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
|
169 |
public Object getSource() { |
|
170 |
return getResultData(); |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
174 |
public Object toConcordance() { |
|
175 |
// TODO Auto-generated method stub |
|
176 |
return null; |
|
177 |
} |
|
178 |
@Override |
|
179 |
public Object toIndex() { |
|
180 |
// TODO Auto-generated method stub |
|
181 |
return null; |
|
182 |
} |
|
183 |
@Override |
|
184 |
public Object toProgression() { |
|
185 |
// TODO Auto-generated method stub |
|
186 |
return null; |
|
187 |
} |
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
@Override |
|
192 |
public CAH getResultData() { |
|
193 |
return (CAH) super.getResultData(); |
|
194 |
} |
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
@Override |
|
199 |
public boolean usingCorpus(Corpus corpus) { |
|
200 |
CAH cah = getResultData(); |
|
201 |
if (cah != null && cah.getCorpus() != null) |
|
202 |
return cah.getCorpus().getName().equals(corpus.getName()); |
|
203 |
return false; |
|
204 |
} |
|
205 |
|
|
206 |
|
|
207 |
@Override |
|
208 |
public boolean updateCorpus(Corpus corpus) { |
|
209 |
// TODO Auto-generated method stub |
|
210 |
return false; |
|
211 |
} |
|
212 |
} |
|
0 | 213 |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/commands/package.html (revision 225) | ||
---|---|---|
1 |
<html> |
|
2 |
<body> |
|
3 |
<p>Commands which call textometry functions</p> |
|
4 |
</body> |
|
5 |
</html> |
|
0 | 6 |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/commands/ComputeCAH.java (revision 225) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.cah.rcp.commands; |
|
29 |
|
|
30 |
import org.eclipse.core.commands.AbstractHandler; |
|
31 |
import org.eclipse.core.commands.ExecutionEvent; |
|
32 |
import org.eclipse.core.commands.ExecutionException; |
|
33 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
34 |
import org.eclipse.core.runtime.IStatus; |
|
35 |
import org.eclipse.core.runtime.Status; |
|
36 |
import org.eclipse.jface.dialogs.Dialog; |
|
37 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
38 |
import org.eclipse.jface.window.Window; |
|
39 |
import org.eclipse.swt.SWT; |
|
40 |
import org.eclipse.swt.layout.GridLayout; |
|
41 |
import org.eclipse.swt.widgets.Button; |
|
42 |
import org.eclipse.swt.widgets.Composite; |
|
43 |
import org.eclipse.swt.widgets.Control; |
|
44 |
import org.eclipse.swt.widgets.Display; |
|
45 |
import org.eclipse.swt.widgets.Label; |
|
46 |
import org.eclipse.swt.widgets.Shell; |
|
47 |
import org.eclipse.swt.widgets.Spinner; |
|
48 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
49 |
import org.txm.Toolbox; |
|
50 |
import org.txm.ca.core.functions.CA; |
|
51 |
import org.txm.ca.core.preferences.CAPreferences; |
|
52 |
import org.txm.cah.core.functions.CAH; |
|
53 |
import org.txm.cah.core.preferences.CAHPreferences; |
|
54 |
import org.txm.cah.rcp.messages.CAUIPMessages; |
|
55 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
56 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
|
57 |
import org.txm.core.preferences.TXMPreferences; |
|
58 |
import org.txm.lexicaltable.functions.LexicalTableFactory; |
|
59 |
import org.txm.rcpapplication.JobsTimer; |
|
60 |
import org.txm.rcpapplication.TxmPreferences; |
|
61 |
import org.txm.rcpapplication.actions.LexicalTableDialog; |
|
62 |
import org.txm.rcpapplication.utils.JobHandler; |
|
63 |
import org.txm.rcpapplication.views.CorporaView; |
|
64 |
import org.txm.rcpapplication.views.QueriesView; |
|
65 |
import org.txm.rcpapplication.views.RVariablesView; |
|
66 |
import org.txm.searchengine.cqp.corpus.Partition; |
|
67 |
import org.txm.searchengine.cqp.corpus.Property; |
|
68 |
import org.txm.stat.StatException; |
|
69 |
import org.txm.stat.data.LexicalTable; |
|
70 |
import org.txm.stat.engine.r.RWorkspaceException; |
|
71 |
import org.txm.utils.logger.Log; |
|
72 |
|
|
73 |
/** |
|
74 |
* If the selection is a CA or a Lexical Table result computes the CAH. |
|
75 |
* |
|
76 |
* @author mdecorde |
|
77 |
* @author sjacquot |
|
78 |
*/ |
|
79 |
public class ComputeCAH extends AbstractHandler { |
|
80 |
|
|
81 |
|
|
82 |
// FIXME: should be put in an Activator? or better in an extension point loaded by the corpora view? or in a method called here as initTreeDoubleClickListener(Class resultDataType, String commandId)? |
|
83 |
// adds a double click listener to the Corpus View |
|
84 |
static { |
|
85 |
CorporaView.addDoubleClickListener(CAH.class, "ComputeCAH"); //$NON-NLS-1$ |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
/* (non-Javadoc) |
|
90 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
91 |
*/ |
|
92 |
@Override |
|
93 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
94 |
|
|
95 |
|
|
96 |
if (!Toolbox.isStatEngineInitialized()) { |
|
97 |
System.out.println(CAUIPMessages.ComputeCAH_4); |
|
98 |
return null; |
|
99 |
} |
|
100 |
|
|
101 |
CAH cah = null; |
|
102 |
CA ca = null; |
|
103 |
LexicalTable lexicaltable = null; |
|
104 |
Partition partition = null; |
|
105 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
106 |
|
|
107 |
|
|
108 |
// Build the CA or not depending on the selection |
|
109 |
if (selection.getFirstElement() instanceof CAH) { |
|
110 |
cah = (CAH) selection.getFirstElement(); |
|
111 |
} else if (selection.getFirstElement() instanceof CA) { |
|
112 |
//System.out.println("Compute CAH with CA : "+((CA)selection.getFirstElement()).getName()); |
|
113 |
ca = (CA) selection.getFirstElement(); |
|
114 |
} else if (selection.getFirstElement() instanceof LexicalTable) { |
|
115 |
//System.out.println("Compute CAH with LT : "+((LexicalTable)selection.getFirstElement()).getName()); |
|
116 |
lexicaltable = (LexicalTable) selection.getFirstElement(); |
|
117 |
|
|
118 |
try { |
|
119 |
ca = new CA(lexicaltable); |
|
120 |
} catch (StatException e) { |
|
121 |
System.out.println("Failed to build the CA with lexical table " + lexicaltable + ": " + e); |
|
122 |
Log.printStackTrace(e); |
|
123 |
} |
|
124 |
lexicaltable.storeResult(ca); |
|
125 |
|
|
126 |
// if (lexicaltable.getPartition() != null) |
|
127 |
// lexicaltable.getPartition().storeResult(ca); |
|
128 |
// else if (lexicaltable.getCorpus() != null) |
|
129 |
// lexicaltable.getCorpus().storeResult(ca); |
|
130 |
} else if (selection.getFirstElement() instanceof Partition) { |
|
131 |
//System.out.println("Compute CAH with Partition : "+((Partition)selection.getFirstElement()).getName()); |
|
132 |
partition = (Partition)selection.getFirstElement(); |
|
133 |
try { |
|
134 |
String title = CAUIPMessages.bind(CAUIPMessages.ComputeCAH_0, partition.getName()); |
|
135 |
int vmax = TXMPreferences.getInt(CAPreferences.PREFERENCES_NODE, CAPreferences.V_MAX); |
|
136 |
int fmin = TXMPreferences.getInt(CAPreferences.PREFERENCES_NODE, CAPreferences.F_MIN); |
|
137 |
Shell shell = Display.getCurrent().getActiveShell(); |
|
138 |
LexicalTableDialog d = new LexicalTableDialog(shell, partition.getCorpus(), title); |
|
139 |
d.setFminAndVMax(fmin, vmax); |
|
140 |
|
|
141 |
if (d.open() == Window.OK) { |
|
142 |
Property property = d.getProperty(); |
|
143 |
fmin = d.getFmin(); |
|
144 |
vmax = d.getMaxLines(); |
|
145 |
|
|
146 |
lexicaltable = LexicalTableFactory.getLexicalTable(partition, property, fmin); // use the CAPreferencePage Fmin |
|
147 |
lexicaltable.cut(vmax); |
|
148 |
partition.storeResult(lexicaltable); |
|
149 |
|
|
150 |
ca = new CA(lexicaltable); |
|
151 |
lexicaltable.storeResult(ca); |
|
152 |
} else { |
|
153 |
// canceled |
|
154 |
return null; |
|
155 |
} |
|
156 |
} catch (Exception e) { |
|
157 |
System.out.println("Failed to build the lexical table of " + partition + ": " + e); |
|
158 |
Log.printStackTrace(e); |
|
159 |
return null; |
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
final boolean computeColumns = true; |
|
164 |
|
|
165 |
// Use existent CAH (used when reopening an editor from a CAH result node) |
|
166 |
if (cah != null) { |
|
167 |
if (cah.getParent() != null) { |
|
168 |
cah.getParent().removeResult(cah); |
|
169 |
} |
|
170 |
} else { |
|
171 |
// if (ca == null) cah = new CAH(lexicaltable, computeColumns, method, metric, ncluster, display2D); |
|
172 |
// else |
|
173 |
cah = new CAH(ca, computeColumns, |
|
174 |
TXMPreferences.getString(CAHPreferences.PREFERENCES_NODE, CAHPreferences.METHOD), |
|
175 |
TXMPreferences.getString(CAHPreferences.PREFERENCES_NODE, CAHPreferences.METRIC), |
|
176 |
TXMPreferences.getInt(CAHPreferences.PREFERENCES_NODE, CAHPreferences.NCLUSTER) |
|
177 |
); |
|
178 |
} |
|
179 |
|
|
180 |
try { |
|
181 |
compute(cah, null); |
|
182 |
} |
|
183 |
catch(RWorkspaceException e) { |
|
184 |
System.out.println("Failed to compute CAH: "+e); |
|
185 |
Log.printStackTrace(e); |
|
186 |
} |
|
187 |
|
|
188 |
return null; |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Computes the CAH. Also creates the chart. Opens a chart editor if <code>chartEditor</code> is null otherwise refreshes the existing chart editor. |
|
193 |
* @param newResult |
|
194 |
* @throws RWorkspaceException |
|
195 |
*/ |
|
196 |
public static void compute(final CAH cah, final ChartEditorPart chartEditor) throws RWorkspaceException { |
|
197 |
|
|
198 |
JobHandler jobhandler = new JobHandler(CAUIPMessages.CAHEditor_0) { |
|
199 |
@Override |
|
200 |
protected IStatus run(IProgressMonitor monitor) { |
|
201 |
this.runInit(monitor); |
|
202 |
try { |
|
203 |
|
|
204 |
this.acquireSemaphore(); |
|
205 |
cah.stepCompute(); |
|
206 |
this.releaseSemaphore(); |
|
207 |
|
|
208 |
// Store result |
|
209 |
if(chartEditor == null) { |
|
210 |
// if (cah.getPartition() != null) { |
|
211 |
// cah.getPartition().storeResult(cah); |
|
212 |
// } |
|
213 |
// else if (cah.getCorpus() != null) { |
|
214 |
// cah.getCorpus().storeResult(cah); |
|
215 |
// } |
|
216 |
cah.getCA().storeResult(cah); |
|
217 |
} |
|
218 |
|
|
219 |
// Refresh views |
|
220 |
this.syncExec(new Runnable() { |
|
221 |
@Override |
|
222 |
public void run() { |
|
223 |
|
|
224 |
// Create a new chart editor |
|
225 |
if(chartEditor == null) { |
|
226 |
SWTChartsComponentsProvider.getCurrent().openEditor(cah.getName(), cah, CAHPreferences.PREFERENCES_NODE); |
|
227 |
|
|
228 |
// FIXME: temporary force R/SVG version because the CAH charts are not yet implemented in JFC mode |
|
229 |
// RChartsEngine tmpChartsEngine = new RChartsEngine(ChartsEngine.OUTPUT_FORMAT_SVG); |
|
230 |
// SVGSWTChartsComponentsProvider tmpSWTComponentsProvider = (SVGSWTChartsComponentsProvider) SWTChartsComponentsProvider.getComponentsProvider(tmpChartsEngine); |
|
231 |
// // FIXME: charts creator is not yet implemented |
|
232 |
// //ChartEditorPart chartEditor = tmpSWTComponentsProvider.createCAHChartEditorPart(IImageKeys.getImage(IImageKeys.ACTION_CAH), cah); |
|
233 |
// // Create and open the chart editor |
|
234 |
// tmpSWTComponentsProvider.openEditor(chartEditor); |
|
235 |
} |
|
236 |
// Refresh the existing chart editor |
|
237 |
else { |
|
238 |
// FIXME: charts creator is not yet implemented |
|
239 |
// Create and load the new chart |
|
240 |
//chartEditor.getComposite().loadChart(tmpChartsEngine.createCAHChart(((CAHChartEditor) chartEditor).getResultData(), ((CAHChartEditor) chartEditor).getResultData().isDisplay2D())); |
|
241 |
chartEditor.forceFocus(); |
|
242 |
} |
|
243 |
|
|
244 |
|
|
245 |
// Refresh UI |
|
246 |
CorporaView.refresh(); |
|
247 |
CorporaView.expand(cah.getParent()); |
|
248 |
QueriesView.refresh(); |
|
249 |
RVariablesView.refresh(); |
|
250 |
} |
|
251 |
}); |
|
252 |
|
|
253 |
|
|
254 |
} |
|
255 |
catch (ThreadDeath td) { |
|
256 |
return Status.CANCEL_STATUS; |
|
257 |
} |
|
258 |
catch (Exception e) { |
|
259 |
System.out.println(e.getLocalizedMessage()); |
|
260 |
org.txm.rcpapplication.utils.Logger.printStackTrace(e); |
|
261 |
Log.severe("Error while computing CAH: "+e.getLocalizedMessage()); |
|
262 |
} |
|
263 |
finally { |
|
264 |
monitor.done(); |
|
265 |
JobsTimer.stopAndPrint(); |
|
266 |
} |
|
267 |
return Status.OK_STATUS; |
|
268 |
} |
|
269 |
}; |
|
270 |
jobhandler.startJob(); |
|
271 |
|
|
272 |
} |
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
// FIXME: to remove when charts engine will be validated, be careful this method contains some old code to open a dialog bog, do we need to keep it ? |
|
282 |
// public Object execute1(ExecutionEvent event) throws ExecutionException { |
|
283 |
// |
|
284 |
// if (!Toolbox.isStatEngineInitialized()) { |
|
285 |
// System.out.println("StatEngine is not ready. Canceling command."); |
|
286 |
// return null; |
|
287 |
// } |
|
288 |
// |
|
289 |
// HandlerUtil.getActiveWorkbenchWindow(event); |
|
290 |
// IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
291 |
// |
|
292 |
// if (selection.getFirstElement() instanceof CA) { |
|
293 |
// //System.out.println("Compute CAH with CA : "+((CA)selection.getFirstElement()).getName()); |
|
294 |
// ca = (CA) selection.getFirstElement(); |
|
295 |
// } else if (selection.getFirstElement() instanceof LexicalTable) { |
|
296 |
// //System.out.println("Compute CAH with LT : "+((LexicalTable)selection.getFirstElement()).getName()); |
|
297 |
// lexicaltable = (LexicalTable) selection.getFirstElement(); |
|
298 |
// } |
|
299 |
// |
|
300 |
// openEditor1(ca, lexicaltable); |
|
301 |
// |
|
302 |
//// //Open CAH parameters dialog |
|
303 |
//// CAHParamDialog d = new CAHParamDialog(window.getShell()); |
|
304 |
//// |
|
305 |
//// if (d.open() == Window.OK) { |
|
306 |
//// final int ncluster = d.getNcluster(); |
|
307 |
//// final String metric = TxmPreferences.getString(CAHPreferences.METRIC, CAH.getDefaultMetric()); |
|
308 |
//// final String method = TxmPreferences.getString(CAHPreferences.METHOD, CAH.getDefaultMethod()); |
|
309 |
//// final Boolean displayMode = TxmPreferences.getBoolean(CAHPreferences.DISPLAY, false); |
|
310 |
//// final boolean docol = d.isDoculumns(); |
|
311 |
//// |
|
312 |
//// JobHandler jobhandler = new JobHandler(RCPCAHMessages.ComputeCAH_3+ca.getName()) { |
|
313 |
//// @Override |
|
314 |
//// protected IStatus run(IProgressMonitor monitor) { |
|
315 |
//// try { |
|
316 |
//// JobsTimer.start(); |
|
317 |
//// monitor.beginTask("", 100); //$NON-NLS-1$ |
|
318 |
//// |
|
319 |
//// monitor.subTask(RCPCAHMessages.ComputeCAH_0); |
|
320 |
//// |
|
321 |
//// final CAH cah; |
|
322 |
//// if (ca != null) { |
|
323 |
//// cah = new CAH(ca, docol, method, metric, ncluster, displayMode); |
|
324 |
//// cah.stepCompute(); |
|
325 |
//// ca.getPartition().storeResult(cah); |
|
326 |
//// } else { |
|
327 |
//// cah = new CAH(lexicaltable, docol, method, metric, ncluster, displayMode); |
|
328 |
//// cah.stepCompute(); |
|
329 |
//// lexicaltable.getPartition().storeResult(cah); |
|
330 |
//// } |
|
331 |
//// if (monitor.isCanceled()) |
|
332 |
//// return Status.CANCEL_STATUS; |
|
333 |
//// |
|
334 |
//// monitor.worked(20); |
|
335 |
//// |
|
336 |
//// monitor.subTask(RCPCAHMessages.ComputeCAH_1); |
|
337 |
//// |
|
338 |
//// syncExec(new Runnable() { |
|
339 |
//// @Override |
|
340 |
//// public void run() { |
|
341 |
//// |
|
342 |
//// RDevice device = RDevice.valueOf(TxmPreferences.getString(ExportPreferencePage.RDEVICE, RDevice.SVG.toString())); |
|
343 |
//// String txmhome = Toolbox.getParam(Toolbox.USER_TXM_HOME); |
|
344 |
//// File resultDir = new File(txmhome, "results"); //$NON-NLS-1$ |
|
345 |
//// resultDir.mkdirs(); |
|
346 |
//// File outfile; |
|
347 |
//// try { |
|
348 |
//// outfile = File.createTempFile("cah", device.getExt(), resultDir); //$NON-NLS-1$ |
|
349 |
//// if (!outfile.canWrite()) { |
|
350 |
//// System.out.println(NLS.bind(RCPCAHMessages.ComputeCAH_2, outfile)); |
|
351 |
//// } |
|
352 |
//// } catch (IOException e1) { |
|
353 |
//// // TODO Auto-generated catch block |
|
354 |
//// org.txm.rcpapplication.utils.Logger.printStackTrace(e1); |
|
355 |
//// return; |
|
356 |
//// } |
|
357 |
//// |
|
358 |
//// try { |
|
359 |
//// //System.out.println("CAH file : "+outfile); |
|
360 |
//// cah.toSVG(outfile, device); |
|
361 |
//// OpenGraph.OpenFile(outfile, device, cah.getPartition().getName()+": "+cah.getName(), IImageKeys.ACTION_CAH); //$NON-NLS-1$ |
|
362 |
//// } catch (REXPMismatchException e) { |
|
363 |
//// // TODO Auto-generated catch block |
|
364 |
//// org.txm.rcpapplication.utils.Logger.printStackTrace(e); |
|
365 |
//// } catch (StatException e) { |
|
366 |
//// // TODO Auto-generated catch block |
|
367 |
//// org.txm.rcpapplication.utils.Logger.printStackTrace(e); |
|
368 |
//// } |
|
369 |
//// } |
|
370 |
//// }); |
|
371 |
//// monitor.worked(50); |
|
372 |
//// |
|
373 |
//// syncExec(new Runnable() { |
|
374 |
//// @Override |
|
375 |
//// public void run() { |
|
376 |
//// CorporaView.refresh(); |
|
377 |
//// CorporaView.expand(cah.getPartition()); |
|
378 |
//// } |
|
379 |
//// }); |
|
380 |
//// |
|
381 |
//// monitor.worked(100); |
|
382 |
//// } catch (Exception e) { |
|
383 |
//// org.txm.rcpapplication.utils.Logger.printStackTrace(e); |
|
384 |
//// } finally { |
|
385 |
//// monitor.done(); |
|
386 |
//// } |
|
387 |
//// JobsTimer.stopAndPrint(); |
|
388 |
//// return Status.OK_STATUS; |
|
389 |
//// } |
|
390 |
//// }; |
|
391 |
//// jobhandler.startJob(); |
|
392 |
//// } |
|
393 |
// return null; |
|
394 |
// } |
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
/** |
|
400 |
* The Class CAHParamDialog. |
|
401 |
*/ |
|
402 |
public class CAHParamDialog extends Dialog { |
|
403 |
|
|
404 |
//protected Combo methodsCombo; |
|
405 |
//protected Combo metricsCombo; |
|
406 |
/** The ncluster spinner. */ |
|
407 |
protected Spinner nclusterSpinner; |
|
408 |
|
|
409 |
/** The docolumns button. */ |
|
410 |
protected Button docolumnsButton; |
|
411 |
|
|
412 |
/** The title. */ |
|
413 |
protected String title; |
|
414 |
|
|
415 |
/** |
|
416 |
* Instantiates a new cAH param dialog. |
|
417 |
* |
|
418 |
* @param parentShell the parent shell |
|
419 |
*/ |
|
420 |
public CAHParamDialog(Shell parentShell) { |
|
421 |
super(parentShell); |
|
422 |
this.title = CAUIPMessages.CAHEditorTitle; |
|
423 |
} |
|
424 |
|
|
425 |
/* (non-Javadoc) |
|
426 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
|
427 |
*/ |
|
428 |
@Override |
|
429 |
protected void configureShell(Shell newShell) { |
|
430 |
super.configureShell(newShell); |
|
431 |
|
|
432 |
if (title != null) |
|
433 |
newShell.setText(title); |
|
434 |
else |
|
435 |
newShell.setText(CAUIPMessages.CAHEditorTitle); |
|
436 |
} |
|
437 |
|
|
438 |
/** The composite. */ |
|
439 |
protected Composite composite; |
|
440 |
|
|
441 |
/** The method. */ |
|
442 |
private String method; |
|
443 |
|
|
444 |
/** The metric. */ |
|
445 |
private String metric; |
|
446 |
|
|
447 |
/** The Ncluster. */ |
|
448 |
private int Ncluster; |
|
449 |
|
|
450 |
/** The doculumns. */ |
|
451 |
private boolean doculumns; |
|
452 |
|
|
453 |
/* (non-Javadoc) |
|
454 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
455 |
*/ |
|
456 |
@Override |
|
457 |
protected Control createDialogArea(Composite parent) { |
|
458 |
composite = new Composite(parent, SWT.NONE); |
|
459 |
GridLayout layout = new GridLayout(2, false); |
|
460 |
composite.setLayout(layout); |
|
461 |
|
|
462 |
// N CLUSTERS |
|
463 |
Label label = new Label(composite, SWT.NONE); |
|
464 |
label.setText(CAUIPMessages.CAHPreferencePage_2); |
|
465 |
|
|
466 |
nclusterSpinner = new Spinner(composite, SWT.BORDER); |
|
467 |
nclusterSpinner.setMinimum(2); |
|
468 |
nclusterSpinner.setIncrement(1); |
|
469 |
nclusterSpinner.setSelection(TxmPreferences.getInt(CAHPreferences.NCLUSTER, 2)); |
|
470 |
nclusterSpinner.setMaximum(50); |
|
471 |
|
|
472 |
// ROWS OR COLS |
|
473 |
docolumnsButton = new Button(composite, SWT.RADIO); |
|
474 |
docolumnsButton.setText(CAUIPMessages.ComputeClassification_5); |
|
475 |
docolumnsButton.setSelection(true); |
|
476 |
|
|
477 |
Button dorowsButton = new Button(composite, SWT.RADIO); |
|
478 |
dorowsButton.setText(CAUIPMessages.ComputeClassification_6); |
|
479 |
|
|
480 |
/* |
|
481 |
// METHODS |
|
482 |
Label methodLabel = new Label(composite, SWT.NONE); |
|
483 |
methodLabel.setText("Methods"); |
|
484 |
|
|
485 |
methodLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, |
|
486 |
false, false)); |
|
487 |
|
|
488 |
methodsCombo = new Combo(composite, SWT.READ_ONLY); |
|
489 |
methodsCombo.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
490 |
true, false)); |
|
491 |
methodsCombo.select(methodsCombo.indexOf(CAH.getDefaultMethod())); |
|
492 |
for(String method : CAH.getMethods()) |
|
493 |
methodsCombo.add(method); |
|
494 |
|
|
495 |
// METRICS |
|
496 |
Label metricsLabel = new Label(composite, SWT.NONE); |
|
497 |
metricsLabel.setText("Methods"); |
|
498 |
|
|
499 |
metricsLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, |
|
500 |
false, false)); |
|
501 |
|
|
502 |
metricsCombo = new Combo(composite, SWT.READ_ONLY); |
|
503 |
metricsCombo.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
|
504 |
true, false)); |
|
505 |
metricsCombo.select(metricsCombo.indexOf(CAH.getDefaultMetric())); |
|
506 |
for(String method : CAH.getMetrics()) |
|
507 |
metricsCombo.add(method); |
|
508 |
*/ |
|
509 |
|
|
510 |
return composite; |
|
511 |
} |
|
512 |
|
|
513 |
/* (non-Javadoc) |
|
514 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
515 |
*/ |
|
516 |
@Override |
|
517 |
protected void okPressed() { |
|
518 |
/*int idx = methodsCombo.getSelectionIndex(); |
|
519 |
method = methodsCombo.getItem(idx); |
|
520 |
|
|
521 |
idx = metricsCombo.getSelectionIndex(); |
|
522 |
metric = metricsCombo.getItem(idx); |
|
523 |
*/ |
|
524 |
Ncluster = this.nclusterSpinner.getSelection(); |
|
525 |
|
|
526 |
doculumns = this.docolumnsButton.getSelection(); |
|
527 |
|
|
528 |
super.okPressed(); |
|
529 |
} |
|
530 |
|
|
531 |
/** |
|
532 |
* Gets the method. |
|
533 |
* |
|
534 |
* @return the method |
|
535 |
*/ |
|
536 |
public String getMethod() { |
|
537 |
return method; |
|
538 |
} |
|
539 |
|
|
540 |
/** |
|
541 |
* Gets the metric. |
|
542 |
* |
|
543 |
* @return the metric |
|
544 |
*/ |
|
545 |
public String getMetric() { |
|
546 |
return metric; |
|
547 |
} |
|
548 |
|
|
549 |
/** |
|
550 |
* Gets the ncluster. |
|
551 |
* |
|
552 |
* @return the ncluster |
|
553 |
*/ |
|
554 |
public int getNcluster() { |
|
555 |
return Ncluster; |
|
556 |
} |
|
557 |
|
|
558 |
/** |
|
559 |
* Checks if is doculumns. |
|
560 |
* |
|
561 |
* @return true, if is doculumns |
|
562 |
*/ |
|
563 |
public boolean isDoculumns() { |
|
564 |
return doculumns; |
|
565 |
} |
|
566 |
} |
|
567 |
|
|
568 |
|
|
569 |
} |
|
0 | 570 |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/preferences/CAHPreferencePage.java (revision 225) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.cah.rcp.preferences; |
|
29 |
|
|
30 |
import org.eclipse.jface.preference.ComboFieldEditor; |
|
31 |
import org.eclipse.jface.preference.IntegerFieldEditor; |
|
32 |
import org.eclipse.jface.preference.RadioGroupFieldEditor; |
|
33 |
import org.eclipse.swt.widgets.Group; |
|
34 |
import org.eclipse.ui.IWorkbench; |
|
35 |
import org.txm.cah.core.functions.CAH; |
|
36 |
import org.txm.cah.core.preferences.CAHPreferences; |
|
37 |
import org.txm.cah.rcp.adapters.CAHAdapterFactory; |
|
38 |
import org.txm.cah.rcp.messages.CAUIPMessages; |
|
39 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
40 |
import org.txm.rcp.preferences.TXMPreferencePage; |
|
41 |
import org.txm.rcp.preferences.TXMPreferenceStore; |
|
42 |
// TODO: Auto-generated Javadoc |
|
43 |
/** |
|
44 |
* This class represents a preference page that is contributed to the |
|
45 |
* Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we |
|
46 |
* can use the field support built into JFace that allows us to create a page |
|
47 |
* that is small and knows how to save, restore and apply itself. |
|
48 |
* <p> |
|
49 |
* This page is used to modif y preferences only. They are stored in the |
|
50 |
* preference store that belongs to the main plug-in class. That way, |
|
51 |
* preferences can be accessed directly via the preference store. |
|
52 |
* |
|
53 |
* @author mdecorde |
|
54 |
* @author sjacquot |
|
55 |
*/ |
|
56 |
public class CAHPreferencePage extends TXMPreferencePage { |
|
57 |
|
|
58 |
|
|
59 |
/** |
|
60 |
* Instantiates a new cah preference page. |
|
61 |
*/ |
|
62 |
public CAHPreferencePage() { |
|
63 |
super(); |
|
64 |
} |
|
65 |
|
|
66 |
|
|
67 |
/** |
|
68 |
* |
|
69 |
* @return |
|
70 |
*/ |
|
71 |
public static TXMPreferenceStore getNewPreferenceStore() { |
|
72 |
return new TXMPreferenceStore(CAHPreferences.PREFERENCES_NODE); |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
/** |
|
77 |
* Creates the field editors. Field editors are abstractions of the common |
|
78 |
* GUI blocks needed to manipulate various types of preferences. Each field |
|
79 |
* editor knows how to save and restore itself. |
|
80 |
*/ |
|
81 |
@Override |
|
82 |
public void createFieldEditors() { |
|
83 |
|
|
84 |
|
|
85 |
IntegerFieldEditor defaultncluster = new IntegerFieldEditor(CAHPreferences.NCLUSTER, CAUIPMessages.CAHPreferencePage_2, getFieldEditorParent()); |
|
86 |
addField(defaultncluster); |
|
87 |
|
|
88 |
String list[] = CAH.getMethods(); |
|
89 |
String methods[][] = new String[list.length][2]; |
|
90 |
for(int i = 0 ; i < list.length ; i++) |
|
91 |
methods[i][0] = methods[i][1] = list[i]; |
|
92 |
|
|
93 |
ComboFieldEditor defaultmethod = new ComboFieldEditor(CAHPreferences.METHOD, CAUIPMessages.CAHPreferencePage_3, methods, getFieldEditorParent()); |
|
94 |
addField(defaultmethod); |
|
95 |
|
|
96 |
list = CAH.getMetrics(); |
|
97 |
String metrics[][] = new String[list.length][2]; |
|
98 |
for(int i = 0 ; i < list.length ; i++) |
|
99 |
metrics[i][0] = metrics[i][1] = list[i]; |
|
100 |
|
|
101 |
ComboFieldEditor defaultmetric = new ComboFieldEditor(CAHPreferences.METRIC, CAUIPMessages.CAHPreferencePage_4, metrics, getFieldEditorParent()); |
|
102 |
addField(defaultmetric); |
|
103 |
|
|
104 |
|
|
105 |
// Charts |
|
106 |
Group chartsGroup = SWTChartsComponentsProvider.createChartsRenderingPreferencesGroup(getFieldEditorParent()); |
|
107 |
|
|
108 |
String[][] labelAndValues = {{"2D", "true"}, {"3D", "false"}}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
109 |
RadioGroupFieldEditor default2D3Ddisplay = new RadioGroupFieldEditor(CAHPreferences.DISPLAY_2D, CAUIPMessages.CAHPreferencePage_0, 2, labelAndValues, chartsGroup); |
|
110 |
addField(default2D3Ddisplay); |
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
} |
|
116 |
|
|
117 |
@Override |
|
118 |
public void init(IWorkbench workbench) { |
|
119 |
this.setPreferenceStore(getNewPreferenceStore()); |
|
120 |
//setDescription("CAH"); |
|
121 |
this.setTitle(CAUIPMessages.CAHPreferencePage_2); |
|
122 |
this.setImageDescriptor(CAHAdapterFactory.ICON); |
|
123 |
} |
|
124 |
|
|
125 |
} |
|
0 | 126 |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/adapters/CAHAdapterFactory.java (revision 225) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
package org.txm.cah.rcp.adapters; |
|
3 |
|
|
4 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
5 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
|
6 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
7 |
import org.osgi.framework.FrameworkUtil; |
|
8 |
import org.txm.cah.core.functions.CAH; |
|
9 |
import org.txm.rcp.adapters.BaseAdapterFactory; |
|
10 |
|
|
11 |
/** |
|
12 |
* A factory for creating Adapter objects. |
|
13 |
* |
|
14 |
* @author mdecorde |
|
15 |
* @author sjacquot |
|
16 |
*/ |
|
17 |
public class CAHAdapterFactory extends BaseAdapterFactory { |
|
18 |
|
|
19 |
|
|
20 |
public static final ImageDescriptor ICON = |
|
21 |
AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(CAHAdapterFactory.class).getSymbolicName(), |
|
22 |
"platform:/plugin/"+ FrameworkUtil.getBundle(CAHAdapterFactory.class).getSymbolicName() + "/icons/cah.png"); //$NON-NLS-1$ |
|
23 |
|
|
24 |
/** |
|
25 |
* Gets the adapter. |
|
26 |
* |
|
27 |
* @param adaptableObject the adaptable object |
|
28 |
* @param adapterType the adapter type |
|
29 |
* @return the adapter |
|
30 |
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) |
|
31 |
*/ |
|
32 |
@Override |
|
33 |
public Object getAdapter(Object adaptableObject, Class adapterType) { |
|
34 |
|
|
35 |
if(adapterType == IWorkbenchAdapter.class) { |
|
36 |
if(adaptableObject instanceof CAH) { |
|
37 |
return new IWorkbenchAdapter() { |
|
38 |
@Override |
|
39 |
public Object[] getChildren(Object resultData) { |
|
40 |
return new Object[0]; |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public ImageDescriptor getImageDescriptor(Object object) { |
|
45 |
return ICON; |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public String getLabel(Object resultData) { |
|
50 |
return ((CAH) resultData).getName(); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public Object getParent(Object resultData) { |
|
55 |
return ((CAH) resultData).getCorpus(); |
|
56 |
} |
|
57 |
}; |
|
58 |
} |
|
59 |
} |
|
60 |
return null; |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
} |
|
0 | 65 |
tmp/org.txm.cah.rcp/build.properties (revision 225) | ||
---|---|---|
1 |
source.. = src/ |
|
2 |
output.. = bin/ |
|
3 |
bin.includes = META-INF/,\ |
|
4 |
.,\ |
|
5 |
plugin.xml |
|
0 | 6 |
tmp/org.txm.cah.rcp/OSGI-INF/l10n/bundle.properties (revision 225) | ||
---|---|---|
1 |
command.name=Classification |
|
2 |
command.tooltip=Classification |
|
3 |
editor.name=Classification |
|
0 | 4 |
tmp/org.txm.cah.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 225) | ||
---|---|---|
1 |
command.name=Classification |
|
2 |
command.tooltip=Calculer la classification |
|
0 | 3 |
tmp/org.txm.cah.rcp/OSGI-INF/l10n/bundle_ru_utf-8.properties (revision 225) | ||
---|---|---|
1 |
command.name=Классификация |
|
2 |
command.tooltip=Классификация |
|
0 | 3 |
tmp/org.txm.cah.rcp/plugin.xml (revision 225) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<?eclipse version="3.4"?> |
|
3 |
<plugin> |
|
4 |
<extension |
|
5 |
point="org.eclipse.ui.commands"> |
|
6 |
<command |
|
7 |
categoryId="org.txm.rcpapplication.category.txm" |
|
8 |
defaultHandler="org.txm.cah.rcp.commands.ComputeCAH" |
|
9 |
id="ComputeCAH" |
|
10 |
name="%command.name"> |
|
11 |
</command> |
|
12 |
</extension> |
|
13 |
<extension |
|
14 |
point="org.eclipse.ui.menus"> |
|
15 |
<menuContribution |
|
16 |
allPopups="false" |
|
17 |
locationURI="toolbar:org.txm.rcpapplication.toolbartools"> |
|
18 |
<command |
|
19 |
commandId="ComputeCAH" |
|
20 |
icon="icons/cah.png" |
|
21 |
style="push" |
|
22 |
tooltip="%command.tooltip"> |
|
23 |
<visibleWhen |
|
24 |
checkEnabled="false"> |
|
25 |
<or> |
|
26 |
<reference |
|
27 |
definitionId="OneCASelected"> |
|
28 |
</reference> |
|
29 |
<reference |
|
30 |
definitionId="OneLexicalTableSelected"> |
|
31 |
</reference> |
|
32 |
<reference |
|
33 |
definitionId="OnePartitionSelected"> |
|
34 |
</reference> |
|
35 |
</or> |
|
36 |
</visibleWhen> |
|
37 |
</command> |
|
38 |
</menuContribution> |
|
39 |
<menuContribution |
|
40 |
allPopups="false" |
|
41 |
locationURI="popup:org.txm.rcpapplication.views.CorporaView"> |
|
42 |
<command |
|
43 |
commandId="ComputeCAH" |
|
44 |
icon="icons/cah.png" |
|
45 |
style="push"> |
|
46 |
<visibleWhen |
|
47 |
checkEnabled="false"> |
|
48 |
<or> |
|
49 |
<reference |
|
50 |
definitionId="OneCASelected"> |
|
51 |
</reference> |
|
52 |
<reference |
|
53 |
definitionId="OneLexicalTableSelected"> |
|
54 |
</reference> |
|
55 |
<reference |
|
56 |
definitionId="OnePartitionSelected"> |
|
57 |
</reference> |
|
58 |
</or> |
|
59 |
</visibleWhen> |
|
60 |
</command> |
|
61 |
</menuContribution> |
|
62 |
<menuContribution |
|
63 |
locationURI="menu:menu.tools"> |
|
64 |
<command |
|
65 |
commandId="ComputeCAH" |
|
66 |
icon="icons/cah.png" |
|
67 |
style="push"> |
|
68 |
<visibleWhen |
|
69 |
checkEnabled="false"> |
|
70 |
<or> |
|
71 |
<reference |
|
72 |
definitionId="OneCASelected"> |
|
73 |
</reference> |
|
74 |
<reference |
|
75 |
definitionId="OneLexicalTableSelected"> |
|
76 |
</reference> |
|
77 |
<reference |
|
78 |
definitionId="OnePartitionSelected"> |
|
79 |
</reference> |
|
80 |
</or> |
|
81 |
</visibleWhen> |
|
82 |
</command> |
|
83 |
</menuContribution> |
|
84 |
</extension> |
|
85 |
<extension |
|
86 |
point="org.eclipse.ui.editors"> |
|
87 |
<editor |
|
88 |
default="false" |
|
89 |
icon="icons/cah.png" |
|
90 |
id="org.txm.cah.core.functions.CAH" |
|
91 |
name="%editor.name"> |
|
92 |
</editor> |
|
93 |
</extension> |
|
94 |
<extension |
|
95 |
point="org.eclipse.core.runtime.adapters"> |
|
96 |
<factory |
|
97 |
adaptableType="org.txm.cah.core.functions.CAH" |
|
98 |
class="org.txm.cah.rcp.adapters.CAHAdapterFactory"> |
|
99 |
<adapter |
|
100 |
type="org.eclipse.ui.model.IWorkbenchAdapter"> |
|
101 |
</adapter> |
|
102 |
</factory> |
|
103 |
</extension> |
|
104 |
|
|
105 |
</plugin> |
|
0 | 106 |
tmp/org.txm.cah.rcp/.settings/org.eclipse.core.resources.prefs (revision 225) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
encoding//src/org/txm/cah/rcp/messages/messages_ru_utf8.properties=UTF-8 |
|
0 | 3 |
tmp/org.txm.cah.rcp/.settings/org.eclipse.jdt.core.prefs (revision 225) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
|
3 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 |
|
4 |
org.eclipse.jdt.core.compiler.compliance=1.6 |
|
5 |
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
|
6 |
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
|
7 |
org.eclipse.jdt.core.compiler.source=1.6 |
|
0 | 8 |
tmp/org.txm.cah.rcp/.classpath (revision 225) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
|
5 |
<classpathentry kind="src" path="src"/> |
|
6 |
<classpathentry kind="output" path="bin"/> |
|
7 |
</classpath> |
|
0 | 8 |
tmp/org.txm.cah.rcp/META-INF/MANIFEST.MF (revision 225) | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Bundle-ManifestVersion: 2 |
|
3 |
Bundle-Name: CAH RCP |
|
4 |
Bundle-SymbolicName: org.txm.cah.rcp;singleton:=true |
|
5 |
Bundle-Version: 1.0.0.qualifier |
|
6 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
|
7 |
Export-Package: org.txm.cah.rcp.adapters, |
|
8 |
org.txm.cah.rcp.commands, |
|
9 |
org.txm.cah.rcp.editors, |
|
10 |
org.txm.cah.rcp.messages, |
|
11 |
org.txm.cah.rcp.preferences |
|
12 |
Require-Bundle: org.txm.chartsengine.rcp;bundle-version="1.0.0", |
|
13 |
org.txm.lexicaltable.core;bundle-version="1.0.0", |
|
14 |
org.txm.ca.core, |
|
15 |
org.eclipse.core.runtime;bundle-version="3.10.0", |
|
16 |
org.txm.r;bundle-version="1.0.0", |
|
17 |
org.eclipse.ui;bundle-version="3.106.1", |
|
18 |
org.txm.core;bundle-version="0.7.0", |
|
19 |
org.txm.cah.core;bundle-version="1.0.0", |
|
20 |
org.txm.rcp;bundle-version="0.7.8" |
|
0 | 21 |
Formats disponibles : Unified diff