Revision 1199

tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/debug/EnginesDebugView.java (revision 1199)
39 39

  
40 40
import org.eclipse.jface.layout.GridDataFactory;
41 41
import org.eclipse.jface.viewers.IContentProvider;
42
import org.eclipse.jface.viewers.ISelection;
42 43
import org.eclipse.jface.viewers.ITreeContentProvider;
43 44
import org.eclipse.jface.viewers.LabelProvider;
45
import org.eclipse.jface.viewers.StructuredSelection;
44 46
import org.eclipse.jface.viewers.TreeViewer;
45 47
import org.eclipse.swt.SWT;
46 48
import org.eclipse.swt.custom.ScrolledComposite;
49
import org.eclipse.swt.events.KeyEvent;
50
import org.eclipse.swt.events.KeyListener;
51
import org.eclipse.swt.events.MouseEvent;
52
import org.eclipse.swt.events.MouseListener;
47 53
import org.eclipse.swt.events.SelectionEvent;
48 54
import org.eclipse.swt.events.SelectionListener;
49 55
import org.eclipse.swt.layout.GridData;
......
92 98

  
93 99
	/** The ID. */
94 100
	public static String ID = EnginesDebugView.class.getName(); //$NON-NLS-1$
101
	private TreeViewer viewer;
95 102

  
96 103
	/**
97 104
	 * Instantiates a new queries view.
......
122 129

  
123 130
		parent.setLayout(new GridLayout(1, true));
124 131

  
125
		TreeViewer viewer = new TreeViewer(parent);
132
		viewer = new TreeViewer(parent);
126 133
		viewer.getTree().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
127 134
		
128 135
		viewer.setLabelProvider(new LabelProvider() {
......
180 187
			}
181 188
		});
182 189
		
190
		viewer.getTree().addKeyListener(new KeyListener() {
191
			
192
			@Override
193
			public void keyReleased(KeyEvent e) {
194
				// TODO Auto-generated method stub
195
				
196
			}
197
			
198
			@Override
199
			public void keyPressed(KeyEvent e) {
200
				if (e.keyCode == SWT.F5) {
201
					viewer.refresh();
202
				}
203
			}
204
		});
205
		
206
		viewer.getTree().addMouseListener(new MouseListener() {
207
			
208
			@Override
209
			public void mouseUp(MouseEvent e) {
210
				// TODO Auto-generated method stub
211
			}
212
			
213
			@Override
214
			public void mouseDown(MouseEvent e) {
215
				// TODO Auto-generated method stub
216
			}
217
			
218
			@Override
219
			public void mouseDoubleClick(MouseEvent e) {
220
				ISelection isel = viewer.getSelection();
221
				if (isel instanceof StructuredSelection) {
222
					StructuredSelection sel = (StructuredSelection)isel;
223
					if (!sel.isEmpty()) {
224
						for (Object o : sel.toList()) {
225
							if (o instanceof Engine) {
226
								System.out.println(((Engine)o).getDetails());
227
							}
228
						}
229
					}
230
				}
231
			}
232
		});
233
		
183 234
		LinkedHashMap<EngineType, EnginesManager<?>> i = Toolbox.getEngineManagers();
184 235
		viewer.setInput(i);
185 236
	}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/function/RenameResult.java (revision 1199)
1 1
package org.txm.rcp.commands.function;
2 2

  
3
import java.util.List;
4

  
3 5
import org.eclipse.core.commands.AbstractHandler;
4 6
import org.eclipse.core.commands.ExecutionEvent;
5 7
import org.eclipse.core.commands.ExecutionException;
......
8 10
import org.eclipse.jface.viewers.IStructuredSelection;
9 11
import org.eclipse.ui.IWorkbenchWindow;
10 12
import org.eclipse.ui.handlers.HandlerUtil;
13
import org.txm.Toolbox;
11 14
import org.txm.core.preferences.TXMPreferences;
12 15
import org.txm.core.results.TXMResult;
16
import org.txm.objects.CorpusBuild;
13 17
import org.txm.rcp.swt.dialog.TextDialog;
14 18
import org.txm.rcp.views.corpora.CorporaView;
15 19

  
......
30 34
			if (dialog.open() == TextDialog.OK) {
31 35
				String newName = dialog.getText();
32 36
				//if (newName.length() > 0) {
37
				
38
					if (r instanceof CorpusBuild) { // test if another corpus has the same name
39
						List<TXMResult> corpora = Toolbox.workspace.getDeepChildren(CorpusBuild.class);
40
					}
41
				
33 42
					r.setUserName(newName);
34 43
					try {
35 44
						r.autoSaveParametersFromAnnotations();
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1199)
471 471
	}
472 472

  
473 473
	/**
474
	 * @return the commandParametersComposite. Put here you main parameter widgets
474
	 * @return the commandParametersComposite. Put here you main parameter widgets using RowData data layout
475 475
	 */
476 476
	public Group getExtendedParametersGroup() {
477 477
		return this.extendedParametersGroup;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/GLComposite.java (revision 1199)
39 39
	 */
40 40
	public final void setLayout(Layout layout) {
41 41
		System.out.println("Warning: GLComposite.setLayout is called without effect: "+name);
42
		Thread.dumpStack();
42 43
		//super.setLayout(layout);
43 44
	}
44 45

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationArea.java (revision 1199)
116 116
	public abstract boolean isDirty();
117 117
	
118 118
	public abstract boolean discardChanges();
119

  
120
	/**
121
	 * 
122
	 * @return true if the corpus indexes & editions needs to be updated after saving annotation
123
	 */
124
	public abstract boolean needToUpdateIndexes();
119 125
}
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 1199)
131 131
			@Override
132 132
			public void widgetSelected(SelectionEvent e) {
133 133
				boolean saveSuccessful = true;
134
				boolean needToUpdateIndexes = false;
134 135
				//System.out.println("Saving annotations...");
135 136
				if (annotationAreas != null) {
136 137
					for (AnnotationArea aa : annotationAreas) {
137 138
						saveSuccessful = saveSuccessful && aa.save();
139
						needToUpdateIndexes = needToUpdateIndexes || aa.needToUpdateIndexes();
138 140
					}
139 141
				}
140 142

  
141
				JobHandler job = new JobHandler("Updating corpus editions and indexes", true) {
143
				if (saveSuccessful && needToUpdateIndexes) {
144
					JobHandler job = new JobHandler("Updating corpus editions and indexes", true) {
142 145

  
143
					@Override
144
					protected IStatus run(IProgressMonitor monitor) {
145
						final MainCorpus corpus = (MainCorpus) editor.getResult().getFirstParent(MainCorpus.class);
146
						monitor.setTaskName("updating corpus indexes and editions");
147
						if (corpus != null && UpdateCorpus.update(corpus) != null) {
148
							monitor.worked(50);
149
							this.syncExec(new Runnable() {
150
								public void run() {
151
									CorporaView.refreshObject(corpus);
152
								}
153
							});
154
							return Status.OK_STATUS;
155
						} else {
156
							monitor.worked(50);
157
							System.out.println("Fail to update corpus. Aborting");
158
							System.out.println("Fix XML-TXM files and call command 'UpdateCorpus'");
159
							return Status.CANCEL_STATUS;
146
						@Override
147
						protected IStatus run(IProgressMonitor monitor) {
148
							final MainCorpus corpus = (MainCorpus) editor.getResult().getFirstParent(MainCorpus.class);
149
							monitor.setTaskName("updating corpus indexes and editions");
150
							if (corpus != null && UpdateCorpus.update(corpus) != null) {
151
								monitor.worked(50);
152
								this.syncExec(new Runnable() {
153
									public void run() {
154
										CorporaView.refreshObject(corpus);
155
									}
156
								});
157
								return Status.OK_STATUS;
158
							} else {
159
								monitor.worked(50);
160
								System.out.println("Fail to update corpus. Aborting");
161
								System.out.println("Fix XML-TXM files and call command 'UpdateCorpus'");
162
								return Status.CANCEL_STATUS;
163
							}
160 164
						}
161
					}
162
				};
163
				job.schedule();
165
					};
166
					job.schedule();
167
				}
164 168

  
165

  
166 169
			}
167 170

  
168 171
			@Override
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/SimpleKRAnnotation.java (revision 1199)
700 700
		return false;
701 701
	}
702 702

  
703
	@Override
704
	public boolean needToUpdateIndexes() {
705
		return true;
706
	}
703 707
}
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java (revision 1199)
916 916
	public boolean discardChanges() {
917 917
		return false;
918 918
	}
919

  
920
	@Override
921
	public boolean needToUpdateIndexes() {
922
		return true;
923
	}
919 924
}
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java (revision 1199)
731 731
	public boolean discardChanges() {
732 732
		return false;
733 733
	}
734

  
735
	@Override
736
	public boolean needToUpdateIndexes() {
737
		return true;
738
	}
734 739
}
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/KRAnnotationEngine.java (revision 1199)
14 14
import org.txm.annotation.kr.core.repository.KnowledgeRepository;
15 15
import org.txm.annotation.kr.core.repository.KnowledgeRepositoryManager;
16 16
import org.txm.annotation.kr.core.repository.SQLKnowledgeRepository;
17
import org.txm.core.results.TXMResult;
17 18
import org.txm.objects.Project;
18
import org.txm.objects.BaseOldParameters;
19 19
import org.txm.searchengine.cqp.corpus.CQPCorpus;
20 20
import org.txm.searchengine.cqp.corpus.MainCorpus;
21 21
import org.txm.sql.SQLConnection;
22
import org.txm.utils.DeleteDir;
22 23
import org.txm.utils.logger.Log;
23 24
import org.w3c.dom.Element;
24 25
import org.w3c.dom.NodeList;
......
414 415
		// TODO not implemented yet.
415 416
		return false;
416 417
	}
418

  
419
	@Override
420
	public void notify(TXMResult r, String state) {
421
		
422
		if (r instanceof MainCorpus && "clean".equals(state)) {
423
			MainCorpus c = (MainCorpus)r;
424
			File buildDirectory = new File(c.getProjectDirectory(), "temporary_annotations/"+c.getID());
425
			if (buildDirectory.exists()) {
426
				DeleteDir.deleteDirectory(buildDirectory);
427
			}
428
		} else if (r instanceof Project && "clean".equals(state)) {
429
			Project c = (Project)r;
430
			File buildDirectory = new File(c.getProjectDirectory(), "temporary_annotations");
431
			if (buildDirectory.exists()) {
432
				DeleteDir.deleteDirectory(buildDirectory);
433
			}
434
		}
435
	}
436

  
437
	@Override
438
	public String getDetails() {
439
		return "";
440
	}
417 441
}
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationManager.java (revision 1199)
12 12
import org.txm.annotation.kr.core.repository.TypedValue;
13 13
import org.txm.annotation.kr.core.storage.temporary.TemporaryAnnotationManager;
14 14
import org.txm.core.engines.Engine;
15
import org.txm.core.results.TXMResult;
16
import org.txm.objects.Project;
15 17
import org.txm.searchengine.cqp.corpus.MainCorpus;
16 18
import org.txm.searchengine.cqp.corpus.query.Match;
17 19
import org.txm.utils.logger.Log;
......
22 24
 * @author mdecorde
23 25
 *
24 26
 */
25
public class AnnotationManager implements Engine {
27
public class AnnotationManager {
26 28

  
27 29
	MainCorpus corpus;
28 30
	TemporaryAnnotationManager tempManager;
......
308 310
		return tempManager.getEntityManager() != null && tempManager.getEntityManager().isOpen();
309 311
	}
310 312

  
311
	@Override
312
	public String getName() {
313
		return "Annotation";
314
	}
315 313

  
316
	@Override
317
	public boolean isRunning() {
318
		return isOpen();
319
	}
320

  
321
	@Override
322 314
	public boolean initialize() throws Exception {
323 315
		tempManager = new TemporaryAnnotationManager(corpus);
324 316
		dirty = tempManager.getAnnotations().size() > 0;
325 317
		cqpManager = new CQPAnnotationManager(corpus);
326 318
		return false;
327 319
	}
328

  
329
	@Override
330
	public boolean start(IProgressMonitor arg0) throws Exception {
331
		return true;
332
	}
333

  
334
	@Override
335
	public boolean stop() throws Exception {
336
		return true;
337
	}
338 320
	
339 321
	/**
340 322
	 * 
tmp/org.txm.setups/shared/debian/DEBIAN/control (revision 1199)
1 1
Package: txm
2
Version: 0.8.0
2
Version: TXMVERSION
3 3
Section: base
4 4
Priority: optional
5 5
Architecture: all
tmp/org.txm.setups/shared/debian/DEBIAN/preinst (revision 1199)
2 2
VERSION=-TXMVERSION
3 3

  
4 4
echo "removing /usr/lib/TXM${VERSION}"
5
if [ ! -d "/usr/lib/TXM${VERSION}" ]; then
5
if [ -d "/usr/lib/TXM${VERSION}" ]; then
6 6
	rm -rf "/usr/lib/TXM${VERSION}"
7 7
fi
8 8

  
9 9
echo "removing /usr/share/doc/txm${VERSION}"
10
if [ ! -d "/usr/share/doc/txm${VERSION}" ]; then
10
if [ -d "/usr/share/doc/txm${VERSION}" ]; then
11 11
	rm -rf "/usr/share/doc/txm${VERSION}"
12 12
fi
13 13

  
14 14
echo "removing /usr/share/lintian/overrides/txm${VERSION}"
15
if [ ! -d "/usr/share/lintian/overrides/txm${VERSION}" ]; then
15
if [ -d "/usr/share/lintian/overrides/txm${VERSION}" ]; then
16 16
	rm -rf "/usr/share/lintian/overrides/txm${VERSION}"
17 17
fi
18 18

  
19 19
echo "removing /usr/share/TXM${VERSION}"
20
if [ ! -d "/usr/share/TXM${VERSION}" ]; then
20
if [ -d "/usr/share/TXM${VERSION}" ]; then
21 21
	rm -rf "/usr/share/TXM${VERSION}"
22 22
fi
23 23

  
24 24
echo "removing /usr/share/applications/TXM${VERSION}.desktop"
25
if [ ! -f "/usr/share/applications/TXM${VERSION}.desktop" ]; then
25
if [ -f "/usr/share/applications/TXM${VERSION}.desktop" ]; then
26 26
	rm "/usr/share/applications/TXM${VERSION}.desktop"
27
fi
28

  
29
echo "removing /usr/share/applications/TXM${VERSION} debug.desktop"
30
if [ -f "/usr/share/applications/TXM${VERSION}.desktop" ]; then
27 31
	rm "/usr/share/applications/TXM${VERSION} debug.desktop"
28 32
fi
29 33

  
30 34
echo "removing /usr/bin/TXM${VERSION}"
31
if [ ! -f "/usr/bin/TXM${VERSION}" ]; then
35
if [ -f "/usr/bin/TXM${VERSION}" ]; then
32 36
	rm "/usr/bin/TXM${VERSION}"
33 37
fi
34 38

  
tmp/org.txm.setups/shared/debian/DEBIAN/copyright (revision 1199)
4 4
Upstream-Name: txm
5 5
Source : https://sourceforge.net/projects/txm/
6 6

  
7
Copyright: Copyright © 2010-2017 ENS de Lyon. Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of Nice Sophia Antipolis, University of Paris 3.
7
Copyright: Copyright © 2010-2018 ENS de Lyon. Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of Nice Sophia Antipolis, University of Paris 3.
8 8
License: GPL-2+
9 9
 The TXM platform is free software: you can redistribute it
10 10
 and/or modify it under the terms of the GNU General Public
tmp/org.txm.setups/shared/debian/usr/bin/TXM (revision 1199)
1 1
# This script launches TXM in the right directory and with the right TXM.ini file
2 2
UBUNTU_MENUPROXY=0
3 3
VERSION=-TXMVERSION
4

  
5 4
echo "TXM: Preparing redirections in $HOME/TXM_PostInstallOutputLogs.txt and $HOME/TXM_PostInstallErrorLogs.txt files."
6 5

  
7 6
LOGFILESMSG=", see $HOME/TXM_PostInstallOutputLogs.txt and $HOME/TXM_PostInstallErrorLogs.txt output and error messages files."
......
94 93
	    echo "TXM: Failed to remove $DOTTXMHOME directory$LOGFILESMSG"
95 94
	    exit 1 ;
96 95
	fi
96
	
97
	echo "TXM: resetting RCP workspace."
98
	rm -rf "$TXMHOME/corpora/.metadata"
99
	if [ -d "$TXMHOME/corpora/.metadata" ]; then
100
	    zenity --info --text="TXM: Failed to remove $TXMHOME/corpora/.metadata"
101
	    echo "TXM: Failed to remove $TXMHOME/corpora/.metadata"
102
	    exit 1 ;
103
	fi
97 104

  
98 105
    mkdir "$DOTTXMHOME"
99 106
    if [ ! -d "$DOTTXMHOME" ]; then
......
150 157
## uncomment next lien to enable full debug
151 158
#DEBUGOPTIONS="-log -consolelog -clean -debug -console -noexit"
152 159

  
153
SWT_GTK3=0 UBUNTU_MENUPROXY=0 exec "${TXMINSTALL}/TXM" -run --launcher.ini "$DOTTXMHOME/TXM.ini" $DEBUGOPTIONS -data "$TXMHOME/corpora" -user "$DOTTXMHOME/user" -install "$TXMINSTALL"
160
SWT_GTK3=0 UBUNTU_MENUPROXY=0 exec "${TXMINSTALL}/TXM" "$@" -run --launcher.ini "$DOTTXMHOME/TXM.ini" $DEBUGOPTIONS -data "$TXMHOME/corpora" -user "$DOTTXMHOME/user" -install "$TXMINSTALL"
tmp/org.txm.setups/shared/debian/usr/share/applications/TXM.desktop (revision 1199)
1 1
[Desktop Entry]
2 2
Encoding=UTF-8
3 3
Type=Application
4
Name=TXM 0.8.0
5
Version=0.8.0
4
Name=TXM TXMVERSION
5
Version=TXMVERSION
6 6
GenericName=Textual data analysis software
7 7
GenericName[cn]= 文本分析软件
8 8
GenericName[de]=Textanalysesoftware
......
14 14
Comment[de]=Textometrie, quantitative und qualitative Analyse von elektronischen Textkorpora
15 15
Comment[fr]=Textométrie, analyse quantitative et qualitative de données textuelles
16 16
Comment[ru]=текстометрия, количественный и качественный анализ цифровых корпусов текстов 
17
Icon=/usr/share/TXM/TXM.png
18
Exec=/usr/bin/TXM
17
Icon=/usr/share/TXM-TXMVERSION/TXM.png
18
Exec=/usr/bin/TXM-TXMVERSION
19 19
Terminal=false
20
Categories=Sciences;Education;Science;
20
Categories=Sciences;Education;Science;
tmp/org.txm.setups/shared/debian/usr/share/applications/TXM debug.desktop (revision 1199)
1 1
[Desktop Entry]
2 2
Encoding=UTF-8
3 3
Type=Application
4
Name=TXM 0.8.0 Debug
5
Version=0.8.0
4
Name=TXM TXMVERSION Debug
5
Version=TXMVERSION
6 6
GenericName=Textual data analysis software
7 7
GenericName[cn]= 文本分析软件
8 8
GenericName[de]=Textanalysesoftware
......
14 14
Comment[de]=Textometrie, quantitative und qualitative Analyse von elektronischen Textkorpora
15 15
Comment[fr]=Textométrie, analyse quantitative et qualitative de données textuelles
16 16
Comment[ru]=текстометрия, количественный и качественный анализ цифровых корпусов текстов 
17
Icon=/usr/share/TXM/TXM.png
18
Exec=/usr/bin/TXM
17
Icon=/usr/share/TXM-TXMVERSION/TXM debug.png
18
Exec=/usr/bin/TXM-TXMVERSION -log -debug -console -consoleLog -noredirection
19 19
Terminal=true
20
Categories=Sciences;Education;Science;
20
Categories=Sciences;Education;Science;
tmp/org.txm.setups/shared/debian/usr/share/lintian/overrides/txm (revision 1199)
1
txm binary: arch-independent-package-contains-binary-or-object
2
txm binary: unstripped-binary-or-object
1
txm-TXMVERSION binary: arch-independent-package-contains-binary-or-object
2
txm-TXMVERSION binary: unstripped-binary-or-object
tmp/org.txm.setups/BuildLinux64bit.sh (revision 1199)
64 64
find "$APP/DEBIAN/preinst" -type f -exec sed -i "s/TXMVERSION/$VERSION/g" {} \;
65 65
find "$APP/DEBIAN/postinst" -type f -exec sed -i "s/TXMVERSION/$VERSION/g" {} \;
66 66
find "$APP/usr/bin/TXM" -type f -exec sed -i "s/TXMVERSION/$VERSION/g" {} \;
67
find "$APP/DEBIAN/control" -type f -exec sed -i "s/Package: txm/Package: txm-${VERSION}/g" {} \;
67
find "$APP/DEBIAN/control" -type f -exec sed -i "s/TXMVERSION/${VERSION}/g" {} \;
68

  
68 69
mv "$APP/usr/bin/TXM" "$APP/usr/bin/TXM-$VERSION"
69 70
mv "$APP/usr/lib/TXM" "$APP/usr/lib/TXM-$VERSION"
70
find "$APP/usr/share/applications/TXM.desktop" -type f -exec sed -i "s/\/usr\/share\/TXM/\/usr\/share\/TXM-$VERSION/g" {} \;
71
find "$APP/usr/share/applications/TXM.desktop" -type f -exec sed -i "s/\/usr\/bin\/TXM/\/usr\/bin\/TXM-$VERSION/g" {} \;
72
find "$APP/usr/share/applications/TXM debug.desktop" -type f -exec sed -i "s/\/usr\/share\/TXM/\/usr\/share\/TXM-$VERSION/g" {} \;
73
find "$APP/usr/share/applications/TXM debug.desktop" -type f -exec sed -i "s/\/usr\/bin\/TXM/\/usr\/bin\/TXM-$VERSION/g" {} \;
71

  
72
find "$APP/usr/share/applications/TXM.desktop" -type f -exec sed -i "s/TXMVERSION/$VERSION/g" {} \;
73
find "$APP/usr/share/applications/TXM.desktop" -type f -exec sed -i "s/TXMVERSION/$VERSION/g" {} \;
74
find "$APP/usr/share/applications/TXM debug.desktop" -type f -exec sed -i "s/TXMVERSION/$VERSION/g" {} \;
75
find "$APP/usr/share/applications/TXM debug.desktop" -type f -exec sed -i "s/TXMVERSION/$VERSION/g" {} \;
74 76
mv "$APP/usr/share/applications/TXM.desktop" "$APP/usr/share/applications/TXM-$VERSION.desktop"
75 77
mv "$APP/usr/share/applications/TXM debug.desktop" "$APP/usr/share/applications/TXM-$VERSION debug.desktop"
78

  
76 79
mv "$APP/usr/share/doc/txm" "$APP/usr/share/doc/txm-$VERSION"
77
find "$APP/usr/share/lintian/overrides/txm" -type f -exec sed -i "s/txm binary/txm-$VERSION binary/g" {} \;
80

  
81
find "$APP/usr/share/lintian/overrides/txm" -type f -exec sed -i "s/TXMVERSION/$VERSION/g" {} \;
78 82
mv "$APP/usr/share/lintian/overrides/txm" "$APP/usr/share/lintian/overrides/txm-$VERSION"
79 83
mv "$APP/usr/share/TXM" "$APP/usr/share/TXM-$VERSION"
80 84

  
tmp/org.txm.queryindex.rcp/plugin.xml (revision 1199)
5 5
         point="org.eclipse.ui.editors">
6 6
         
7 7
         <editor
8
            class="org.txm.queryindex.rcp.editors.queryindex.QueryIndexEditor"
8
            class="org.txm.queryindex.rcp.editors.QueryIndexEditor"
9 9
            default="false"
10 10
            icon="icons/functions/QueryIndex.png"
11 11
            id="org.txm.rcp.editors.queryindex.QueryIndexEditor"
tmp/org.txm.queryindex.rcp/META-INF/MANIFEST.MF (revision 1199)
12 12
Export-Package: org.txm.queryindex.core.functions,
13 13
 org.txm.queryindex.rcp.commands.function,
14 14
 org.txm.queryindex.rcp.commands.link,
15
 org.txm.queryindex.rcp.editors.input,
16
 org.txm.queryindex.rcp.editors.queryindex,
15
 org.txm.queryindex.rcp.editors,
17 16
 queryindexrcp,
18 17
 queryindexrcp.actions,
19 18
 queryindexrcp.adapters
tmp/org.txm.queryindex.rcp/src/org/txm/queryindex/rcp/commands/function/ComputeQueryIndex.java (revision 1199)
31 31
import org.eclipse.core.commands.ExecutionEvent;
32 32
import org.eclipse.core.commands.ExecutionException;
33 33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.ui.IEditorPart;
34 35
import org.eclipse.ui.IWorkbenchPage;
35 36
import org.eclipse.ui.handlers.HandlerUtil;
37
import org.txm.queryindex.core.functions.QueryIndex;
38
import org.txm.queryindex.rcp.editors.QueryIndexEditor;
36 39
import org.txm.index.rcp.messages.IndexUIMessages;
37
import org.txm.queryindex.rcp.editors.input.QueryIndexEditorInput;
38
import org.txm.queryindex.rcp.editors.queryindex.QueryIndexEditor;
39 40
import org.txm.rcp.StatusLine;
40 41
import org.txm.rcp.TXMWindows;
42
import org.txm.rcp.editors.TXMResultEditorInput;
41 43
import org.txm.searchengine.cqp.corpus.CQPCorpus;
42 44
import org.txm.searchengine.cqp.corpus.Partition;
43 45
import org.txm.utils.logger.Log;
44
// TODO: Auto-generated Javadoc
46

  
45 47
/**
46
 * open the Index Editor 
48
 * Open the Query Index Editor
49
 * 
47 50
 * @author mdecorde.
48 51
 */
49 52
public class ComputeQueryIndex extends AbstractHandler {
......
78 81
	
79 82
	public static void openEditor(CQPCorpus corpus) {
80 83
		IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage();
81
		QueryIndexEditorInput editorInput = new QueryIndexEditorInput(corpus);
84
		TXMResultEditorInput<QueryIndex> editorInput = new TXMResultEditorInput<QueryIndex>(new QueryIndex(corpus));
82 85
		try {
83 86
			StatusLine.setMessage(IndexUIMessages.ComputeIndex_0);
84
			QueryIndexEditor voceditor = (QueryIndexEditor) page
85
					.openEditor(editorInput,QueryIndexEditor.ID);
86
			voceditor.initializeFields();
87
			IEditorPart editor =  page.openEditor(editorInput,QueryIndexEditor.ID);
88
			if (editor instanceof QueryIndexEditor) {
89
				QueryIndexEditor voceditor = (QueryIndexEditor)editor;
90
				voceditor.initializeFields();
91
			}
87 92
		} catch (Exception e) {
88 93
			Log.printStackTrace(e);
89 94
		}
......
91 96
	
92 97
	public static void openEditor(Partition partition) {
93 98
		IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage();
94
		QueryIndexEditorInput editorInput = new QueryIndexEditorInput(partition);
99
		TXMResultEditorInput<QueryIndex> editorInput = new TXMResultEditorInput<QueryIndex>(new QueryIndex(partition));
95 100
		try {
96 101
			StatusLine.setMessage(IndexUIMessages.ComputeIndex_0);
97 102
			QueryIndexEditor voceditor = (QueryIndexEditor) page
tmp/org.txm.queryindex.rcp/src/org/txm/queryindex/rcp/editors/LineLabelProvider.java (revision 1199)
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.queryindex.rcp.editors;
29

  
30
import org.eclipse.jface.viewers.ILabelProviderListener;
31
import org.eclipse.jface.viewers.ITableLabelProvider;
32
import org.eclipse.swt.graphics.Image;
33
import org.txm.queryindex.core.functions.QueryIndexLine;
34

  
35
// TODO: Auto-generated Javadoc
36
/**
37
 * The Class LineLabelProvider.
38
 */
39
public class LineLabelProvider implements ITableLabelProvider {
40

  
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
43
	 */
44
	@Override
45
	public Image getColumnImage(Object element, int columnIndex) {
46
		return null;
47
	}
48

  
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
51
	 */
52
	@Override
53
	public String getColumnText(Object element, int columnIndex) {
54
		QueryIndexLine line = (QueryIndexLine) element;
55
		switch (columnIndex) {
56
		case 0:
57
			return ""; //$NON-NLS-1$
58
		case 1:
59
			return line.getName();
60
		case 2:
61
			return "" + line.getFrequency(); //$NON-NLS-1$
62
		default:
63
			if (line.getFreqs().length > 1
64
					&& columnIndex - 3 < line.getFreqs().length)
65
				return "" + line.getFrequency(columnIndex - 3); //$NON-NLS-1$
66
			else
67
				return "";//$NON-NLS-1$
68
		}
69
	}
70

  
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
73
	 */
74
	@Override
75
	public void addListener(ILabelProviderListener listener) {
76
		// TODO Auto-generated method stub
77
	}
78

  
79
	/* (non-Javadoc)
80
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
81
	 */
82
	@Override
83
	public void dispose() {
84
		// TODO Auto-generated method stub
85
	}
86

  
87
	/* (non-Javadoc)
88
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
89
	 */
90
	@Override
91
	public boolean isLabelProperty(Object element, String property) {
92
		// TODO Auto-generated method stub
93
		return false;
94
	}
95

  
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
98
	 */
99
	@Override
100
	public void removeListener(ILabelProviderListener listener) {
101
		// TODO Auto-generated method stub
102
	}
103
}
0 104

  
tmp/org.txm.queryindex.rcp/src/org/txm/queryindex/rcp/editors/QueryIndexEditor.java (revision 1199)
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.queryindex.rcp.editors;
29

  
30
import java.io.File;
31
import java.io.IOException;
32
import java.util.ArrayList;
33
import java.util.List;
34

  
35
import org.eclipse.core.runtime.IProgressMonitor;
36
import org.eclipse.core.runtime.IStatus;
37
import org.eclipse.core.runtime.Status;
38
import org.eclipse.jface.action.MenuManager;
39
import org.eclipse.jface.viewers.ISelection;
40
import org.eclipse.jface.viewers.StructuredSelection;
41
import org.eclipse.jface.viewers.TableViewer;
42
import org.eclipse.swt.SWT;
43
import org.eclipse.swt.events.KeyEvent;
44
import org.eclipse.swt.events.KeyListener;
45
import org.eclipse.swt.events.MouseAdapter;
46
import org.eclipse.swt.events.MouseEvent;
47
import org.eclipse.swt.events.SelectionEvent;
48
import org.eclipse.swt.events.SelectionListener;
49
import org.eclipse.swt.graphics.Font;
50
import org.eclipse.swt.graphics.FontData;
51
import org.eclipse.swt.graphics.Point;
52
import org.eclipse.swt.layout.GridData;
53
import org.eclipse.swt.layout.GridLayout;
54
import org.eclipse.swt.layout.RowData;
55
import org.eclipse.swt.widgets.Button;
56
import org.eclipse.swt.widgets.Composite;
57
import org.eclipse.swt.widgets.Display;
58
import org.eclipse.swt.widgets.FileDialog;
59
import org.eclipse.swt.widgets.Group;
60
import org.eclipse.swt.widgets.Label;
61
import org.eclipse.swt.widgets.Menu;
62
import org.eclipse.swt.widgets.Spinner;
63
import org.eclipse.swt.widgets.TableColumn;
64
import org.eclipse.ui.IEditorInput;
65
import org.eclipse.ui.IEditorSite;
66
import org.eclipse.ui.PartInitException;
67
import org.txm.core.messages.TXMCoreMessages;
68
import org.txm.index.core.functions.LineComparator.SortMode;
69
import org.txm.index.rcp.messages.IndexUIMessages;
70
import org.txm.queryindex.core.functions.Messages;
71
import org.txm.queryindex.core.functions.QueryIndex;
72
import org.txm.queryindex.core.functions.QueryIndexLine;
73
import org.txm.rcp.JobsTimer;
74
import org.txm.rcp.StatusLine;
75
import org.txm.rcp.editors.TXMEditor;
76
import org.txm.rcp.editors.TXMResultEditorInput;
77
import org.txm.rcp.editors.TableKeyListener;
78
import org.txm.rcp.messages.TXMUIMessages;
79
import org.txm.rcp.swt.GLComposite;
80
import org.txm.rcp.swt.dialog.LastOpened;
81
import org.txm.rcp.swt.widget.NamedAssistedQueryWidget;
82
import org.txm.rcp.swt.widget.NavigationWidget;
83
import org.txm.rcp.utils.JobHandler;
84
import org.txm.rcp.views.QueriesView;
85
import org.txm.rcp.views.corpora.CorporaView;
86
import org.txm.searchengine.cqp.CQPSearchEngine;
87
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
88
import org.txm.searchengine.cqp.corpus.CQPCorpus;
89
import org.txm.searchengine.cqp.corpus.Partition;
90
import org.txm.searchengine.cqp.corpus.Property;
91
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
92
import org.txm.statsengine.r.rcp.views.RVariablesView;
93
import org.txm.utils.logger.Log;
94

  
95
/**
96
 * display the query index parameters and result.
97
 * 
98
 * @author mdecorde
99
 */
100
public class QueryIndexEditor extends TXMEditor<QueryIndex> {
101

  
102
	/** The Constant ID. */
103
	public static final String ID = "org.txm.rcp.editors.queryindex.QueryIndexEditor"; //$NON-NLS-1$
104

  
105
	/** The corpus. */
106
	protected CQPCorpus corpus;
107
	protected Partition partition; // can be null
108

  
109
	/** The index. */
110
	protected QueryIndex queryindex;
111
	boolean stored = false; // start storing at first line added
112
	// protected boolean saveQueryIndex = true;
113

  
114
	// params
115
	/** The query label. */
116
	protected Label queryLabel;
117

  
118
	/** The query widget. */
119
	protected NamedAssistedQueryWidget queryWidget;
120

  
121
	/** The N ligne p page spinner. */
122
	protected Spinner NLignePPageSpinner;
123
	// infos
124
	/** The navigation area. */
125
	protected NavigationWidget navigationArea;
126

  
127
	/** The l fmin info. */
128
	protected Label lFminInfo;
129

  
130
	/** The l fmax info. */
131
	protected Label lFmaxInfo;
132

  
133
	/** The l v info. */
134
	protected Label lVInfo;
135

  
136
	/** The l t info. */
137
	protected Label lTInfo;
138
	// result
139
	/** The line table viewer. */
140
	protected TableViewer viewer;
141

  
142
	/** The n column. */
143
	protected TableColumn nColumn;
144

  
145
	/** The unit column. */
146
	protected TableColumn unitColumn;
147

  
148
	/** The freq column. */
149
	protected TableColumn freqColumn;
150

  
151
	/** The separator column. */
152
	protected TableColumn separatorColumn;
153

  
154
	/** The top line. */
155
	protected int topLine;
156

  
157
	/** The bottom line. */
158
	protected int bottomLine;
159

  
160
	/** The nblinesperpage. */
161
	protected int nblinesperpage;
162

  
163
	/** The nblinesmax. */
164
	protected int nblinesmax;
165

  
166
//	/** The scroll composite. */
167
//	private ScrolledComposite scrollComposite;
168
//
169
//	/** The head composite. */
170
//	private Composite headComposite;
171

  
172
	/** The title. */
173
	String title;
174

  
175
	/**
176
	 * Instantiates a new index editor.
177
	 */
178
	public QueryIndexEditor() {
179
		super();
180
	}
181

  
182
	/**
183
	 * Do save.
184
	 * 
185
	 * @param arg0
186
	 *            the arg0
187
	 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
188
	 */
189
	@Override
190
	public void doSave(IProgressMonitor arg0) {
191
		// TODO Auto-generated method stub
192
	}
193

  
194
	/**
195
	 * Do save as.
196
	 * 
197
	 * @see org.eclipse.lyon gournd zeroui.part.EditorPart#doSaveAs()
198
	 */
199
	@Override
200
	public void doSaveAs() {
201
		// TODO Auto-generated method stub
202
	}
203

  
204
	/**
205
	 * Inits the.
206
	 * 
207
	 * @param site
208
	 *            the site
209
	 * @param input
210
	 *            the input
211
	 * @throws PartInitException
212
	 *             the part init exception
213
	 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
214
	 *      org.eclipse.ui.IEditorInput)
215
	 */
216
	@Override
217
	public void init(IEditorSite site, IEditorInput input)
218
			throws PartInitException {
219
		setSite(site);
220
		setInput(input);
221

  
222
		TXMResultEditorInput<QueryIndex> tre = (TXMResultEditorInput)input;
223
		this.corpus = tre.getResult().getCorpus();
224
		this.partition = tre.getResult().getPartition();
225
		this.queryindex = tre.getResult();
226
	}
227

  
228
	/**
229
	 * Checks if is dirty.
230
	 * 
231
	 * @return true, if is dirty
232
	 * @see org.eclipse.ui.part.EditorPart#isDirty()
233
	 */
234
	@Override
235
	public boolean isDirty() {
236
		return false;
237
	}
238

  
239
	/**
240
	 * Checks if is save as allowed.
241
	 * 
242
	 * @return true, if is save as allowed
243
	 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
244
	 */
245
	@Override
246
	public boolean isSaveAsAllowed() {
247
		return false;
248
	}
249

  
250
	private QueryIndex createQueryIndex() {
251
		if (queryindex == null) {
252
			if (partition != null) {
253
				queryindex = new QueryIndex(partition);
254
				title = Messages.QueryIndexEditor_0 + partition.getName();
255
			} else {
256
				queryindex = new QueryIndex(corpus);
257
				title = Messages.QueryIndexEditor_0 + corpus;
258
			}
259
		}
260
		return queryindex;
261
	}
262

  
263
	/**
264
	 * Compute index.
265
	 */
266
	public void compute() {
267

  
268
		createQueryIndex();
269

  
270
		StatusLine.setMessage(IndexUIMessages.IndexEditor_33);
271
		final CQLQuery query; // if the query is empty then we put "[]" instead
272
		if (!queryWidget.getQueryString().equals("\"\"")) {//$NON-NLS-1$
273
			query = new CQLQuery(queryWidget.getQueryString());
274
		} else {
275
			System.err.println(IndexUIMessages.IndexEditor_0);
276
			return;
277
		}
278

  
279
		final String name;
280
		if (queryWidget.getQueryName().length() == 0) {
281
			name = query.toString();
282
		} else {
283
			name = queryWidget.getQueryName();
284
		}
285

  
286
		title = "Computing QueryIndex...";
287
		
288
		try {
289
			JobHandler jobhandler = new JobHandler(title,
290
					queryWidget.getParent()) {
291
				@Override
292
				protected IStatus run(IProgressMonitor monitor) {
293
					this.runInit(monitor);
294
					JobsTimer.start();
295
					final QueryIndexLine line;
296
					try {
297
						try {
298
							if (queryindex.hasLine(name)) {
299
								System.out.println(Messages.QueryIndexEditor_1 + name);
300
								queryindex.removeLine(name);
301
							}
302
							line = queryindex.addLine(name, query);
303
						} catch (CqiClientException e2) {
304
							System.out
305
									.println(Messages.QueryIndexEditor_2
306
											+ query);
307
							Log.printStackTrace(e2);
308
							return Status.CANCEL_STATUS;
309
						}
310

  
311
						if (line == null) {
312
							System.out
313
									.println(Messages.QueryIndexEditor_2
314
											+ query);
315
							return Status.CANCEL_STATUS;
316
						}
317

  
318
						if (monitor.isCanceled())
319
							return Status.CANCEL_STATUS;
320

  
321
						queryindex.sortLines(SortMode.FREQUNIT, true);
322

  
323
						if (monitor.isCanceled())
324
							return Status.CANCEL_STATUS;
325

  
326
						this.acquireSemaphore();
327
						this.releaseSemaphore();
328

  
329
						final String message = Messages.QueryIndexEditor_3;
330

  
331
						if (monitor.isCanceled())
332
							return Status.CANCEL_STATUS;
333

  
334
						monitor.worked(95);
335
						// refresh ui
336
						syncExec(new Runnable() {
337
							@Override
338
							public void run() {
339

  
340
								System.out.println(message);
341
								StatusLine.setMessage(message);
342

  
343
								CorporaView.refresh();
344
								CorporaView.expand(queryindex.getParent());
345
								QueriesView.refresh();
346
								RVariablesView.refresh();
347

  
348
								setPartName(title);
349

  
350
								queryWidget.memorize();
351
								nblinesperpage = NLignePPageSpinner
352
										.getSelection();
353

  
354
								fillDisplayArea(0,
355
										NLignePPageSpinner.getSelection());
356

  
357
								if (line != null) {
358
									queryWidget.setText(""); //$NON-NLS-1$
359
									queryWidget.setName(""); //$NON-NLS-1$
360
									queryWidget.focus();
361
								}
362
							}
363
						});
364
					} catch (Exception e) {
365
						System.out.println(e.getLocalizedMessage());
366
						try {
367
							System.out.println(TXMUIMessages.LastCQPError
368
									+ CQPSearchEngine.getCqiClient().getLastCQPError());
369
						} catch (Exception e1) {
370
							System.out.println(IndexUIMessages.IndexEditor_10
371
									+ e1);
372
							Log.printStackTrace(e1);
373
						}
374
						Log.severe("Error while computing QueryIndex: "+e.getLocalizedMessage());
375
					} catch (ThreadDeath td) {
376
						return Status.CANCEL_STATUS;
377
					} finally {
378
						monitor.done();
379
						JobsTimer.stopAndPrint();
380
					}
381
					return Status.OK_STATUS;
382
				}
383
			};
384
			jobhandler.startJob();
385

  
386
		} catch (Exception e1) {
387
			Log.printStackTrace(e1);
388
		}
389
	}
390

  
391
	/**
392
	 * Creates the part control.
393
	 * 
394
	 * @param parent
395
	 *            the parent
396
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
397
	 */
398
	@Override
399
	public void _createPartControl() {
400

  
401

  
402
		final Group paramArea = getExtendedParametersGroup();
403

  
404

  
405
		GLComposite resultArea = getResultArea();
406

  
407
		// on créé une Query, ici le pivot de la concordance est "[]"
408
		// Query Area: query itself + view properties
409
		Composite queryArea = new Composite(paramArea, SWT.NONE);
410
		RowData rdata = new RowData();
411
		queryArea.setLayoutData(rdata);
412
		queryArea.setLayout(new GridLayout(4, false));
413

  
414
		// | Query: [ (v)] [Search] |
415
		// Query:
416
		// queryLabel = new Label(queryArea, SWT.NONE);
417
		// queryLabel.setText(RCPMessages.IndexEditor_3);
418
		// queryLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
419
		// true));
420

  
421
		// [ (v)]
422
		queryWidget = new NamedAssistedQueryWidget(queryArea, SWT.DROP_DOWN,
423
				this.corpus);
424
		GridData layoutData = new GridData(GridData.FILL);
425
		layoutData.horizontalAlignment = GridData.FILL;
426
		layoutData.grabExcessHorizontalSpace = true;
427
		layoutData.minimumWidth = 400;
428
		layoutData.widthHint = 900;
429
		queryWidget.setLayoutData(layoutData);
430
		queryWidget.addKeyListener(new KeyListener() {
431
			@Override
432
			public void keyPressed(KeyEvent e) {
433
				// System.out.println("key pressed : "+e.keyCode);
434
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
435
					compute();
436
				}
437
			}
438

  
439
			@Override
440
			public void keyReleased(KeyEvent e) {
441
			}
442
		});
443

  
444
		Button loadFromFile = new Button(queryArea, SWT.BOLD);
445
		loadFromFile.setEnabled(true);
446
		loadFromFile.setText(Messages.QueryIndexEditor_4);
447
		loadFromFile
448
				.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
449
		loadFromFile.addSelectionListener(new SelectionListener() {
450
			@Override
451
			public void widgetSelected(SelectionEvent e) {
452
				File propFile = null;
453
				if (LastOpened.getFile(ID) != null)
454
					propFile = new File(LastOpened.getFolder(ID));
455

  
456
				FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
457
				String[] exts = { "*.properties" }; //$NON-NLS
458
				dialog.setFilterExtensions(exts);
459
				if (propFile != null) {
460
					dialog.setFilterPath(propFile.getParent());
461
					dialog.setFileName(propFile.getName());
462
				}
463
				String path = dialog.open();
464
				if (path != null) {
465
					propFile = new File(path);
466
					// compute();
467
					// System.out.println("TODO: load from file "+propFile);
468
					createQueryIndex();
469
					try {
470
						queryindex.addLinesFromFile(propFile);
471
						queryindex.sortLines(SortMode.FREQUNIT, true);
472

  
473
						stored = true;
474

  
475
						fillDisplayArea(0, NLignePPageSpinner.getSelection());
476

  
477
						CorporaView.refresh();
478
						CorporaView.expand(queryindex.getParent());
479
						QueriesView.refresh();
480
						RVariablesView.refresh();
481

  
482
						setPartName(title);
483

  
484
						queryWidget.focus();
485
					} catch (CqiClientException e1) {
486
						// TODO Auto-generated catch block
487
						Log.printStackTrace(e1);
488
					} catch (IOException e1) {
489
						// TODO Auto-generated catch block
490
						System.out
491
								.println(Messages.QueryIndexEditor_6 + propFile);
492
						Log.printStackTrace(e1);
493
					}
494
				}
495
			}
496

  
497
			@Override
498
			public void widgetDefaultSelected(SelectionEvent e) {
499
			}
500
		});
501

  
502
		Button go = new Button(queryArea, SWT.BOLD);
503
		go.setText(Messages.QueryIndexEditor_12);
504

  
505
		Font f = go.getFont();
506
		FontData defaultFont = f.getFontData()[0];
507
		defaultFont.setStyle(SWT.BOLD);
508
		Font newf = new Font(go.getDisplay(), defaultFont);
509
		go.setFont(newf);
510

  
511
		layoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
512
		layoutData.horizontalAlignment = GridData.FILL;
513
		layoutData.grabExcessHorizontalSpace = false;
514
		go.setLayoutData(layoutData);
515

  
516
		go.addSelectionListener(new SelectionListener() {
517
			@Override
518
			public void widgetSelected(SelectionEvent e) {
519
				compute();
520
			}
521

  
522
			@Override
523
			public void widgetDefaultSelected(SelectionEvent e) {
524
			}
525
		});
526

  
527
		// Filters
528
		Composite filtercontrols = new Composite(paramArea, SWT.NONE);
529

  
530
		GridLayout gridLayout = new GridLayout();
531
		gridLayout.numColumns = 9;
532
		gridLayout.makeColumnsEqualWidth = false;
533
		filtercontrols.setLayout(gridLayout);
534

  
535
		Label lNLigneppage = new Label(filtercontrols, SWT.NONE);
536
		lNLigneppage.setText(IndexUIMessages.IndexEditor_8);
537
		lNLigneppage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
538
				false));
539

  
540
		NLignePPageSpinner = new Spinner(filtercontrols, SWT.BORDER);
541
		NLignePPageSpinner.setMinimum(0);
542
		NLignePPageSpinner.setMaximum(99999);
543
		NLignePPageSpinner.setSelection(100);
544
		NLignePPageSpinner.setIncrement(1);
545
		NLignePPageSpinner.setPageIncrement(100);
546
		NLignePPageSpinner.setLayoutData(new GridData(
547
				GridData.VERTICAL_ALIGN_END));
548
		NLignePPageSpinner.addSelectionListener(new SelectionListener() {
549
			@Override
550
			public void widgetSelected(SelectionEvent e) {
551
			}
552

  
553
			@Override
554
			public void widgetDefaultSelected(SelectionEvent e) {
555
				fillDisplayArea(0, NLignePPageSpinner.getSelection());
556
				viewer.getTable().select(0);
557
				viewer.getTable().showSelection();
558
			}
559
		});
560

  
561
		// compose infosArea
562
		// infosArea.setLayout(new GridLayout(6, false));
563

  
564
		navigationArea = new NavigationWidget(filtercontrols, SWT.NONE);
565
		navigationArea.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true,
566
				false));
567

  
568
		navigationArea.addFirstListener(new SelectionListener() {
569
			@Override
570
			public void widgetDefaultSelected(SelectionEvent e) {
571
			}
572

  
573
			@Override
574
			public void widgetSelected(SelectionEvent e) {
575
				fillDisplayArea(0, NLignePPageSpinner.getSelection());
576
				viewer.getTable().select(0);
577
				viewer.getTable().showSelection();
578
			}
579
		});
580
		navigationArea.addLastListener(new SelectionListener() {
581
			@Override
582
			public void widgetDefaultSelected(SelectionEvent e) {
583
			}
584

  
585
			@Override
586
			public void widgetSelected(SelectionEvent e) {
587
				int top = (queryindex.getV() / NLignePPageSpinner
588
						.getSelection()) * NLignePPageSpinner.getSelection();
589
				int bottom = top + NLignePPageSpinner.getSelection();
590
				fillDisplayArea(top, bottom);
591
				viewer.getTable().select(0);
592
				viewer.getTable().showSelection();
593
			}
594
		});
595
		navigationArea.addNextListener(new SelectionListener() {
596
			@Override
597
			public void widgetDefaultSelected(SelectionEvent e) {
598
			}
599

  
600
			@Override
601
			public void widgetSelected(SelectionEvent e) {
602
				int top = topLine + NLignePPageSpinner.getSelection();
603
				int bottom = top + NLignePPageSpinner.getSelection();
604
				fillDisplayArea(top, bottom);
605
				viewer.getTable().select(0);
606
				viewer.getTable().showSelection();
607
			}
608
		});
609
		navigationArea.addPreviousListener(new SelectionListener() {
610
			@Override
611
			public void widgetDefaultSelected(SelectionEvent e) {
612
			}
613

  
614
			@Override
615
			public void widgetSelected(SelectionEvent e) {
616
				int top = topLine - NLignePPageSpinner.getSelection();
617
				if (top < 0)
618
					top = 0;
619
				int bottom = top + NLignePPageSpinner.getSelection();
620
				fillDisplayArea(top, bottom);
621
				viewer.getTable().select(0);
622
				viewer.getTable().showSelection();
623
			}
624
		});
625

  
626
		// Labels
627
		lTInfo = new Label(filtercontrols, SWT.NONE);
628
		lTInfo.setText(""); //$NON-NLS-1$
629
		lTInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
630

  
631
		lVInfo = new Label(filtercontrols, SWT.NONE);
632
		lVInfo.setText(""); //$NON-NLS-1$
633
		lVInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
634

  
635
		lFminInfo = new Label(filtercontrols, SWT.NONE);
636
		lFminInfo.setText(""); //$NON-NLS-1$
637
		lFminInfo
638
				.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
639

  
640
		lFmaxInfo = new Label(filtercontrols, SWT.NONE);
641
		lFmaxInfo.setText(""); //$NON-NLS-1$
642
		lFmaxInfo
643
				.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
644

  
645
		// results
646
		viewer = new TableViewer(resultArea, SWT.MULTI | SWT.FULL_SELECTION
647
				| SWT.BORDER);
648
		viewer.getTable().setLinesVisible(true);
649
		viewer.getTable().setHeaderVisible(true);
650
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
651
		viewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
652
		if (corpus != null && corpus.getProject().getFont() != null
653
				&& corpus.getProject().getFont().length() > 0) {
654
			Font old = viewer.getTable().getFont();
655
			FontData fD = old.getFontData()[0];
656
			Font font = new Font(Display.getCurrent(), corpus.getProject().getFont(),
657
					fD.getHeight(), fD.getStyle());
658
			viewer.getTable().setFont(font);
659
		}
660

  
661
		viewer.setLabelProvider(new LineLabelProvider());
662
		viewer.setContentProvider(new LineContentProvider());
663
		viewer.setInput(new ArrayList<Property>());
664

  
665
		viewer.getTable().addMouseListener(new MouseAdapter() {
666
			@Override
667
			public void mouseDoubleClick(MouseEvent e) {
668
				Point mouseposition = new Point(e.x
669
						+ viewer.getTable().getHorizontalBar().getSelection(),
670
						e.y);
671
				int col = getPointedColumn(mouseposition);
672
				if (col == 1) {
673
					// IndexToConcordance.link(self,
674
					// (IStructuredSelection) viewer
675
					// .getSelection());
676
					System.out.println(Messages.QueryIndexEditor_7);
677
				} else if (col == 2) {
678
					System.out.println(Messages.QueryIndexEditor_8);
679
				}
680
			}
681
		});
682

  
683
		viewer.getTable().addKeyListener(new KeyListener() {
684
			@Override
685
			public void keyReleased(KeyEvent e) {
686
			}
687

  
688
			@Override
689
			public void keyPressed(KeyEvent e) {
690
				if (e.keyCode == SWT.DEL) {
691
					System.out.println(Messages.QueryIndexEditor_9);
692
					ISelection sel = viewer.getSelection();
693
					if (sel instanceof StructuredSelection) {
694
						List<?> lines = ((StructuredSelection) sel).toList();
695
						for (Object obj : lines) {
696
							if (obj instanceof QueryIndexLine) {
697
								QueryIndexLine line = (QueryIndexLine) obj;
698
								queryindex.removeLine(line.getName());
699
							}
700
						}
701
						fillDisplayArea(topLine, bottomLine);
702
					}
703
				}
704
			}
705
		});
706

  
707
		nColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
708
		nColumn.setText(" "); //$NON-NLS-1$
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff