Révision 3382

TXM/trunk/org.txm.internalview.rcp/plugin.xml (revision 3382)
96 96
      <definition
97 97
            id="OneInternalViewSelected">
98 98
         <with
99
               variable="selection">
99
               variable="corporaSelection">
100 100
            <iterate
101 101
                  ifEmpty="false"
102 102
                  operator="and">
......
126 126
                            <reference
127 127
                                  definitionId="InternalViewEditorActive">
128 128
                            </reference>
129
                            <reference
130
                     definitionId="SelectionIsNotEmpty">
131
               </reference>
129 132
                                     <reference
130 133
                                           definitionId="SendSelectionContextNotActive">
131 134
                                     </reference>
......
140 143
                         <reference
141 144
                               definitionId="InternalViewEditorActive">
142 145
                         </reference>
146
                         <reference
147
                     definitionId="SelectionIsNotEmpty">
148
               </reference>
143 149
                                  <reference
144 150
                                        definitionId="SendSelectionContextNotActive">
145 151
                                  </reference>
......
154 160
                            <reference
155 161
                                  definitionId="InternalViewEditorActive">
156 162
                            </reference>
163
                            <reference
164
                     definitionId="SelectionIsNotEmpty">
165
               </reference>
157 166
                                     <reference
158 167
                                           definitionId="SendSelectionContextNotActive">
159 168
                                     </reference>
TXM/trunk/org.txm.links.rcp/src/org/txm/links/rcp/handlers/SendSelectionToQueryable.java (revision 3382)
90 90
		
91 91
		ISelection selection = HandlerUtil.getCurrentSelection(event);
92 92
		
93
		if (selection != null) {
93
		if (selection != null && !selection.isEmpty()) {
94 94
			
95
			
96
			
95 97
			String query = this.createQuery(event, selection);
96 98
			String queries = this.createQueries(event, selection);
97 99
			Integer index = this.getIndexResult(event, selection);
TXM/trunk/org.txm.querycooccurrences.rcp/src/org/txm/rcp/commands/function/ComputeQueryCooccurrence.java (revision 3382)
61 61
import org.txm.functions.coocmatrix.QueryCooccurrence;
62 62
//import org.txm.functions.queryindex.*;
63 63
import org.txm.rcp.JobsTimer;
64
import org.txm.rcp.handlers.BaseAbstractHandler;
64 65
import org.txm.rcp.messages.TXMUIMessages;
65 66
import org.txm.rcp.utils.JobHandler;
66 67
import org.txm.rcp.views.QueriesView;
......
79 80
 * if the selection is a corpus, open an empty Cooc editor if the selection is a
80 81
 * concordance, open a Cooc editor already computed @ author mdecorde.
81 82
 */
82
public class ComputeQueryCooccurrence extends AbstractHandler {
83
public class ComputeQueryCooccurrence extends BaseAbstractHandler {
83 84

  
84 85
	float reqtime = 0.5f;
85 86

  
......
88 89
	 */
89 90
	@Override
90 91
	public Object execute(ExecutionEvent event) throws ExecutionException {
91
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
92
		
93
		IStructuredSelection selection = this.getCorporaViewSelection(event);
92 94
		final Object element = selection.getFirstElement();
93 95

  
94 96
		final Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event)
TXM/trunk/org.txm.querycooccurrences.rcp/src/org/txm/rcp/commands/function/ComputeQueryAutoCooccurrence.java (revision 3382)
58 58
import org.txm.queryindex.core.functions.QueryIndex;
59 59
import org.txm.queryindex.core.functions.QueryIndexLine;
60 60
import org.txm.rcp.JobsTimer;
61
import org.txm.rcp.handlers.BaseAbstractHandler;
61 62
import org.txm.rcp.messages.TXMUIMessages;
62 63
import org.txm.rcp.utils.JobHandler;
63 64
import org.txm.rcp.views.QueriesView;
......
77 78
 * if the selection is a corpus, open an empty Cooc editor if the selection is a
78 79
 * concordance, open a Cooc editor already computed @ author mdecorde.
79 80
 */
80
public class ComputeQueryAutoCooccurrence extends AbstractHandler {
81
public class ComputeQueryAutoCooccurrence extends BaseAbstractHandler {
81 82

  
82 83
	float reqtime = 0.5f;
83 84

  
......
86 87
	 */
87 88
	@Override
88 89
	public Object execute(ExecutionEvent event) throws ExecutionException {
89
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
90
		
91
		IStructuredSelection selection = this.getCorporaViewSelection(event);
90 92
		final Object element = selection.getFirstElement();
91 93

  
92 94
		final Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event)
TXM/trunk/org.txm.querycooccurrences.rcp/plugin.xml (revision 3382)
55 55
      <definition
56 56
            id="OneQueryCooccurrenceSelected">
57 57
         <with
58
               variable="selection">
58
               variable="corporaSelection">
59 59
            <iterate
60 60
                  ifEmpty="false"
61 61
                  operator="and">
TXM/trunk/org.txm.cql2lsa.rcp/src/org/txm/rcp/commands/function/ComputeValuesOfQuery.java (revision 3382)
50 50
import org.eclipse.ui.handlers.HandlerUtil;
51 51
import org.txm.functions.cql2lsa.ValuesOfQuery;
52 52
import org.txm.rcp.JobsTimer;
53
import org.txm.rcp.handlers.BaseAbstractHandler;
53 54
import org.txm.rcp.swt.widget.AssistedQueryWidget;
54 55
import org.txm.rcp.utils.JobHandler;
55 56
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
......
64 65
 * 
65 66
 * @author mdecorde.
66 67
 */
67
public class ComputeValuesOfQuery extends AbstractHandler {
68
public class ComputeValuesOfQuery extends BaseAbstractHandler {
68 69
	
69 70
	/** The ID. */
70 71
	public static String ID = "org.txm.rcp.commands.function.ComputeQueryIndex"; //$NON-NLS-1$
......
79 80
	@Override
80 81
	public Object execute(ExecutionEvent event) throws ExecutionException {
81 82
		Log.info("Compute QueryIndex: start");
82
		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
83
		selection = this.getCorporaViewSelection(event);
83 84
		
84 85
		Object s = selection.getFirstElement();
85 86
		if (!(s instanceof CQPCorpus)) return null;
TXM/trunk/org.txm.cooccurrence.rcp/plugin.xml (revision 3382)
158 158
      <definition
159 159
            id="OneCooccurrenceSelected">
160 160
         <with
161
               variable="selection">
161
               variable="corporaSelection">
162 162
            <iterate
163 163
                  ifEmpty="false"
164 164
                  operator="and">
......
189 189
                     definitionId="CooccurrenceEditorActive">
190 190
               </reference>
191 191
               <reference
192
                     definitionId="SelectionIsNotEmpty">
193
               </reference>
194
               <reference
192 195
                     definitionId="SendSelectionContextNotActive">
193 196
               </reference>
194 197
            </and></activeWhen>
TXM/trunk/org.txm.ahc.rcp/plugin.xml (revision 3382)
131 131
      <definition
132 132
            id="OneCAHSelected">
133 133
         <with
134
               variable="selection">
134
               variable="corporaSelection">
135 135
            <iterate
136 136
                  ifEmpty="false"
137 137
                  operator="and">
TXM/trunk/org.txm.searchengine.cqp.rcp/plugin.xml (revision 3382)
386 386
      <definition
387 387
            id="OneMainCorpusSelected">
388 388
         <with
389
               variable="selection">
389
               variable="corporaSelection">
390 390
            <iterate
391 391
                  ifEmpty="false"
392 392
                  operator="and">
......
402 402
      <definition
403 403
            id="OneSubCorpusSelected">
404 404
         <with
405
               variable="selection">
405
               variable="corporaSelection">
406 406
            <iterate
407 407
                  operator="and">
408 408
               <instanceof
......
417 417
      <definition
418 418
            id="OneCorpusSelected">
419 419
         <with
420
               variable="selection">
420
               variable="corporaSelection">
421 421
            <iterate
422 422
                  ifEmpty="false"
423 423
                  operator="and">
TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeIntersection.java (revision 3382)
12 12
import org.eclipse.jface.viewers.IStructuredSelection;
13 13
import org.eclipse.ui.handlers.HandlerUtil;
14 14
import org.txm.Toolbox;
15
import org.txm.rcp.handlers.BaseAbstractHandler;
15 16
import org.txm.searchengine.cqp.AbstractCqiClient;
16 17
import org.txm.searchengine.cqp.CQPSearchEngine;
17 18
import org.txm.searchengine.cqp.corpus.CQPCorpus;
......
19 20
import org.txm.searchengine.cqp.corpus.MainCorpus;
20 21
import org.txm.searchengine.cqp.corpus.Subcorpus;
21 22

  
22
public class ComputeIntersection extends AbstractHandler {
23
public class ComputeIntersection extends BaseAbstractHandler {
23 24
	
24 25
	@Override
25 26
	public void addHandlerListener(IHandlerListener handlerListener) {
......
34 35
	
35 36
	@Override
36 37
	public Object execute(ExecutionEvent event) throws ExecutionException {
37
		ISelection isel = HandlerUtil.getCurrentSelection(event);
38
		
39
		ISelection isel = this.getCorporaViewSelection(event);
38 40
		if (!(isel instanceof IStructuredSelection)) return null;
39 41
		IStructuredSelection selection = (IStructuredSelection) isel;
40 42
		List list = selection.toList();
TXM/trunk/org.txm.specificities.rcp/plugin.xml (revision 3382)
170 170
      <definition
171 171
            id="OneSpecificitiesResultSelected">
172 172
         <with
173
               variable="selection">
173
               variable="corporaSelection">
174 174
            <iterate
175 175
                  ifEmpty="false"
176 176
                  operator="and">
TXM/trunk/org.txm.ca.rcp/plugin.xml (revision 3382)
148 148
      <definition
149 149
            id="OneICAComputableSelected">
150 150
         <with
151
               variable="selection">
151
               variable="corporaSelection">
152 152
            <iterate
153 153
                  ifEmpty="false"
154 154
                  operator="and">
......
161 161
      <definition
162 162
            id="OneCASelected">
163 163
         <with
164
               variable="selection">
164
               variable="corporaSelection">
165 165
            <iterate
166 166
                  ifEmpty="false"
167 167
                  operator="and">
TXM/trunk/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ComputeInterTextDistance.java (revision 3382)
1 1
package org.txm.lexicaltable.rcp.handlers;
2 2

  
3
import org.eclipse.core.commands.AbstractHandler;
4 3
import org.eclipse.core.commands.ExecutionEvent;
5 4
import org.eclipse.core.commands.ExecutionException;
6 5
import org.eclipse.core.commands.IHandlerListener;
7 6
import org.eclipse.jface.viewers.IStructuredSelection;
8
import org.eclipse.ui.handlers.HandlerUtil;
9 7
import org.txm.core.messages.TXMCoreMessages;
10 8
import org.txm.functions.intertextualdistance.InterTextDistance;
11 9
import org.txm.lexicaltable.core.functions.LexicalTable;
10
import org.txm.rcp.handlers.BaseAbstractHandler;
12 11
import org.txm.utils.logger.Log;
13 12

  
14
public class ComputeInterTextDistance extends AbstractHandler {
13
public class ComputeInterTextDistance extends BaseAbstractHandler {
15 14
	
16 15
	private IStructuredSelection selection;
17 16
	
......
25 24
		super.dispose();
26 25
	}
27 26
	
28
	
29 27
	@Override
30 28
	public Object execute(ExecutionEvent event) throws ExecutionException {
31
		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
29
		selection = this.getCorporaViewSelection(event);
32 30
		
33 31
		Object s = selection.getFirstElement();
34 32
		if (!(s instanceof LexicalTable))
TXM/trunk/org.txm.lexicaltable.rcp/plugin.xml (revision 3382)
230 230
      <definition
231 231
            id="OneLexicalTableSelected">
232 232
         <with
233
               variable="selection">
233
               variable="corporaSelection">
234 234
            <iterate
235 235
                  ifEmpty="false"
236 236
                  operator="and">
TXM/trunk/org.txm.wordcloud.rcp/plugin.xml (revision 3382)
133 133
      <definition
134 134
            id="OneWordCloudSelected">
135 135
         <with
136
               variable="selection">
136
               variable="corporaSelection">
137 137
            <iterate
138 138
                  ifEmpty="false"
139 139
                  operator="and">
TXM/trunk/org.txm.partition.rcp/plugin.xml (revision 3382)
112 112
      <definition
113 113
            id="OnePartitionSelected">
114 114
         <with
115
               variable="selection">
115
               variable="corporaSelection">
116 116
            <iterate
117 117
                  ifEmpty="false"
118 118
                  operator="and">
TXM/trunk/org.txm.referencer.rcp/plugin.xml (revision 3382)
141 141
                  definitionId="ReferencerEditorActive">
142 142
            </reference>
143 143
            <reference
144
                     definitionId="SelectionIsNotEmpty">
145
               </reference>
146
            <reference
144 147
                  definitionId="SendSelectionContextNotActive">
145 148
            </reference>
146 149
            </and>
TXM/trunk/org.txm.queryindex.rcp/src/org/txm/queryindex/rcp/commands/function/ComputeQueryIndex.java (revision 3382)
40 40
import org.txm.rcp.StatusLine;
41 41
import org.txm.rcp.TXMWindows;
42 42
import org.txm.rcp.editors.TXMResultEditorInput;
43
import org.txm.rcp.handlers.BaseAbstractHandler;
43 44
import org.txm.searchengine.cqp.corpus.CQPCorpus;
44 45
import org.txm.searchengine.cqp.corpus.Partition;
45 46
import org.txm.utils.logger.Log;
......
49 50
 * 
50 51
 * @author mdecorde.
51 52
 */
52
public class ComputeQueryIndex extends AbstractHandler {
53
public class ComputeQueryIndex extends BaseAbstractHandler {
53 54

  
54 55
	/** The ID. */
55 56
	public static String ID = "org.txm.rcp.commands.function.ComputeQueryIndex"; //$NON-NLS-1$
......
63 64
	@Override
64 65
	public Object execute(ExecutionEvent event) throws ExecutionException {
65 66
		Log.info("Compute QueryIndex: start");
66
		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
67
		selection = this.getCorporaViewSelection(event);
67 68

  
68 69
		Object s = selection.getFirstElement();
69 70
		if (s instanceof CQPCorpus) {
TXM/trunk/org.txm.index.rcp/plugin.xml (revision 3382)
288 288
      <definition
289 289
            id="OneIndexSelected">
290 290
         <with
291
               variable="selection">
291
               variable="corporaSelection">
292 292
            <iterate
293 293
                  ifEmpty="false"
294 294
                  operator="and">
......
301 301
      <definition
302 302
            id="OneLexiconSelected">
303 303
         <with
304
               variable="selection">
304
               variable="corporaSelection">
305 305
            <iterate
306 306
                  ifEmpty="false"
307 307
                  operator="and">
......
341 341
      <definition
342 342
            id="OnePartitionIndexSelected">
343 343
         <with
344
               variable="selection">
344
               variable="corporaSelection">
345 345
            <iterate
346 346
                  ifEmpty="false"
347 347
                  operator="and">
......
385 385
         
386 386
         </or>
387 387
         <reference
388
                     definitionId="SelectionIsNotEmpty">
389
               </reference>
390
         <reference
388 391
               definitionId="SendSelectionContextNotActive">
389 392
         </reference>
390 393
         </and>
......
406 409
                     definitionId="PartitionIndexEditorActive">
407 410
               </reference>
408 411
            </or>
409
            
410
            
411 412
               <reference
413
                     definitionId="SelectionIsNotEmpty">
414
               </reference>
415
               <reference
412 416
                     definitionId="SendSelectionContextNotActive">
413 417
               </reference>
414 418
            
......
431 435
                     definitionId="PartitionIndexEditorActive">
432 436
               </reference>
433 437
            </or>
438
            <reference
439
                     definitionId="SelectionIsNotEmpty">
440
               </reference>
434 441
               <reference
435 442
                     definitionId="SendSelectionContextNotActive">
436 443
               </reference>
......
446 453
                     definitionId="LexiconEditorActive">
447 454
               </reference>
448 455
               <reference
456
                     definitionId="SelectionIsNotEmpty">
457
               </reference>
458
               <reference
449 459
                     definitionId="SendSelectionContextNotActive">
450 460
               </reference>
451 461
            </and>
TXM/trunk/org.txm.treesearch.rcp/src/org/txm/treesearch/command/ComputeTreeSearch.java (revision 3382)
40 40
import org.txm.core.preferences.TXMPreferences;
41 41
import org.txm.core.results.TXMResult;
42 42
import org.txm.rcp.editors.TXMEditor;
43
import org.txm.rcp.handlers.BaseAbstractHandler;
43 44
import org.txm.searchengine.cqp.corpus.CQPCorpus;
44 45
import org.txm.treesearch.editor.TreeSearchEditor;
45 46
import org.txm.treesearch.function.TreeSearch;
......
53 54
 * 
54 55
 * @author mdecorde.
55 56
 */
56
public class ComputeTreeSearch extends AbstractHandler {
57
public class ComputeTreeSearch extends BaseAbstractHandler {
57 58
	
58 59
	/** The ID. */
59 60
	public static String ID = ComputeTreeSearch.class.getName();
......
73 74
			s = TXMResult.getResult(parametersNodePath); // a TreeSearch or a CQPCorpus
74 75
		}
75 76
		else { // From view result node
76
			IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
77
			IStructuredSelection selection = this.getCorporaViewSelection(event);
77 78
			s = selection.getFirstElement();
78 79
		}
79 80
		
TXM/trunk/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java (revision 3382)
2 2

  
3 3
import java.io.File;
4 4
import java.net.URL;
5
import java.net.URLEncoder;
5 6
import java.util.ArrayList;
6 7
import java.util.Arrays;
7 8
import java.util.Collection;
......
782 783
	@Override
783 784
	public void setURL(String url) {
784 785
		if (!this.browser.isDisposed()) {
785
			super.setURL(url);
786
			int begin = url.indexOf(":/");
787
			String start = url.substring(0, begin);
788
			String end = URLEncoder.encode(url.substring(begin+2));
789
			super.setURL(start+":/"+end);
786 790
		}
787 791
	}
788 792
	
TXM/trunk/org.txm.edition.rcp/plugin.xml (revision 3382)
136 136
            commandId="org.txm.concordance.rcp.handlers.ComputeConcordance">
137 137
         <activeWhen>
138 138
            <and>
139
            <reference
140
                     definitionId="SelectionIsNotEmpty">
141
               </reference>
139 142
               <reference
140 143
                     definitionId="SendSelectionContextNotActive">
141 144
               </reference>
TXM/trunk/org.txm.chartsengine.rcp/plugin.xml (revision 3382)
246 246
      <definition
247 247
            id="OneChartResultSelected">
248 248
         <with
249
               variable="selection">
249
               variable="corporaSelection">
250 250
            <iterate
251 251
                  ifEmpty="false"
252 252
                  operator="and">
TXM/trunk/org.txm.progression.rcp/plugin.xml (revision 3382)
154 154
      <definition
155 155
            id="OneProgressionSelected">
156 156
         <with
157
               variable="selection">
157
               variable="corporaSelection">
158 158
            <iterate
159 159
                  ifEmpty="false"
160 160
                  operator="and">
......
185 185
                     definitionId="ProgressionEditorActive">
186 186
               </reference>
187 187
               <reference
188
                     definitionId="SelectionIsNotEmpty">
189
               </reference>
190
               <reference
188 191
                     definitionId="SendSelectionContextNotActive">
189 192
               </reference>
190 193
            </and>
TXM/trunk/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 3382)
1467 1467
		try {
1468 1468
			QueriesView.refresh();
1469 1469
			
1470
			this.fillDisplayArea(update );
1470
			this.fillDisplayArea(update);
1471 1471
			
1472 1472
			boolean b = concordance.getQueryResultParameter() == null;
1473 1473
			this.queryWidget.setEnabled(b); // disable the widget if a QueryResult was provided
......
1614 1614
		concordance.setRefViewPattern(referencePattern);
1615 1615
		sort();
1616 1616
		this.resetLeftTableColumnWidths();
1617
		getResultArea().layout(true, true);
1617 1618
	}
1618 1619
	
1619 1620
	/**
......
2311 2312
		
2312 2313
		((FormData) sash.getLayoutData()).left = new FormAttachment(0, 25 + (int) (refMax * W));
2313 2314
		
2314
		referenceColumn.setWidth(2 * (int) (refMax * W));
2315
		getResultArea().layout(true, true);
2315
		int s = 2 * (int) (refMax * W);
2316
		referenceColumn.setWidth(s);
2317
//		System.out.println("REFSIZE="+s);
2316 2318
	}
2317 2319
	
2318 2320
	/**
......
2341 2343
				max = MAX_CHARS_LENGTH_TO_SHOW;
2342 2344
			}
2343 2345
			
2344
			column.setWidth(15 + (int) (max * W));
2346
			int s = 15 + (int) (max * W);
2347
			column.setWidth(s);
2348
//			System.out.println(column.getText()+"SIZE="+s);
2345 2349
		}
2346 2350
		
2347 2351
		viewerRight.getTable().layout(true, true);
2352
		
2348 2353
		tableResizeListener.handleEvent(null); // center on keyword column
2349 2354
		return n;
2350 2355
	}
......
2358 2363
	 * @return the number of lines in the table
2359 2364
	 */
2360 2365
	public int resetColumnWidths() {
2366
		if (!concordance.hasBeenComputedOnce()) return 0;
2367
		
2368
		
2361 2369
		resetLeftTableColumnWidths();
2362
		return resetRightTableColumnWidths();
2370
		int c = resetRightTableColumnWidths();
2371
		getResultArea().layout(true, true);
2372
		return c;
2363 2373
	}
2364 2374
	
2365 2375
	public Composite getExtensionButtonComposite() {
TXM/trunk/org.txm.concordance.rcp/plugin.xml (revision 3382)
21 21
      <definition
22 22
            id="OneConcordanceSelected">
23 23
         <with
24
               variable="selection">
24
               variable="corporaSelection">
25 25
            <iterate
26 26
                  ifEmpty="false"
27 27
                  operator="and">
......
234 234
                  </reference>
235 235
               </or>
236 236
               <reference
237
                     definitionId="SelectionIsNotEmpty">
238
               </reference>
239
               <reference
237 240
                     definitionId="SendSelectionContextNotActive">
238 241
               </reference>
239 242
            </and>
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/CorporaSourceProvider.java (revision 3382)
1
package org.txm.rcp;
2

  
3
import java.util.HashMap;
4
import java.util.Map;
5

  
6
import org.eclipse.jface.viewers.ISelection;
7
import org.eclipse.ui.AbstractSourceProvider;
8
import org.txm.utils.logger.Log;
9

  
10
public class CorporaSourceProvider extends AbstractSourceProvider {
11
	
12
	public static final String NAME = "corporaSelection";
13
	public static final String[] NAMES = {NAME};
14
	HashMap<String, ISelection> currentState = new HashMap<String, ISelection>();
15
	
16
	public static CorporaSourceProvider instance = null;
17
	
18
	public CorporaSourceProvider() {
19
		
20
		currentState.put(NAME, null);
21
		instance = this;
22
	}
23
	
24
	public static void updateSelection(ISelection selection) {
25
		if (instance != null) {
26
			instance.currentState.put(NAME, selection);
27
			instance.fireSourceChanged(1, NAME, selection);
28
			Log.fine("UPDATE SOURCE: "+selection);
29
		}
30
	}
31
	
32
	@Override
33
	public void dispose() {
34
		
35
	}
36
	
37
	@Override
38
	public Map<String, ISelection> getCurrentState() {
39
		
40
		return currentState;
41
	}
42
	
43
	//	// Selection SourceProvider
44
	//
45
	//	ISelection selection;
46
	//	private IWorkbench workbench;
47
	//	
48
	//	@Override
49
	//	public void initialize(IServiceLocator locator) {
50
	////		this.locator = locator;
51
	//		super.initialize(locator);
52
	//		IWorkbenchLocationService wls = locator.getService(IWorkbenchLocationService.class);
53
	//		workbench = wls.getWorkbench();
54
	//	}
55
	//	
56
	//	private IWorkbenchWindow getActiveWindow() {
57
	//		final Shell newActiveShell = workbench.getDisplay().getActiveShell();
58
	//		final IContextService contextService = workbench.getService(IContextService.class);
59
	//		if (contextService != null) {
60
	//			final int shellType = contextService.getShellType(newActiveShell);
61
	//			if (shellType != IContextService.TYPE_DIALOG) {
62
	//				return workbench.getActiveWorkbenchWindow();
63
	//			}
64
	//		}
65
	//		return null;
66
	//	}
67
	
68
	
69
	@Override
70
	public String[] getProvidedSourceNames() {
71
		
72
		return NAMES;
73
	}
74
	
75
}
0 76

  
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/BaseAbstractHandler.java (revision 3382)
12 12
import org.eclipse.core.commands.ParameterValuesException;
13 13
import org.eclipse.core.commands.ParameterizedCommand;
14 14
import org.eclipse.core.commands.common.NotDefinedException;
15
import org.eclipse.jface.viewers.IStructuredSelection;
15 16
import org.eclipse.ui.IViewPart;
16 17
import org.eclipse.ui.IWorkbenchPage;
17 18
import org.eclipse.ui.IWorkbenchWindow;
......
86 87
	 * @param event the ExecutionEvent that provoke the command call.
87 88
	 * @return the corpora view current selection
88 89
	 */
90
	public IStructuredSelection getCorporaViewSelection(ExecutionEvent event) {
91
		
92
		// FIXME: check this, because it may be too linked to the Corpora view
93
		return (IStructuredSelection) (CorporaView.getInstance().getTreeViewer().getSelection());
94
//		// otherwise use this code
95
//		// yeah but selection might be tricky
96
//		// Object o = (IStructuredSelection) HandlerUtil.getCurrentSelection(event).getFirstElement();
97
//		if (o == null) {
98
//			Log.severe("BaseAbstractHandler.getCorporaViewSelectedObject(): current selection is null.");
99
//		}
100
//		
101
//		Log.fine("BaseAbstractHandler.getCorporaViewSelectedObject(): selected object = " + o);
102
//		
103
//		return o;
104
	}
105
	
106
	/**
107
	 * Gets the current selected object.
108
	 * 
109
	 * @param event the ExecutionEvent that provoke the command call.
110
	 * @return the corpora view current selected object
111
	 */
89 112
	public Object getCorporaViewSelectedObject(ExecutionEvent event) {
90 113
		
91 114
		// FIXME: check this, because it may be too linked to the Corpora view
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java (revision 3382)
73 73
import org.txm.core.results.TXMResult;
74 74
import org.txm.objects.Project;
75 75
import org.txm.objects.Workspace;
76
import org.txm.rcp.CorporaSourceProvider;
76 77
import org.txm.rcp.IImageKeys;
77 78
import org.txm.rcp.StatusLine;
78 79
import org.txm.rcp.commands.workspace.OpenCorpus;
......
315 316
				if (sel.length == 0)
316 317
					return;
317 318
				
319
				CorporaSourceProvider.updateSelection(treeViewer.getSelection());
320
				
318 321
				CorporaView.this.setFocus(); // force focus on the corpora view -> ensure the active selection is the corpora view selection
319 322
				
320 323
				ISelection tsel = treeViewer.getSelection();
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/commands/OpenBrowser.java (revision 3382)
29 29

  
30 30
import java.io.File;
31 31
import java.net.URL;
32
import java.net.URLEncoder;
32 33

  
33 34
import org.eclipse.core.commands.AbstractHandler;
34 35
import org.eclipse.core.commands.ExecutionEvent;
......
73 74
		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event)
74 75
				.getShell();
75 76
		
76
		String filename = event
77
				.getParameter("org.txm.rcp.commands.commandParameter2"); //$NON-NLS-1$
78
		if (filename != null && !filename.matches("") && !filename.matches(" ")) //$NON-NLS-1$ //$NON-NLS-2$
79
		{
77
		String filename = event.getParameter("org.txm.rcp.commands.commandParameter2"); //$NON-NLS-1$
78
		if (filename != null && !filename.matches("") && !filename.matches(" ")) { //$NON-NLS-1$ //$NON-NLS-2$
80 79
			openfile(filename);
81 80
			return null;
82 81
		}
......
94 93
		}
95 94
		
96 95
		if (file == null) {
96
			
97 97
			FileDialog dialog = new FileDialog(shell, SWT.OPEN);
98 98
			String txmhome = Toolbox.getTxmHomePath();
99 99
			if (LastOpened.getFile(ID) != null) {
......
104 104
				dialog.setFilterPath(txmhome);
105 105
			}
106 106
			if (dialog.open() != null) {
107
				String filepath = dialog.getFilterPath()
108
						+ "/" + dialog.getFileName(); //$NON-NLS-1$
107
				String filepath = dialog.getFilterPath() + "/" + dialog.getFileName(); //$NON-NLS-1$
109 108
				LastOpened.set(ID, dialog.getFilterPath(), dialog.getFileName());
110 109
				if (dialog.getFileName().length() > 0) {
111 110
					lastopenedfile = filepath;
......
118 117
				FileDialog dialog = new FileDialog(shell, SWT.OPEN);
119 118
				dialog.setFilterPath(file.getAbsolutePath());
120 119
				if (dialog.open() == null) return null;
121
				String filepath = dialog.getFilterPath()
122
						+ "/" + dialog.getFileName(); //$NON-NLS-1$
120
				String filepath = dialog.getFilterPath() + "/" + dialog.getFileName(); //$NON-NLS-1$
123 121
				LastOpened.set(ID, dialog.getFilterPath(), dialog.getFileName());
124 122
				lastopenedfile = filepath;
125 123
				return openfile(filepath);
......
179 177
	public static TXMBrowserEditor openEdition(String filepath, String editorname) {
180 178
		try {
181 179

  
182
			WebBrowserEditorInput editorInput;
183 180
			File localfile = new File(filepath);
184
			if (filepath == null || filepath.length() == 0)
185
				editorInput = new WebBrowserEditorInput(null, BrowserViewer.BUTTON_BAR | BrowserViewer.LOCATION_BAR);
186
			else if (localfile.exists())
187
				editorInput = new WebBrowserEditorInput(localfile.toURI().toURL(), BrowserViewer.BUTTON_BAR | BrowserViewer.LOCATION_BAR);
188
			else
189
				editorInput = new WebBrowserEditorInput(new URL(filepath), BrowserViewer.BUTTON_BAR | BrowserViewer.LOCATION_BAR);
181
			URL url = null;
182
			if (filepath == null || filepath.length() == 0) {
183

  
184
			} else if (localfile.exists()) {
185
				url = localfile.toURI().toURL();
186
			} else {
187
				url = new URL(filepath);
188
			}
190 189
			
190
			String s = url.toString();
191
			int begin = s.indexOf(":/");
192
			String start = s.substring(0, begin);
193
			String end = URLEncoder.encode(s.substring(begin+2));
194
			
195
			WebBrowserEditorInput editorInput = new WebBrowserEditorInput(new URL(start+":/"+end), BrowserViewer.BUTTON_BAR | BrowserViewer.LOCATION_BAR);
196
			
191 197
			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
192 198
			IWorkbenchPage page = window.getActivePage();
193 199
			
TXM/trunk/org.txm.rcp/plugin.xml (revision 3382)
30 30
      <product
31 31
            application="org.txm.rcp.Application"
32 32
            description="%product.description"
33
            name="TXM">
33
            name="TXM 0.8.2">
34 34
         <property
35 35
               name="appName"
36
               value="TXM">
36
               value="TXM 0.8.2">
37 37
         </property>
38 38
         <property
39 39
               name="windowImages"
......
3136 3136
                  </iterate>
3137 3137
               </with>
3138 3138
            </definition>
3139
            <definition
3140
                  id="SelectionIsNotEmpty">
3141
               <with
3142
                     variable="selection">
3143
                  <iterate
3144
                        ifEmpty="false"
3145
                        operator="and">
3146
                     <instanceof
3147
                           value="java.lang.Object">
3148
                     </instanceof>
3149
                  </iterate>
3150
               </with>
3151
            </definition>
3139 3152
   </extension>
3140 3153
  
3141 3154
   <extension
......
3349 3362
            name="Paths">
3350 3363
      </page>
3351 3364
   </extension>
3365
   <extension
3366
         point="org.eclipse.ui.services">
3367
      <sourceProvider
3368
            provider="org.txm.rcp.CorporaSourceProvider">
3369
         <variable
3370
               name="corporaSelection"
3371
               priorityLevel="workbench">
3372
         </variable>
3373
      </sourceProvider>
3374
   </extension>
3352 3375

  
3353 3376
</plugin>

Formats disponibles : Unified diff