Revision 1141

tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ComputeLexicalTable.java (revision 1141)
40 40
import org.eclipse.ui.dialogs.ListDialog;
41 41
import org.eclipse.ui.handlers.HandlerUtil;
42 42
//import org.txm.functions.queryindex.QueryIndex;
43
import org.txm.index.core.functions.Index;
43
import org.txm.index.core.functions.PartitionIndex;
44 44
import org.txm.lexicaltable.core.functions.LexicalTable;
45 45
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor;
46 46
import org.txm.lexicaltable.rcp.messages.LexicalTableUIMessages;
......
77 77
		LexicalTable lexicalTable = null;
78 78
		
79 79
		// Creating from Index
80
		if (selection instanceof Index) {
80
		if (selection instanceof PartitionIndex) {
81 81
			
82 82
			IWorkbenchWindow window = TXMWindows.getActiveWindow();
83
			List<Index> vocabularies = ((IStructuredSelection) HandlerUtil.getCurrentSelection(event)).toList();
83
			List<PartitionIndex> vocabularies = ((IStructuredSelection) HandlerUtil.getCurrentSelection(event)).toList();
84 84
			
85 85
			Log.info(LexicalTableUIMessages.ComputeLexicalTable_3);
86 86
			ArrayList<String> choices = new ArrayList<String>();
......
118 118
			}
119 119

  
120 120
			vocabularies = vocabularies.subList(0, 1);
121
			for (Index voc : vocabularies) {
121
			for (PartitionIndex voc : vocabularies) {
122 122
				if (!voc.isComputedWithPartition()) {
123 123
					System.out.println(LexicalTableUIMessages.ComputeLexicalTable_5);
124 124
					StatusLine.setMessage(LexicalTableUIMessages.ComputeLexicalTable_5);
......
127 127
			}
128 128
			
129 129
			List<WordProperty> properties = vocabularies.get(0).getProperties();
130
			for (Index voc : vocabularies) {
130
			for (PartitionIndex voc : vocabularies) {
131 131
				if (!properties.equals(voc.getProperties())) {
132 132
					Log.warning(NLS.bind(LexicalTableUIMessages.ComputeLexicalTable_6, properties));
133 133
					return false;
134 134
				}
135 135
			}
136 136
			
137
			final Index firstIndex = vocabularies.get(0);
137
			final PartitionIndex firstIndex = vocabularies.get(0);
138 138
			Partition firstPartition = firstIndex.getPartition();
139
			for (Index voc : vocabularies) {
139
			for (PartitionIndex voc : vocabularies) {
140 140
				if (!firstPartition.equals(voc.getPartition())) {
141 141
					Log.warning(NLS.bind(LexicalTableUIMessages.ComputeLexicalTable_7, firstPartition));
142 142
					return false;
tmp/org.txm.lexicaltable.rcp/plugin.xml (revision 1141)
25 25
                        definitionId="OnePartitionSelected">
26 26
                  </reference>
27 27
                  <reference
28
                        definitionId="OneIndexSelected">
28
                        definitionId="OnePartitionIndexSelected">
29 29
                  </reference>
30 30
                  <reference
31 31
                        definitionId="OneLexicalTableAbleSelected">
......
47 47
                        definitionId="OnePartitionSelected">
48 48
                  </reference>
49 49
                  <reference
50
                        definitionId="OneIndexSelected">
50
                        definitionId="OnePartitionIndexSelected">
51 51
                  </reference>
52 52
                  <reference
53 53
                        definitionId="OneLexicalTableAbleSelected">
......
68 68
                  checkEnabled="false">
69 69
               <or>
70 70
                  <reference
71
                        definitionId="OneIndexSelected">
71
                        definitionId="OnePartitionIndexSelected">
72 72
                  </reference>
73 73
                  <reference
74 74
                        definitionId="OneLexicalTableAbleSelected">
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 1141)
58 58
		Log.warning("Installing AnnotationExtension...");
59 59
		Log.warning(Arrays.toString(config));
60 60

  
61
		System.out.println("Installing annotation modes... ");
62 61
		ArrayList<String> modes = new ArrayList<String>();
63 62
		ArrayList<SelectionListener> listeners = new ArrayList<SelectionListener>();
64 63
		for (final IConfigurationElement celement : config) {
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/IndexToLexicalTable.java (revision 1141)
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.swt.widgets.Shell;
34
import org.eclipse.ui.IWorkbenchWindow;
35
import org.eclipse.ui.handlers.HandlerUtil;
36
import org.txm.rcp.handlers.BaseAbstractHandler;
37
// TODO: Auto-generated Javadoc
38
/**
39
 * The Class IndexToLexicalTable.
40
 */
41
// FIXME: not used?
42
public class IndexToLexicalTable extends BaseAbstractHandler {
43

  
44
	/** The window. */
45
	private IWorkbenchWindow window;
46
	
47
	/** The selection. */
48
	private IStructuredSelection selection;
49
	private static Shell shell;
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
52
	 */
53
	@Override
54
	public Object execute(ExecutionEvent event) throws ExecutionException {
55
		
56
		if(!this.checkStatsEngine()) {
57
			return null;
58
		}
59

  
60
		
61
		// TODO Auto-generated method stub
62
		window = HandlerUtil.getActiveWorkbenchWindow(event);
63
		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
64
		shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
65
		return null;
66
	}
67

  
68
	/**
69
	 * Builds the lexical table.
70
	 *
71
	 * @param voc the voc
72
	 * @param from the from
73
	 * @param to the to
74
	 * @return true, if successful
75
	 */
76
	// FIXME: SJ: temporary commented to avoid cyclic dependencies
77
//	public boolean buildLexicalTable(Index voc, int from, int to) {
78
//		LexicalTable table;
79
//
80
//		if (!voc.isComputedWithPartition()) {
81
//			
82
//			System.out.println(TXMUIMessages.IndexToLexicalTable_0);
83
//			StatusLine.setMessage(TXMUIMessages.IndexToLexicalTable_0);
84
//			return false;
85
//		}
86
//
87
//		System.out.println(LexicalTableUIMessages.ComputeLexicalTable_3);
88
//		ArrayList<String> choices = new ArrayList<String>();
89
//		choices.add(LexicalTableUIMessages.ComputeLexicalTable_16);
90
//		choices.add(LexicalTableUIMessages.ComputeLexicalTable_12);
91
//		ListSelectionDialog dialog = new ListSelectionDialog(shell, 
92
//				choices, new ArrayContentProvider(), new LabelProvider(), 
93
//				LexicalTableUIMessages.ComputeLexicalTable_13);
94
//		
95
//		int ret = dialog.open();
96
//		//System.out.println("ret= "+ret);
97
//		if (ret == Dialog.OK_OPTION) {
98
//			
99
//		} else {
100
//			return false;
101
//		}
102
//		
103
//		try {
104
//			table = new LexicalTable(voc);
105
//		} catch (Exception e) {
106
//			// TODO Auto-generated catch block
107
//			org.txm.rcp.utils.Logger.printStackTrace(e);
108
//			return false;
109
//		}
110
//
111
//		try {
112
//			IWorkbenchWindow window = PlatformUI.getWorkbench()
113
//					.getActiveWorkbenchWindow();
114
//			IWorkbenchPage page = window.getActivePage();
115
//			___LexicalTableEditorInput editorInput = new ___LexicalTableEditorInput(table);
116
//			StatusLine.setMessage(LexicalTableUIMessages.ComputeLexicalTable_10);
117
//			page.openEditor(editorInput, "org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$
118
//		} catch (PartInitException e) {
119
//			org.txm.rcp.utils.Logger.printStackTrace(e);
120
//		} 
121
//
122
//		return true;
123
//	}
124

  
125
}
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputePartitionIndex.java (revision 1141)
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.txm.core.preferences.TXMPreferences;
33
import org.txm.index.core.functions.PartitionIndex;
34
import org.txm.index.rcp.editors.PartitionIndexEditor;
35
import org.txm.rcp.editors.TXMEditor;
36
import org.txm.rcp.handlers.BaseAbstractHandler;
37
import org.txm.searchengine.cqp.corpus.CQPCorpus;
38
import org.txm.searchengine.cqp.corpus.Partition;
39

  
40
/**
41
 * Opens a PartitionIndex editor.
42
 * Computes the result if it contains all required parameters.
43
 * 
44
 * @author mdecorde
45
 * @author sjacquot
46
 * 
47
 */
48
public class ComputePartitionIndex extends BaseAbstractHandler {
49

  
50

  
51
	@Override
52
	public Object execute(ExecutionEvent event) throws ExecutionException {
53

  
54
		if (!this.checkCorpusEngine()) {
55
			return false;
56
		}
57

  
58
		PartitionIndex index = null;
59

  
60
		// From link: creating from parameters node
61
		String parametersNodePath = event.getParameter(TXMPreferences.RESULT_PARAMETERS_NODE_PATH);
62
		if (parametersNodePath != null && !parametersNodePath.isEmpty()) {
63
			index = new PartitionIndex(parametersNodePath);
64
		}
65
		// From view result node
66
		else	{
67
			Object selection = this.getCorporaViewSelectedObject(event);
68

  
69
			// New editor from corpus
70
			if (selection instanceof Partition) {
71
				index = new PartitionIndex((Partition) selection);
72
			}
73
			// Reopen an existing result
74
			else if (selection instanceof PartitionIndex) { 
75
				index = (PartitionIndex) selection;
76
			}
77
			else {
78
				return super.logCanNotExecuteCommand(selection);
79
			}
80
		}
81

  
82
		TXMEditor.openEditor(index, PartitionIndexEditor.class.getName());
83

  
84
		return null;
85
	}
86

  
87
}
0 88

  
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/PartitionIndexToLexicalTable.java (revision 1141)
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.swt.widgets.Shell;
34
import org.eclipse.ui.IWorkbenchWindow;
35
import org.eclipse.ui.handlers.HandlerUtil;
36
import org.txm.rcp.handlers.BaseAbstractHandler;
37
// TODO: Auto-generated Javadoc
38
/**
39
 * The Class IndexToLexicalTable.
40
 */
41
// FIXME: not used?
42
public class PartitionIndexToLexicalTable extends BaseAbstractHandler {
43

  
44
	/** The window. */
45
	private IWorkbenchWindow window;
46
	
47
	/** The selection. */
48
	private IStructuredSelection selection;
49
	private static Shell shell;
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
52
	 */
53
	@Override
54
	public Object execute(ExecutionEvent event) throws ExecutionException {
55
		
56
		if(!this.checkStatsEngine()) {
57
			return null;
58
		}
59

  
60
		
61
		// TODO Auto-generated method stub
62
		window = HandlerUtil.getActiveWorkbenchWindow(event);
63
		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
64
		shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
65
		return null;
66
	}
67

  
68
	/**
69
	 * Builds the lexical table.
70
	 *
71
	 * @param voc the voc
72
	 * @param from the from
73
	 * @param to the to
74
	 * @return true, if successful
75
	 */
76
	// FIXME: SJ: temporary commented to avoid cyclic dependencies
77
//	public boolean buildLexicalTable(Index voc, int from, int to) {
78
//		LexicalTable table;
79
//
80
//		if (!voc.isComputedWithPartition()) {
81
//			
82
//			System.out.println(TXMUIMessages.IndexToLexicalTable_0);
83
//			StatusLine.setMessage(TXMUIMessages.IndexToLexicalTable_0);
84
//			return false;
85
//		}
86
//
87
//		System.out.println(LexicalTableUIMessages.ComputeLexicalTable_3);
88
//		ArrayList<String> choices = new ArrayList<String>();
89
//		choices.add(LexicalTableUIMessages.ComputeLexicalTable_16);
90
//		choices.add(LexicalTableUIMessages.ComputeLexicalTable_12);
91
//		ListSelectionDialog dialog = new ListSelectionDialog(shell, 
92
//				choices, new ArrayContentProvider(), new LabelProvider(), 
93
//				LexicalTableUIMessages.ComputeLexicalTable_13);
94
//		
95
//		int ret = dialog.open();
96
//		//System.out.println("ret= "+ret);
97
//		if (ret == Dialog.OK_OPTION) {
98
//			
99
//		} else {
100
//			return false;
101
//		}
102
//		
103
//		try {
104
//			table = new LexicalTable(voc);
105
//		} catch (Exception e) {
106
//			// TODO Auto-generated catch block
107
//			org.txm.rcp.utils.Logger.printStackTrace(e);
108
//			return false;
109
//		}
110
//
111
//		try {
112
//			IWorkbenchWindow window = PlatformUI.getWorkbench()
113
//					.getActiveWorkbenchWindow();
114
//			IWorkbenchPage page = window.getActivePage();
115
//			___LexicalTableEditorInput editorInput = new ___LexicalTableEditorInput(table);
116
//			StatusLine.setMessage(LexicalTableUIMessages.ComputeLexicalTable_10);
117
//			page.openEditor(editorInput, "org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$
118
//		} catch (PartInitException e) {
119
//			org.txm.rcp.utils.Logger.printStackTrace(e);
120
//		} 
121
//
122
//		return true;
123
//	}
124

  
125
}
0 126

  
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputeIndex.java (revision 1141)
35 35
import org.txm.rcp.editors.TXMEditor;
36 36
import org.txm.rcp.handlers.BaseAbstractHandler;
37 37
import org.txm.searchengine.cqp.corpus.CQPCorpus;
38
import org.txm.searchengine.cqp.corpus.Partition;
39 38

  
40 39
/**
41 40
 * Opens a Index editor.
......
70 69
			if (selection instanceof CQPCorpus) {
71 70
				index = new Index((CQPCorpus) selection);
72 71
			}
73
			// New editor from partition
74
			else if (selection instanceof Partition) {
75
				index = new Index((Partition) selection);
76
			}
77 72
			// Reopen an existing result
78 73
			else if (selection instanceof Index) { 
79 74
				index = (Index) selection;
tmp/org.txm.index.rcp/src/org/txm/index/rcp/adapters/PartitionIndexAdapterFactory.java (revision 1141)
1
// Copyright © 2010-2013 ENS de Lyon.
2
package org.txm.index.rcp.adapters;
3

  
4
import org.eclipse.jface.resource.ImageDescriptor;
5
import org.eclipse.ui.plugin.AbstractUIPlugin;
6
import org.osgi.framework.FrameworkUtil;
7
import org.txm.index.core.functions.PartitionIndex;
8
import org.txm.rcp.adapters.TXMResultAdapter;
9
import org.txm.rcp.adapters.TXMResultAdapterFactory;
10

  
11

  
12
/**
13
 * Display an Index or Lexicon icon dependaing on the Index used a lexicon to compute
14
 *  
15
 * @author mdecorde
16
 * @author sjacquot
17
 */
18
public class PartitionIndexAdapterFactory extends TXMResultAdapterFactory {
19

  
20

  
21
	public static final ImageDescriptor ICON =
22
			AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(PartitionIndexAdapterFactory.class).getSymbolicName(),
23
					"platform:/plugin/"+ FrameworkUtil.getBundle(PartitionIndexAdapterFactory.class).getSymbolicName() + "/icons/partitionindex.png"); //$NON-NLS-1$ //$NON-NLS-2$
24
	
25
	@Override
26
	public Object getAdapter(Object adaptableObject, Class adapterType) {
27
		if(this.canAdapt(adapterType) && adaptableObject instanceof PartitionIndex)	{
28
			return new TXMResultAdapter() {
29
				@Override
30
				public ImageDescriptor getImageDescriptor(Object object) {
31
					return ICON;
32
				}
33
			};
34
		}
35
		return null;
36
	}
37

  
38

  
39
}
0 40

  
tmp/org.txm.index.rcp/src/org/txm/index/rcp/adapters/IndexRAdaptor.java (revision 1141)
5 5

  
6 6
import org.txm.index.core.functions.Index;
7 7
import org.txm.index.core.functions.Line;
8
import org.txm.index.core.functions.PartitionIndex;
8 9
import org.txm.statsengine.r.core.RWorkspace;
9 10
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
10 11
import org.txm.statsengine.r.rcp.handlers.RAdaptor;
......
31 32
	 * 
32 33
	 * @throws RWorkspaceException the r workspace exception
33 34
	 */
34
	public String sendToR(Index index) throws RWorkspaceException {
35
	public String sendToR(PartitionIndex index) throws RWorkspaceException {
35 36
		
36 37
		if (sended.containsKey(index)) {
37 38
			return sended.get(index);
......
101 102
		
102 103
		return symbol;
103 104
	}
105
	
106
	/**
107
	 * @return the R symbol
108
	 * 
109
	 * @throws RWorkspaceException the r workspace exception
110
	 */
111
	public String sendToR(Index index) throws RWorkspaceException {
112
		
113
		if (sended.containsKey(index)) {
114
			return sended.get(index);
115
		}
116
		
117
		String symbol = prefixR+no_index;
118

  
119
		ArrayList<String> colnames = new ArrayList<String>();
120

  
121
		colnames.add("F"); //$NON-NLS-1$
122

  
123
		//System.out.println("cols: "+colnames);
124

  
125
		List<Line> lines = index.getAllLines();
126
		String[] keywords = new String[lines.size()];
127

  
128
		int[] freq = new int[lines.size()];
129

  
130
		for (int i = 0 ; i < lines.size() ; i++) 
131
		{
132
			Line ligne = lines.get(i);
133
			freq[i] = ligne.getFrequency(); 
134
			keywords[i] = ligne.toString();
135

  
136
		}
137

  
138
		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
139
		rw.addVectorToWorkspace("vocfreq", freq); //$NON-NLS-1$
140
		rw.addVectorToWorkspace("vockeywords", keywords); //$NON-NLS-1$
141
		rw.addVectorToWorkspace("voccolnames", colnames.toArray(new String[colnames.size()])); //$NON-NLS-1$
142

  
143
		int ncol = 1;
144

  
145
		int nrow = lines.size();
146
		String partscmd = ""; //$NON-NLS-1$
147

  
148
		rw.eval(symbol+ "<- matrix(data = c(vocfreq"+partscmd+"), nrow = "+nrow+", ncol = "+ncol+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
149
		rw.eval("colnames("+symbol+" ) <- voccolnames"); //$NON-NLS-1$ //$NON-NLS-2$
150
		rw.eval("rownames("+symbol+" ) <- vockeywords"); //$NON-NLS-1$ //$NON-NLS-2$
151
		rw.eval(symbol+ "<- list(data="+symbol+")"); //$NON-NLS-1$ //$NON-NLS-2$
152

  
153
		no_index++;
154
		
155
		sended.put(index, symbol);
156
		symbols.put(symbol, index);
157
		
158
		return symbol;
159
	}
104 160
}
tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 1141)
446 446
		});
447 447

  
448 448
		freqColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
449
		try {
450
			if (index.getPartition() != null)
451
				freqColumn.setText(TXMCoreMessages.common_frequency+" T="+index.getPartition().getTotalSize()); //$NON-NLS-1$
452
			else
453
				freqColumn.setText(TXMCoreMessages.common_frequency);
454
		} catch (CqiClientException e2) {
455
			// TODO Auto-generated catch block
456
			org.txm.rcp.utils.Logger.printStackTrace(e2);
457
		}
449
			freqColumn.setText(TXMCoreMessages.common_frequency);
458 450
		freqColumn.setToolTipText(TXMCoreMessages.common_frequency);
459 451
		freqColumn.setWidth(100);
460 452
		freqColumn.addSelectionListener(new SelectionListener() {
......
482 474
			}
483 475
		});
484 476

  
485
		// rmv/creates parts columns if needed
486
		if (index.getPartition() != null) {
487
			List<String> partnames = index.getPartition().getPartNames();
488
			if (partnames.size() > 1)
489
				if (viewer.getTable().getColumnCount() < partnames.size() + 3) {
490
					for (int i = 0; i < partnames.size(); i++) {
491
						final TableColumn partColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
492
						try {
493
							partColumn.setText(partnames.get(i) + " t=" + index.getPartition().getParts().get(i).getSize()); //$NON-NLS-1$
494
						} catch (CqiClientException e1) {
495
							org.txm.rcp.utils.Logger.printStackTrace(e1);
496
						}
497
						partColumn.setToolTipText(partnames.get(i));
498
						partColumn.setWidth(100);
499
					}
500
				}
501
		}
502 477
		separatorColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
503 478
		separatorColumn.setText(""); //$NON-NLS-1$
504 479
		separatorColumn.pack();
tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/PartitionIndexEditor.java (revision 1141)
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.editors;
29

  
30
import java.util.ArrayList;
31
import java.util.List;
32

  
33
import org.eclipse.jface.viewers.TableViewer;
34
import org.eclipse.swt.SWT;
35
import org.eclipse.swt.events.SelectionEvent;
36
import org.eclipse.swt.events.SelectionListener;
37
import org.eclipse.swt.graphics.Font;
38
import org.eclipse.swt.graphics.FontData;
39
import org.eclipse.swt.layout.FormAttachment;
40
import org.eclipse.swt.layout.FormData;
41
import org.eclipse.swt.layout.FormLayout;
42
import org.eclipse.swt.layout.GridData;
43
import org.eclipse.swt.layout.GridLayout;
44
import org.eclipse.swt.widgets.Composite;
45
import org.eclipse.swt.widgets.Display;
46
import org.eclipse.swt.widgets.Label;
47
import org.eclipse.swt.widgets.Spinner;
48
import org.eclipse.swt.widgets.TableColumn;
49
import org.txm.core.messages.TXMCoreMessages;
50
import org.txm.core.preferences.TXMPreferences;
51
import org.txm.core.results.Parameter;
52
import org.txm.index.core.functions.Line;
53
import org.txm.index.core.functions.LineComparator.SortMode;
54
import org.txm.index.core.functions.PartitionIndex;
55
import org.txm.index.rcp.messages.IndexUIMessages;
56
import org.txm.rcp.StatusLine;
57
import org.txm.rcp.editors.TXMEditor;
58
import org.txm.rcp.editors.TableKeyListener;
59
import org.txm.rcp.editors.listeners.ComputeKeyListener;
60
import org.txm.rcp.editors.listeners.ComputeSelectionListener;
61
import org.txm.rcp.messages.TXMUIMessages;
62
import org.txm.rcp.swt.GLComposite;
63
import org.txm.rcp.swt.widget.AssistedChoiceQueryWidget;
64
import org.txm.rcp.swt.widget.NavigationWidget;
65
import org.txm.rcp.swt.widget.PropertiesSelector;
66
import org.txm.rcp.views.QueriesView;
67
import org.txm.searchengine.core.Query;
68
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
69
import org.txm.searchengine.cqp.corpus.CQPCorpus;
70
import org.txm.searchengine.cqp.corpus.Property;
71
import org.txm.searchengine.cqp.corpus.WordProperty;
72
import org.txm.statsengine.r.rcp.views.RVariablesView;
73
import org.txm.utils.logger.Log;
74

  
75
/**
76
 * display an index/lexicon parameters and result.
77
 *
78
 * @author mdecorde
79
 */
80
public class PartitionIndexEditor extends TXMEditor<PartitionIndex> {
81

  
82
	/** The index. */
83
	protected PartitionIndex index;
84

  
85
	// params
86
	/** The query label. */
87
	protected Label queryLabel;
88

  
89
	// infos
90
	/** The navigation area. */
91
	protected NavigationWidget navigationArea;
92

  
93
	/** The l fmin info. */
94
	protected Label lFminInfo;
95

  
96
	/** The l fmax info. */
97
	protected Label lFmaxInfo;
98

  
99
	/** The l v info. */
100
	protected Label lVInfo;
101

  
102
	/** The l t info. */
103
	protected Label lTInfo;
104
	// result
105
	/** The line table viewer. */
106
	protected TableViewer viewer;
107

  
108
	/** The n column. */
109
	protected TableColumn nColumn;
110

  
111
	/** The unit column. */
112
	protected TableColumn unitColumn;
113

  
114
	/** The freq column. */
115
	protected TableColumn freqColumn;
116

  
117
	/** The separator column. */
118
	protected TableColumn separatorColumn;
119

  
120

  
121
	/** The title. */
122
	String title;
123

  
124
	/** The query widget. */
125
	@Parameter(key=TXMPreferences.QUERY)
126
	protected AssistedChoiceQueryWidget queryWidget;
127

  
128
	/** The Fmin spinner. */
129
	@Parameter(key=TXMPreferences.F_MIN)
130
	protected Spinner fMinSpinner;
131

  
132
	/** The Fmax spinner. */
133
	@Parameter(key=TXMPreferences.F_MAX)
134
	protected Spinner fMaxSpinner;
135

  
136
	/** The Tmax spinner. */
137
	@Parameter(key=TXMPreferences.V_MAX)
138
	protected Spinner vMaxSpinner;
139

  
140
	/** The N ligne p page spinner. */
141
	@Parameter(key=TXMPreferences.N_LINES_PER_PAGE)
142
	protected Spinner nLinesPerPageSpinner;
143
	
144
	/**
145
	 * Word properties selector.
146
	 */
147
	@Parameter(key=TXMPreferences.UNIT_PROPERTIES)
148
	protected PropertiesSelector<WordProperty> propertiesSelector;
149
	
150
	/**
151
	 * Creates the part control.
152
	 *
153
	 * @param parent the parent
154
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
155
	 */
156
	@Override
157
	public void _createPartControl() {
158

  
159
		
160
		this.index = (PartitionIndex) this.getResult();
161
		
162
		// Computing listeners
163
		ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this);
164
		ComputeKeyListener computeKeyListener = new ComputeKeyListener(this);
165
		
166
		Composite paramArea = this.getExtendedParametersComposite();
167
		paramArea.setLayout(new FormLayout());
168

  
169
		// info&navigation panel
170
		final GLComposite infosArea = this.getBottomToolbar().installGLComposite(IndexUIMessages.composite_infos, 1, false);
171
		infosArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
172
		infosArea.getLayout().numColumns = 5; // nav panel + labels
173
		
174
		// on créé une Query, ici le pivot de la concordance est "[]"
175
		// Query Area: query itself + view properties
176
		Composite queryArea = new Composite(paramArea, SWT.NONE);
177

  
178
		FormData queryLayoutData = new FormData();
179
		queryLayoutData.top = new FormAttachment(0);
180
		queryLayoutData.left = new FormAttachment(0);
181
		queryLayoutData.right = new FormAttachment(100);
182
		queryArea.setLayoutData(queryLayoutData);
183

  
184
		queryArea.setLayout(new GridLayout(4, false));
185

  
186
		// | Query: [ (v)] [Search] |
187
		
188
		// Query:
189
		getMainParametersComposite().getLayout().numColumns = 3;
190
		// make the zone expandable to display the longest query field
191
		getMainParametersComposite().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
192
				
193
		// Query:
194
		queryLabel = new Label(getMainParametersComposite(), SWT.NONE);
195
		queryLabel.setText(TXMCoreMessages.common_query);
196
		queryLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, true));
197

  
198
		// [ (v)]
199
		queryWidget = new AssistedChoiceQueryWidget(getMainParametersComposite(), SWT.DROP_DOWN, index.getCorpus());
200
		GridData layoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
201
		layoutData.horizontalAlignment = GridData.FILL;
202
		layoutData.grabExcessHorizontalSpace = true;
203
		queryWidget.setLayoutData(layoutData);
204
		queryWidget.addKeyListener(computeKeyListener);
205

  
206
		
207
		// Word properties selector
208
		propertiesSelector = new PropertiesSelector<WordProperty>(getMainParametersComposite(), SWT.NONE);
209
		propertiesSelector.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
210
		propertiesSelector.setLayout(new GridLayout(3, false));
211
		try {
212
			List<WordProperty> props = index.getCorpus().getOrderedProperties();
213
			propertiesSelector.setProperties(props);
214
		}
215
		catch (CqiClientException e) {
216
			Log.printStackTrace(e);
217
		}
218
		// Listener
219
		propertiesSelector.addSelectionListener(computeSelectionListener);
220
		
221
		// Filters
222
		Composite filtercontrols = new Composite(paramArea, SWT.NONE);
223
		FormData filtersLayoutData = new FormData();
224
		filtersLayoutData.top = new FormAttachment(queryArea, 0);
225
		filtersLayoutData.bottom = new FormAttachment(100);
226
		filtersLayoutData.left = new FormAttachment(0);
227
		filtersLayoutData.right = new FormAttachment(100);
228
		filtercontrols.setLayoutData(filtersLayoutData);
229

  
230
		GridLayout gridLayout = new GridLayout();
231
		gridLayout.numColumns = 9;
232
		gridLayout.makeColumnsEqualWidth = false;
233
		filtercontrols.setLayout(gridLayout);
234

  
235
		Label tmp = new Label(filtercontrols, SWT.NONE);
236
		tmp.setText(IndexUIMessages.IndexEditor_9);
237
		tmp.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
238

  
239
		Label lFmin = new Label(filtercontrols, SWT.NONE);
240
		lFmin.setText(TXMCoreMessages.common_fMin);
241
		lFmin.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
242

  
243
		GridData fieldsGridData = new GridData(GridData.VERTICAL_ALIGN_END);
244
		fieldsGridData.minimumWidth = 100;
245

  
246
		fMinSpinner = new Spinner(filtercontrols, SWT.BORDER);
247
		fMinSpinner.setMinimum(0);
248
		fMinSpinner.setMaximum(9999999);
249
		fMinSpinner.setIncrement(1);
250
		fMinSpinner.setPageIncrement(100);
251
		fMinSpinner.setLayoutData(fieldsGridData);
252
		fMinSpinner.addKeyListener(computeKeyListener);
253
		fMinSpinner.addSelectionListener(computeSelectionListener);
254

  
255
		Label lFmax = new Label(filtercontrols, SWT.NONE);
256
		lFmax.setText(TXMCoreMessages.common_fMax);
257
		lFmax.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
258

  
259
		fMaxSpinner = new Spinner(filtercontrols, SWT.BORDER);
260
		fMaxSpinner.setMinimum(0);
261
		fMaxSpinner.setMaximum(9999999);
262
		fMaxSpinner.setIncrement(1);
263
		fMaxSpinner.setPageIncrement(100);
264
		fMaxSpinner.setLayoutData(fieldsGridData);
265
		fMaxSpinner.addKeyListener(computeKeyListener);
266
		fMaxSpinner.addSelectionListener(computeSelectionListener);
267

  
268
		Label lVmax = new Label(filtercontrols, SWT.NONE);
269
		lVmax.setText(TXMCoreMessages.VMAX_1);
270
		lVmax.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
271

  
272
		vMaxSpinner = new Spinner(filtercontrols, SWT.BORDER);
273
		vMaxSpinner.setMinimum(0);
274
		vMaxSpinner.setMaximum(9999999);
275
		vMaxSpinner.setIncrement(1);
276
		vMaxSpinner.setPageIncrement(100);
277
		vMaxSpinner.setLayoutData(fieldsGridData);
278
		vMaxSpinner.addKeyListener(computeKeyListener);
279
		vMaxSpinner.addSelectionListener(computeSelectionListener);
280

  
281
		Label lNLigneppage = new Label(filtercontrols, SWT.NONE);
282
		lNLigneppage.setText(IndexUIMessages.IndexEditor_8);
283
		lNLigneppage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
284

  
285
		nLinesPerPageSpinner = new Spinner(filtercontrols, SWT.BORDER);
286
		nLinesPerPageSpinner.setMinimum(0);
287
		nLinesPerPageSpinner.setMaximum(99999);
288
		nLinesPerPageSpinner.setIncrement(1);
289
		nLinesPerPageSpinner.setPageIncrement(100);
290
		nLinesPerPageSpinner.setLayoutData(fieldsGridData);
291
		nLinesPerPageSpinner.addSelectionListener(new SelectionListener() {
292
			@Override
293
			public void widgetSelected(SelectionEvent e) { }
294

  
295
			@Override
296
			public void widgetDefaultSelected(SelectionEvent e) {
297
				index.setTopLine(0);
298
				index.setNLinesPerPage(nLinesPerPageSpinner.getSelection());
299
				fillResultArea();
300
				viewer.getTable().select(0);
301
				viewer.getTable().showSelection();
302
			}
303
		});
304

  
305
		navigationArea = new NavigationWidget(infosArea, SWT.NONE);
306
		navigationArea.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true,	false));
307

  
308
		navigationArea.addFirstListener(new SelectionListener() {
309
			@Override
310
			public void widgetDefaultSelected(SelectionEvent e) {
311
			}
312

  
313
			@Override
314
			public void widgetSelected(SelectionEvent e) {
315
				index.setTopLine(0);
316
				index.setNLinesPerPage(nLinesPerPageSpinner.getSelection());
317
				fillResultArea();
318
				viewer.getTable().select(0);
319
				viewer.getTable().showSelection();
320
			}
321
		});
322
		navigationArea.addLastListener(new SelectionListener() {
323
			@Override
324
			public void widgetDefaultSelected(SelectionEvent e) {
325
			}
326

  
327
			@Override
328
			public void widgetSelected(SelectionEvent e) {
329
				int i = (index.getV()/nLinesPerPageSpinner.getSelection());
330
				int top = i*nLinesPerPageSpinner.getSelection();
331
				
332
				index.setTopLine(top);
333
				fillResultArea();
334
				
335
				viewer.getTable().select(0);
336
				viewer.getTable().showSelection();
337
			}
338
		});
339
		navigationArea.addNextListener(new SelectionListener() {
340
			@Override
341
			public void widgetDefaultSelected(SelectionEvent e) {
342
			}
343

  
344
			@Override
345
			public void widgetSelected(SelectionEvent e) {
346
				index.setTopLine(index.getTopIndex() + index.getNLinesPerPage());
347
				fillResultArea();
348
				viewer.getTable().select(0);
349
				viewer.getTable().showSelection();
350
			}
351
		});
352
		navigationArea.addPreviousListener(new SelectionListener() {
353
			@Override
354
			public void widgetDefaultSelected(SelectionEvent e) {
355
			}
356

  
357
			@Override
358
			public void widgetSelected(SelectionEvent e) {
359
				int top = index.getTopIndex() - index.getNLinesPerPage();
360
				if (top < 0) { top = 0; }
361
				index.setTopLine(top);
362
				fillResultArea();
363
				viewer.getTable().select(0);
364
				viewer.getTable().showSelection();
365
			}
366
		});
367

  
368
		// Labels added after the top toolbar
369
		lTInfo = new Label(infosArea, SWT.NONE);
370
		lTInfo.setText(""); //$NON-NLS-1$
371
//		lTInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
372

  
373
		lVInfo = new Label(infosArea, SWT.NONE);
374
		lVInfo.setText(""); //$NON-NLS-1$
375
//		lVInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
376

  
377
		lFminInfo = new Label(infosArea, SWT.NONE);
378
		lFminInfo.setText(""); //$NON-NLS-1$
379
//		lFminInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
380

  
381
		lFmaxInfo = new Label(infosArea, SWT.NONE);
382
		lFmaxInfo.setText(""); //$NON-NLS-1$
383
//		lFmaxInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
384

  
385
		// results
386
		Composite resultArea = this.getResultArea();
387

  
388
		viewer = new TableViewer(resultArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
389
		
390
		viewer.getTable().setLinesVisible(true);
391
		viewer.getTable().setHeaderVisible(true);
392
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
393

  
394
		String fontName = index.getCorpus().getProject().getFont();
395
		if (fontName != null && fontName.length() > 0) {
396
			Font old = viewer.getTable().getFont();
397
			FontData fD = old.getFontData()[0];
398
			//Font f = new Font(old.getDevice(), corpus.getFont(), fD.getHeight(), fD.getStyle());
399
			Font font = new Font(Display.getCurrent(), fontName, fD.getHeight(), fD.getStyle()); 
400
			viewer.getTable().setFont(font);
401
		}
402

  
403
		viewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
404

  
405
		viewer.setLabelProvider(new LineLabelProvider());
406
		viewer.setContentProvider(new LineContentProvider());
407
		viewer.setInput(new ArrayList<Property>());
408

  
409
		nColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
410
		nColumn.setText(" "); //$NON-NLS-1$
411
		nColumn.pack();
412

  
413
		unitColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
414
		unitColumn.setText(TXMCoreMessages.common_units);
415
		unitColumn.setToolTipText(TXMCoreMessages.common_units);
416
		unitColumn.setWidth(200);
417
		unitColumn.addSelectionListener(new SelectionListener() {
418
			@Override
419
			public void widgetSelected(SelectionEvent e) {
420
				StatusLine.setMessage(TXMUIMessages.SORT_COLUMN);
421
				if (viewer.getTable().getSortColumn() != unitColumn) {
422
					viewer.getTable().setSortColumn(unitColumn);
423
					viewer.getTable().setSortDirection(SWT.UP);
424
					index.sortLines(SortMode.UNIT, false);
425
				} else {
426
					if (viewer.getTable().getSortDirection() == SWT.UP) {
427
						viewer.getTable().setSortDirection(SWT.DOWN);
428
						index.sortLines(SortMode.UNITFREQ, true);
429
					} else {
430
						viewer.getTable().setSortDirection(SWT.UP);
431
						index.sortLines(SortMode.UNITFREQ, false);
432
					}
433
				}
434

  
435
				StatusLine.setMessage(TXMUIMessages.SORT_DONE);
436
				fillResultArea();
437
			}
438

  
439
			@Override
440
			public void widgetDefaultSelected(SelectionEvent e) {
441
			}
442
		});
443

  
444
		freqColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
445
		try {
446
			if (index.getPartition() != null)
447
				freqColumn.setText(TXMCoreMessages.common_frequency+" T="+index.getPartition().getTotalSize()); //$NON-NLS-1$
448
			else
449
				freqColumn.setText(TXMCoreMessages.common_frequency);
450
		} catch (CqiClientException e2) {
451
			// TODO Auto-generated catch block
452
			org.txm.rcp.utils.Logger.printStackTrace(e2);
453
		}
454
		freqColumn.setToolTipText(TXMCoreMessages.common_frequency);
455
		freqColumn.setWidth(100);
456
		freqColumn.addSelectionListener(new SelectionListener() {
457
			@Override
458
			public void widgetSelected(SelectionEvent e) {
459
				if (viewer.getTable().getSortColumn() != freqColumn) {
460
					viewer.getTable().setSortColumn(freqColumn);
461
					viewer.getTable().setSortDirection(SWT.UP);
462
					index.sortLines(SortMode.FREQUNIT, false);
463
				} else {
464
					if (viewer.getTable().getSortDirection() == SWT.UP) {
465
						viewer.getTable().setSortDirection(SWT.DOWN);
466
						index.sortLines(SortMode.FREQUNIT, true);
467
					} else {
468
						viewer.getTable().setSortDirection(SWT.UP);
469
						index.sortLines(SortMode.FREQUNIT, false);
470
					}
471
				}
472
				StatusLine.setMessage(TXMUIMessages.SORT_DONE);
473
				fillResultArea();
474
			}
475

  
476
			@Override
477
			public void widgetDefaultSelected(SelectionEvent e) {
478
			}
479
		});
480

  
481
		// rmv/creates parts columns if needed
482
		if (index.getPartition() != null) {
483
			List<String> partnames = index.getPartition().getPartNames();
484
			if (partnames.size() > 1)
485
				if (viewer.getTable().getColumnCount() < partnames.size() + 3) {
486
					for (int i = 0; i < partnames.size(); i++) {
487
						final TableColumn partColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
488
						try {
489
							partColumn.setText(partnames.get(i) + " t=" + index.getPartition().getParts().get(i).getSize()); //$NON-NLS-1$
490
						} catch (CqiClientException e1) {
491
							org.txm.rcp.utils.Logger.printStackTrace(e1);
492
						}
493
						partColumn.setToolTipText(partnames.get(i));
494
						partColumn.setWidth(100);
495
					}
496
				}
497
		}
498
		separatorColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
499
		separatorColumn.setText(""); //$NON-NLS-1$
500
		separatorColumn.pack();
501
		paramArea.pack();
502

  
503
		// Add double click, "Send to" command
504
		TXMEditor.addDoubleClickCommandListener(viewer.getTable(), 1, "org.txm.concordance.rcp.handlers.ComputeConcordance"); //$NON-NLS-1$
505
		TXMEditor.addDoubleClickCommandListener(viewer.getTable(), 2, "org.txm.progression.rcp.handlers.ComputeProgression"); //$NON-NLS-1$
506
		
507
		// Register the context menu
508
		TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer);
509

  
510
		
511
		if (queryWidget != null && !queryWidget.isDisposed()) {
512
			queryWidget.setFocus();
513
		}
514

  
515
	}
516

  
517
	
518
	
519

  
520
	@Override
521
	public void updateResultFromEditor() {
522
		// nothing to do
523
	}
524

  
525
	
526
	/**
527
	 * Computes index.
528
	 */
529
	@Override
530
	public void updateEditorFromResult(final boolean update) {
531

  
532
		QueriesView.refresh();
533
		RVariablesView.refresh();
534

  
535
		if (!queryWidget.isDisposed()) {
536
			queryWidget.memorize();
537
		}
538

  
539
		fillResultArea();
540

  
541
		viewer.getTable().setFocus();
542
	}
543

  
544

  
545

  
546
	/**
547
	 * Fill result area using the index top and index number of results per page parameters.
548
	 *
549
	 */
550
	public void fillResultArea() {
551
		// System.out.println("call fill from "+from+" to "+to);
552
		int from = index.getTopIndex();
553
		
554
		int to = from + index.getNLinesPerPage();
555
		to = Math.min(to, index.getV());
556
		
557
		List<Line> lines = null;
558
		if (index.getV() > 0) {
559
			lines = index.getLines(from, to);
560
		}
561
		else {
562
			lines = new ArrayList<Line>();
563
		}
564

  
565
		navigationArea.setInfoLineText(""+(from + 1), //$NON-NLS-1$
566
				"-" + (to) + " / " + index.getV()); //$NON-NLS-1$ //$NON-NLS-2$
567
		navigationArea.setPreviousEnabled(from > 0);
568
		navigationArea.setFirstEnabled(from > 0);
569
		navigationArea.setNextEnabled(to < index.getV());
570
		navigationArea.setLastEnabled(to < index.getV());
571

  
572
		lFminInfo.setText(TXMCoreMessages.FMIN_2 + index.getFmin());
573
		lFmaxInfo.setText(TXMCoreMessages.FMAX_2 + index.getFmax());
574
		lTInfo.setText(TXMCoreMessages.T + index.getT());
575
		lVInfo.setText(TXMCoreMessages.V + index.getV());
576

  
577
		lVInfo.getParent().layout();
578

  
579
		String unitColumnHeader = ""; //$NON-NLS-1$
580
		for (Property p : index.getProperties()) {
581
			unitColumnHeader += p.getName() + index.getPropertySeparator();
582
		}
583
		if (unitColumnHeader.length() > 0) {
584
			unitColumnHeader = unitColumnHeader.substring(0, unitColumnHeader.length() - 1);
585
		}
586
		unitColumn.setText(unitColumnHeader);
587

  
588
		viewer.setInput(lines);
589

  
590
		// Refresh and pack the columns
591
		TXMEditor.packColumns(viewer);
592
		
593
	}
594

  
595
	/**
596
	 * Sets the focus.
597
	 *
598
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
599
	 */
600
	@Override
601
	public void setFocus() {
602
		if (!this.queryWidget.isDisposed()) {
603
			this.queryWidget.setFocus();
604
		}
605
		StatusLine.setMessage(IndexUIMessages.IndexEditor_29);
606
	}
607

  
608
	/**
609
	 * Gets the corpus.
610
	 *
611
	 * @return the corpus
612
	 */
613
	public CQPCorpus getCorpus() {
614
		return index.getCorpus();
615
	}
616

  
617
	/**
618
	 * Sets the focus.
619
	 *
620
	 * @param query the new focus
621
	 */
622
	public void setFocus(String query) {
623
		this.queryWidget.setText(query);
624
	}
625

  
626
	public Query getQuery() {
627
		return queryWidget.getQuery();
628
	}
629
}
0 630

  
tmp/org.txm.index.rcp/plugin.xml (revision 1141)
25 25
                  checkEnabled="false">
26 26
               <or>
27 27
                  <reference
28
                        definitionId="OnePartitionSelected">
28
                        definitionId="OneCorpusSelected">
29 29
                  </reference>
30
               </or>
31
            </visibleWhen>
32
         </command>
33
         <command
34
               commandId="org.txm.index.rcp.handlers.ComputePartitionIndex"
35
               icon="icons/partitionindex.png"
36
               style="push">
37
            <visibleWhen
38
                  checkEnabled="false">
39
               <or>
30 40
                  <reference
31
                        definitionId="OneCorpusSelected">
41
                        definitionId="OnePartitionSelected">
32 42
                  </reference>
33 43
               </or>
34 44
            </visibleWhen>
......
55 65
                  checkEnabled="false">
56 66
               <or>
57 67
                  <reference
58
                        definitionId="OnePartitionSelected">
68
                        definitionId="OneCorpusSelected">
59 69
                  </reference>
70
               </or>
71
            </visibleWhen>
72
         </command>
73
         <command
74
               commandId="org.txm.index.rcp.handlers.ComputePartitionIndex"
75
               icon="icons/partitionindex.png"
76
               style="push">
77
            <visibleWhen
78
                  checkEnabled="false">
79
               <or>
60 80
                  <reference
61
                        definitionId="OneCorpusSelected">
81
                        definitionId="OnePartitionSelected">
62 82
                  </reference>
63 83
               </or>
64 84
            </visibleWhen>
......
92 112
               </or>
93 113
            </visibleWhen>
94 114
         </command>
95
      </menuContribution>
96
      <menuContribution
97
            allPopups="false"
98
            locationURI="toolbar:org.txm.rcp.toolbartools?after=ComputeLexicalTableFromPartition">
99 115
         <command
100
               commandId="org.txm.index.rcp.handlers.ComputeIndex"
101
               icon="icons/index.png"
102
               id="ComputeIndexFromPartition"
103
               style="push"
104
               tooltip="%command.tooltip">
116
               commandId="org.txm.index.rcp.handlers.ComputePartitionIndex"
117
               icon="icons/partitionindex.png"
118
               style="push">
105 119
            <visibleWhen
106 120
                  checkEnabled="false">
107 121
               <or>
......
163 177
            id="org.txm.index.rcp.editors.DictionnaryEditor"
164 178
            name="%editor.name.0">
165 179
      </editor>
180
      <editor
181
            class="org.txm.index.rcp.editors.PartitionIndexEditor"
182
            default="false"
183
            icon="icons/partitionindex.png"
184
            id="org.txm.index.rcp.editors.PartitionIndexEditor"
185
            name="PartitionIndex">
186
      </editor>
166 187
   </extension>
167 188
   <extension
168 189
         point="org.eclipse.core.runtime.adapters">
......
186 207
               type="org.eclipse.ui.model.IWorkbenchAdapter2">
187 208
         </adapter>
188 209
      </factory>
210
      <factory
211
            adaptableType="org.txm.index.core.functions.PartitionIndex"
212
            class="org.txm.index.rcp.adapters.PartitionIndexAdapterFactory">
213
         <adapter
214
               type="org.eclipse.ui.model.IWorkbenchAdapter">
215
         </adapter>
216
         <adapter
217
               type="org.eclipse.ui.model.IWorkbenchAdapter2">
218
         </adapter>
219
      </factory>
189 220
   </extension>
190 221
   <extension
191 222
         point="org.eclipse.ui.commands">
......
209 240
            id="org.txm.synopticedition.rcp.commands.link.IndexToLexicalTable"
210 241
            name="%command.name.43">
211 242
      </command>
243
      <command
244
            categoryId="org.txm.rcp.category.txm"
245
            defaultHandler="org.txm.index.rcp.handlers.ComputePartitionIndex"
246
            id="org.txm.index.rcp.handlers.ComputePartitionIndex"
247
            name="PartitionIndex"
248
            returnTypeId="org.txm.index.core.functions.PartitionIndex">
249
      </command>
212 250
      
213 251
      
214 252
   </extension>
......
246 284
               variable="activePart">
247 285
            <instanceof
248 286
                  value="org.txm.index.rcp.editors.IndexEditor">
287
       
288
      <definition
289
            id="PartitionIndexEditorActive">
290
         <with
291
               variable="activePart">
292
            <instanceof
293
                  value="org.txm.index.rcp.editors.IndexEditor">
249 294
            </instanceof>
250 295
         </with>
251 296
      </definition>
252 297
      <definition
298
            id="OnePartitionIndexSelected">
299
         <with
300
               variable="selection">
301
            <iterate
302
                  ifEmpty="false"
303
                  operator="and">
304
               <instanceof
305
                     value="org.txm.index.core.functions.Index">
306
               </instanceof>
307
            </iterate>
308
         </with>
309
      </definition>     </instanceof>
310
         </with>
311
      </definition>
312
      <definition
253 313
            id="LexiconEditorActive">
254 314
         <with
255 315
               variable="activePart">
......
258 318
            </instanceof>
259 319
         </with>
260 320
      </definition>
321
      <definition
322
            id="PartitionIndexEditorActive">
323
         <with
324
               variable="activePart">
325
            <instanceof
326
                  value="org.txm.index.rcp.editors.IndexEditor">
327
               <definition
328
                     id="PartitionIndexEditorActive">
329
                  <with
330
                        variable="activePart">
331
                     <instanceof
332
                           value="org.txm.index.rcp.editors.IndexEditor">
333
                     </instanceof>
334
                  </with>
335
               </definition>
336
               <definition
337
                     id="OnePartitionIndexSelected">
338
                  <with
339
                        variable="selection">
340
                     <iterate
341
                           ifEmpty="false"
342
                           operator="and">
343
                        <instanceof
344
                              value="org.txm.index.core.functions.Index">
345
                        </instanceof>
346
                     </iterate>
347
                  </with>
348
               </definition>
349
            </instanceof>
350
         </with>
351
      </definition>
352
      <definition
353
            id="OnePartitionIndexSelected">
354
         <with
355
               variable="selection">
356
            <iterate
357
                  ifEmpty="false"
358
                  operator="and">
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff