Revision 130

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

  
tmp/org.txm.chartsengine.rcp/OSGI-INF/l10n/bundle.properties (revision 130)
1
ChartEditorToolBar_SHARED_BUTTON_EXPORT_VIEW_LABEL=Export view
2
ChartEditorToolBar_SHARED_BUTTON_EXPORT_VIEW_TOOLTIP=Export the current view
3
ChartEditorToolBar_SHARED_BUTTON_RESET_VIEW_LABEL=Reset view
4
ChartEditorToolBar_SHARED_BUTTON_RESET_VIEW_TOOLTIP=Reset the chart view
5
ChartsEnginePreferencePage_COMBO_FIELD_SELECT_DISPLAY_FORMAT_LABEL=Display format
6
ChartsEnginePreferencePage_COMBO_FIELD_SELECT_ENGINE_LABEL=Current Engine
7
ChartsEnginePreferencePage_LOG_RECREATING_CHARTS_ENGINE=Recreating Charts Engine and SWT chart components provider
8
ChartsEnginePreferencePage_PreferencesWillBeAppliedToNewChart=These preferences will apply to new charts, previously created charts will not be affected.
9
ChartsEnginePreferencePage_RenderingColorsMode=Rendering colors mode
10
ChartsEnginePreferencePage_RenderingModeBlackAndWhite=Black and white
11
ChartsEnginePreferencePage_RenderingModeColors=Colors
12
ChartsEnginePreferencePage_RenderingModeGrayscale=Grayscale
13
ChartsEngineSharedPreferencePage_CHARTS_RENDERING_DEFAULT_PREFERENCES=Charts rendering
14
command.description = Reset the chart view
15
command.description.0 = Export the current view
16
command.description.1 = Copy the current view to clipboard
17
command.name = Reset view
18
command.name.0 = Export view
19
command.name.1 = Copy chart view to clipboard
20
page.name = Charts Engine
21
SWTChartsComponentProvider_CA_TOOLBAR_AXES_SELECTION_COMBO_BOX_LABEL=Axes: 
22
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL=Show columns
23
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_TOOLTIP=Show/hide the column points
24
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL=Show rows
25
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_TOOLTIP=Show/hide the row points
26
SWTChartsComponentProvider_CAH_TOOLBAR_BUTTON_NUMBER_OF_CLUSTERS=Number of clusters: 
27
SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_CONCORDANCE=Send selection to concordance
28
SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_COOCCURRENCE=Send selection to cooccurrence
29
SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_INDEX=Send selection to index
30
SWTChartsComponentProvider_SHOW_GRID=Show grid
31
SWTChartsComponentProvider_SHOW_LEGEND=Show legend
32
SWTChartsComponentProvider_SHOW_TITLE=Show title
0 33

  
tmp/org.txm.chartsengine.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 130)
1
ChartEditorToolBar_SHARED_BUTTON_EXPORT_VIEW_LABEL=Exporter la vue
2
ChartEditorToolBar_SHARED_BUTTON_EXPORT_VIEW_TOOLTIP=Exporter la vue actuelle du graphique
3
ChartEditorToolBar_SHARED_BUTTON_RESET_VIEW_LABEL=Rétablir la vue initiale
4
ChartEditorToolBar_SHARED_BUTTON_RESET_VIEW_TOOLTIP=Rétablir la vue initiale
5
ChartsEnginePreferencePage_COMBO_FIELD_SELECT_DISPLAY_FORMAT_LABEL=Format d'affichage
6
ChartsEnginePreferencePage_COMBO_FIELD_SELECT_ENGINE_LABEL=Moteur de graphiques courant
7
ChartsEnginePreferencePage_LOG_RECREATING_CHARTS_ENGINE=Réinitialisation du moteur de production de graphiques et du fournisseur de composants SWT
8
ChartsEnginePreferencePage_RenderingColorsMode=Mode de rendu des couleurs
9
ChartsEnginePreferencePage_RenderingModeBlackAndWhite=Noir et blanc
10
ChartsEnginePreferencePage_RenderingModeColors=Couleurs
11
ChartsEnginePreferencePage_RenderingModeGrayscale=Niveaux de gris
12
ChartsEngineSharedPreferencePage_CHARTS_RENDERING_DEFAULT_PREFERENCES=Rendu des graphiques
13
command.description = Rétablir la vue initiale
14
command.description.0 = Exporter la vue actuelle du graphique
15
command.description.1 = Copier la vue dans le presse-papier
16
command.name = Rétablir la vue initiale
17
command.name.0 = Exporter la vue
18
command.name.1 = Copier la vue dans le presse-papier
19
page.name = Moteur de Graphiques 2
20
SWTChartsComponentProvider_CA_TOOLBAR_AXES_SELECTION_COMBO_BOX_LABEL=Axes : 
21
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL=Afficher les colonnes
22
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_TOOLTIP=Afficher/masquer les points-colonnes
23
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL=Afficher les lignes
24
SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_TOOLTIP=Afficher/masquer les points-lignes
25
SWTChartsComponentProvider_CAH_TOOLBAR_BUTTON_NUMBER_OF_CLUSTERS=Nombre de clusters : 
26
SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_CONCORDANCE=Envoyer la sélection vers la concordance
27
SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_COOCCURRENCE=Envoyer la sélection vers la cooccurrence
28
SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_INDEX=Envoyer la s�lection vers l'index
29
SWTChartsComponentProvider_SHOW_GRID=Afficher la grille
30
SWTChartsComponentProvider_SHOW_LEGEND=Afficher la légende
31
SWTChartsComponentProvider_SHOW_TITLE=Afficher le titre
0 32

  
tmp/org.txm.chartsengine.rcp/plugin.xml (revision 130)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension-point id="org.txm.rcp.swtchartscomponentsprovider" name="SWT Charts Component Provider" schema="schema/org.txm.rcp.swtchartscomponentsprovider.exsd"/>
5
   <extension-point id="org.txm.chartsengine.eventcallback" name="Chart composite event call back" schema="schema/org.txm.chartsengine.eventcallback.exsd"/>
6
   <extension
7
         point="org.eclipse.ui.preferencePages">
8
      <page
9
            category="org.txm.rcpapplication.preferences.AdvancePreferencePage"
10
            class="org.txm.chartsengine.rcp.preferences.ChartsEnginePreferencePage"
11
            id="org.txm.rcp.chartsengine.core.preferences.ChartsEnginePreferencePage"
12
            name="%page.name">
13
      </page>
14
   </extension>
15
   <extension
16
         point="org.eclipse.ui.bindings">
17
      <key
18
            commandId="ResetChartView"
19
            contextId="org.eclipse.ui.contexts.window"
20
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
21
            sequence="M1+R">
22
      </key>
23
      <key
24
            commandId="ExportChartEditorView"
25
            contextId="org.eclipse.ui.contexts.window"
26
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
27
            sequence="M1+E">
28
      </key>
29
      <key
30
            commandId="CopyChartViewToClipboard"
31
            contextId="org.eclipse.ui.contexts.window"
32
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
33
            sequence="M1+C">
34
      </key>
35
   </extension>
36
   <extension
37
         point="org.eclipse.ui.editors">
38
      <editor
39
            class="org.txm.chartsengine.rcp.editors.ChartEditorPart"
40
            default="false"
41
            id="org.txm.chartsengine.rcp.editors.ChartEditorPart"
42
            name="Chart Editor Part">
43
      </editor>
44
   </extension>
45
   <extension
46
         point="org.eclipse.ui.menus">
47
      <menuContribution
48
            allPopups="false"
49
            locationURI="toolbar:ChartEditorToolBar">
50
         <command
51
               commandId="ExportChartEditorView"
52
               icon="icons/charts_export_view.png"
53
               style="push">
54
         </command>
55
         <command
56
               commandId="ResetChartView"
57
               icon="icons/charts_reset_view.png"
58
               style="push">
59
         </command>
60
         <command
61
               commandId="CopyChartViewToClipboard"
62
               icon="icons/charts_copy_view.gif"
63
               style="push">
64
         </command>
65
      </menuContribution>
66
      <menuContribution
67
            allPopups="false"
68
            locationURI="popup:ChartEditorContextMenu">
69
         <command
70
               commandId="ExportChartEditorView"
71
               icon="icons/charts_export_view.png"
72
               style="push">
73
         </command>
74
         <command
75
               commandId="ResetChartView"
76
               icon="icons/charts_reset_view.png"
77
               style="push">
78
         </command>
79
         <command
80
               commandId="CopyChartViewToClipboard"
81
               icon="icons/charts_copy_view.gif"
82
               style="push">
83
         </command>
84
      </menuContribution>
85
   </extension>
86
   <extension
87
         point="org.eclipse.ui.commands">
88
      <command
89
            defaultHandler="org.txm.chartsengine.rcp.handlers.ResetChartView"
90
            id="ResetChartView"
91
            name="%command.name">
92
      </command>
93
      <command
94
            defaultHandler="org.txm.chartsengine.rcp.handlers.ExportChartEditorView"
95
            id="ExportChartEditorView"
96
            name="%command.name.0">
97
      </command>
98
      <command
99
            defaultHandler="org.txm.chartsengine.rcp.handlers.CopyChartViewToClipboard"
100
            id="CopyChartViewToClipboard"
101
            name="%command.name.1">
102
      </command>
103
   </extension>
104

  
105
</plugin>
0 106

  
tmp/org.txm.chartsengine.rcp/.settings/org.eclipse.jdt.core.prefs (revision 130)
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.chartsengine.rcp/.classpath (revision 130)
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.chartsengine.rcp/META-INF/MANIFEST.MF (revision 130)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Charts Engine Editors Core
4
Bundle-SymbolicName: org.txm.chartsengine.rcp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
7
Require-Bundle: org.eclipse.core.resources,
8
 org.txm.chartsengine.core;bundle-version="1.0.0";visibility:=reexport,
9
 org.eclipse.ui;bundle-version="3.106.1";visibility:=reexport,
10
 org.eclipse.core.runtime;bundle-version="3.10.0",
11
 org.txm.core;bundle-version="0.7.0",
12
 org.txm.rcp;bundle-version="0.7.8",
13
 org.eclipse.swt
14
Export-Package: org.txm.chartsengine.rcp,
15
 org.txm.chartsengine.rcp.editors,
16
 org.txm.chartsengine.rcp.events,
17
 org.txm.chartsengine.rcp.handlers,
18
 org.txm.chartsengine.rcp.messages,
19
 org.txm.chartsengine.rcp.preferences,
20
 org.txm.chartsengine.rcp.swt
21
Bundle-Vendor: TXM
0 22

  
tmp/org.txm.chartsengine.rcp/schema/org.txm.rcp.swtchartscomponentsprovider.exsd (revision 130)
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.txm.chartsengine.rcp" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.txm.chartsengine.rcp" id="org.txm.rcp.swtchartscomponentsprovider" name="SWT Charts Component Provider"/>
7
      </appinfo>
8
      <documentation>
9
         [Enter description of this extension point.]
10
      </documentation>
11
   </annotation>
12

  
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
19
      <complexType>
20
         <choice minOccurs="1" maxOccurs="unbounded">
21
            <element ref="SWTChartsComponentsProvider"/>
22
         </choice>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appinfo>
43
                  <meta.attribute translatable="true"/>
44
               </appinfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49

  
50
   <element name="SWTChartsComponentsProvider">
51
      <complexType>
52
         <attribute name="class" type="string">
53
            <annotation>
54
               <documentation>
55
                  
56
               </documentation>
57
               <appinfo>
58
                  <meta.attribute kind="java" basedOn="SWTChartsComponentProvider2:"/>
59
               </appinfo>
60
            </annotation>
61
         </attribute>
62
         <attribute name="name" type="string" use="required">
63
            <annotation>
64
               <documentation>
65
                  
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
         <attribute name="inputFormat" type="string" use="required">
70
            <annotation>
71
               <documentation>
72
                  List of input formats supported by the editors of the SWT components provider, eg. &quot;bmp,png&quot;.
73
               </documentation>
74
            </annotation>
75
         </attribute>
76
      </complexType>
77
   </element>
78

  
79
   <annotation>
80
      <appinfo>
81
         <meta.section type="since"/>
82
      </appinfo>
83
      <documentation>
84
         [Enter the first release in which this extension point appears.]
85
      </documentation>
86
   </annotation>
87

  
88
   <annotation>
89
      <appinfo>
90
         <meta.section type="examples"/>
91
      </appinfo>
92
      <documentation>
93
         [Enter extension point usage example here.]
94
      </documentation>
95
   </annotation>
96

  
97
   <annotation>
98
      <appinfo>
99
         <meta.section type="apiinfo"/>
100
      </appinfo>
101
      <documentation>
102
         [Enter API information here.]
103
      </documentation>
104
   </annotation>
105

  
106
   <annotation>
107
      <appinfo>
108
         <meta.section type="implementation"/>
109
      </appinfo>
110
      <documentation>
111
         [Enter information about supplied implementation of this extension point.]
112
      </documentation>
113
   </annotation>
114

  
115

  
116
</schema>
0 117

  
tmp/org.txm.chartsengine.rcp/schema/org.txm.chartsengine.eventcallback.exsd (revision 130)
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.txm.chartsengine.rcp" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.txm.chartsengine.rcp" id="org.txm.chartsengine.eventcallback" name="Chart composite event call back"/>
7
      </appinfo>
8
      <documentation>
9
         [Enter description of this extension point.]
10
      </documentation>
11
   </annotation>
12

  
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
19
      <complexType>
20
         <choice minOccurs="1" maxOccurs="unbounded">
21
            <element ref="EventCallBack"/>
22
         </choice>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appinfo>
43
                  <meta.attribute translatable="true"/>
44
               </appinfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49

  
50
   <element name="EventCallBack">
51
      <complexType>
52
         <attribute name="class" type="string">
53
            <annotation>
54
               <documentation>
55
                  
56
               </documentation>
57
               <appinfo>
58
                  <meta.attribute kind="java" basedOn="org.txm.chartsengine.rcp.events.EventCallBack:"/>
59
               </appinfo>
60
            </annotation>
61
         </attribute>
62
         <attribute name="chartsEngineName" type="string" use="default" value="jfreechart_charts_engine">
63
            <annotation>
64
               <documentation>
65
                  The charts engine name linked to the callback.
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
         <attribute name="resultDataClass" type="string">
70
            <annotation>
71
               <documentation>
72
                  The result class linked to the callback.
73
               </documentation>
74
            </annotation>
75
         </attribute>
76
      </complexType>
77
   </element>
78

  
79
   <annotation>
80
      <appinfo>
81
         <meta.section type="since"/>
82
      </appinfo>
83
      <documentation>
84
         [Enter the first release in which this extension point appears.]
85
      </documentation>
86
   </annotation>
87

  
88
   <annotation>
89
      <appinfo>
90
         <meta.section type="examples"/>
91
      </appinfo>
92
      <documentation>
93
         [Enter extension point usage example here.]
94
      </documentation>
95
   </annotation>
96

  
97
   <annotation>
98
      <appinfo>
99
         <meta.section type="apiinfo"/>
100
      </appinfo>
101
      <documentation>
102
         [Enter API information here.]
103
      </documentation>
104
   </annotation>
105

  
106
   <annotation>
107
      <appinfo>
108
         <meta.section type="implementation"/>
109
      </appinfo>
110
      <documentation>
111
         [Enter information about supplied implementation of this extension point.]
112
      </documentation>
113
   </annotation>
114

  
115

  
116
</schema>
0 117

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

  
3

  
4
import java.awt.event.MouseEvent;
5
import java.awt.event.MouseListener;
6
import java.awt.event.MouseMotionListener;
7
import java.io.File;
8
import java.util.ArrayList;
9
import java.util.Arrays;
10
import java.util.List;
11
import java.util.Properties;
12

  
13
import javax.swing.JComponent;
14

  
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.jface.preference.BooleanFieldEditor;
19
import org.eclipse.jface.preference.ComboFieldEditor;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.graphics.Point;
22
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.layout.RowLayout;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Event;
26
import org.eclipse.swt.widgets.Group;
27
import org.eclipse.swt.widgets.Label;
28
import org.eclipse.swt.widgets.Listener;
29
import org.eclipse.swt.widgets.TabFolder;
30
import org.eclipse.swt.widgets.TabItem;
31
import org.eclipse.swt.widgets.ToolBar;
32
import org.eclipse.ui.IWorkbenchPage;
33
import org.eclipse.ui.IWorkbenchWindow;
34
import org.eclipse.ui.PartInitException;
35
import org.eclipse.ui.PlatformUI;
36
import org.txm.chartsengine.core.ChartCreator;
37
import org.txm.chartsengine.core.ChartsEngine;
38
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
39
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
40
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
41
import org.txm.chartsengine.rcp.events.EventCallBack;
42
import org.txm.chartsengine.rcp.events.EventCallBackHandler;
43
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages;
44
import org.txm.chartsengine.rcp.preferences.___KeyboardBindingProperties;
45
import org.txm.chartsengine.rcp.preferences.___MouseBindingProperties;
46
import org.txm.chartsengine.rcp.swt.ChartComposite;
47
import org.txm.functions.TXMResult;
48
import org.txm.rcp.preferences.TXMPreferencePage;
49
import org.txm.utils.logger.Log;
50

  
51
/**
52
 * A class providing EditorPart and EditorInput according to the current charts engine.
53
 * @author sjacquot
54
 * 
55
 */
56
public abstract class SWTChartsComponentsProvider {
57

  
58
	/**
59
	 * The charts engine.
60
	 */
61
	protected ChartsEngine chartsEngine;
62

  
63

  
64
	/**
65
	 * The name of the provider.
66
	 */
67
	protected String name;
68
	
69
	/**
70
	 * The supported editor input formats.
71
	 */
72
	protected List<String> supportedInputFormats;
73
	
74
	
75
	/**
76
	 * Mouse control properties which will be shared by all implementations and chart editors.
77
	 */
78
	protected Properties mouseBindingProperties;
79

  
80

  
81
	/**
82
	 * Keyboard control properties which will be shared by all implementations and chart editors.
83
	 */
84
	protected Properties keyboardBindingProperties;
85

  
86

  
87
	
88
	/**
89
	 * Installed SWT charts components providers.
90
	 */
91
	protected static ArrayList<SWTChartsComponentsProvider> chartsComponentsProviders;
92
	
93
	/**
94
	 * Current SWT charts components provider index in the providers list.
95
	 */
96
	protected static int currentChartsComponentsProviderIndex;
97
	
98
	
99
	
100
	public SWTChartsComponentsProvider(ChartsEngine chartsEngine, Properties mouseBindingProperties, Properties keyboardBindingProperties) {
101
		this.chartsEngine = chartsEngine;
102

  
103
		this.mouseBindingProperties = mouseBindingProperties;
104
		this.keyboardBindingProperties = keyboardBindingProperties;
105

  
106
		// FIXME: chart engine plugin split tests
107
	//	this.chartEditorCreators = new HashMap<Class, ChartEditorCreator>();
108
		
109

  
110
		// FIXME : see if we need to define the L&F as system for AWT/Swing components
111
		// If yes, we need to find a way to manage the GTK L&F/Linux bug, see ticket #761
112
        // System Look and feel
113
//        try {
114
//			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
115
//		}
116
//		catch(ClassNotFoundException e) {
117
//			// TODO Auto-generated catch block
118
//			e.printStackTrace();
119
//		}
120
//		catch(InstantiationException e) {
121
//			// TODO Auto-generated catch block
122
//			e.printStackTrace();
123
//		}
124
//		catch(IllegalAccessException e) {
125
//			// TODO Auto-generated catch block
126
//			e.printStackTrace();
127
//		}
128
//		catch(UnsupportedLookAndFeelException e) {
129
//			// TODO Auto-generated catch block
130
//			e.printStackTrace();
131
//		}
132
	}
133

  
134
	
135
	public SWTChartsComponentsProvider(ChartsEngine chartsEngine) {
136
		this(chartsEngine, new ___MouseBindingProperties(), new ___KeyboardBindingProperties());
137
	}
138

  
139
	
140
	public SWTChartsComponentsProvider() {
141
		this(null);
142
	}
143

  
144
	
145
	
146
	/**
147
	 * Creates and return a SWT EditorPart filled with a new chart for the specified result and chart type.
148
	 * @param editorInputName
149
	 * @param resultData
150
	 * @param preferencesNode
151
	 * @param chartType
152
	 * @return
153
	 */
154
	public ChartEditorPart createChartEditor(String editorInputName, TXMResult resultData, String preferencesNode, String chartType) {
155
		ChartEditorInput chartEditorInput = new ChartEditorInput(this, editorInputName, resultData, preferencesNode, chartType, null);
156
		this.createChart(chartEditorInput, resultData, preferencesNode, chartType);
157
		ChartEditorPart editor = new ChartEditorPart(this, chartEditorInput);
158
		return editor;
159
	}
160

  
161
	
162
	
163
	/**
164
	 * Creates a new chart for the specified result data and save it in the specified editor input.
165
	 * A chart editor created with the editor input will be filled with chart.
166
	 * @param chartEditorInput
167
	 * @param resultData
168
	 * @param params
169
	 */
170
	public void createChart(ChartEditorInput chartEditorInput, TXMResult resultData, String preferencesNode)	{
171
		this.createChart(chartEditorInput, resultData, preferencesNode, chartEditorInput.getChartType()); 
172
	}
173
	
174
	/**
175
	 * Creates a new chart for the specified result data and chart type and save it in the specified editor input.
176
	 * A chart editor created with the editor input will be filled with chart.
177
	 * @param chartEditorInput
178
	 * @param resultData
179
	 * @param chartType
180
	 * @param params
181
	 */
182
	protected abstract boolean createChart(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput, TXMResult resultData, String preferencesNode, String chartType);
183
	
184
	/**
185
	 * Creates a new chart for the specified result data and chart type and save it in the specified editor input.
186
	 * @param chartEditorInput
187
	 * @param resultData
188
	 * @param chartType
189
	 * @param params
190
	 * @return
191
	 */
192
	protected boolean createChart(ChartEditorInput chartEditorInput, TXMResult resultData, String preferencesNode, String chartType)	{
193
		return this.createChart(this.getChartsEngine(), chartEditorInput, resultData, preferencesNode, chartType);
194
	}
195
	
196
	
197
	/**
198
	 * Updates the specified chart stored in the editor and according to the stored TXM result.
199
	 * @param chartsEngine
200
	 * @param editor
201
	 * @param chartType
202
	 * @param command
203
	 * @param params
204
	 * @return
205
	 */
206
	public boolean updateChart(ChartEditorPart editor, String preferencesNode, String chartType)	{
207
		ChartCreator chartCreator = this.chartsEngine.getChartCreator(editor.getResultData().getClass(), chartType);
208
		if(chartCreator != null)	{
209
			chartCreator.updateChart(editor.getChart(), editor.getResultData(), preferencesNode);
210
			return true;
211
		}
212
		return false;
213
	}
214
	
215
	
216
	/**
217
	 * Updates the specified chart stored in the editor and according to the stored TXM result.
218
	 * @param editor
219
	 * @param command
220
	 * @param params
221
	 * @return
222
	 */
223
	public boolean updateChart(ChartEditorPart editor)	{
224
		return this.updateChart(editor, editor.getPreferencesNodeQualifier(), editor.getChartType());
225
	}
226
	
227

  
228
	
229
	/**
230
	 * Creates and stores SWT charts components providers from installed extension contributions and define the current one according to the specified charts engine output format and provider supported input format.
231
	 * @return
232
	 */
233
	public static void createSWTChartsComponentsProviders()	{
234
		
235
		
236
		SWTChartsComponentsProvider.chartsComponentsProviders = new ArrayList<SWTChartsComponentsProvider>();
237
		
238
		String extensionPointId = "org.txm.rcp.swtchartscomponentsprovider"; //$NON-NLS-1$
239
		IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId);
240
		
241
		for(int i = 0; i < contributions.length; i++) {
242
			
243
			// FIXME: to manage more than one input format, Store them in the class rather than in the extension schema?
244
			String formatsStr = contributions[i].getAttribute("inputFormat").replace(" ", "").trim();
245
			String[] formats = formatsStr.split(",");
246
			
247
			try {
248
				SWTChartsComponentsProvider swtChartsComponentsProvider = (SWTChartsComponentsProvider)contributions[i].createExecutableExtension("class");  //$NON-NLS-1$
249
				swtChartsComponentsProvider.setName(contributions[i].getAttribute("name")); //$NON-NLS-1$
250
				swtChartsComponentsProvider.setEditorSupportedInputFormat(Arrays.asList(formats));
251
				
252
				// Add the first charts engine that supports the input format
253
				ChartsEngine chartsEngine = null;
254
				for(int j = 0; j < formats.length; j++) {
255
					chartsEngine = ChartsEngine.getChartsEngine(formats[j]);
256
					if(chartsEngine != null)	{
257
						break;
258
					}
259
				}
260
				swtChartsComponentsProvider.setChartsEngine(chartsEngine);					
261
				
262
				SWTChartsComponentsProvider.chartsComponentsProviders.add(swtChartsComponentsProvider);
263
				Log.warning("Starting SWT charts components provider: " + swtChartsComponentsProvider);
264
				
265
				
266
			}
267
			catch(CoreException e) {
268
				// TODO Auto-generated catch block
269
				e.printStackTrace();
270
			}
271
		}
272
	}
273
	
274
	
275
	/**
276
	 * Gets the current charts component provider.
277
	 * @return the current charts engine
278
	 */
279
	public static SWTChartsComponentsProvider getCurrent()	{
280
		return SWTChartsComponentsProvider.chartsComponentsProviders.get(SWTChartsComponentsProvider.currentChartsComponentsProviderIndex);
281
	}
282
	
283
	/**
284
	 * Sets the current charts component provider according to the specified charts engine output format and provider supported input format. 
285
	 * @param name the name of the charts engine to set as current
286
	 */
287
	public static void setCurrrentComponentsProvider(ChartsEngine chartsEngine)	{
288
		for(int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
289
			if(SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getEditorSupportedInputFormats().contains(chartsEngine.getOutputFormat()))	{
290
				// Set new charts engine
291
				SWTChartsComponentsProvider.chartsComponentsProviders.get(i).setChartsEngine(chartsEngine);
292
				
293
				SWTChartsComponentsProvider.currentChartsComponentsProviderIndex = i;
294
				Log.warning("Set current SWT charts components provider to: " + SWTChartsComponentsProvider.getCurrent());
295
				break;
296
			}
297
		}
298
	}
299
	
300
	
301
	/**
302
	 * Gets an SWT charts component provider according to the specified charts engine output format and provider supported input format. 
303
	 * @param chartsEngine
304
	 * @return
305
	 */
306
	public static SWTChartsComponentsProvider getComponentsProvider(ChartsEngine chartsEngine)	{
307
		
308
		SWTChartsComponentsProvider chartsComponentsProvider = null;
309
		
310
		for(int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
311
			if(SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getEditorSupportedInputFormats().contains(chartsEngine.getOutputFormat()))	{
312

  
313
				chartsComponentsProvider = SWTChartsComponentsProvider.chartsComponentsProviders.get(i);
314
				break;
315
			}
316
		}
317
		
318
		return chartsComponentsProvider;
319
	}
320
	
321
	
322
	/**
323
	 * Gets an installed charts components provider according to its class type.
324
	 * @param type
325
	 * @return the installed charts components provider according to its class type if it exists otherwise null;
326
	 */
327
	public static SWTChartsComponentsProvider getComponentsProvider(Class type)	{
328
		SWTChartsComponentsProvider provider = null;
329
		for(int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
330
			if(SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getClass().equals(type))	{
331
				provider = SWTChartsComponentsProvider.chartsComponentsProviders.get(i);
332
				break;
333
			}
334
		}
335
		return provider;
336
	}
337
	
338

  
339
//	/**
340
//	 * Creates and return a SWT EditorPart for the specified CA result.
341
//	 * @param ca
342
//	 * @return a SWT EditorPart
343
//	 */
344
//	public abstract ChartEditorPart createCAFactorialMapChartEditorPart(CA ca);
345
//
346
//
347
//	/**
348
//	 * Creates and return a SWT EditorPart for the singular values of the specified CA result.
349
//	 * @param ca
350
//	 * @return a SWT EditorPart
351
//	 */
352
//	public abstract ChartEditorPart createCASingularValuesBarChartEditorPart(CA ca);
353
//
354

  
355
	/**
356
	 * Creates and return a SWT EditorPart for the specified CAH result.
357
	 * @param cah
358
	 * @return a SWT EditorPart
359
	 */
360
//	public abstract ChartEditorPart createCAHChartEditorPart(Image titleImage, CAH cah);
361

  
362

  
363
	/**
364
	 * Creates and return a SWT EditorPart for the specified dimensions of partition result.
365
	 * @param titleImage
366
	 * @param partition
367
	 * @param sortPartsBySize
368
	 * @return a SWT EditorPart
369
	 */
370
//	public abstract ChartEditorPart createDimensionsPartitionChartEditorPart(Image titleImage, Partition partition, boolean sortPartsBySize);
371

  
372

  
373
	/**
374
	 * Creates and return a SWT EditorPart for the specified specificities result.
375
	 * @param titleImage the editor title image
376
	 * @param specificitiesResult the specificities result
377
	 * @param typeNames the type names
378
	 * @param partNames the part names
379
	 * @param specIndex the specificities indices
380
	 * @param transpose the transpose
381
	 * @param drawBars the draw bar chart state
382
	 * @param drawLines the draw line chart state
383
	 * @param banalite
384
	 * @param monochrome
385
	 * @return
386
	 */
387
//	public abstract ChartEditorPart createSpecificitiesChartEditorPart(Image titleImage, SpecificitesResult specificitiesResult, boolean transpose, boolean drawBars, boolean drawLines, float banalite, boolean monochrome);
388

  
389

  
390
	/**
391
	 * Creates and return a SWT EditorPart for the specified progression result.
392
	 * @param titleImage
393
	 * @param progression
394
	 * @param monochrome
395
	 * @param monostyle
396
	 * @param doCumulative
397
	 * @param file
398
	 * @return
399
	 */
400
	//public abstract ChartEditorPart createProgressionChartEditorPart(Image titleImage, Progression progression, boolean monochrome, boolean monostyle, boolean doCumulative);
401

  
402

  
403
	/**
404
	 * Set the current charts engine.
405
	 * @param chartsEngine the chartsEngine to set
406
	 */
407
	public void setChartsEngine(ChartsEngine chartsEngine) {
408
		this.chartsEngine = chartsEngine;
409
	}
410

  
411

  
412
	/**
413
	 * Gets the charts engine.
414
	 * @return the chartsEngine
415
	 */
416
	public ChartsEngine getChartsEngine() {
417
		return chartsEngine;
418
	}
419

  
420

  
421
	 /**
422
	  * Creates the chart drawing area composite.
423
	  * @param parent
424
	  * @param style
425
	  * @return the composite
426
	  */
427
	 public abstract ChartComposite createComposite(ChartEditorPart chartEditor, Composite parent);
428

  
429

  
430
	/**
431
	 * Returns the export formats supported by the implementation of the <code>EditorPart</code> for the view.
432
	 * @return
433
	 */
434
	public abstract ArrayList<String> getEditorSupportedExportFileFormats();
435
	
436
	/**
437
	 * Returns the input formats supported by the implementation of the <code>EditorPart</code> for viewing.
438
	 * @return
439
	 */
440
	public List<String> getEditorSupportedInputFormats()	{
441
		return this.supportedInputFormats;
442
	}
443
	
444

  
445
	/**
446
	 * Sets the input formats supported by the implementation of the <code>EditorPart</code> for viewing.
447
	 * @param supportedInputFormats
448
	 */
449
	public void setEditorSupportedInputFormat(List<String> supportedInputFormats)	{
450
		this.supportedInputFormats = supportedInputFormats;
451
	}
452
	
453
	/**
454
	 * Returns the export formats supported by the implementation of the <code>ChartsEngine</code> for the total chart.
455
	 * @return
456
	 */
457
	public abstract ArrayList<String> getChartsEngineSupportedExportFileFormats();
458

  
459

  
460
	/**
461
	 * Creates a SWT group for the charts engine default preferences area in preference pages.
462
	 * @return
463
	 */
464
	public static Group createChartsRenderingPreferencesGroup(Composite parent)	{
465

  
466
		Group chartsGroup = new Group(parent, SWT.NONE);
467

  
468
		chartsGroup.setText(SWTComponentsProviderMessages.ChartsEngineSharedPreferencePage_CHARTS_RENDERING_DEFAULT_PREFERENCES);
469

  
470
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
471
		gridData.horizontalSpan = 2;
472
		gridData.verticalIndent = 10;
473
		chartsGroup.setLayoutData(gridData);
474

  
475
		return chartsGroup;
476
	}
477
	
478
	/**
479
	 * Creates a tab folder with a tab item for rendering preferences.
480
	 * @param parent
481
	 * @return
482
	 */
483
	public static Composite createChartsRenderingPreferencesTabFolderComposite(Composite parent)	{
484

  
485
		
486
		TabFolder tabFolder = new TabFolder(parent, SWT.TOP);
487
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
488
		gridData.horizontalSpan = 2;
489
		tabFolder.setLayoutData(gridData);
490

  
491
		TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
492
		tabItem.setText(SWTComponentsProviderMessages.ChartsEngineSharedPreferencePage_CHARTS_RENDERING_DEFAULT_PREFERENCES);
493
		Composite composite = new Composite(tabFolder, SWT.NULL);
494
		tabItem.setControl(composite);
495
		
496

  
497
		return composite;
498
	}
499
	
500
	/**
501
	 * 
502
	 * @param page
503
	 * @param composite
504
	 */
505
	public static void createChartsRenderingPreferencesFields(TXMPreferencePage page, Composite composite)	{
506
		
507
		Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
508
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
509
		gridData.horizontalSpan = 2;
510
		separator.setLayoutData(gridData);
511

  
512
		
513
		page.addField(new BooleanFieldEditor(ChartsEnginePreferences.SHOW_TITLE, SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_TITLE, composite));
514
		page.addField(new BooleanFieldEditor(ChartsEnginePreferences.SHOW_LEGEND, SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_LEGEND, composite));
515
		page.addField(new BooleanFieldEditor(ChartsEnginePreferences.SHOW_GRID, SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_GRID, composite));
516

  
517
		// Rendering colors mode selection
518
		String colorsModes[][] = new String[3][2];
519
		colorsModes[0][0] = SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeColors;
520
		colorsModes[0][1] = "0"; //$NON-NLS-1$
521
		colorsModes[1][0] = SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeGrayscale;
522
		colorsModes[1][1] = "1"; //$NON-NLS-1$
523
		colorsModes[2][0] = SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeBlackAndWhite;
524
		colorsModes[2][1] = "2"; //$NON-NLS-1$
525
		
526
		ComboFieldEditor renderingModeComboField = new ComboFieldEditor(ChartsEnginePreferences.RENDERING_COLORS_MODE, SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingColorsMode, colorsModes, composite);
527
		page.addField(renderingModeComboField);
528

  
529
	}
530
	
531

  
532
	/**
533
	 * Creates a composite panel used to extend the default tool bar.
534
	 * @param toolBar
535
	 * @return
536
	 */
537
	// FIXME: became useless ?
538
	public static Composite createToolBarParametersPanel(ToolBar toolBar)	{
539

  
540
		Composite parametersPanel = new Composite(toolBar, SWT.NONE);
541

  
542
		RowLayout layout = new RowLayout();
543
		layout.wrap = true;
544
		layout.center = true;
545
		layout.marginTop = 0;
546
		layout.marginBottom = 0;
547
		layout.marginHeight = 0;
548
		parametersPanel.setLayout(layout);
549

  
550
		return parametersPanel;
551
	}
552

  
553
	/**
554
	 * Export the current view of chart editor in the specified file.
555
	 * @param chartEditor
556
	 * @param file
557
	 * @param fileFormat
558
	 * @return
559
	 */
560
	public abstract File exportView(ChartEditorPart chartEditor, File file, String fileFormat);
561

  
562
	
563
	/**
564
	 * Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part.
565
	 * The ID of the editor and the chart type are the editor input result data class name.
566
	 * @param chartEditorInput
567
	 * @return
568
	 */
569
	public ChartEditorPart openEditor(ChartEditorInput chartEditorInput)	{
570
		return this.openEditor(chartEditorInput, chartEditorInput.getResultData().getClass().getName());
571
	}
572

  
573
	/**
574
	 * Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part.
575
	 * The chart type is the editor input result data class name.
576
	 * @param chartEditorInput
577
	 * @param editorPartId
578
	 * @return
579
	 */
580
	public ChartEditorPart openEditor(ChartEditorInput chartEditorInput, String editorPartId)	{
581
		return this.openEditor(chartEditorInput, editorPartId, chartEditorInput.getResultData().getClass().getName());	
582
	}
583
	
584
	
585
	/**
586
	 * Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the <code>EventCallBack</code> installed extensions. 
587
	 * @param chartEditorInput
588
	 * @param editorPartId
589
	 * @param chartType
590
	 * @return
591
	 */
592
	// FIXME: this method have some trouble when calling through a progress dialog
593
	public ChartEditorPart openEditor(ChartEditorInput chartEditorInput, String editorPartId, String chartType)	{
594

  
595
		ChartEditorPart openedChartEditorPart = null;
596

  
597
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
598
		IWorkbenchPage page = window.getActivePage();
599

  
600
//		IWorkbenchWindow window = PlatformUI.getWorkbench().getWorkbenchWindows()[0];
601
//		IWorkbenchPage page = window.getActivePage();
602
		
603
		boolean isAlreadyOpened = page.findEditor(chartEditorInput) != null;
604
		
605
		// if the editor is already open or the charts engine can create the specified chart type
606
		if(isAlreadyOpened || this.chartsEngine.canCreateChart(chartEditorInput.getResultData().getClass(), chartType))	{
607
			
608
			//Log.info(this.name + " - Opening editor for result data type " + chartEditorInput.getResultData().getClass() + " and editor id " + editorPartId);
609

  
610
			
611
			try {
612
				
613
				openedChartEditorPart  = (ChartEditorPart) page.openEditor(chartEditorInput, editorPartId, true);
614
				openedChartEditorPart.setWasAlreadyOpened(isAlreadyOpened);
615
				
616
				
617
				// directly returns if the editor was already opened
618
				if(isAlreadyOpened)	{
619
					return openedChartEditorPart;
620
				}
621
				
622
				// FIXME: directly close the editor if it contains no chart
623
//				if(openedChartEditorPart.getChart() == null)	{
624
//					page.closeEditor(openedChartEditorPart, false);
625
//					return openedChartEditorPart;
626
//				}
627

  
628
				
629
				
630
				// FIXME: tests with reuseEditor()
631
				//openedChartEditorPart  = (ChartEditorPart) page.reuseEditor(editorPart, editorPart.getEditorInput());
632
				
633
				
634
				// initialize the default shared context menus as Export, etc.
635
				initDefaultContextMenus(openedChartEditorPart.getComposite());
636
				
637
				
638
				
639
				// registers user entries event call back extensions
640
				String extensionPointId = "org.txm.chartsengine.eventcallback"; //$NON-NLS-1$
641
				IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId);
642
				
643
				for(int i = 0; i < contributions.length; i++) {
644
					if(contributions[i].getAttribute("chartsEngineName").equals(this.chartsEngine.getName()) //$NON-NLS-1$
645
							&& contributions[i].getAttribute("resultDataClass").equals(openedChartEditorPart.getResultData().getClass().getName()) //$NON-NLS-1$
646
							)	{
647
						try {
648
							EventCallBack eventCallBack = (EventCallBack)contributions[i].createExecutableExtension("class");  //$NON-NLS-1$
649
							
650
							eventCallBack.setChartEditor(openedChartEditorPart);
651
							
652
							EventCallBackHandler mouseHandler = openedChartEditorPart.getComposite().getMouseCallBackHandler();
653
							if(mouseHandler != null && mouseHandler.getEventCallBack(eventCallBack.getClass()) == null)	 {
654
								mouseHandler.registerEventCallBack(eventCallBack);
655
							}
656
							EventCallBackHandler keyboardHandler = openedChartEditorPart.getComposite().getKeyCallBackHandler();
657
							if(keyboardHandler != null && keyboardHandler.getEventCallBack(eventCallBack.getClass()) == null)	 {
658
								keyboardHandler.registerEventCallBack(eventCallBack);
659
							}
660
						}
661
						catch(CoreException e) {
662
							e.printStackTrace();
663
						}
664
						break;
665
					}
666
				}
667
				
668
				openedChartEditorPart.forceFocus();
669
				
670
			}
671
			catch(PartInitException e) {
672
				e.printStackTrace();
673
			}
674
			
675
		}
676
		// get the first installed charts engine that can create chart and use the SWT provider matching it
677
		else	{
678
			Log.warning("Rendering failed with current charts engine, trying to rendering chart with other installed SWT components provider and other charts engine:");
679
	
680
			boolean canCreate = false;
681
			for(int i = 0; i < ChartsEngine.getChartsEngines().size() && !canCreate; i++) {
682
				if(ChartsEngine.getChartsEngines().get(i) != this.chartsEngine)	{
683
					ChartsEngine chartsEngine = ChartsEngine.getChartsEngines().get(i);
684
					canCreate = chartsEngine.canCreateChart(chartEditorInput.getResultData().getClass());
685
					// get a provider that can manage the charts engine
686
					if(canCreate)	{
687
						SWTChartsComponentsProvider provider = SWTChartsComponentsProvider.getComponentsProvider(chartsEngine);
688
						if(provider != null)	{
689
							provider.setChartsEngine(chartsEngine);
690
							chartEditorInput.setSWTChartsComponentsProvider(provider);
691
							Log.warning(provider.toString());
692
							return provider.openEditor(chartEditorInput, editorPartId);
693
						}
694
					}
695
				}
696
			}
697
		}
698
		
699
	
700
		return openedChartEditorPart;
701
	}
702
	
703
	/**
704
	 * 
705
	 * @param titleImage
706
	 * @param editorInputName
707
	 * @param resultData
708
	 * @param chartType
709
	 * @param params
710
	 * @return
711
	 */
712
	public ChartEditorPart openEditor(String editorInputName, TXMResult resultData, String preferencesNode, String chartType)	{
713
		return this.openEditor(this.createChartEditor(editorInputName, resultData, preferencesNode, chartType), chartType);
714
	}
715
	
716
	/**
717
	 * 
718
	 * @param editorInputName
719
	 * @param resultData
720
	 * @param params
721
	 * @return
722
	 */
723
	public ChartEditorPart openEditor(String editorInputName, TXMResult resultData, String preferencesNode)	{
724
		return this.openEditor(editorInputName, resultData, preferencesNode, resultData.getClass().getName());
725
	}
726
	
727
	
728
	/**
729
	 * Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part.
730
	 * The ID of the editor is the editor input result data class name.
731
	 * @param editorPart
732
	 * @return
733
	 */
734
	public ChartEditorPart openEditor(ChartEditorPart editorPart)	{
735
		return this.openEditor(editorPart, editorPart.getEditorInput().getResultData().getClass().getName());
736
	}
737
	
738
	/**
739
	 * Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part.
740
	 * The ID of the editor is the editor input result data class name.
741
	 * @param chartEditorInput
742
	 * @return
743
	 */
744
	public ChartEditorPart openEditor(ChartEditorPart editorPart, String chartType)	{
745
		return this.openEditor(editorPart, editorPart.getEditorInput().getResultData().getClass().getName(), chartType);
746
	}
747
	
748
	
749
	/**
750
	 * Copy a chart as image in the clipboard from the specified chart component.
751
	 * @param chartComponent
752
	 */
753
	public abstract void copyChartToClipboard(Object chartComponent);
754
	
755
	
756
	/**
757
	 * Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part.
758
	 * @param editorPart
759
	 * @param editorId
760
	 * @return
761
	 */
762
	public ChartEditorPart openEditor(ChartEditorPart editorPart, String editorId, String chartType)	{
763
		return this.openEditor(editorPart.getEditorInput(), editorId, chartType);
764
	}
765
	
766
	
767
	
768
	/**
769
	 * Initializes the default context menus.
770
	 * @param composite
771
	 */
772
	public static void initDefaultContextMenus(ChartComposite composite)	{
773
		if(composite != null)	{
774
			composite.initItemAreaContextMenu();
775
			composite.initEmptyAreaContextMenu();
776
			composite.setCurrentContextMenu(EventCallBack.AREA_EMPTY);
777
		}
778
	}
779
	
780
	
781

  
782
	
783
	/**
784
	 * Initializes AWT default events to delegate AWT events to SWT.
785
	 * @param chartEditor
786
	 * @param swingComponent
787
	 */
788
	public static void initializeAWTDelegationListeners(final ChartEditorPart chartEditor, final JComponent swingComponent)	{
789

  
790
		// AWT to  SWT
791
		swingComponent.addMouseMotionListener(new MouseMotionListener() {
792

  
793
			@Override
794
			public void mouseMoved(final MouseEvent e) {
795
				chartEditor.getComposite().getDisplay().asyncExec(new Runnable () {
796
					public void run() {
797
						if(!chartEditor.getComposite().isDisposed())	{
798
							chartEditor.getComposite().notifyListeners(SWT.MouseMove, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseMove));
799
						}
800
					}
801
				});
802
			}
803

  
804
			@Override
805
			public void mouseDragged(MouseEvent e) {
806
				// TODO Auto-generated method stub
807

  
808
			}
809
		});
810

  
811
		swingComponent.addMouseListener(new MouseListener() {
812

  
813
			@Override
814
			public void mouseReleased(final MouseEvent e) {
815
				chartEditor.getComposite().getDisplay().asyncExec(new Runnable () {
816
					public void run() {
817
						
818
						// FIXME: context menu
819
						if(e.isPopupTrigger())	{
820

  
821
							//System.err.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mouseReleased(...).new Runnable() {...}.run(): AWT popup trigger detected");
822
							
823

  
824
							
825
							// update the mouse over item selection according to the mouse event
826
							chartEditor.getComposite().getChartComponent().updateMouseOverItem(e);
827
							
828
							// FIXME: temporary disabled for 0.7.8
829
							// manually pop up the menu
830
							if(chartEditor.getComposite().getMenu() != null)	{
831
								chartEditor.getComposite().getMenu().setLocation(new Point(e.getXOnScreen(), e.getYOnScreen()));
832
								chartEditor.getComposite().getMenu().setVisible(true);
833
							}
834

  
835
							// FIXME: the SWT.MenuDetect event delegation doesn't work, it would be better than manually pop up the menu (but other problem is the dynamic menu on chart entity item)
836
							//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect));
837
							// FIXME: try to delegate the Menu detect event, DOES NOT SEEM TO WORK
838
							//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect));
839
							//chartEditor.getComposite().notifyListeners(SWT.Show, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.Show));
840
							
841
						}
842
						chartEditor.getComposite().notifyListeners(SWT.MouseUp, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseUp));
843
					}
844
				});
845
			}
846

  
847
			@Override
848
			public void mousePressed(final MouseEvent e) {
849

  
850
				// SWT thread
851
				chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
852
					@Override
853
					public void run() {
854

  
855
						chartEditor.getComposite().notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown));
856
						
857
						// FIXME: Debug
858
						//System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()");
859
						// Activate the editor part on AWT mouse pressed event
860
						//chartEditor.activate();
861
					}
862
				});
863

  
864
			}
865

  
866
			@Override
867
			public void mouseExited(java.awt.event.MouseEvent e) {
868
				// TODO Auto-generated method stub
869

  
870
			}
871

  
872
			@Override
873
			public void mouseEntered(java.awt.event.MouseEvent e) {
874

  
875
				// TODO: DEbug
876
				//System.err.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...) AWT mouse entered");
877

  
878
				// Force the focus in the component on mouse enter
879
				/*if(!swingComponent.isFocusOwner())	{
880

  
881
					// SWT thread
882
					if(!chartEditor.getComposite().isDisposed())	{
883
						chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
884
							public void run() {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff