Révision 838

tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 838)
170 170
	@Parameter
171 171
	private QueryResult pQueryResult;
172 172
	
173
	
174
	
175

  
173 176
	/**
174 177
	 * 
175 178
	 * @param corpus
176 179
	 */
177
	public Concordance(Corpus corpus) {
178
		super(corpus);
179
		if (corpus != null) {
180
			this.setCQLSeparator(corpus.getCQLLimitQuery());
180
	public Concordance(Corpus corpus)	{
181
		this(null, corpus);
182
	}
183

  
184
	/**
185
	 * 
186
	 * @param uuid
187
	 */
188
	public Concordance(String uuid)	{
189
		this(uuid, null);
190
	}
191
	
192
	/**
193
	 * 
194
	 * @param corpus
195
	 */
196
	public Concordance(String uuid, Corpus corpus) {
197
		super(uuid, corpus);
198
		if (this.parent != null) {
199
			this.setCQLSeparator(this.getCorpus().getCQLLimitQuery());
181 200
		}
182 201
	}
183 202

  
203
	/**
204
	 * Checks if this concordance is equal to specified concordance.
205
	 * @param other
206
	 * @return
207
	 */
184 208
	public boolean equals(Concordance other) {
185 209
		if (other == null) return false;
186 210
		
......
1630 1654
	 * @param query the query to set
1631 1655
	 */
1632 1656
	public void setQuery(Query query) {
1633
		//updateDirty(pQuery, query);
1634 1657
		this.pQuery = query;
1635 1658
	}
1636 1659

  
......
1678 1701
	public boolean loadParameters() {
1679 1702

  
1680 1703
		try {
1704
			
1705
			if(!this.getStringParameterValue(ConcordancePreferences.QUERY).isEmpty())	{
1706
				this.setQuery(this.getStringParameterValue(ConcordancePreferences.QUERY));
1707
			}
1708
			
1709
			
1681 1710
//			this.pTopIndex = this.getIntParameterValue(ConcordancePreferences.TOP_INDEX);
1682 1711
//			this.pNLinesPerPage = this.getIntParameterValue(ConcordancePreferences.N_LINE_PER_PAGE);
1683 1712
//
tmp/org.txm.concordance.core/src/org/txm/concordance/core/preferences/ConcordancePreferences.java (revision 838)
18 18
	// auto populate the preference node qualifier from the current bundle id
19 19
	public static final String PREFERENCES_NODE = FrameworkUtil.getBundle(ConcordancePreferences.class).getSymbolicName();
20 20
	
21
	public static final String PREFERENCES_PREFIX = "concordance_"; //$NON-NLS-1$
21
	// FIXME: tests
22
	//public static final String PREFERENCES_PREFIX = "concordance_"; //$NON-NLS-1$
23
	public static final String PREFERENCES_PREFIX = ""; //$NON-NLS-1$
22 24
	
23 25
	public static final String N_LINES_PER_PAGE = PREFERENCES_PREFIX + "n_lines_per_page"; //$NON-NLS-1$
24 26
	public static final String LEFT_CONTEXT_SIZE = PREFERENCES_PREFIX + "left_context_size"; //$NON-NLS-1$
25 27
	public static final String RIGHT_CONTEXT_SIZE = PREFERENCES_PREFIX + "right_context_size"; //$NON-NLS-1$
26 28

  
27
	public static final String QUERY = PREFERENCES_PREFIX + "query"; //$NON-NLS-1$
28 29
	public static final String LEFT_ANALYSIS_PROPERTIES = PREFERENCES_PREFIX + "left_analysis_properties"; //$NON-NLS-1$
29 30
	public static final String KEYWORD_ANALYSIS_PROPERTIES = PREFERENCES_PREFIX + "keyword_analysis_properties"; //$NON-NLS-1$
30 31
	public static final String RIGHT_ANALYSIS_PROPERTIES = PREFERENCES_PREFIX + "right_analysis_properties"; //$NON-NLS-1$
......
38 39
	public static final String LIMIT_CQL = "limit_cql"; //$NON-NLS-1$
39 40
	public static final String TOP_INDEX = "top_index"; //$NON-NLS-1$
40 41
	
41
	public static final String WORD = "word"; //$NON-NLS-1$
42
	
43 42
	@Override
44 43
	public void initializeDefaultPreferences() {
45 44
		Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE);
......
49 48
		preferences.putInt(LEFT_CONTEXT_SIZE, 8);
50 49
		preferences.putInt(RIGHT_CONTEXT_SIZE, 12);
51 50
		
52
		preferences.put(LEFT_ANALYSIS_PROPERTIES, WORD);
53
		preferences.put(KEYWORD_ANALYSIS_PROPERTIES, WORD);
54
		preferences.put(RIGHT_ANALYSIS_PROPERTIES, WORD);
55
		preferences.put(LEFT_VIEW_PROPERTIES, WORD);
56
		preferences.put(KEYWORD_VIEW_PROPERTIES, WORD);
57
		preferences.put(RIGHT_VIEW_PROPERTIES, WORD);
51
		preferences.put(LEFT_ANALYSIS_PROPERTIES, TXMPreferences.DEFAULT_UNIT_PROPERTY);
52
		preferences.put(KEYWORD_ANALYSIS_PROPERTIES, TXMPreferences.DEFAULT_UNIT_PROPERTY);
53
		preferences.put(RIGHT_ANALYSIS_PROPERTIES, TXMPreferences.DEFAULT_UNIT_PROPERTY);
54
		preferences.put(LEFT_VIEW_PROPERTIES, TXMPreferences.DEFAULT_UNIT_PROPERTY);
55
		preferences.put(KEYWORD_VIEW_PROPERTIES, TXMPreferences.DEFAULT_UNIT_PROPERTY);
56
		preferences.put(RIGHT_VIEW_PROPERTIES, TXMPreferences.DEFAULT_UNIT_PROPERTY);
58 57
		
59 58
		preferences.put(VIEW_REFERENCE_PATTERN, "*"); //$NON-NLS-1$
60 59
		preferences.put(ANALYSIS_REFERENCE_PATTERN, "*"); //$NON-NLS-1$
tmp/org.txm.ahc.core/src/org/txm/ahc/core/functions/AHC.java (revision 838)
627 627

  
628 628
	@Override
629 629
	public String getSimpleName() {
630
		StringBuffer buffer = new StringBuffer();
631
		buffer.append(this.columnsComputing ? "cols" : "rows"); //$NON-NLS-1$
632
		buffer.append(this.method);
633
		buffer.append(this.metric);
634
		buffer.append(this.numberOfClusters);
630
		// FIXME: to define
631
//		StringBuffer buffer = new StringBuffer();
632
//		buffer.append(this.columnsComputing ? "cols" : "rows"); //$NON-NLS-1$
633
//		buffer.append(this.method);
634
//		buffer.append(this.metric);
635
//		buffer.append(this.numberOfClusters);
635 636
		return this.getName();
636 637
	}
637 638

  
tmp/org.txm.index.rcp/plugin.xml (revision 838)
115 115
               <menuContribution
116 116
            locationURI="popup:org.txm.index.rcp.editors.IndexEditor">
117 117
         <command
118
               commandId="org.txm.rcp.commands.link.ToConcordance"
118
               commandId="org.txm.links.rcp.commands.SendToConcordance"
119 119
               style="push">
120 120
         </command>
121 121
         <command
122
               commandId="org.txm.rcp.commands.link.IndexToCooccurrence"
122
               commandId="org.txm.links.rcp.commands.SendToCooccurrence"
123 123
               style="push">
124 124
         </command>
125 125
         <command
126
               commandId="org.txm.index.rcp.handlers.IndexToProgression"
126
               commandId="org.txm.links.rcp.commands.SendToProgression"
127 127
               style="push">
128 128
         </command>
129 129
      </menuContribution>
......
186 186
      </command>
187 187

  
188 188
      <command
189
            defaultHandler="org.txm.index.rcp.handlers.IndexToProgression"
189
            defaultHandler="org.txm.index.rcp.handlers.SendToProgression"
190 190
            id="org.txm.index.rcp.handlers.IndexToProgression"
191 191
            name="%command.label.103">
192 192
      </command>
......
245 245
            name="%page.name">
246 246
      </page>
247 247
   </extension>
248
   <extension
249
         point="org.eclipse.ui.handlers">
250
      <handler
251
            class="org.txm.index.rcp.handlers.SendToProgression"
252
            commandId="org.txm.links.rcp.commands.SendToProgression">
253
      </handler>
254
      <handler
255
            class="org.txm.index.rcp.handlers.SendToConcordance"
256
            commandId="org.txm.links.rcp.commands.SendToConcordance">
257
      </handler>
258
   </extension>
248 259

  
249 260
</plugin>
tmp/org.txm.index.rcp/META-INF/MANIFEST.MF (revision 838)
1 1
Manifest-Version: 1.0
2
Require-Bundle: org.txm.utils;bundle-version="1.0.0";visibility:=reexp
3
 ort,org.eclipse.osgi;bundle-version="3.10.2";visibility:=reexport,org
4
 .eclipse.core.runtime;bundle-version="3.10.0";visibility:=reexport, o
5
 rg.txm.statsengine.core;bundle-version="1.0.0";visibility:=reexport,o
6
 rg.txm.statsengine.r.core;bundle-version="1.0.0";visibility:=reexport
7
 ,org.txm.searchengine.cqp.core;bundle-version="1.1.0";visibility:=ree
8
 xport,org.txm.core;bundle-version="0.7.0";visibility:=reexport,org.tx
9
 m.index.core;bundle-version="1.0.0";visibility:=reexport,org.txm.stat
10
 sengine.r.rcp;visibility:=reexport,org.eclipse.ui;bundle-version="3.1
11
 06.1";visibility:=reexport,org.txm.rcp;visibility:=reexport,org.eclip
12
 se.core.expressions;bundle-version="3.4.600";visibility:=reexport,org
13
 .txm.searchengine.core;bundle-version="1.0.0";visibility:=reexport
2
Require-Bundle: org.txm.utils;bundle-version="1.0.0";visibility:=reexport,
3
 org.eclipse.osgi;bundle-version="3.10.2";visibility:=reexport,
4
 org.eclipse.core.runtime;bundle-version="3.10.0";visibility:=reexport,
5
 org.txm.statsengine.core;bundle-version="1.0.0";visibility:=reexport,
6
 org.txm.statsengine.r.core;bundle-version="1.0.0";visibility:=reexport,
7
 org.txm.searchengine.cqp.core;bundle-version="1.1.0";visibility:=reexport,
8
 org.txm.core;bundle-version="0.7.0";visibility:=reexport,
9
 org.txm.index.core;bundle-version="1.0.0";visibility:=reexport,
10
 org.txm.statsengine.r.rcp;visibility:=reexport,
11
 org.eclipse.ui;bundle-version="3.106.1";visibility:=reexport,
12
 org.txm.rcp;visibility:=reexport,
13
 org.eclipse.core.expressions;bundle-version="3.4.600";visibility:=reexport,
14
 org.txm.searchengine.core;bundle-version="1.0.0";visibility:=reexport
14 15
Export-Package: org.txm.index.rcp.adapters,org.txm.index.rcp.editors,o
15 16
 rg.txm.index.rcp.handlers,org.txm.index.rcp.messages
16 17
Bundle-Vendor: Textometrie.org
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/IndexToProgression.java (revision 838)
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.index.rcp.handlers;
29

  
30
import java.util.List;
31

  
32
import org.eclipse.core.commands.ExecutionEvent;
33
import org.eclipse.core.commands.ExecutionException;
34
import org.eclipse.jface.viewers.IStructuredSelection;
35
import org.eclipse.ui.handlers.HandlerUtil;
36
import org.txm.core.preferences.TXMPreferences;
37
import org.txm.index.core.functions.Index;
38
import org.txm.index.core.functions.Line;
39
import org.txm.rcp.editors.TXMEditor;
40
import org.txm.rcp.handlers.BaseAbstractHandler;
41
import org.txm.searchengine.cqp.corpus.Corpus;
42
import org.txm.searchengine.cqp.corpus.query.Query;
43

  
44
/**
45
 * Sends the lines of an index to compute a progression.
46
 * 
47
 * @author mdecorde
48
 * @author sjacquot
49
 * 
50
 */
51
public class IndexToProgression extends BaseAbstractHandler {
52

  
53
	@Override
54
	public Object execute(ExecutionEvent event) throws ExecutionException {
55

  
56
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
57

  
58
		if (selection != null && selection.getFirstElement() instanceof Line) {
59

  
60
			List<Query> queries = Index.createQueries(selection.toList());
61

  
62
			TXMEditor editor = (TXMEditor) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActivePart();
63
			Corpus corpus = Corpus.getFirstParentCorpus(editor.getResult());
64

  
65
			// FIXME: tests:
66
			// 1) create an UUID for the future TXMResult
67
			// 2) store some parameters in the local preference node
68
			// 3) call the command in the command target plug-in
69
			String uuid = "test_link_index_to_progression"; 
70
			TXMPreferences.put(uuid, TXMPreferences.PARENT_UUID, corpus.getUUID());
71
			TXMPreferences.put(uuid, TXMPreferences.QUERIES, Query.queriesToString(queries));
72
			BaseAbstractHandler.executeCommand("org.txm.progression.rcp.handlers.ComputeProgression", uuid); //$NON-NLS-1$
73
		}
74
		else	{
75
			this.logCanNotCompute(selection);
76
		}
77
		return null;
78
	}
79

  
80

  
81
	
82
	
83
}
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/IndexToConcordance.java (revision 838)
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.index.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.IWorkbenchWindow;
37
import org.eclipse.ui.handlers.HandlerUtil;
38
import org.txm.index.core.functions.Index;
39
import org.txm.index.core.functions.Line;
40
import org.txm.index.rcp.editors.IndexEditor;
41
import org.txm.rcp.editors.TXMResultEditorInput;
42
import org.txm.searchengine.cqp.corpus.Corpus;
43
import org.txm.searchengine.cqp.corpus.Property;
44
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
45
import org.txm.searchengine.cqp.corpus.query.Query;
46

  
47
// TODO: Auto-generated Javadoc
48
/**
49
 * use the lines of a index to compute a concordance @ author mdecorde.
50
 */
51
public class IndexToConcordance extends AbstractHandler {
52

  
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
55
	 */
56
	@Override
57
	public Object execute(ExecutionEvent event) throws ExecutionException {
58
		IWorkbenchWindow window;
59
		IStructuredSelection selection;
60
		TXMResultEditorInput editorInput;
61
		window = HandlerUtil.getActiveWorkbenchWindow(event);
62
		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
63

  
64
		assert (selection.getFirstElement() instanceof Line);
65

  
66
		String query = getQuery(selection);
67

  
68
		IndexEditor voceditor = (IndexEditor) HandlerUtil
69
				.getActiveWorkbenchWindow(event).getActivePage()
70
				.getActivePart();
71

  
72
		Corpus corpus = voceditor.getCorpus();
73

  
74
		// FIXME: call here the ComputeConcordance command passing the UUID of the result and of the parent
75
		
76
		
77
//		Concordance concordance = new Concordance(corpus);
78
//		concordance.setParameters(new Query(query), null, null, null, null, null, null, null, null, null, null);
79
//		editorInput = new TXMResultEditorInput(concordance);
80
//
81
//		IWorkbenchPage page = window.getActivePage();
82
//		try {
83
//			ConcordanceEditor conceditor = (ConcordanceEditor) page
84
//					.openEditor(editorInput, ConcordanceEditor.ID); //$NON-NLS-1$
85
//		} catch (PartInitException e) {
86
//			System.err.println("Error: "+e.getLocalizedMessage());
87
//		}
88

  
89
		return null;
90
	}
91

  
92
//	/**
93
//	 * Link.
94
//	 *
95
//	 * @param voceditor the voceditor
96
//	 * @param selection the selection
97
//	 * @return the object
98
//	 */
99
//	public static Object link(IndexEditor voceditor,
100
//			IStructuredSelection selection) {
101
//		assert (selection.getFirstElement() instanceof Line);
102
//		String query = getQuery(selection);
103
//		if (query.length() == 0)
104
//			return null;
105
//		Corpus corpus = voceditor.getCorpus();
106
//		Concordance concordance = new Concordance(corpus);
107
//		concordance.setParameters(new Query(query), null, null, null, null, null, null, null, null, null, null);
108
//		TXMResultEditorInput editorInput = new TXMResultEditorInput(concordance);
109
////		try {
110
////			System.out.println("Compute indexResult query: "+voceditor.getQuery());
111
////			QueryResult indexResult = corpus.query(voceditor.getQuery(), "Index", false);
112
////			System.out.println("N result: "+indexResult.getNMatch());
113
////
114
////			System.out.println("Compute indexOccResult query: "+query);
115
////			QueryResult indexOccResult = corpus.query(new Query(query), "IndexOcc", false);
116
////			System.out.println("N result: "+indexOccResult.getNMatch());
117
////
118
////			String queryname = "Q"+Corpus.getNextQueryCounter();
119
////			String interQueryString = queryname+"=intersect "+indexResult.getQualifiedCqpId()+" "+indexOccResult.getQualifiedCqpId()+";"; 
120
////			System.out.println("Compute inter query: "+interQueryString);
121
////			((MemCqiClient)CQPSearchEngine.getCqiClient()).query(interQueryString);
122
////			
123
////			QueryResult inter = new QueryResult(queryname, queryname, corpus, new Query(interQueryString));
124
////			System.out.println("indexResult size: "+indexResult.getNMatch());
125
////			System.out.println("indexOccResult size: "+indexOccResult.getNMatch());
126
////			System.out.println("inter size: "+inter.getNMatch());
127
////			
128
////			QueryResult inter2 = corpus.query(new Query("intersect "+indexResult.getQualifiedCqpId()+" "+indexOccResult.getQualifiedCqpId()), "Q"+Corpus.getNextQueryCounter(),false);
129
////			System.out.println("inter2 size: "+inter2.getNMatch());
130
////		} catch (Exception e) {
131
////			e.printStackTrace();
132
////			try {
133
////				System.out.println("CQP error: "+CQPSearchEngine.getCqiClient().getLastError());
134
////			} catch (Exception e1) {
135
////				e1.printStackTrace();
136
////			}
137
////		}
138
////		
139
////		return null;
140
//
141
//		IWorkbenchPage page = voceditor.getEditorSite().getWorkbenchWindow()
142
//				.getActivePage();
143
//		try {
144
//			ConcordanceEditor conceditor = (ConcordanceEditor) page
145
//					.openEditor(editorInput, ConcordanceEditor.ID); //$NON-NLS-1$
146
//		} catch (PartInitException e) {
147
//			System.err.println("Error: "+e.getLocalizedMessage());
148
//		}
149
//
150
//		return null;
151
//	}
152

  
153

  
154
	/**
155
	 * Gets the query.
156
	 *
157
	 * @param selection the selection
158
	 * @return the query
159
	 */
160
	private static String getQuery(IStructuredSelection selection) {
161
		return Index.createQuery(selection.toList());
162
	}
163
}
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/SendToProgression.java (revision 838)
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.index.rcp.handlers;
29

  
30
import java.util.List;
31

  
32
import org.eclipse.core.commands.ExecutionEvent;
33
import org.eclipse.core.commands.ExecutionException;
34
import org.eclipse.jface.viewers.IStructuredSelection;
35
import org.eclipse.ui.handlers.HandlerUtil;
36
import org.txm.core.preferences.TXMPreferences;
37
import org.txm.core.results.TXMResult;
38
import org.txm.index.core.functions.Index;
39
import org.txm.index.core.functions.Line;
40
import org.txm.rcp.editors.TXMEditor;
41
import org.txm.rcp.handlers.BaseAbstractHandler;
42
import org.txm.searchengine.cqp.corpus.query.Query;
43

  
44
/**
45
 * Sends the lines of an index to compute a progression.
46
 * 
47
 * @author mdecorde
48
 * @author sjacquot
49
 * 
50
 */
51
public class SendToProgression extends BaseAbstractHandler {
52

  
53
	@Override
54
	public Object execute(ExecutionEvent event) throws ExecutionException {
55

  
56
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
57

  
58
		if (selection != null && selection.getFirstElement() instanceof Line) {
59

  
60
			List<Query> queries = Index.createQueries(selection.toList());
61

  
62
			TXMEditor editor = (TXMEditor) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActivePart();
63

  
64
			// FIXME: tests:
65
			// 1) create an UUID for the future TXMResult
66
			// 2) store some parameters in the local preference node
67
			// 3) call the command in the command target plug-in
68
			//String uuid = "test_link_index_to_progression"; 
69
			String uuid = TXMResult.createUUID();
70
			TXMPreferences.put(uuid, TXMPreferences.PARENT_UUID, editor.getResult().getParent().getUUID());
71
			TXMPreferences.put(uuid, TXMPreferences.QUERIES, Query.queriesToString(queries));
72
			BaseAbstractHandler.executeCommand("org.txm.progression.rcp.handlers.ComputeProgression", uuid); //$NON-NLS-1$
73
		}
74
		else	{
75
			this.logCanNotCompute(selection);
76
		}
77
		return null;
78
	}
79

  
80

  
81
	
82
	
83
}
0 84

  
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/SendToConcordance.java (revision 838)
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.index.rcp.handlers;
29

  
30
import org.eclipse.core.commands.ExecutionEvent;
31
import org.eclipse.core.commands.ExecutionException;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.ui.handlers.HandlerUtil;
34
import org.txm.core.preferences.TXMPreferences;
35
import org.txm.core.results.TXMResult;
36
import org.txm.index.core.functions.Index;
37
import org.txm.index.core.functions.Line;
38
import org.txm.rcp.editors.TXMEditor;
39
import org.txm.rcp.handlers.BaseAbstractHandler;
40
import org.txm.searchengine.cqp.corpus.Corpus;
41

  
42
/**
43
 * Sends the lines of an index to compute a concordance.
44
 * 
45
 * @author mdecorde
46
 * @author sjacquot
47
 * 
48
 */
49
public class SendToConcordance extends BaseAbstractHandler {
50

  
51

  
52
	@Override
53
	public Object execute(ExecutionEvent event) throws ExecutionException {
54
		
55
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
56

  
57
		if (selection != null && selection.getFirstElement() instanceof Line) {
58
			
59
			String query = Index.createQuery(selection.toList());
60

  
61
			TXMEditor editor = (TXMEditor) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActivePart();
62

  
63
			// FIXME: tests:
64
			// 1) create an UUID for the future TXMResult
65
			// 2) store some parameters in the local preference node
66
			// 3) call the command in the command target plug-in
67
			//String uuid = "test_link_index_to_concordance";
68
			String uuid = TXMResult.createUUID();
69
			TXMPreferences.put(uuid, TXMPreferences.PARENT_UUID, editor.getResult().getParent().getUUID());
70
			TXMPreferences.put(uuid, TXMPreferences.QUERY, query);
71
			BaseAbstractHandler.executeCommand("org.txm.concordance.rcp.handlers.ComputeConcordance", uuid); //$NON-NLS-1$
72
		}
73
		else	{
74
			this.logCanNotCompute(selection);
75
		}
76
		return null;
77
	}
78

  
79
//	/**
80
//	 * Link.
81
//	 *
82
//	 * @param voceditor the voceditor
83
//	 * @param selection the selection
84
//	 * @return the object
85
//	 */
86
//	public static Object link(IndexEditor voceditor,
87
//			IStructuredSelection selection) {
88
//		assert (selection.getFirstElement() instanceof Line);
89
//		String query = getQuery(selection);
90
//		if (query.length() == 0)
91
//			return null;
92
//		Corpus corpus = voceditor.getCorpus();
93
//		Concordance concordance = new Concordance(corpus);
94
//		concordance.setParameters(new Query(query), null, null, null, null, null, null, null, null, null, null);
95
//		TXMResultEditorInput editorInput = new TXMResultEditorInput(concordance);
96
////		try {
97
////			System.out.println("Compute indexResult query: "+voceditor.getQuery());
98
////			QueryResult indexResult = corpus.query(voceditor.getQuery(), "Index", false);
99
////			System.out.println("N result: "+indexResult.getNMatch());
100
////
101
////			System.out.println("Compute indexOccResult query: "+query);
102
////			QueryResult indexOccResult = corpus.query(new Query(query), "IndexOcc", false);
103
////			System.out.println("N result: "+indexOccResult.getNMatch());
104
////
105
////			String queryname = "Q"+Corpus.getNextQueryCounter();
106
////			String interQueryString = queryname+"=intersect "+indexResult.getQualifiedCqpId()+" "+indexOccResult.getQualifiedCqpId()+";"; 
107
////			System.out.println("Compute inter query: "+interQueryString);
108
////			((MemCqiClient)CQPSearchEngine.getCqiClient()).query(interQueryString);
109
////			
110
////			QueryResult inter = new QueryResult(queryname, queryname, corpus, new Query(interQueryString));
111
////			System.out.println("indexResult size: "+indexResult.getNMatch());
112
////			System.out.println("indexOccResult size: "+indexOccResult.getNMatch());
113
////			System.out.println("inter size: "+inter.getNMatch());
114
////			
115
////			QueryResult inter2 = corpus.query(new Query("intersect "+indexResult.getQualifiedCqpId()+" "+indexOccResult.getQualifiedCqpId()), "Q"+Corpus.getNextQueryCounter(),false);
116
////			System.out.println("inter2 size: "+inter2.getNMatch());
117
////		} catch (Exception e) {
118
////			e.printStackTrace();
119
////			try {
120
////				System.out.println("CQP error: "+CQPSearchEngine.getCqiClient().getLastError());
121
////			} catch (Exception e1) {
122
////				e1.printStackTrace();
123
////			}
124
////		}
125
////		
126
////		return null;
127
//
128
//		IWorkbenchPage page = voceditor.getEditorSite().getWorkbenchWindow()
129
//				.getActivePage();
130
//		try {
131
//			ConcordanceEditor conceditor = (ConcordanceEditor) page
132
//					.openEditor(editorInput, ConcordanceEditor.ID); //$NON-NLS-1$
133
//		} catch (PartInitException e) {
134
//			System.err.println("Error: "+e.getLocalizedMessage());
135
//		}
136
//
137
//		return null;
138
//	}
139

  
140

  
141
}
0 142

  
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputeLexicon.java (revision 838)
40 40
			try {
41 41
				index.setQuery(new Query("[]")); //$NON-NLS-1$
42 42
				index.setProperties(Arrays.asList(corpus.getWordProperty()));
43
				index.setVisible(false);
43 44
			} catch (CqiClientException e) {
44 45
				// TODO Auto-generated catch block
45 46
				e.printStackTrace();
tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/DictionnaryEditor.java (revision 838)
2 2
package org.txm.index.rcp.editors;
3 3

  
4 4
import org.eclipse.swt.layout.GridData;
5
import org.eclipse.swt.widgets.Composite;
6 5

  
7 6
/**
8 7
 * extends the index editor to : 
......
13 12
 */
14 13
public class DictionnaryEditor extends IndexEditor {
15 14

  
16
	/* (non-Javadoc)
17
	 * @see org.txm.rcp.editors.index.IndexEditor#createPartControl(org.eclipse.swt.widgets.Composite)
18
	 */
15

  
16
	
19 17
	@Override
20 18
	public void _createPartControl() {
21 19
		super._createPartControl();
......
34 32
		getMainParametersComposite().setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
35 33
		
36 34
	}
35
	
37 36
}
tmp/org.txm.chartsengine.svgbatik.rcp/src/org/txm/chartsengine/svgbatik/rcp/swt/SVGComposite.java (revision 838)
1 1
package org.txm.chartsengine.svgbatik.rcp.swt;
2
import java.awt.BorderLayout;
3 2
import java.awt.Component;
4
import java.awt.EventQueue;
5
import java.awt.Frame;
6 3
import java.awt.Graphics2D;
7 4
import java.awt.Toolkit;
8 5
import java.awt.datatransfer.DataFlavor;
......
13 10
import java.io.IOException;
14 11
import java.net.MalformedURLException;
15 12

  
16
import javax.swing.JPanel;
17

  
18
import org.eclipse.swt.awt.SWT_AWT;
19 13
import org.eclipse.swt.widgets.Composite;
20 14
import org.txm.chartsengine.rcp.IChartComponent;
21 15
import org.txm.chartsengine.rcp.editors.ChartEditor;
22
import org.txm.chartsengine.rcp.events.EventCallBackHandler;
23
import org.txm.chartsengine.rcp.swt.ChartComposite;
16
import org.txm.chartsengine.rcp.swt.SwingChartComposite;
24 17
import org.txm.chartsengine.svgbatik.rcp.swing.SVGPanel;
25 18
import org.txm.utils.logger.Log;
26 19
import org.w3c.dom.svg.SVGDocument;
......
31 24
 * @author sjacquot
32 25
 *
33 26
 */
34
public class SVGComposite extends ChartComposite	{
27
public class SVGComposite extends SwingChartComposite	{
35 28

  
36
	// FIXME: useless ? for reducing the flickering on resize under Window but it doesn't seem to work
37
//	static
38
//	{
39
//		System.setProperty("sun.awt.noerasebackground", "true"); //$NON-NLS-1$ //$NON-NLS-2$
40
//	}
41

  
42 29
	
43
	
44 30
	/**
45 31
	 * The loaded SVG file.
46 32
	 */
47 33
	protected File file;
48 34
	
49
	protected Frame frame;
50 35
	
51
	protected JPanel rootPanel;
52
	
53
	
54 36
	/**
55 37
	 * Creates a Batik SVG composite.
56 38
	 * @param parent
......
60 42
		super(chartEditor, parent, style);
61 43
	
62 44
		this.file = null;
63
		
64
		this.frame = SWT_AWT.new_Frame(this);
65
		// Need to add an AWT Panel to fix mouse events and mouse cursors changes on Swing JPanel
66
		this.rootPanel = new JPanel(new BorderLayout());
67
		
68
		this.frame.add(this.rootPanel);
69

  
70
		//this.frame.pack();
71
		this.frame.setVisible(true);
72
		
73 45
	}
74 46

  
75 47

  
......
114 86
	}
115 87

  
116 88
	
117
	@Override
118
	public void requestFocusInComposite()	{
119
		EventQueue.invokeLater(new Runnable () {
120
			public void run () {
121
				getPanel().requestFocusInWindow();
122
			}
123
		});
124
	}
125 89

  
126 90
	
127 91
	@Override
128
	public void loadChart()	{
129
		
130
		// loads the chart from the result
131
		Object chart = this.chartEditor.getChart();
132

  
133
		if(chart != null) {
134
			// creates components if they not exist
135
			if(this.chartComponent == null)	{
136
				
137
				// recreates the chart if not of right type
138
				if(!(chart instanceof File))	{
139
					try {
140
						this.chartEditor.getResult().clearLastRenderingParameters();
141
						this.chartEditor.getResult().compute();
142
					}
143
					catch (Exception e) {
144
						// TODO Auto-generated catch block
145
						e.printStackTrace();
146
					}
147
				}
148
				
149
				
150
				this.chartEditor.getSWTChartsComponentsProvider().createChartContainer(this.chartEditor.getEditorInput());
151
				this.chartComponent = (IChartComponent) this.chartEditor.getEditorInput().getChartContainer();
152
				
153
				this.rootPanel.add((Component) this.chartComponent);
154

  
155
				this.frame.setVisible(true);
156
			}
157
			this.file = (File) chart;	
158
			this.loadSVGDocument(this.file);
159
		}
160
	}
161
	
162
	
163
	@Override
164 92
	public void loadChart(Object data) {
165 93
		this.loadSVGDocument((File) data);
166 94
	}
......
168 96
	
169 97

  
170 98

  
171
	@Override
172
	public void copyChartViewToClipboard() {
173
		SVGPanel panel = this.getPanel();
174
		int w = panel.getWidth();
175
		int h = panel.getHeight();
176
		final BufferedImage bufferedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
177
		Graphics2D g = bufferedImg.createGraphics();
178
		panel.paint(g);
179
		
180
		Transferable img = new Transferable() {
181
			
182
			@Override
183
			public boolean isDataFlavorSupported(DataFlavor flavor) {
184
				return DataFlavor.imageFlavor.equals(flavor);
185
			}
186
			
187
			@Override
188
			public DataFlavor[] getTransferDataFlavors() {
189
				return new DataFlavor[] {DataFlavor.imageFlavor};
190
			}
191
			
192
			@Override
193
			public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
194
				if(!DataFlavor.imageFlavor.equals(flavor))					    {
195
					throw new UnsupportedFlavorException(flavor);
196
				}
197
				return bufferedImg;
198
			}
199 99

  
200
		};
201
		
202
		Toolkit.getDefaultToolkit().getSystemClipboard().setContents(img, null);
203
		
204
	}
205 100

  
206 101
	@Override
207 102
	public Object getChart() {
208 103
		return this.file;
209 104
	}
210 105

  
211
	
212
	@Override
213
	public EventCallBackHandler getMouseCallBackHandler() {
214
		return super.getMouseCallBackHandler(this.getPanel());
215
	}
216 106

  
217

  
218 107
	@Override
219
	public EventCallBackHandler getKeyCallBackHandler() {
220
		return super.getKeyCallBackHandler(this.getPanel());
221
	}
222

  
223

  
224
	@Override
225 108
	public void clearChartItemsSelection() {
226 109
		System.err.println("SVGComposite.clearChartItemsSelection(): not implemented.");
227 110
	}
tmp/org.txm.index.core/src/org/txm/index/core/messages/messages_fr.properties (revision 838)
1 1

  
2
DetailsFromCorpus = Index:\n\	Corpus {0}\n\	Requ�te {1}\n\	propri�t�s {2}\n\	Fmin {3}\n\	Fmax {4}
2
DetailsFromCorpus = Index:\n\	Corpus {0}\n\	Requête {1}\n\	propriétés {2}\n\	Fmin {3}\n\	Fmax {4}
3 3

  
4
DetailsFromPartition = Index:\n\	Partition {0}\n\	Requ�te {1}\n\	propri�t�s {2}\n\	Fmin {3}\n\	Fmax {4}
4
DetailsFromPartition = Index:\n\	Partition {0}\n\	Requête {1}\n\	propriétés {2}\n\	Fmin {3}\n\	Fmax {4}
5 5

  
6 6
Index_0 = ** Erreur lors du calcul du lexique : \n
7 7
Index_1 = console : 
tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 838)
216 216

  
217 217
			}
218 218
			else {
219
				System.out.println("Error: Index parent is neither a Corpus nor a partition.");
219
				Log.severe("Error: Index parent is neither a Corpus nor a partition.");
220 220
				return false;
221 221
			}
222 222
		}
......
416 416
			Property property = pProperties.get(0);
417 417
			if (lexicon == null) {
418 418
				lexicon = new Lexicon(getCorpus());
419
				lexicon.setProperty(property);
420
				lexicon.compute(null);
421
			} else {
422
				lexicon.setProperty(this.pProperties.get(0));
423
				lexicon.compute(monitor);
424 419
			}
425

  
420
			lexicon.setProperty(property);
421
			lexicon.setDirty();
422
			lexicon.compute(monitor);
423
			
424
			
425
			
426 426
			this.nTotalTokens = lexicon.nbrOfToken();
427 427
			String[] forms = lexicon.getForms();
428 428
			int[] freqs = lexicon.getFreq();
tmp/org.txm.information.rcp/plugin.xml (revision 838)
42 42
   <extension
43 43
         point="org.eclipse.ui.menus">
44 44
      <menuContribution
45
            locationURI="toolbar:org.txm.rcp.toolbarcorpus?after=org.txm.synopticedition.rcp.handlers.OpenEdition">
45
            locationURI="toolbar:org.txm.rcp.toolbarcorpus?after=org.txm.edition.rcp.handlers.OpenEdition">
46 46
         <command
47 47
               commandId="org.txm.properties.rcp.handlers.ComputeProperties"
48 48
               icon="icons/functions/properties.png"
tmp/org.txm.chartsengine.jfreechart.rcp/META-INF/MANIFEST.MF (revision 838)
1 1
Manifest-Version: 1.0
2
Require-Bundle: org.txm.chartsengine.jfreechart.core;bundle-version="1
3
 .0.0";visibility:=reexport,org.txm.chartsengine.rcp;bundle-version="1
4
 .0.0";visibility:=reexport,org.txm.rcp;bundle-version="0.7.8";visibil
5
 ity:=reexport,org.txm.ca.core;bundle-version="1.0.0";visibility:=reex
6
 port
7
Export-Package: org.txm.chartsengine.jfreechart.rcp,org.txm.chartsengi
8
 ne.jfreechart.rcp.events,org.txm.chartsengine.jfreechart.rcp.handlers
9
 ,org.txm.chartsengine.jfreechart.rcp.preferences,org.txm.chartsengine
10
 .jfreechart.rcp.swt,org.txm.chartsengine.jfreechart.rcp.themes.base.s
11
 wing,org.txm.chartsengine.jfreechart.rcp.themes.highcharts,org.txm.ch
12
 artsengine.jfreechart.rcp.themes.highcharts.events,org.txm.chartsengi
13
 ne.jfreechart.rcp.themes.highcharts.swing
2
Require-Bundle: org.txm.chartsengine.jfreechart.core;bundle-version="1.0.0";visibility:=reexport,
3
 org.txm.chartsengine.rcp;bundle-version="1.0.0";visibility:=reexport,
4
 org.txm.rcp;bundle-version="0.7.8";visibility:=reexport,
5
 org.txm.ca.core;bundle-version="1.0.0";visibility:=reexport
6
Export-Package: org.txm.chartsengine.jfreechart.rcp,
7
 org.txm.chartsengine.jfreechart.rcp.events,
8
 org.txm.chartsengine.jfreechart.rcp.handlers,
9
 org.txm.chartsengine.jfreechart.rcp.preferences,
10
 org.txm.chartsengine.jfreechart.rcp.swt,
11
 org.txm.chartsengine.jfreechart.rcp.themes.base.swing,
12
 org.txm.chartsengine.jfreechart.rcp.themes.highcharts,
13
 org.txm.chartsengine.jfreechart.rcp.themes.highcharts.events,
14
 org.txm.chartsengine.jfreechart.rcp.themes.highcharts.swing
14 15
Bundle-Vendor: Textometrie.org
15 16
Bundle-Version: 1.0.0.qualifier
16 17
Bundle-Name: JFreeChart Charts Engine RCP
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/JFCChartsSwingComponentsProvider.java (revision 838)
1
package org.txm.chartsengine.jfreechart.rcp;
2

  
3
import java.awt.Color;
4

  
5
import org.jfree.chart.ChartPanel;
6
import org.jfree.chart.JFreeChart;
7
import org.jfree.chart.LegendItemSource;
8
import org.jfree.chart.axis.NumberAxis;
9
import org.jfree.chart.plot.CategoryPlot;
10
import org.jfree.chart.plot.Marker;
11
import org.jfree.chart.plot.Plot;
12
import org.jfree.chart.plot.ValueMarker;
13
import org.jfree.chart.plot.XYPlot;
14
import org.jfree.data.category.DefaultCategoryDataset;
15
import org.jfree.data.general.DatasetUtilities;
16
import org.jfree.data.xy.XYIntervalSeries;
17
import org.jfree.data.xy.XYIntervalSeriesCollection;
18
import org.jfree.data.xy.XYSeries;
19
import org.jfree.data.xy.XYSeriesCollection;
20
import org.jfree.ui.RectangleAnchor;
21
import org.jfree.ui.TextAnchor;
22
import org.txm.chartsengine.jfreechart.core.JFCChartsEngine;
23
import org.txm.chartsengine.jfreechart.core.themes.base.ExtendedNumberAxis;
24
import org.txm.chartsengine.jfreechart.core.themes.base.JFCTheme;
25
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.renderers.ItemSelectionCategoryLineAndShapeRenderer;
26
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
27

  
28
/**
29
 * Swing components provider.
30
 * @author sjacquot
31
 *
32
 */
33
public class JFCChartsSwingComponentsProvider {
34

  
35
	/**
36
	 * The chart production engine.
37
	 */
38
	protected JFCChartsEngine chartsEngine;
39

  
40

  
41
	/**
42
	 * The linked SWT Charts Component Provider.
43
	 */
44
	protected SWTChartsComponentsProvider swtChartsComponentProvider;
45

  
46
	
47
	/**
48
	 *
49
	 * @param chartsEngine
50
	 */
51
	public JFCChartsSwingComponentsProvider(SWTChartsComponentsProvider swtChartsComponentProvider, JFCChartsEngine chartsEngine) {
52
		this.swtChartsComponentProvider = swtChartsComponentProvider;
53
		this.chartsEngine = chartsEngine;
54
	}
55

  
56

  
57

  
58
	/**
59
	 * Creates an empty chart panel.
60
	 * @return
61
	 */
62
	public ChartPanel createDefaultEmptyChartPanel()	{
63
		return this.getTheme().createChartPanel(this.swtChartsComponentProvider, null);
64
	}
65

  
66

  
67
	/**
68
	 * Gets the charts engine.
69
	 * @return the chartsEngine
70
	 */
71
	public JFCChartsEngine getChartsEngine() {
72
		return chartsEngine;
73
	}
74

  
75

  
76
	public JFCTheme getTheme()	{
77
		return this.chartsEngine.getJFCTheme();
78
	}
79
	
80
	
81
	/**
82
	 * Gets the items renderer of the specified plot.
83
	 * @param plot
84
	 * @return
85
	 */
86
	public static LegendItemSource getRenderer(Plot plot)	{
87
		LegendItemSource renderer = null;
88

  
89
		if(plot instanceof XYPlot) {
90
			renderer = ((XYPlot) plot).getRenderer();
91
		}
92
		else if(plot instanceof CategoryPlot)	{
93
			renderer = ((CategoryPlot) plot).getRenderer();
94
		}
95
		
96
		return renderer;
97
	}
98
	
99
	/**
100
	 * Gets the items renderer associated to the plot linked to the specified chart panel.
101
	 * @param panel
102
	 * @return
103
	 */
104
	public static LegendItemSource getRenderer(ChartPanel panel)	{
105
		return getRenderer(panel.getChart().getPlot());
106
	}
107
	
108
}
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/swt/JFCComposite.java (revision 838)
1 1
package org.txm.chartsengine.jfreechart.rcp.swt;
2 2

  
3
import java.awt.BorderLayout;
4 3
import java.awt.Component;
5
import java.awt.EventQueue;
6
import java.awt.Frame;
7
import java.io.File;
8
import java.util.EventListener;
9 4

  
10
import javax.swing.JPanel;
11

  
12 5
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.awt.SWT_AWT;
14 6
import org.eclipse.swt.widgets.Composite;
15 7
import org.jfree.chart.ChartMouseListener;
16 8
import org.jfree.chart.ChartPanel;
17 9
import org.jfree.chart.JFreeChart;
18 10
import org.jfree.chart.plot.CategoryPlot;
19 11
import org.jfree.chart.plot.XYPlot;
20
import org.txm.chartsengine.jfreechart.core.JFCChartsEngine;
21 12
import org.txm.chartsengine.jfreechart.core.renderers.MultipleItemsSelector;
22 13
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IRendererWithItemSelection;
23 14
import org.txm.chartsengine.rcp.IChartComponent;
24 15
import org.txm.chartsengine.rcp.editors.ChartEditor;
25 16
import org.txm.chartsengine.rcp.events.EventCallBackHandler;
26
import org.txm.chartsengine.rcp.swt.ChartComposite;
17
import org.txm.chartsengine.rcp.swt.SwingChartComposite;
27 18

  
28 19
/**
29 20
 * JFreeChart SWT composite.
30 21
 * @author sjacquot
31 22
 *
32 23
 */
33
public class JFCComposite extends ChartComposite {
24
public class JFCComposite extends SwingChartComposite {
34 25

  
35 26

  
36
	// For reducing resize flickering on Windows
37
	static	{
38
		try {
39
			System.setProperty("sun.awt.noerasebackground", "true"); //$NON-NLS-1$ //$NON-NLS-2$
40
		}
41
		catch (NoSuchMethodError error) {
42
		}
43
	}
44

  
45

  
46

  
47
	protected Frame frame;
48
	
49
	//FIXME: tests
50
	//protected Panel rootPanel;
51
	//protected JRootPane rootPanel;
52
	protected JPanel rootPanel;
53
	
54

  
55 27
	/**
56 28
	 * Creates a JFreeChart composite.
57 29
	 * @param parent
......
61 33
		//super(chartEditor, parent, SWT.EMBEDDED | SWT.NO_BACKGROUND);
62 34
		super(chartEditor, parent, SWT.EMBEDDED);
63 35
		//super(parent, SWT.EMBEDDED | SWT.NO_MERGE_PAINTS | SWT.NO_BACKGROUND); // do not fix the transparency problem
64

  
65
		//this.chartComponent = (IChartComponent) panel;
66
		// FIXME : transparency doesn't work with tool tips
67
		// The problem here is that we normally need a JFrame but it seems to be impossible to embed a JFrame
68
//		this.setBackgroundMode(SWT.INHERIT_FORCE); // do not fix
69
//		ToolTipManager.sharedInstance().setLightWeightPopupEnabled(true); // do not fix
70

  
71
		this.frame = SWT_AWT.new_Frame(this);
72
		// Need to add an AWT Panel to fix mouse events and mouse cursors changes on Swing JPanel
73
		//this.rootPanel = new Panel(new BorderLayout());
74
		//this.rootPanel = new JRootPane();
75
		this.rootPanel = new JPanel(new BorderLayout());
76
		
77
		
78
		
79
		this.frame.add(this.rootPanel);
80

  
81

  
82
		
83
		this.frame.setVisible(true);
84
//		this.frame.pack();
85
//		this.pack(true);
86
//		parent.pack();
87
//		this.layout(true);
88
//		parent.layout(true);
89
		
90
		// To fix MAC OS X + Java 1.7/1.8 SWT_AWT BUG
91
		// see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=418245#c12
92
//		SwingUtilities.invokeLater(new Runnable() {
93 36
//
37
//		//this.chartComponent = (IChartComponent) panel;
38
//		// FIXME : transparency doesn't work with tool tips
39
//		// The problem here is that we normally need a JFrame but it seems to be impossible to embed a JFrame
40
////		this.setBackgroundMode(SWT.INHERIT_FORCE); // do not fix
41
////		ToolTipManager.sharedInstance().setLightWeightPopupEnabled(true); // do not fix
94 42
//
95
//		   @Override
96
//		   public void run() {
43
//		this.frame = SWT_AWT.new_Frame(this);
44
//		// Need to add an AWT Panel to fix mouse events and mouse cursors changes on Swing JPanel
45
//		//this.rootPanel = new Panel(new BorderLayout());
46
//		//this.rootPanel = new JRootPane();
47
//		this.rootPanel = new JPanel(new BorderLayout());
48
//		
49
//		
50
//		
51
//		this.frame.add(this.rootPanel);
52
//
53
//
54
//		
55
//		this.frame.setVisible(true);
56
////		this.frame.pack();
57
////		this.pack(true);
58
////		parent.pack();
59
////		this.layout(true);
60
////		parent.layout(true);
61
//		
62
//		// To fix MAC OS X + Java 1.7/1.8 SWT_AWT BUG
63
//		// see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=418245#c12
64
////		SwingUtilities.invokeLater(new Runnable() {
65
////
66
////
67
////		   @Override
68
////		   public void run() {
69
//
70
//
71
//
72
//
73
////			// Need to add an AWT Panel to fix mouse events and mouse cursors changes on Swing JPanel
74
////			this.rootPanel = new Panel(new BorderLayout());
75
////			//rootPanel.add(this.getChartPanel()); // commenter cette ligne pour le test de scrolling ci-dessous
76
////			this.frame.add(this.rootPanel);
77
//
78
//
79
//			// FIXME: test, smarter way to embed the frame ? Actually it doesn't fix neither the tooltip transparency nor the cursor change on pan under Mac OS X
80
//	//		// Need to add an AWT Panel to fix mouse events and mouse cursors changes on Swing JPanel
81
//	//		Panel rootPanel = new Panel(new BorderLayout());
82
//	////		rootPanel.add(this.chartPanel); // commenter cette ligne pour le test de scrolling ci-dessous
83
//	//		frame.add(rootPanel);
84
//	//		JRootPane rootPane = new JRootPane();
85
//	//		rootPanel.add(rootPane);
86
//	//		rootPane.getContentPane().add(this.chartPanel);
87
//
88
//
89
//
90
//			// FIXME: tests with a JApplet as Rootpane rather than Panel
91
//	//		JApplet rootPanel = new JApplet();
92
//	//		rootPanel.add(this.chartPanel); // commenter cette ligne pour le test de scrolling ci-dessous
93
//	//		frame.add(rootPanel);
94
//
95
//
96
//
97
//
98
//			// FIXME : tests scroll Swing: les width des panel sont définies dans les méthodes de JFCChartsSwingComponentsProvider
99
//			// FIXME : ce code fait bugger le changement de couleur des barres au mouse over et la bordure colorée des tooltips
100
//			// FIXME : ce code augmente à fond la RAM consommée, il y a un prob de composants en double ?
101
//			// En fait c'est un problème Java2D apparemment et qui semble "normal"
102
//			//panel.setPreferredSize(new Dimension(20000, 300));
103
//	//		JScrollPane scrollpane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
104
//	//		frame.add(scrollpane);
105
//
106
//
107
//
108
//			// FIXME : version AWT
109
//			// FIXME : ce code aussi n'augmente pas la RAM consommée ? à moins que ce soit uniquement quand la largeur du panel est large (bug de JFC sur les larges plots ?)
110
//	//		ScrollPane scrollpane = new ScrollPane();
111
//	//		scrollpane.add(panel);
112
//	//		frame.add(scrollpane);
113
//
114
//			//frame.pack();
115
//
116
//
117
//			// FIXME : test scroll SWT : fonctionne presque
118
//	//		ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
119
//	//		scrolledComposite.setExpandHorizontal(true);
120
//	//		scrolledComposite.setExpandVertical(true);
121
//	//		//parent.setLayout(new GridLayout(1, true));
122
//	//		parent.setLayout(new FillLayout(SWT.VERTICAL));
123
//	//		//parent.setLayout(new FormLayout());
124
//	//		this.setParent(scrolledComposite);
125
//	//		//this.setLayout(new FillLayout());
126
//	//
127
//	//		scrolledComposite.setContent(this);
128
//	//		scrolledComposite.setAlwaysShowScrollBars(true);
129
//	//
130
//	//		scrolledComposite.setMinSize(16000, 0);
131
//			// ********** Fin test 1
132
//
133
//
134
//
135
//			// FIXME : test scroll SWT
136
//	//		ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
137
//	//		scrolledComposite.setExpandHorizontal(true);
138
//	//		scrolledComposite.setExpandVertical(true);
139
//	//		//parent.setLayout(new GridLayout(1, true));
140
//	//		parent.setLayout(new FormLayout());
141
//	//		this.setParent(scrolledComposite);
142
//	//		this.setLayout(new FillLayout());
143
//	//
144
//	//		scrolledComposite.setContent(this);
145
//	//		scrolledComposite.setAlwaysShowScrollBars(true);
146
//	//
147
//	//		scrolledComposite.setMinSize(16000, 500);
148
//	//
149
//	//		this.setSize(16000, 500);
150
//
151
//
152
//			//scrolledComposite.pack(true);
153
//			//scrolledComposite.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
154
//
155
//	//		frame.pack();
156
//	//		System.err.println("JFCComposite.JFCComposite() frame: " + frame.getWidth() + " - " + frame.getHeight());
157
//
158
//			//scrolledComposite.setMinSize(new Point(2000, 500));
159
//			//frame.setSize(2000, 500);
160
//
161
//
162
//
163
//			// Test tool tips transparency : do not fix transparency and create error
164
//	//		JFrame jFrame = new JFrame();
165
//	//		//jFrame.setContentPane(panel);
166
//	//		jFrame.add(panel);
167
//	//		frame.add(jFrame);
168
//
169
//
170
//			// FIXME: tests fix bug "Reset view" + Java 6 focus bugs
171
//	//		this.chartPanel.addFocusListener(new FocusListener() {
172
//	//
173
//	//			@Override
174
//	//			public void focusLost(FocusEvent e) {
175
//	//				// TODO Auto-generated method stub
176
//	//				System.err.println("JFCComposite.JFCComposite(...).new FocusListener() {...}.focusLost() chart panel");
177
//	//			}
178
//	//
179
//	//			@Override
180
//	//			public void focusGained(FocusEvent e) {
181
//	//				// TODO Auto-generated method stub
182
//	//				System.err.println("JFCComposite.JFCComposite(...).new FocusListener() {...}.focusGained() chart panel");
183
//	//			}
184
//	//		});
185
//
186
//
187
//			// FIXME : axis unit square ratio tests
188
//	//		this.addListener(SWT.Resize, new Listener() {
189
//	//
190
//	//			@Override
191
//	//			public void handleEvent(Event e) {
192
//	//				switch (e.type) {
193
//	//					case SWT.Resize:
194
//	//						System.err.println("ChartComposite.ChartComposite(...).new Listener() {...}.handleEvent()");
195
//	//						resetView();
196
//	//						break;
197
//	//				}
198
//	//
199
//	//			}
200
//	//		});
201
//
202
//
203
//			//this.frame.setVisible(true);
204
//			//parent.pack();
205
//
206
////		   }
207
////	   });
97 208

  
98 209

  
99

  
100

  
101
//			// Need to add an AWT Panel to fix mouse events and mouse cursors changes on Swing JPanel
102
//			this.rootPanel = new Panel(new BorderLayout());
103
//			//rootPanel.add(this.getChartPanel()); // commenter cette ligne pour le test de scrolling ci-dessous
104
//			this.frame.add(this.rootPanel);
105

  
106

  
107
			// FIXME: test, smarter way to embed the frame ? Actually it doesn't fix neither the tooltip transparency nor the cursor change on pan under Mac OS X
108
	//		// Need to add an AWT Panel to fix mouse events and mouse cursors changes on Swing JPanel
109
	//		Panel rootPanel = new Panel(new BorderLayout());
110
	////		rootPanel.add(this.chartPanel); // commenter cette ligne pour le test de scrolling ci-dessous
111
	//		frame.add(rootPanel);
112
	//		JRootPane rootPane = new JRootPane();
113
	//		rootPanel.add(rootPane);
114
	//		rootPane.getContentPane().add(this.chartPanel);
115

  
116

  
117

  
118
			// FIXME: tests with a JApplet as Rootpane rather than Panel
119
	//		JApplet rootPanel = new JApplet();
120
	//		rootPanel.add(this.chartPanel); // commenter cette ligne pour le test de scrolling ci-dessous
121
	//		frame.add(rootPanel);
122

  
123

  
124

  
125

  
126
			// FIXME : tests scroll Swing: les width des panel sont définies dans les méthodes de JFCChartsSwingComponentsProvider
127
			// FIXME : ce code fait bugger le changement de couleur des barres au mouse over et la bordure colorée des tooltips
128
			// FIXME : ce code augmente à fond la RAM consommée, il y a un prob de composants en double ?
129
			// En fait c'est un problème Java2D apparemment et qui semble "normal"
130
			//panel.setPreferredSize(new Dimension(20000, 300));
131
	//		JScrollPane scrollpane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
132
	//		frame.add(scrollpane);
133

  
134

  
135

  
136
			// FIXME : version AWT
137
			// FIXME : ce code aussi n'augmente pas la RAM consommée ? à moins que ce soit uniquement quand la largeur du panel est large (bug de JFC sur les larges plots ?)
138
	//		ScrollPane scrollpane = new ScrollPane();
139
	//		scrollpane.add(panel);
140
	//		frame.add(scrollpane);
141

  
142
			//frame.pack();
143

  
144

  
145
			// FIXME : test scroll SWT : fonctionne presque
146
	//		ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
147
	//		scrolledComposite.setExpandHorizontal(true);
148
	//		scrolledComposite.setExpandVertical(true);
149
	//		//parent.setLayout(new GridLayout(1, true));
150
	//		parent.setLayout(new FillLayout(SWT.VERTICAL));
151
	//		//parent.setLayout(new FormLayout());
152
	//		this.setParent(scrolledComposite);
153
	//		//this.setLayout(new FillLayout());
154
	//
155
	//		scrolledComposite.setContent(this);
156
	//		scrolledComposite.setAlwaysShowScrollBars(true);
157
	//
158
	//		scrolledComposite.setMinSize(16000, 0);
159
			// ********** Fin test 1
160

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

Formats disponibles : Unified diff