Revision 84

tmp/org.txm.partition.rcp/OSGI-INF/l10n/bundle_ru_utf-8.properties (revision 84)
1
command.name=Размеры
2
command.tooltip=Размеры
0 3

  
tmp/org.txm.partition.rcp/OSGI-INF/l10n/bundle.properties (revision 84)
1
Bundle-Name = Partition RCP
2
Bundle-Vendor = TXM
3
command.name = Dimensions
4
editor.name = Dimensions
5
page.name = Partition
6
command.tooltip=Dimensions
7
PreferencesPage_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE=Display parts count in chart title
8
PreferencesPage_DIMENSIONS_SORT_BY_PARTS_SIZE=Sort by part size
0 9

  
tmp/org.txm.partition.rcp/OSGI-INF/l10n/bundle_ru.properties (revision 84)
1
command.name=\u0420\u0430\u0437\u043c\u0435\u0440\u044b
2
command.tooltip=\u0420\u0430\u0437\u043c\u0435\u0440\u044b
0 3

  
tmp/org.txm.partition.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 84)
1
Bundle-Name = Partition RCP
2
Bundle-Vendor = TXM
3
command.name = Dimensions
4
editor.name = Dimensions
5
page.name = Partition
6
command.tooltip=Visualiser la taille des parties
7
PreferencesPage_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE=Afficher le nombre de parties dans le titre du graphique
8
PreferencesPage_DIMENSIONS_SORT_BY_PARTS_SIZE=Trier par taille de partie
0 9

  
tmp/org.txm.partition.rcp/plugin.xml (revision 84)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4

  
5
   <extension
6
         point="org.eclipse.ui.commands">
7
      <command
8
            categoryId="org.txm.rcpapplication.category.txm"
9
            defaultHandler="org.txm.partition.rcp.handlers.ComputePartitionDimensionsBarChart"
10
            id="ComputePartitionDimensionsBarChart"
11
            name="%command.name">
12
      </command>
13
   </extension>
14
   <extension
15
         point="org.eclipse.ui.handlers">
16
      <handler
17
            commandId="ComputePartitionDimensionsBarChart"
18
            class="org.txm.partition.rcp.handlers.ComputePartitionDimensionsBarChart">
19
      </handler>
20
   </extension>
21
   <extension
22
         point="org.eclipse.ui.menus">
23
      <menuContribution
24
            allPopups="false"
25
            locationURI="toolbar:org.txm.rcpapplication.toolbartools">
26
         <command
27
               commandId="ComputePartitionDimensionsBarChart"
28
               icon="icons/dimensions.png"
29
               style="push"
30
               tooltip="%command.tooltip">
31
            <visibleWhen
32
                  checkEnabled="false">
33
               <or>
34
                  <reference
35
                        definitionId="OnePartitionSelected">
36
                  </reference>
37
               </or>
38
            </visibleWhen>
39
         </command>
40
      </menuContribution>
41
      <menuContribution
42
            allPopups="false"
43
            locationURI="popup:org.txm.rcpapplication.views.CorporaView">
44
         <command
45
               commandId="ComputePartitionDimensionsBarChart"
46
               icon="icons/dimensions.png"
47
               style="push">
48
            <visibleWhen
49
                  checkEnabled="false">
50
               <or>
51
                  <reference
52
                        definitionId="OnePartitionSelected">
53
                  </reference>
54
               </or>
55
            </visibleWhen>
56
         </command>
57
      </menuContribution>
58
      <menuContribution
59
            locationURI="menu:menu.tools">
60
         <command
61
               commandId="ComputePartitionDimensionsBarChart"
62
               icon="icons/dimensions.png"
63
               style="push">
64
            <visibleWhen
65
                  checkEnabled="false">
66
               <or>
67
                  <reference
68
                        definitionId="OnePartitionSelected">
69
                  </reference>
70
               </or>
71
            </visibleWhen>
72
         </command>
73
      </menuContribution>
74
   </extension>
75
   <extension
76
         point="org.eclipse.ui.preferencePages">
77
      <page
78
            category="org.txm.rcpapplication.preferences.UserPreferencePage"
79
            class="org.txm.partition.rcp.preferences.PartitionPreferencePage"
80
            id="org.txm.rcp.partition.preferences.PartitionPreferencePage"
81
            name="%page.name">
82
      </page>
83
   </extension>
84
   <extension
85
         point="org.eclipse.ui.editors">
86
      <editor
87
            class="org.txm.chartsengine.rcp.editors.ChartEditorPart"
88
            default="false"
89
            icon="icons/dimensions.png"
90
            id="org.txm.searchengine.cqp.corpus.Partition"
91
            name="%editor.name">
92
      </editor>
93
   </extension>
94

  
95
</plugin>
0 96

  
tmp/org.txm.partition.rcp/.settings/org.eclipse.jdt.core.prefs (revision 84)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4
org.eclipse.jdt.core.compiler.compliance=1.7
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.7
0 8

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

  
tmp/org.txm.partition.rcp/.classpath (revision 84)
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.7"/>
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.partition.rcp/META-INF/MANIFEST.MF (revision 84)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Bundle-Name
4
Bundle-SymbolicName: org.txm.partition.rcp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Require-Bundle: org.txm.chartsengine.rcp,
7
 org.eclipse.ui,
8
 org.eclipse.core.runtime,
9
 org.txm.core;bundle-version="0.7.0",
10
 org.txm.rcp;bundle-version="0.7.8",
11
 org.txm.partition.core;bundle-version="1.0.0",
12
 org.txm.chartsengine.core
13
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
14
Bundle-ActivationPolicy: lazy
15
Bundle-Vendor: %Bundle-Vendor
0 16

  
tmp/org.txm.partition.rcp/.project (revision 84)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.partition.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
		<buildCommand>
24
			<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>org.eclipse.pde.PluginNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
		<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
33
	</natures>
34
</projectDescription>
0 35

  
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/handlers/ComputePartitionDimensionsBarChart.java (revision 84)
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.partition.rcp.handlers;
29

  
30
import java.util.List;
31

  
32
import org.eclipse.core.commands.AbstractHandler;
33
import org.eclipse.core.commands.ExecutionEvent;
34
import org.eclipse.core.commands.ExecutionException;
35
import org.eclipse.jface.viewers.IStructuredSelection;
36
import org.eclipse.ui.handlers.HandlerUtil;
37
import org.txm.Toolbox;
38
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
39
import org.txm.partition.core.preferences.PartitionDimensionsPreferences;
40
import org.txm.rcpapplication.JobsTimer;
41
import org.txm.rcpapplication.Messages;
42
import org.txm.searchengine.cqp.corpus.Part;
43
import org.txm.searchengine.cqp.corpus.Partition;
44

  
45
/**
46
 * Creates and opens a bar chart editor with the dimensions of the selected partition.
47
 * 
48
 * @author mdecorde
49
 * @author sjacquot
50
 * 
51
 */
52
public class ComputePartitionDimensionsBarChart extends AbstractHandler {
53

  
54

  
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
57
	 */
58
	@Override
59
	public Object execute(ExecutionEvent event) throws ExecutionException {
60
		if (!Toolbox.isSearchEngineInitialized()) return false;
61
		
62
		if (!Toolbox.isStatEngineInitialized()) {
63
			System.out.println(Messages.PartsSize_0);
64
			return null;
65
		}
66
		
67
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
68

  
69
		if (selection.getFirstElement() instanceof Partition) {
70
			final Partition partition = (Partition) selection.getFirstElement();
71
			try {
72

  
73
				JobsTimer.start();
74

  
75
				List<Part> parts = partition.getParts();
76
				if(parts.size() == 0)	{
77
					return false;
78
				}
79

  
80
				// Creates and opens the chart editor
81
				SWTChartsComponentsProvider.getCurrent().openEditor(Messages.bind(Messages.PartsSize_18, partition.getName()), partition, PartitionDimensionsPreferences.PREFERENCES_NODE,
82
						"Partition Dimensions Bar Chart");
83

  
84
				// FIXME: Pie chart tests
85
//				SWTChartsComponentsProvider.getCurrent().openEditor(Messages.bind(Messages.PartsSize_18, partition.getName()), partition, PartitionDimensionsPreferences.PREFERENCES_NODE,
86
//						"Partition Dimensions Pie Chart");
87
				
88
				
89
				JobsTimer.stopAndPrint();
90
			} catch (Exception e) {
91
				org.txm.rcpapplication.utils.Logger.printStackTrace(e);
92
			}
93
		}
94

  
95
		return null;
96
	}
97
	
98
}
0 99

  
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/preferences/PartitionPreferencePage.java (revision 84)
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.partition.rcp.preferences;
29

  
30
import org.eclipse.jface.preference.BooleanFieldEditor;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.ui.IWorkbench;
33
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
34
import org.txm.partition.core.preferences.PartitionDimensionsPreferences;
35
import org.txm.partition.rcp.messages.RCPPartitionMessages;
36
import org.txm.rcp.preferences.TXMPreferencePage;
37
import org.txm.rcp.preferences.TXMPreferenceStore;
38
import org.txm.rcpapplication.Messages;
39

  
40
/**
41
 * Partition preference page.
42
 * @author mdecorde
43
 * @author sjacquot
44
 *
45
 */
46
public class PartitionPreferencePage extends TXMPreferencePage {
47

  
48

  
49
	/**
50
	 * Creates the field editors. Field editors are abstractions of the common
51
	 * GUI blocks needed to manipulate various types of preferences. Each field
52
	 * editor knows how to save and restore itself.
53
	 */
54
	@Override
55
	public void createFieldEditors() {
56
		
57
		// Charts rendering
58
		Composite chartsTab = SWTChartsComponentsProvider.createChartsRenderingPreferencesTabFolderComposite(this.getFieldEditorParent());
59
		
60
		this.addField(new BooleanFieldEditor(PartitionDimensionsPreferences.CHART_DIMENSIONS_SORTED_BY_SIZE, RCPPartitionMessages.PreferencesPage_DIMENSIONS_SORT_BY_PARTS_SIZE, chartsTab));
61
		this.addField(new BooleanFieldEditor(PartitionDimensionsPreferences.CHART_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE, RCPPartitionMessages.PreferencesPage_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE, chartsTab));
62
		
63
		// other shared preferences
64
		SWTChartsComponentsProvider.createChartsRenderingPreferencesFields(this, chartsTab);
65

  
66
	}
67

  
68
	
69
	/*
70
	 * (non-Javadoc)
71
	 * 
72
	 * @see
73
	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
74
	 */
75
	@Override
76
	public void init(IWorkbench workbench) {
77
		this.setPreferenceStore(new TXMPreferenceStore(PartitionDimensionsPreferences.PREFERENCES_NODE));
78
		//this.setDescription(Messages.DiagnosticPreferencePage_1);
79
		this.setTitle(Messages.DiagnosticPreferencePage_1);
80
	}
81

  
82

  
83
}
0 84

  
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/messages/RCPPartitionMessages.java (revision 84)
1
package org.txm.partition.rcp.messages;
2

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

  
5

  
6

  
7
public class RCPPartitionMessages extends NLS {
8

  
9
	// FIXME: use the same properties file than the bundle	
10
	private static final String BUNDLE_NAME = "l10n.bundle"; //$NON-NLS-1$
11

  
12
	public static String PreferencesPage_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE;
13
	public static String PreferencesPage_DIMENSIONS_SORT_BY_PARTS_SIZE;
14
	
15

  
16
	static {
17
		// initialize resource bundle
18
		NLS.initializeMessages(BUNDLE_NAME, RCPPartitionMessages.class);
19
	}
20

  
21
	private RCPPartitionMessages() {
22
	}
23
}
0 24

  
tmp/org.txm.partition.rcp/build.properties (revision 84)
1
source.. = src/
2
output.. = bin/
3
bin.includes = plugin.xml,\
4
               META-INF/,\
5
               .,\
6
               icons/,\
7
               OSGI-INF/l10n/bundle.properties
0 8

  
tmp/org.txm.progression.rcp/.classpath (revision 84)
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.progression.rcp/META-INF/MANIFEST.MF (revision 84)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Bundle-Name
4
Bundle-SymbolicName: org.txm.progression.rcp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
7
Require-Bundle: org.txm.chartsengine.rcp;bundle-version="1.0.0",
8
 org.txm.chartsengine.core,
9
 org.eclipse.ui.workbench,
10
 org.eclipse.swt,
11
 org.txm.core;bundle-version="0.7.0",
12
 org.txm.chartsengine.jfreechart.core;bundle-version="1.0.0",
13
 org.txm.rcp,
14
 org.txm.chartsengine.r.core;bundle-version="1.0.0",
15
 org.eclipse.core.runtime;bundle-version="3.10.0",
16
 org.txm.chartsengine.svgbatik.rcp;bundle-version="1.0.0",
17
 org.txm.progression.core;bundle-version="1.0.0"
18
Export-Package: org.txm.progression.rcp.adapters,
19
 org.txm.progression.rcp.dialogs
0 20

  
tmp/org.txm.progression.rcp/.project (revision 84)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.progression.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.progression.rcp/src/org/txm/progression/rcp/chartsengine/jfreechart/events/ProgressionSelectionListener.java (revision 84)
1
package org.txm.progression.rcp.chartsengine.jfreechart.events;
2

  
3
import org.eclipse.swt.events.SelectionEvent;
4
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
5
import org.txm.chartsengine.rcp.events.BaseSelectionListener;
6

  
7
/**
8
 * Progression selection listener.
9
 * @author sjacquot
10
 *
11
 */
12
public class ProgressionSelectionListener extends BaseSelectionListener {
13

  
14

  
15
	/**
16
	 * 
17
	 * @param chartEditor
18
	 * @param commandId
19
	 */
20
	public ProgressionSelectionListener(ChartEditorPart chartEditor, int commandId) {
21
		super(chartEditor, commandId);
22
	}
23

  
24

  
25

  
26
	@Override
27
	public void widgetSelected(SelectionEvent e) {
28
		
29
		
30
		// FIXME: to discuss
31
		// Send to other command
32
//		if(this.commandId == ProgressionSelectionListener.SEND_TO_INDEX || this.commandId == ProgressionSelectionListener.SEND_TO_CONCORDANCE
33
//				|| this.commandId == ProgressionSelectionListener.SEND_TO_COOCCURRENCE)	{
34
//
35
//
36
//			Progression progression = (Progression) this.chartEditor.getResultData();
37
//			// gets the progression queries from the current selected chart series
38
//			String query = progression.getQueriesString(chartEditor.getEditorInput().getSWTChartComponentsProvider().getChartsEngine().getProgressionChartSelectedSeries(chartEditor.getChart()));
39
//			
40
//			// Send to index
41
//			if(this.commandId == ProgressionSelectionListener.SEND_TO_INDEX)	{
42
//	
43
//				IndexEditorInput editorInput = new IndexEditorInput(progression.getCorpus());
44
//	
45
//				try {
46
//					IWorkbenchPage page = this.chartEditor.getEditorSite().getWorkbenchWindow().getActivePage();
47
//					IndexEditor editor = (IndexEditor) page.openEditor(editorInput, IndexEditor.ID);
48
//					editor.setFocus(query);
49
//					editor.compute();
50
//				}
51
//				catch(PartInitException e1) {
52
//					e1.printStackTrace();
53
//				}
54
//			}
55
//			// Send to concordance
56
//			else if(this.commandId == ProgressionSelectionListener.SEND_TO_CONCORDANCE)	{
57
//	
58
//				ConcordancesEditorInput editorInput = new ConcordancesEditorInput(progression.getCorpus(), null);
59
//	
60
//				try {
61
//					IWorkbenchPage page = this.chartEditor.getEditorSite().getWorkbenchWindow().getActivePage();
62
//					ConcordancesEditor editor = (ConcordancesEditor) page.openEditor(editorInput, "org.txm.rcpapplication.editors.ConcordancesEditor"); //$NON-NLS-1$
63
//					editor.setQuery(query);
64
//					editor.compute();
65
//					
66
//					// move in the concordance to the line of the selected progression point
67
//					final ArrayList<Integer> selectedPointPositions = chartEditor.getEditorInput().getSWTChartComponentsProvider().getChartsEngine().getProgressionChartSelectedPointPositions(chartEditor.getChart());
68
//					ArrayList<EditorPart> linkedEditors = new ArrayList<EditorPart>(); 
69
//					linkedEditors.add(editor);
70
//					new ProgressionEventCallBack(this.chartEditor).updateLinkedConcordanceEditor(linkedEditors, selectedPointPositions);
71
//
72
//					
73
//				}
74
//				catch(PartInitException e1) {
75
//					e1.printStackTrace();
76
//				}
77
//			}
78
//			// Send to cooccurrence
79
//			else if(this.commandId == ProgressionSelectionListener.SEND_TO_COOCCURRENCE)	{
80
//	
81
//				CooccurrenceEditorInput editorInput = new CooccurrenceEditorInput(progression.getCorpus());
82
//	
83
//				try {
84
//					IWorkbenchPage page = this.chartEditor.getEditorSite().getWorkbenchWindow().getActivePage();
85
//					CooccurrencesEditor editor = (CooccurrencesEditor) page.openEditor(editorInput, CooccurrencesEditor.ID);
86
//					editor.setFocus(query);
87
//					editor.compute();
88
//				}
89
//				catch(PartInitException e1) {
90
//					e1.printStackTrace();
91
//				}
92
//			}
93
//		}
94
		
95
	}
96

  
97
	@Override
98
	public void widgetDefaultSelected(SelectionEvent e) {
99
		// TODO Auto-generated method stub
100

  
101
	}
102

  
103
}
0 104

  
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/chartsengine/jfreechart/events/ProgressionEventCallBack.java (revision 84)
1
package org.txm.progression.rcp.chartsengine.jfreechart.events;
2

  
3
import java.awt.AWTEvent;
4
import java.awt.event.KeyEvent;
5
import java.awt.event.MouseEvent;
6
import java.util.ArrayList;
7
import java.util.List;
8

  
9
import org.eclipse.e4.ui.workbench.modeling.EModelService;
10
import org.eclipse.jface.viewers.StructuredSelection;
11
import org.eclipse.jface.viewers.TableViewer;
12
import org.eclipse.osgi.util.NLS;
13
import org.eclipse.ui.IWorkbenchPage;
14
import org.eclipse.ui.IWorkbenchWindow;
15
import org.eclipse.ui.PartInitException;
16
import org.eclipse.ui.PlatformUI;
17
import org.eclipse.ui.part.EditorPart;
18
import org.jfree.chart.ChartMouseEvent;
19
import org.jfree.chart.entity.ChartEntity;
20
import org.txm.chartsengine.rcp.events.EventCallBack;
21
import org.txm.chartsengine.rcp.events.ZoomAndPanCallBack;
22
import org.txm.functions.concordances.comparators.LineComparator;
23
import org.txm.objects.Edition;
24
import org.txm.objects.Page;
25
import org.txm.objects.Text;
26
import org.txm.progression.core.functions.Progression2;
27
import org.txm.rcpapplication.Messages;
28
import org.txm.rcpapplication.commands.OpenBrowser;
29
import org.txm.rcpapplication.editors.TXMBrowser;
30
import org.txm.rcpapplication.editors.concordances.ConcordancesEditor;
31
import org.txm.rcpapplication.editors.input.ConcordancesEditorInput;
32
import org.txm.rcpapplication.utils.SWTEditorsUtils;
33
import org.txm.searchengine.cqp.corpus.Corpus;
34
import org.txm.searchengine.cqp.corpus.Property;
35
import org.txm.searchengine.cqp.corpus.StructuralUnit;
36
import org.txm.searchengine.cqp.corpus.query.Match;
37
import org.txm.utils.logger.Log;
38

  
39
/**
40
 * Progression chart mixed mouse and key user entries call back.
41
 * 
42
 * @author sjacquot
43
 *
44
 */
45
public class ProgressionEventCallBack extends EventCallBack {
46

  
47
	/**
48
	 * To keep track of the concordance lines and recomputing only if the selected item is out of this range.
49
	 */
50
	protected int lastConcordanceTopLine = -1;
51
	protected int lastConcordanceBottomLine = -1;
52
	
53
	/**
54
	 * To keep track of the concordance lines sort and recomputing only if the sorting order has changed.
55
	 */
56
	protected LineComparator lastSortingComparator = null;
57
	
58
	
59

  
60

  
61
	@Override
62
	public void processEvent(final AWTEvent event, final int eventArea, final Object o) {
63
		
64
		// Need to run this in the SWT UI thread because it's called from the AWT UI thread in TBX charts engine layer
65
		chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
66
			public void run() {
67

  
68
				// Mouse event
69
				if(event instanceof MouseEvent)	{
70
				
71
					MouseEvent mouseEvent = (MouseEvent)event;
72
					
73
					//return if it's not the left mouse button
74
					if(mouseEvent.getButton() != MouseEvent.BUTTON1)	{
75
						return;
76
					}
77
					
78
					
79
					ChartMouseEvent chartEvent = (ChartMouseEvent) o;
80
					ChartEntity entity = chartEvent.getEntity();
81
					final ArrayList<Integer> selectedPointPositions = chartEditor.getEditorInput().getSWTChartsComponentsProvider().getChartsEngine().getProgressionChartSelectedPointPositions(chartEditor.getChart());
82
	
83
					if(event.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 2 && eventArea == EventCallBack.AREA_ITEM && !selectedPointPositions.isEmpty()) {
84
	
85
						// Linked edition (CTRL/CMD + double click)
86
						if((mouseEvent.getModifiers() & ZoomAndPanCallBack.keyboardZoomModifierKeyMask) != 0) {
87
							// Updates the linked editor
88
							updateLinkedEditionEditor((TXMBrowser) chartEditor.getLinkedEditor(TXMBrowser.class), selectedPointPositions);
89
						}
90
						// Linked concordance
91
						else	{
92
							// Updates the linked editor
93
							updateLinkedConcordanceEditor(chartEditor.getLinkedEditors(ConcordancesEditor.class), selectedPointPositions);
94
						}
95
					}
96
					else if(event.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 1 && eventArea == EventCallBack.AREA_ITEM) {
97

  
98
						// Get the linked concordance editors and update the one linked to the progression curve if it exists
99
						ArrayList<EditorPart> linkedConcordancesEditors = chartEditor.getLinkedEditors(ConcordancesEditor.class);
100
						if(!linkedConcordancesEditors.isEmpty())	{
101
							updateLinkedConcordanceEditor(linkedConcordancesEditors, selectedPointPositions);
102
						}
103
						
104
						
105
						// Get the linked edition editor and update it if exists
106
						TXMBrowser linkedEditionEditor = (TXMBrowser)chartEditor.getLinkedEditor(TXMBrowser.class);
107
						if(linkedEditionEditor != null)	{
108
							updateLinkedEditionEditor(linkedEditionEditor, selectedPointPositions);
109
						}
110
						
111
					}
112
					else if(event.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 2 && eventArea == EventCallBack.AREA_EMPTY) {
113
						// FIXME: debug
114
						//System.err.println("ProgressionMouseClickedCallBack.processEvent(...).new Runnable() {...}.run(): double click in empty area");
115
					}
116
					else if(event.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 1 && eventArea == EventCallBack.AREA_EMPTY) {
117
						// FIXME: debug
118
						//System.err.println("ProgressionMouseClickedCallBack.processEvent(...).new Runnable() {...}.run(): single click in empty area");
119
					}
120
				}
121
				// Key event
122
				else if(event instanceof KeyEvent)	{
123
					KeyEvent keyEvent = (KeyEvent)event;
124
					
125
					// return if zoom and pan modifier
126
					if((keyEvent.getModifiers() & ZoomAndPanCallBack.keyboardZoomModifierKeyMask) != 0) {
127
						return;
128
					}
129
					
130
					// Arrow keys
131
					if(keyEvent.getKeyCode() == KeyEvent.VK_LEFT || keyEvent.getKeyCode() == KeyEvent.VK_RIGHT)	{
132
					
133
						final ArrayList<Integer> selectedPointPositions = chartEditor.getEditorInput().getSWTChartsComponentsProvider().getChartsEngine().getProgressionChartSelectedPointPositions(chartEditor.getChart());
134
	
135
						// Get the linked concordance editors and update the one linked to the progression curve if it exists
136
						ArrayList<EditorPart> linkedConcordancesEditors = chartEditor.getLinkedEditors(ConcordancesEditor.class);
137
						if(!linkedConcordancesEditors.isEmpty())	{
138
							updateLinkedConcordanceEditor(linkedConcordancesEditors, selectedPointPositions);
139
						}
140
						
141
						// Get the linked edition editor and update it if exists
142
						TXMBrowser linkedEditionEditor = (TXMBrowser)chartEditor.getLinkedEditor(TXMBrowser.class);
143
						if(linkedEditionEditor != null)	{
144
							updateLinkedEditionEditor(linkedEditionEditor, selectedPointPositions);
145
						}
146
					}
147
				}
148
			}
149
		});
150

  
151
	}
152

  
153
	
154
	/**
155
	 * Updates the linked concordance editor.
156
	 * If the editor doesn't exist it will be created.
157
	 * @param editor
158
	 */
159
	public void updateLinkedConcordanceEditor(ArrayList<EditorPart> linkedEditors, ArrayList<Integer> selectedPointPositions)	{
160

  
161
		// FIXME: Debug
162
		//System.err.println("ProgressionEventCallBack.updateLinkedConcordanceEditor(): linked editors count: " + linkedEditors.size());
163
		
164
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
165
		IWorkbenchPage page = window.getActivePage();
166

  
167
		// Get and format the progression query from the selected chart series
168
		// FIXME: case 1, the query is the query of the selected chart series
169
//		ArrayList<Integer> selectedSeries = chartEditor.getEditorInput().getSWTChartComponentsProvider().getChartsEngine().getProgressionChartSelectedSeries(chartEditor.getChart());
170
//		String query = ((Progression) chartEditor.getResultData()).getQueries().get(selectedSeries.get(selectedSeries.size() - 1).intValue()).getQueryString();
171
		
172
		int lastSelectedSeries = chartEditor.getEditorInput().getSWTChartsComponentsProvider().getChartsEngine().getProgressionChartLastSelectedSeries(chartEditor.getChart());
173
		String query = ((Progression2) chartEditor.getResultData()).getQueries().get(lastSelectedSeries).getQueryString();
174

  
175
		// Remove "[" and "]" only if it's a simple query as "[faire]" 
176
		if(query.startsWith("[") && !query.contains("="))	{
177
			int length = query.length();
178
			if(query.endsWith("]"))	{
179
				length--;
180
			}
181
			query = query.substring(1, length);
182
		}
183

  
184
		// FIXME: case 2, the query is the combination of all the queries of the progression
185
//		String query = ((Progression) chartEditor.getResultData()).getQueriesString();
186
		
187
		
188
		// gets the linked editor according to the query if it exists
189
		ConcordancesEditor linkedEditor = null;
190
		for(int i = 0; i < linkedEditors.size(); i++) {
191
			if(query.equals(((ConcordancesEditor) linkedEditors.get(i)).getConcordance().getQuery().getQueryString()))	{
192
				linkedEditor = ((ConcordancesEditor) linkedEditors.get(i));
193
				break;
194
			}
195
		}
196
		
197
		
198
		
199
		ConcordancesEditorInput editorInput;
200
		boolean newEditor = false;
201
		// Create the linked editor input if needed
202
		if(linkedEditor == null) {
203
			editorInput = new ConcordancesEditorInput(((Progression2) chartEditor.getResultData()).getCorpus(), null);
204
			newEditor = true;
205
		}
206
		else	{
207
			editorInput = (ConcordancesEditorInput) linkedEditor.getEditorInput();
208
		}
209

  
210
		try {
211
			boolean wasOpenEditor = SWTEditorsUtils.isOpenEditor(editorInput);
212
			
213
			linkedEditor = (ConcordancesEditor) page.openEditor(editorInput, "org.txm.rcpapplication.editors.ConcordancesEditor", false); //$NON-NLS-1$
214
			if(newEditor)	{
215
				chartEditor.addLinkedEditor(linkedEditor);
216
			}
217
			
218
			// Split the area and insert the new editor
219
			if(!wasOpenEditor)	{
220
				
221
				int position = EModelService.BELOW;
222
				EditorPart parentEditor = chartEditor;
223
				
224
				// Split vertically if there is already a concordance editor otherwise split horizontally
225
				if(linkedEditors != null && !linkedEditors.isEmpty())	 {
226
					position = EModelService.RIGHT_OF;
227
					parentEditor = linkedEditors.get(linkedEditors.size() - 1);
228
					
229
					System.err.println("ProgressionEventCallBack.updateLinkedConcordanceEditor(): parent editor for splitting: " + parentEditor);
230
				}
231
				// Split vertically if there is already an edition editor otherwise split horizontally
232
				else	{
233
					TXMBrowser linkedEditionEditor = (TXMBrowser)chartEditor.getLinkedEditor(TXMBrowser.class);
234
					if(linkedEditionEditor != null)	{
235
						position = EModelService.RIGHT_OF;
236
						parentEditor = linkedEditionEditor;
237
					}
238
				}
239
				
240
				
241
				// Split and add linked editor
242
				SWTEditorsUtils.addEditor(parentEditor, linkedEditor, position);
243
			}
244
			
245
		}
246
		catch (PartInitException e) {
247
			System.err.println(NLS.bind(Messages.GetConcordances_4, e));
248
		}
249

  
250
		linkedEditor.setQuery(query);
251
		// Compute the concordance if the query has changed or if the concordance has never been computed
252
		if(linkedEditor.getConcordance() == null || newEditor)	{
253
			linkedEditor.compute(false);
254
			// initialize range change tracking variables
255
			this.lastConcordanceTopLine = 0;
256
			this.lastConcordanceBottomLine = linkedEditor.getLinePerPage();
257
			this.lastSortingComparator = linkedEditor.getCurrentComparator();
258
		}
259

  
260

  
261
	
262
		
263
		final TableViewer tableViewer = linkedEditor.getLineTableViewer();
264
		if(selectedPointPositions.size() > 0)	{
265

  
266
			// Get the index of the last selected point in concordance according to the global token position and concordance sorting order
267
			int lineIndex = linkedEditor.getConcordance().indexOf(selectedPointPositions.get(selectedPointPositions.size() - 1));
268
			
269
			int top = lineIndex - (lineIndex % linkedEditor.getLinePerPage());
270
			int bottom = top + linkedEditor.getLinePerPage() - 1;
271
			
272
			
273
			// Manage the lazy loading of new lines range in the concordance
274
			boolean loadLines = false;
275
			// not open editor (or new editor)
276
			if(!SWTEditorsUtils.isOpenEditor(editorInput))	{
277
				loadLines = true;
278
			}
279
			// page change
280
			else if(this.lastConcordanceTopLine != top || this.lastConcordanceBottomLine != bottom)	{
281
				loadLines = true;
282
			}
283
			// sort change
284
			else if(this.lastSortingComparator != linkedEditor.getCurrentComparator())	{
285
				loadLines = true;
286
			}
287
			
288
			
289
			// Loads new lines, fill the display area and select the table row
290
			if(loadLines)	{
291
				linkedEditor.fillDisplayArea(top, bottom);
292
			}
293

  
294
			// update range change tracking variables
295
			this.lastConcordanceTopLine = top;
296
			this.lastConcordanceBottomLine = bottom;
297
			this.lastSortingComparator = linkedEditor.getCurrentComparator();
298

  
299
			
300
			
301
			final int selectedPointInTableRange = lineIndex - top;						
302
	
303
			tableViewer.getControl().getDisplay().asyncExec(new Runnable() {
304
				@Override
305
				public void run() {
306
					tableViewer.getTable().deselectAll();
307
					
308
					Object line = tableViewer.getElementAt(selectedPointInTableRange);
309
					if(line != null)	{
310
						tableViewer.setSelection(new StructuredSelection(line), true);
311
						// FIXME: commented because the set top index makes the read of the table difficult
312
						//tableViewer.getTable().setTopIndex(selectedPointInTableRange);
313
					}
314
					else	{
315
						Log.info("Selected progression point doesn't exist in the linked Concordance.");
316
					}
317
				}
318
			});
319
		}
320
		else	{
321
			tableViewer.getTable().deselectAll();
322
		}
323
		
324
		// give back the focus to chart editor
325
		chartEditor.setFocus();
326
	}
327

  
328
	    
329
	/**
330
	 * Updates the linked edition editor.
331
	 * If the editor doesn't exist it will be created.
332
	 * @param editor
333
	 */
334
	public void updateLinkedEditionEditor(TXMBrowser linkedEditor, ArrayList<Integer> selectedPointPositions)	{
335
		
336
		try {
337
			
338
			// Unhighlight all tokens if no selected points
339
			if(selectedPointPositions.size() < 1)	{
340
				linkedEditor.setWordsIds(new ArrayList<String>(), new ArrayList<String>());
341
				linkedEditor.showPage(linkedEditor.getCurrentPage());
342
				return;
343
			}
344
			
345
			Corpus corpus = ((Progression2) chartEditor.getResultData()).getCorpus();
346
			StructuralUnit textS = corpus.getStructuralUnit("text"); //$NON-NLS-1$
347
			Property textP = textS.getProperty("id"); //$NON-NLS-1$
348
			Match selectedWordMatch = new Match(selectedPointPositions.get(selectedPointPositions.size() - 1), selectedPointPositions.get(selectedPointPositions.size() - 1));
349
			String textId = selectedWordMatch.getValueForProperty(textP);
350

  
351
			Text text = corpus.getText(textId);
352
			if(text == null) {
353
				Log.severe("Text " + textId + " is missing.");
354
				return;
355
			}
356

  
357
			Edition edition = text.getEdition(corpus.getMainCorpus().getDefaultEdition());
358
			if(edition == null) {
359
				Log.severe("Default edition is missing.");
360
				return;
361
			}
362

  
363
			// Get the current selected word to highlight more
364
			List<String> selectedWordIds = selectedWordMatch.getValuesForProperty(corpus.getProperty("id")); //$NON-NLS-1$;
365

  
366
			// Get all words to highlight from the progression chart data set
367
			ArrayList<Integer> allPointPositions = chartEditor.getEditorInput().getSWTChartsComponentsProvider().getChartsEngine().getProgressionChartAllPointPositions(chartEditor.getChart());
368
			ArrayList<String> wordIds = new ArrayList<String>(allPointPositions.size());
369
			for(int i = 0; i < allPointPositions.size(); i++) {
370
				Match match = new Match(allPointPositions.get(i), allPointPositions.get(i));
371
				if(match.getValueForProperty(textP).equals(textId)) {
372
					wordIds.add(match.getValueForProperty(corpus.getProperty("id"))); //$NON-NLS-1$;
373
				}
374
			}
375

  
376
			Page openPage = edition.getPageForWordId(selectedWordIds.get(0));
377

  
378
			if(openPage != null) {
379

  
380
				// Create the linked editor if needed
381
				if(linkedEditor == null || linkedEditor.isDisposed()) {
382
					linkedEditor = OpenBrowser.openEdition(openPage.getFile().getAbsolutePath(), openPage.getFile().getName());
383
					linkedEditor.setEdition(edition);
384
					chartEditor.addLinkedEditor(linkedEditor);
385
					
386
					
387
					int position = EModelService.BELOW;;
388
					EditorPart parentEditor = chartEditor;
389
					// Split vertically if there is already a concordance editor otherwise split horizontally
390
					ConcordancesEditor linkedConcordanceEditor = (ConcordancesEditor)chartEditor.getLinkedEditor(ConcordancesEditor.class);
391
					if(linkedConcordanceEditor != null)	{
392
						position = EModelService.RIGHT_OF;
393
						parentEditor = linkedConcordanceEditor;
394
					}
395
					
396
					// Split and add linked editor
397
					SWTEditorsUtils.addEditor(parentEditor, linkedEditor, position);
398
				}
399

  
400
				linkedEditor.showPage(openPage);
401
				// Highlight tokens
402
				linkedEditor.setWordsIds(wordIds, selectedWordIds);
403

  
404
				IWorkbenchPage attachedPage = linkedEditor.getEditorSite().getPage();
405
				attachedPage.activate(linkedEditor);
406
			}
407
		}
408
		catch(Exception e) {
409
			Log.printStackTrace(e);
410
		}
411
	}
412

  
413

  
414

  
415
	
416
	    
417
}
0 418

  
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/handlers/ComputeProgression.java (revision 84)
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.progression.rcp.handlers;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.core.runtime.IProgressMonitor;
34
import org.eclipse.core.runtime.IStatus;
35
import org.eclipse.core.runtime.Status;
36
import org.eclipse.jface.viewers.IStructuredSelection;
37
import org.eclipse.jface.window.Window;
38
import org.eclipse.osgi.util.NLS;
39
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.widgets.Shell;
41
import org.eclipse.ui.handlers.HandlerUtil;
42
import org.txm.Toolbox;
43
import org.txm.chartsengine.core.ChartsEngine;
44
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
45
import org.txm.chartsengine.r.core.RChartsEngine;
46
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
47
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
48
import org.txm.chartsengine.svgbatik.rcp.SVGSWTChartsComponentsProvider;
49
import org.txm.core.preferences.TXMPreferences;
50
import org.txm.progression.core.functions.Progression2;
51
import org.txm.progression.core.messages.TBXProgressionMessages;
52
import org.txm.progression.core.preferences.ProgressionPreferences;
53
import org.txm.progression.rcp.dialogs.ProgressionDialog;
54
import org.txm.progression.rcp.forms.ProgressionParametersComposite;
55
import org.txm.rcpapplication.JobsTimer;
56
import org.txm.rcpapplication.Messages;
57
import org.txm.rcpapplication.StatusLine;
58
import org.txm.rcpapplication.utils.JobHandler;
59
import org.txm.rcpapplication.views.CorporaView;
60
import org.txm.searchengine.cqp.corpus.Corpus;
61
import org.txm.utils.logger.Log;
62

  
63
/**
64
 * Open the ProgressionDialog, computes and opens the result editor part.
65
 * 
66
 * @author mdecorde
67
 * @author sjacquot
68
 */
69
public class ComputeProgression extends AbstractHandler {
70
	
71
	
72
	// 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)?
73
	// adds a double click listener to the Corpus View
74
	static	{
75
		CorporaView.addDoubleClickListener(Progression2.class, "ComputeProgression"); //$NON-NLS-1$
76
	}
77
	
78
	
79
	
80
	/* (non-Javadoc)
81
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
82
	 */
83
	@Override
84
	public Object execute(ExecutionEvent event) throws ExecutionException {
85
		if (!Toolbox.isSearchEngineInitialized()) return false;
86
		
87
		if (!Toolbox.isStatEngineInitialized()) {
88
			Log.severe(TBXProgressionMessages.ComputeProgression_5);
89
			return null;
90
		}
91
		
92
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
93

  
94
		
95
		 
96
		// Computes a new progression
97
		if(selection.getFirstElement() instanceof Corpus)	{
98
			Corpus corpus = (Corpus) selection.getFirstElement();
99

  
100
			if (!Progression2.canRunProgression(corpus)) {
101
				Log.severe(TBXProgressionMessages.ComputeProgression_0);
102
				// La fonctionnalité Progression n'est pas encore disponible pour les sous-corpus discontinus.
103
				return null;
104
			}
105

  
106
			
107
			Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
108
			ProgressionDialog d = new ProgressionDialog(shell, corpus);
109
			
110
			int code = d.open();
111
			if (code == Window.OK) {
112
				computeProgression(d);
113
			}
114

  
115
		}
116
		// Reopens a progression result with default preferences
117
		else if(selection.getFirstElement() instanceof Progression2)	{
118
			openEditor((Progression2) selection.getFirstElement());
119
		}
120
		
121
		return null;
122
	}
123

  
124
	
125
	
126
	
127
	/**
128
	 * 
129
	 * @param progression
130
	 * @param blackAndWhite
131
	 * @param monoStyle
132
	 * @param cumulative
133
	 * @return
134
	 */
135
	public static ChartEditorPart openEditor(Progression2 progression) {
136
		
137
		
138
		
139
		ChartEditorPart editor = null;
140
		
141
		// FIXME: temporary force R/SVG version because the Progression density chart is not yet implemented in JFC mode
142
		if(!TXMPreferences.getBoolean(progression, ProgressionPreferences.CHART_CUMULATIVE))	{
143
			SVGSWTChartsComponentsProvider tmpSWTComponentsProvider = (SVGSWTChartsComponentsProvider) SWTChartsComponentsProvider.getComponentsProvider(SVGSWTChartsComponentsProvider.class);
144
			RChartsEngine tmpChartsEngine = (RChartsEngine) ChartsEngine.getChartsEngine(RChartsEngine.class);									
145
			tmpSWTComponentsProvider.setChartsEngine(tmpChartsEngine);
146
			
147
			// Create and open the chart editor
148
			editor = tmpSWTComponentsProvider.openEditor(progression.getCorpus().getName() + ": " + progression.getName(), progression, ProgressionPreferences.PREFERENCES_NODE);
149
		}
150
		else	{
151
			// Create and open the chart editor
152
			editor = SWTChartsComponentsProvider.getCurrent().openEditor(progression.getCorpus().getName() + ": " + progression.getName(), progression, ProgressionPreferences.PREFERENCES_NODE);
153

  
154
			
155

  
156
			// FIXME: tests parameters composite extension
157
			if(!editor.wasAlreadyOpened())	{
158
				new ProgressionParametersComposite(editor.getParametersComposite(), SWT.NONE);
159
			}
160
			// FIXME: tests to use Fields editor and ScopedPreferenceStore for command parameters
161
//			BooleanFieldEditor field = new BooleanFieldEditor(ChartsEnginePreferences.SHOW_TITLE, "test2 show title store", editor.getParametersComposite());
162
//			field.setPreferenceStore(new TXMPreferenceStore(TXMPreferences.getId(progression)));
163
//			field.load();
164
//			field.store();
165
//			try {
166
//				((ScopedPreferenceStore) field.getPreferenceStore()).save();
167
//			}
168
//			catch(IOException e) {
169
//				// TODO Auto-generated catch block
170
//				e.printStackTrace();
171
//			}
172
			
173
			
174
			// FIXME: to discuss
175
//			// initialize extended menus for item selection
176
//			Menu menu = editor.getComposite().getContextMenu(EventCallBack.AREA_ITEM);
177
//			
178
//			// send to index
179
//			MenuItem sendToIndex = new MenuItem(menu.getItem(0).getMenu(), SWT.CASCADE);
180
//		    sendToIndex.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_INDEX);
181
//		    sendToIndex.setImage(IImageKeys.getImage(IImageKeys.ACTION_INDEX));
182
//		    sendToIndex.addSelectionListener(new ProgressionSelectionListener(editor, BaseSelectionListener.SEND_TO_INDEX));
183
//
184
//		    // send to concordance
185
//			MenuItem sendToConcordance = new MenuItem(menu.getItem(0).getMenu(), SWT.CASCADE);
186
//		    sendToConcordance.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_CONCORDANCE);
187
//		    sendToConcordance.setImage(IImageKeys.getImage(IImageKeys.ACTION_CONCORDANCES));
188
//		    sendToConcordance.addSelectionListener(new ProgressionSelectionListener(editor, BaseSelectionListener.SEND_TO_CONCORDANCE));
189
//		    
190
//		    // send to cooccurrence
191
//			MenuItem sendToCoorccurrence = new MenuItem(menu.getItem(0).getMenu(), SWT.CASCADE);
192
//		    sendToCoorccurrence.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_COOCCURRENCE);
193
//		    sendToCoorccurrence.setImage(IImageKeys.getImage(IImageKeys.ACTION_COOCCURRENCE));
194
//		    sendToCoorccurrence.addSelectionListener(new ProgressionSelectionListener(editor, BaseSelectionListener.SEND_TO_COOCCURRENCE));
195
//		    //*****************************************************
196

  
197
		}
198
		
199
		return editor;
200
	}
201
	
202
	
203
	
204
	
205
	/**
206
	 * Computes progression and open the result editor.
207
	 *
208
	 * @param dialog the dialog box
209
	 */
210
	public static Object computeProgression(final ProgressionDialog dialog) {
211
		if (!Toolbox.isSearchEngineInitialized()) return false;
212
		
213
		JobHandler jobhandler = new JobHandler(NLS.bind(TBXProgressionMessages.ComputeProgression_2, dialog.getQueries(), dialog.getCorpus().getName())) {
214
			@Override
215
			protected IStatus run(IProgressMonitor monitor) {
216
				this.runInit(monitor);
217
				JobsTimer.start();
218
				try {
219
					final Corpus corpus = dialog.getCorpus();
220
					if (dialog.getQueries().size() == 0) {
221
						Log.severe(TBXProgressionMessages.ComputeProgression_6);
222
						return Status.CANCEL_STATUS;
223
					}
224

  
225
					
226
					final Progression2 progression = new Progression2(dialog.getCorpus(), dialog.getQueries(), dialog.getStructuralUnit(), dialog.getStructuralProperty(), dialog.getPropertyregex(),
227
							dialog.isCumulativeType(), dialog.getLineWidth(), dialog.isRepeatvalues(), dialog.getBandeMultiplier());
228

  
229
					
230
					// persistence
231
					if(dialog.isBlackAndWhite())	{
232
						TXMPreferences.putLocalInt(progression, ChartsEnginePreferences.RENDERING_COLORS_MODE, ChartsEngine.RENDERING_MONOCHROME_MODE);	
233
					}
234
					TXMPreferences.putLocalBoolean(progression, ProgressionPreferences.CHART_MONO_STYLE, dialog.isMonoStyle());
235
					TXMPreferences.putLocalBoolean(progression, ProgressionPreferences.CHART_CUMULATIVE, dialog.isCumulativeType());
236
					
237
					
238
					
239
					Log.info(NLS.bind(TBXProgressionMessages.ComputeProgression_4, 
240
							new Object[]{dialog.getCorpus(), dialog.getQueries(), dialog.getStructuralUnit(), dialog.getStructuralProperty(), dialog.isCumulativeType()}));
241
					
242
					
243
					
244
					monitor.worked(50);
245
					if (monitor.isCanceled())
246
						return Status.CANCEL_STATUS;
247
					boolean success = true;//progression.process();
248

  
249
					if (!progression.stepQueries()) {
250
						System.out.println(TBXProgressionMessages.ComputeProgression_3);
251
						return Status.CANCEL_STATUS;
252
					}
253
					if (monitor.isCanceled()) return Status.CANCEL_STATUS;
254
					monitor.worked(10);
255

  
256
					if (!progression.stepStructuralUnits() || monitor.isCanceled())
257
						return Status.CANCEL_STATUS;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff