Révision 501

tmp/org.txm.annotation.rcp/.project (revision 501)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.annotation.rcp</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
0 29

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/SaveAnnotations.java (revision 501)
1
package org.txm.annotation.rcp.commands;
2

  
3
import org.eclipse.core.commands.AbstractHandler;
4
import org.eclipse.core.commands.ExecutionEvent;
5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.core.runtime.IProgressMonitor;
7
import org.eclipse.core.runtime.IStatus;
8
import org.eclipse.core.runtime.Status;
9
import org.eclipse.jface.dialogs.MessageDialog;
10
import org.eclipse.jface.viewers.ISelection;
11
import org.eclipse.jface.viewers.IStructuredSelection;
12
import org.eclipse.swt.widgets.Display;
13
import org.eclipse.swt.widgets.MessageBox;
14
import org.eclipse.ui.handlers.HandlerUtil;
15
import org.txm.annotation.core.AnnotationManager;
16
import org.txm.annotation.core.KRAnnotationEngine;
17
import org.txm.rcp.Messages;
18
import org.txm.rcp.commands.CloseEditorsUsing;
19
import org.txm.rcp.commands.workspace.UpdateCorpus;
20
import org.txm.rcp.utils.JobHandler;
21
import org.txm.rcp.views.corpora.CorporaView;
22
import org.txm.searchengine.cqp.corpus.MainCorpus;
23
import org.txm.utils.logger.Log;
24

  
25
public class SaveAnnotations extends AbstractHandler {
26

  
27
	public static final String ID = SaveAnnotations.class.getCanonicalName();
28

  
29
	@Override
30
	public Object execute(ExecutionEvent event) throws ExecutionException {
31

  
32
		ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
33
		if (!(sel instanceof IStructuredSelection)) return null;
34
		IStructuredSelection selection = (IStructuredSelection) sel;
35

  
36
		Object s = selection.getFirstElement();
37
		if (!(s instanceof MainCorpus))
38
			return null;
39
		MainCorpus corpus = (MainCorpus) s;
40
		save(corpus);
41

  
42
		return corpus;
43
	}
44

  
45
	public static JobHandler save(final MainCorpus corpus) {
46
		final AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus);
47
		if (am == null) return null; // nothing to do
48
		
49
		if (!KRAnnotationEngine.needToSaveAnnotations(corpus)) {
50
			return null;
51
		}
52

  
53
		//System.out.println("DISPLAY="+Display.getDefault());
54
		Display.getDefault().syncExec(new Runnable() {
55
			@Override
56
			public void run() {
57
				if (!MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Before saving annotations...", "All editors using this corpus are going to be closed. Continue ?")) {
58
					return;
59
				}
60
			}
61
		});
62

  
63
		JobHandler jobhandler = new JobHandler("Saving annotations of "+corpus) { //$NON-NLS-1$
64
			@Override
65
			protected IStatus run(IProgressMonitor monitor) {
66
				this.runInit(monitor);
67
				try {
68
					monitor.beginTask("Saving annotations", 100);
69

  
70
					monitor.setTaskName("writing annotations in XML-TXM files");
71
					boolean rez = am.saveAnnotations();
72
					monitor.worked(30);
73

  
74
					if (rez) {
75
						System.out.println("Annotations are saved in XML-TXM files. Updating corpus indexes and editions");
76

  
77
						monitor.setTaskName("updating corpus indexes and editions");
78
						if (UpdateCorpus.update(corpus) != null) {
79
							monitor.worked(50);
80
							this.syncExec(new Runnable() {
81
								public void run() {CorporaView.refreshObject(corpus);}
82
							});
83
						} else {
84
							monitor.worked(50);
85
							System.out.println("Fail to update corpus. Aborting");
86
							System.out.println("Fix XML-TXM files and call command 'UpdateCorpus'");
87
						}
88
					} else {
89
						System.out.println("Error while saving annotations (see logs above).");
90
					}
91

  
92
				} catch(Exception e) {
93
					System.out.println("Error while saving annotations: "+e);
94
					Log.printStackTrace(e);
95
					return Status.CANCEL_STATUS;
96
				}
97
				return Status.OK_STATUS;
98
			}
99
		};
100

  
101
		jobhandler.startJob(true);
102

  
103
		return jobhandler;
104
	}
105
}
0 106

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/RecodeCorpus.java (revision 501)
1
package org.txm.annotation.rcp.commands;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.util.HashMap;
6
import java.util.LinkedHashMap;
7
import java.util.logging.Level;
8
import java.util.regex.Pattern;
9

  
10
import javax.xml.stream.XMLStreamException;
11

  
12
import org.eclipse.core.commands.AbstractHandler;
13
import org.eclipse.core.commands.ExecutionEvent;
14
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Status;
18
import org.eclipse.jface.viewers.ISelection;
19
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.swt.widgets.Display;
21
import org.eclipse.ui.handlers.HandlerUtil;
22
import org.kohsuke.args4j.Option;
23
import org.txm.Toolbox;
24
import org.txm.annotation.core.conversion.CorpusRuledConvertion;
25
import org.txm.core.preferences.TBXPreferences;
26
import org.txm.importer.ImportKeys;
27
import org.txm.objects.BaseParameters;
28
import org.txm.rcp.commands.CloseEditorsUsing;
29
import org.txm.rcp.commands.ExecuteImportScript;
30
import org.txm.rcp.swt.widget.parameters.ParametersDialog;
31
import org.txm.rcp.utils.JobHandler;
32
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
33
import org.txm.searchengine.cqp.corpus.MainCorpus;
34
import org.txm.searchengine.cqp.corpus.Property;
35
import org.txm.utils.logger.Log;
36

  
37
public class RecodeCorpus extends AbstractHandler {
38

  
39
	public static final String ID = RecodeCorpus.class.getCanonicalName();
40

  
41
	@Option(name="conversionFile", usage="conversionFile", widget="File", required=true, def="conv.tsv")
42
	protected File conversionFile;
43
	@Option(name="oldType", usage="oldType", widget="String", required=true, def="pos")
44
	protected String oldType;
45
	@Option(name="newType", usage="newType", widget="String", required=true, def="pos2")
46
	protected String newType;
47
	@Option(name="gestionInconnus", usage="oldType", widget="String", required=true, def="abandon")
48
	protected String gestionInconnus;
49

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

  
53
		ISelection isel = HandlerUtil.getCurrentSelection(event);
54
		if (isel == null) return null ;
55
		if (!(isel instanceof IStructuredSelection)) return null ;
56
		IStructuredSelection selection = (IStructuredSelection) isel;
57
		Object s = selection.getFirstElement();
58
		if (!(s instanceof MainCorpus)) return null;
59

  
60
		final MainCorpus corpus = (MainCorpus) s;
61

  
62
		try {
63
			if (ParametersDialog.open(this)) {
64

  
65
				JobHandler job = new JobHandler("Recode corpus "+corpus) {
66
					@Override
67
					protected IStatus run(IProgressMonitor monitor) {
68
						try {
69
							recode(corpus, conversionFile, oldType, newType, monitor);
70
						} catch (Exception e) {
71
							System.out.println("Fail to convert properties of corpus "+corpus);
72
							e.printStackTrace();
73
							return Status.CANCEL_STATUS;
74
						}
75
						return Status.OK_STATUS;
76
					}
77
				};
78
				job.startJob();
79
				return corpus;
80
			}
81
		} catch (Exception e) {
82
			e.printStackTrace();
83
		}
84

  
85
		return corpus;
86
	}
87

  
88
	public static JobHandler recode(final MainCorpus corpus, CorpusRuledConvertion crc, String oldType, String newType, IProgressMonitor monitor) throws IOException, CqiClientException, XMLStreamException {
89

  
90
		Property p1 = corpus.getProperty(oldType);
91
		if (p1 == null) {
92
			System.out.println("Corpus "+corpus+" has not property "+oldType);
93
			return null;
94
		}
95

  
96
		System.out.println("Recoding "+corpus+" property "+oldType+" in "+newType);
97

  
98
		monitor.beginTask("Recoding corpus properties...", 2);
99
		monitor.setTaskName("Recoding XML-TXM files");
100
		// apply conversion file
101
		if (!crc.process(corpus)) {
102
			System.out.println("Failed to edit XML-TXM of the corpus: "+corpus);
103
			return null;
104
		}
105
		monitor.worked(1);
106
		
107
		// update corpus indexes and edition
108
		String txmhome = Toolbox.getParam(TBXPreferences.USER_TXM_HOME);
109

  
110
		BaseParameters params = corpus.getBase().getBaseParameters();
111
		params.getKeyValueParameters().put(ImportKeys.MULTITHREAD, "false"); //too soon
112
		params.getKeyValueParameters().put(ImportKeys.DEBUG, Log.getLevel().intValue() < Level.WARNING.intValue()); // need debug for experimental stuff
113
		params.getKeyValueParameters().put(ImportKeys.UPDATECORPUS, "true");
114

  
115
		monitor.setTaskName("Updating corpus");
116
		File scriptDir = new File(txmhome, "scripts/import");
117
		File script = new File(scriptDir, "xtzLoader.groovy");
118
		System.out.println("Updating corpus "+corpus+" using "+params.paramFile);
119
		JobHandler ret = ExecuteImportScript.executeScript(script.getAbsolutePath(), params);
120
		Display.getDefault().syncExec(new Runnable() {
121
			@Override
122
			public void run() {CloseEditorsUsing.corpus(corpus);}
123
		});
124
		monitor.worked(1);
125
		return ret;
126
	}
127

  
128
	public static JobHandler recode(final MainCorpus corpus, LinkedHashMap<Pattern, String> rules, String oldType, String newType, IProgressMonitor monitor) throws IOException, CqiClientException, XMLStreamException {
129

  
130
		// apply conversion file
131
		CorpusRuledConvertion crc = new CorpusRuledConvertion(rules, newType, oldType);
132
		return recode(corpus, crc, oldType, newType , monitor);
133
	}
134

  
135
	public static JobHandler recode(final MainCorpus corpus, File conversionFile, String oldType, String newType, IProgressMonitor monitor) throws IOException, CqiClientException, XMLStreamException {
136
		System.out.println("Create CorpusRuledConvertion with "+conversionFile);
137
		// apply conversion file
138
		CorpusRuledConvertion crc = new CorpusRuledConvertion(conversionFile, oldType, newType);
139

  
140
		return recode(corpus, crc, oldType, newType, monitor);
141
	}
142
}
0 143

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/InitializeKnowledgeRepository.java (revision 501)
1
package org.txm.annotation.rcp.commands;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import org.eclipse.core.commands.AbstractHandler;
7
import org.eclipse.core.commands.ExecutionEvent;
8
import org.eclipse.core.commands.ExecutionException;
9
import org.eclipse.jface.viewers.ISelection;
10
import org.eclipse.jface.viewers.IStructuredSelection;
11
import org.eclipse.swt.widgets.Display;
12
import org.eclipse.ui.handlers.HandlerUtil;
13
import org.txm.annotation.core.KRAnnotationEngine;
14
import org.txm.annotation.core.repository.KnowledgeRepository;
15
import org.txm.annotation.core.repository.KnowledgeRepositoryManager;
16
import org.txm.rcp.swt.dialog.UsernamePasswordDialog;
17
import org.txm.searchengine.cqp.corpus.MainCorpus;
18

  
19
public class InitializeKnowledgeRepository extends AbstractHandler {
20

  
21
	public static final String ID = InitializeKnowledgeRepository.class.getCanonicalName();
22
	
23
	@Override
24
	public Object execute(ExecutionEvent event) throws ExecutionException {
25
		
26
		ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
27
		if (!(sel instanceof IStructuredSelection)) return null;
28
		IStructuredSelection selection = (IStructuredSelection) sel;
29

  
30
		Object s = selection.getFirstElement();
31
		if (!(s instanceof MainCorpus))
32
			return null;
33
		
34
		MainCorpus corpus = (MainCorpus) s;
35
		return get(corpus);
36
	}
37
	
38
	/**
39
	 * Use this method to set eventual login+password needed by SQL knowledge repositories
40
	 * 
41
	 * @param corpus
42
	 * @return
43
	 */
44
	public static List<KnowledgeRepository> get(MainCorpus corpus) {
45
		List<KnowledgeRepository> ret = new ArrayList<KnowledgeRepository>();
46
		
47
		for (String kr_name : KRAnnotationEngine.getKnowledgeRepositoryNames(corpus)) {
48
			KnowledgeRepository kr = KRAnnotationEngine.getKnowledgeRepository(corpus, kr_name);
49
			if (kr == null) {
50
				System.out.println("Warning '"+kr_name+"' KR is null. Please check KR configuration.");
51
				continue;
52
			}
53
			//System.out.println("IS CREDENTIAL NEEDED: "+kr_name+" "+corpus);
54
			boolean[] must = KnowledgeRepositoryManager.mustLoginToKnowledgeRepository(kr_name, corpus);
55
			
56
			if (must[0] || must[1]) {
57
				System.out.println("Asking credentials for "+kr_name+" KR login");
58
				UsernamePasswordDialog dialog = new UsernamePasswordDialog(Display.getCurrent().getActiveShell(), must, kr_name);
59
				
60
				if (dialog.open() == UsernamePasswordDialog.OK) {
61
					System.out.println("Temporary save login+password");
62
					System.setProperty(KnowledgeRepository.LOGIN_KEY+kr_name, dialog.getUser());
63
					System.setProperty(KnowledgeRepository.PASSWORD_KEY+kr_name, dialog.getPassword());
64
				} else {
65
					System.out.println("Cancelling login for "+kr_name+" KR");
66
					continue; // ignoring
67
				}
68
			}
69
			
70
			if (!kr.checkConnection()) {
71
				System.out.println("Error during connection to '"+kr_name+"'. Please check login, password and Internet connection.");
72
			} else {
73
				ret.add(kr);
74
			}
75
		}
76
		return ret;
77
	}
78
}
0 79

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/ExportStandoff.java (revision 501)
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.annotation.rcp.commands;
29

  
30
import java.io.File;
31

  
32
import org.eclipse.core.commands.AbstractHandler;
33
import org.eclipse.core.commands.ExecutionEvent;
34
import org.eclipse.core.commands.ExecutionException;
35
import org.eclipse.core.runtime.IProgressMonitor;
36
import org.eclipse.core.runtime.IStatus;
37
import org.eclipse.core.runtime.Status;
38
import org.eclipse.jface.viewers.ISelection;
39
import org.eclipse.jface.viewers.IStructuredSelection;
40
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.widgets.FileDialog;
42
import org.eclipse.swt.widgets.Shell;
43
import org.eclipse.ui.handlers.HandlerUtil;
44
import org.txm.Toolbox;
45
import org.txm.annotation.core.AnnotationManager;
46
import org.txm.annotation.core.KRAnnotationEngine;
47
import org.txm.core.preferences.TBXPreferences;
48
import org.txm.rcp.Messages;
49
import org.txm.rcp.StatusLine;
50
import org.txm.rcp.swt.dialog.LastOpened;
51
import org.txm.rcp.utils.JobHandler;
52
import org.txm.searchengine.cqp.corpus.MainCorpus;
53
import org.txm.utils.logger.Log;
54

  
55
// TODO: Auto-generated Javadoc
56
/**
57
 * Open a file in the TxtEditor @ author mdecorde.
58
 */
59
public class ExportStandoff extends AbstractHandler {
60

  
61
	public static final String ID = ExportStandoff.class.getCanonicalName();
62
	
63
	
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
66
	 */
67
	@Override
68
	public Object execute(ExecutionEvent event) throws ExecutionException {
69

  
70
		ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
71
		if (!(sel instanceof IStructuredSelection)) return null;
72
		IStructuredSelection selection = (IStructuredSelection) sel;
73

  
74
		Object s = selection.getFirstElement();
75
		if (!(s instanceof MainCorpus)) {
76
			System.out.println("Selection is not a Corpus. Aborting.");
77
			return null;
78
		}
79

  
80
		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
81
		//FileDialog dialog = new FileDialog(shell, SWT.SAVE);
82
		FileDialog dialog = new FileDialog(shell, SWT.SAVE);
83
		MainCorpus corpus = (MainCorpus) s;
84
		String path = Toolbox.getParam(TBXPreferences.USER_TXM_HOME);
85
		dialog.setFilterPath(path); //To set a specific path
86
		dialog.setFileName(corpus.getName()+"_annotations.zip");
87
		dialog.setFilterExtensions(new String[]{"*.zip"});
88
		if (dialog.open() != null) {
89
			StatusLine.setMessage(Messages.ExportAnnotation_0);
90
			String filepath = dialog.getFilterPath();
91
			String filename = dialog.getFileName();
92

  
93
			final File resultZipFile = new File(filepath, filename);
94
			LastOpened.set(ID, resultZipFile.getParent(), resultZipFile.getName());
95
			
96
			exportAnnotations(corpus, resultZipFile);
97
		}
98
		return corpus;
99
	}
100

  
101
	public static boolean exportAnnotations(final MainCorpus corpus, final File resultZipFile) {
102
		final AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus);
103
		if (am == null) return true; // nothing to do
104
		
105
		JobHandler saveJob = SaveAnnotations.save(corpus);
106
		if (saveJob != null)
107
			try {
108
				saveJob.join();
109
			} catch (InterruptedException e1) {
110
				// TODO Auto-generated catch block
111
				e1.printStackTrace();
112
			}
113
		
114
		JobHandler jobhandler = new JobHandler("Exporting annotations as standoff for "+corpus) { //$NON-NLS-1$
115
			@Override
116
			protected IStatus run(IProgressMonitor monitor) {
117
				this.runInit(monitor);
118
				try {
119
					monitor.beginTask("Exporting annotations as standoff", 100);
120
					
121
					monitor.setTaskName("Writing annotations in XML-TXM stand-off files");
122
					/*if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Before saving annotations...", "All editors using this corpus are going to be closed. Continue ?")) {
123
						return false;
124
					}*/
125
					
126
					///lecture de tous les fichiers un par un
127
					///chaque annotation est récupérée et selon l'annotateur, écrite dans un fichier spécifique à celui-ci
128

  
129
					if (!am.exportAnnotationsToSyMoGIH(resultZipFile)) {
130
						System.out.println("Error while saving stand-off annotations (see logs above).");
131
						return Status.CANCEL_STATUS;
132
					}
133
					monitor.worked(30);
134
					
135
					System.out.println("Done.");
136

  
137
				} catch(Exception e) {
138
					System.out.println("Error while saving annotations: "+e);
139
					Log.printStackTrace(e);
140
					return Status.CANCEL_STATUS;
141
				}
142
				return Status.OK_STATUS;
143
			}
144
		};
145

  
146
		jobhandler.startJob(true);
147
		return true;
148
	}
149
}
0 150

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/krview/Reload.java (revision 501)
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.annotation.rcp.commands.krview;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.ui.handlers.HandlerUtil;
35
import org.txm.annotation.core.repository.KnowledgeRepository;
36
import org.txm.annotation.rcp.views.knowledgerepositories.KRView;
37

  
38
/**
39
 * Reloads a KnowledgeRepository
40
 */
41
public class Reload extends AbstractHandler {
42

  
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
45
	 */
46
	@Override
47
	public Object execute(ExecutionEvent event) throws ExecutionException {
48
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
49
//		System.out.println("Reload: "+selection);
50
		reload(selection);
51

  
52
		return null;
53
	}
54

  
55
	/**
56
	 * Copy.
57
	 *
58
	 * @param selection the selection
59
	 */
60
	public static void reload(IStructuredSelection selection)
61
	{
62
		Object selectedItem = selection.getFirstElement();
63
		if (selectedItem instanceof KnowledgeRepository) {
64
			((KnowledgeRepository)selectedItem).reload();
65
			KRView.refresh();
66
		}
67
	}
68
}
0 69

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/krview/Add.java (revision 501)
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.annotation.rcp.commands.krview;
29

  
30
import java.io.File;
31

  
32
import org.eclipse.core.commands.AbstractHandler;
33
import org.eclipse.core.commands.ExecutionEvent;
34
import org.eclipse.core.commands.ExecutionException;
35
import org.eclipse.jface.dialogs.InputDialog;
36
import org.eclipse.jface.viewers.IStructuredSelection;
37
import org.eclipse.swt.widgets.Display;
38
import org.eclipse.swt.widgets.Shell;
39
import org.eclipse.ui.handlers.HandlerUtil;
40
import org.txm.annotation.core.repository.AnnotationType;
41
import org.txm.annotation.core.repository.KnowledgeRepository;
42
import org.txm.annotation.core.repository.KnowledgeRepositoryManager;
43
import org.txm.annotation.core.repository.LocalKnowledgeRepository;
44
import org.txm.annotation.core.repository.SQLKnowledgeRepository;
45
import org.txm.annotation.core.repository.TypedValue;
46
import org.txm.annotation.rcp.views.knowledgerepositories.KRView;
47
import org.txm.utils.AsciiUtils;
48

  
49
// TODO: Auto-generated Javadoc
50
/**
51
 * Copy KnowledgeRepository or AnnotationType toString() in clipboard
52
 */
53
public class Add extends AbstractHandler {
54

  
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
57
	 */
58
	@Override
59
	public Object execute(ExecutionEvent event) throws ExecutionException {
60
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
61
//		System.out.println("Add: "+selection);
62
		add(selection);
63

  
64
		return null;
65
	}
66

  
67
	/**
68
	 * Copy.
69
	 *
70
	 * @param selection the selection
71
	 */
72
	public static void add(IStructuredSelection selection)
73
	{
74
		Object selectedItem = selection.getFirstElement();
75
		if (selectedItem instanceof SQLKnowledgeRepository) {
76

  
77
		} else if (selectedItem instanceof LocalKnowledgeRepository) {
78
			LocalKnowledgeRepository kr = ((LocalKnowledgeRepository)selectedItem);
79
			Shell shell = Display.getDefault().getActiveShell();
80
			InputDialog dialog = new InputDialog(shell, "Type name", "Please enter the new type name", "", null);
81
			if (dialog.open() == InputDialog.OK) {
82
				String name = dialog.getValue();
83
				String id = AsciiUtils.buildId(name);
84
				
85
				//Generate an URL page 
86
				//String pathFile = KnowledgeRepositoryManager.generateLocalURLPage(kr.getName(), name, id);
87
				String pathFile = null; //@TODO build page for type or KR will be done in another version (after 0.7.8)
88
				//System.out.println("URL for new type : "+pathFile);
89
				AnnotationType at = kr.addType(name, id, pathFile);
90
				KRView.refresh();
91
				//kr.add(at);
92
			} else {
93
				System.out.println("Creation aborted.");
94
			}
95
		} else if (selectedItem instanceof AnnotationType) {
96
			AnnotationType t = ((AnnotationType)selectedItem);
97

  
98
			String krname = t.getKnowledgeRepository();
99
			
100
			KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(krname);
101
			if (kr instanceof LocalKnowledgeRepository) {
102
				LocalKnowledgeRepository lkr = ((LocalKnowledgeRepository)kr);
103
				System.out.println("Add a value...");
104
				Shell shell = Display.getDefault().getActiveShell();
105
				InputDialog dialog = new InputDialog(shell, "Value name", "Please enter the new value name", "", null);
106
				if (dialog.open() == InputDialog.OK) {
107
					String name = dialog.getValue();
108
					String id = name;
109
					/*String baseid = AsciiUtils.buildId(name);
110
					String id = AsciiUtils.buildId(name);
111
					int c = 1;
112
					while (kr.getValue(t, id) != null) {
113
						id = baseid+"_"+(c++);
114
					}*/
115
					TypedValue val = lkr.addValue(name, id, t.getId());
116
					//t.addTypedValue(val);
117
					KnowledgeRepositoryManager.generateLocalURLPage(lkr.getName(), t.getName(), t.getId());
118
					KRView.refresh();
119
				}
120
			}
121
		} else if (selectedItem instanceof TypedValue) {
122
		
123

  
124
		}
125
	}
126
}
0 127

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/krview/Informations.java (revision 501)
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.annotation.rcp.commands.krview;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.ui.handlers.HandlerUtil;
35
import org.txm.annotation.core.repository.AnnotationType;
36
import org.txm.annotation.core.repository.LocalKnowledgeRepository;
37
import org.txm.annotation.core.repository.SQLKnowledgeRepository;
38
import org.txm.annotation.core.repository.TypedValue;
39
import org.txm.rcp.commands.OpenLocalizedWebPage;
40

  
41
/**
42
 * Shows a web page displaying informations about the current selection
43
 */
44
public class Informations extends AbstractHandler {
45

  
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
48
	 */
49
	@Override
50
	public Object execute(ExecutionEvent event) throws ExecutionException {
51
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
52
//		System.out.println("Informations: "+selection);
53
		show(selection);
54

  
55
		return null;
56
	}
57

  
58
	/**
59
	 * Copy.
60
	 *
61
	 * @param selection the selection
62
	 */
63
	public static void show(IStructuredSelection selection)
64
	{
65
		Object selectedItem = selection.getFirstElement();
66
		
67
		String url = "";
68
		if (selectedItem instanceof SQLKnowledgeRepository) {
69
			url = ((SQLKnowledgeRepository)selectedItem).getURL();
70
		} else if (selectedItem instanceof LocalKnowledgeRepository) {
71
			LocalKnowledgeRepository kr = ((LocalKnowledgeRepository)selectedItem);
72
			url = ((LocalKnowledgeRepository)selectedItem).getURL();
73
		} else if (selectedItem instanceof AnnotationType) {
74
			url = ((AnnotationType)selectedItem).getURL();
75
		} else if (selectedItem instanceof TypedValue) {
76
			url = ""; // TODO: see how to retrieve its KR
77
		}
78
		
79
		if (url != null && url.length() > 0) {
80
			OpenLocalizedWebPage.openfile(url);
81
		} else {
82
			System.out.println(selectedItem);
83
		}
84
	}
85
}
0 86

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/krview/OpenKRView.java (revision 501)
1
package org.txm.annotation.rcp.commands.krview;
2

  
3
import org.eclipse.core.commands.AbstractHandler;
4
import org.eclipse.core.commands.ExecutionEvent;
5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.ui.IWorkbenchPage;
7
import org.eclipse.ui.IWorkbenchWindow;
8
import org.eclipse.ui.PartInitException;
9
import org.eclipse.ui.handlers.HandlerUtil;
10
import org.txm.annotation.core.repository.AnnotationType;
11
import org.txm.annotation.rcp.views.knowledgerepositories.KRView;
12

  
13
// extends org.eclipse.ui.views.showView
14
public class OpenKRView extends AbstractHandler {
15
	public static final String ID = OpenKRView.class.getCanonicalName(); // org.txm.rcp.commands.krview.OpenKRView
16

  
17
	@Override
18
	public final Object execute(final ExecutionEvent event)
19
			throws ExecutionException {
20
		System.out.println("hello");
21
		IWorkbenchWindow window = HandlerUtil
22
				.getActiveWorkbenchWindowChecked(event);
23

  
24
		try {
25
			openView(window);
26
		} catch (PartInitException e) {
27
			throw new ExecutionException("Part could not be initialized", e); //$NON-NLS-1$
28
		}
29

  
30
		return null;
31
	}
32

  
33
	/**
34
	 * Opens the view with the given identifier.
35
	 * 
36
	 * @param viewId
37
	 *            The view to open; must not be <code>null</code>
38
	 * @throws PartInitException
39
	 *             If the part could not be initialized.
40
	 */
41
	public static void openView(final IWorkbenchWindow activeWorkbenchWindow, AnnotationType type)
42
					throws PartInitException {
43

  
44
		final IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
45
		if (activePage == null) {
46
			return;
47
		}
48

  
49
		activePage.showView(KRView.ID);
50
		
51
		if (type != null) {
52
			KRView.showType(type);
53
		}
54
	}
55
	
56
	/**
57
	 * Opens the view with the given identifier.
58
	 * 
59
	 * @param viewId
60
	 *            The view to open; must not be <code>null</code>
61
	 * @throws PartInitException
62
	 *             If the part could not be initialized.
63
	 */
64
	public static void openView(final IWorkbenchWindow activeWorkbenchWindow)
65
					throws PartInitException {
66
		openView(activeWorkbenchWindow, null);
67
	}
68
}
0 69

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/krview/Copy.java (revision 501)
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.annotation.rcp.commands.krview;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.ui.handlers.HandlerUtil;
35
import org.txm.annotation.core.repository.AnnotationType;
36
import org.txm.annotation.core.repository.SQLKnowledgeRepository;
37
import org.txm.annotation.core.repository.TypedValue;
38
import org.txm.rcp.utils.IOClipboard;
39

  
40
// TODO: Auto-generated Javadoc
41
/**
42
 * Copy KnowledgeRepository or AnnotationType toString() in clipboard
43
 */
44
public class Copy extends AbstractHandler {
45

  
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
48
	 */
49
	@Override
50
	public Object execute(ExecutionEvent event) throws ExecutionException {
51
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
52
//		System.out.println("Copy: "+selection);
53
		copy(selection);
54

  
55
		return null;
56
	}
57

  
58
	/**
59
	 * Copy.
60
	 *
61
	 * @param selection the selection
62
	 */
63
	public static void copy(IStructuredSelection selection)
64
	{
65
		Object selectedItem = selection.getFirstElement();
66
		
67
		String text = null;
68
		if (selectedItem instanceof SQLKnowledgeRepository) {
69
			text = ((SQLKnowledgeRepository)selectedItem).toHumanString();
70
		} else if (selectedItem instanceof AnnotationType) {
71
			text = ((AnnotationType)selectedItem).toHumanString();
72
		} else if (selectedItem instanceof TypedValue) {
73
			text = ((TypedValue)selectedItem).toHumanString();
74
		}
75
		if (text != null) {
76
			IOClipboard.write(text);
77
		}
78
	}
79
}
0 80

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/krview/Delete.java (revision 501)
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.annotation.rcp.commands.krview;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.jface.viewers.TreeViewer;
35
import org.eclipse.swt.widgets.TreeItem;
36
import org.eclipse.ui.handlers.HandlerUtil;
37
import org.txm.annotation.core.repository.AnnotationType;
38
import org.txm.annotation.core.repository.KnowledgeRepository;
39
import org.txm.annotation.core.repository.KnowledgeRepositoryManager;
40
import org.txm.annotation.core.repository.LocalKnowledgeRepository;
41
import org.txm.annotation.core.repository.SQLKnowledgeRepository;
42
import org.txm.annotation.core.repository.TypedValue;
43
import org.txm.annotation.rcp.views.knowledgerepositories.KRView;
44

  
45
// TODO: Auto-generated Javadoc
46
/**
47
 * Copy KnowledgeRepository or AnnotationType toString() in clipboard
48
 */
49
public class Delete extends AbstractHandler {
50

  
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
53
	 */
54
	@Override
55
	public Object execute(ExecutionEvent event) throws ExecutionException {
56
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
57
//		System.out.println("Delete: "+selection);
58
		delete(selection);
59

  
60
		return null;
61
	}
62

  
63
	/**
64
	 * Copy.
65
	 *
66
	 * @param selection the selection
67
	 */
68
	public static void delete(IStructuredSelection selection)
69
	{
70
		Object selectedItem = selection.getFirstElement();
71

  
72
		if (selectedItem instanceof SQLKnowledgeRepository) {
73

  
74
		} else if (selectedItem instanceof LocalKnowledgeRepository) {
75
			LocalKnowledgeRepository kr = ((LocalKnowledgeRepository)selectedItem);
76
			System.out.println("Delete a LocalKnowledgeRepository...");
77
			
78
			//TODO: confirm message dialog to generate
79
			//KnowledgeRepositoryManager.deleteKnowledgeRepository(kr);
80
			//KRView.refresh();
81
			
82
		} else if (selectedItem instanceof AnnotationType) {
83
			final AnnotationType t = ((AnnotationType)selectedItem);
84
			KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(t.getKnowledgeRepository());
85
			
86
			if (kr instanceof LocalKnowledgeRepository) {
87
				final LocalKnowledgeRepository lkr = ((LocalKnowledgeRepository)kr);
88
				System.out.println("Delete an AnnotationType...");
89
				
90
				/*JobHandler job = new JobHandler("Deleting all annotations for type : "+t) {
91
					@Override
92
					protected IStatus run(IProgressMonitor monitor) {
93
						this.setCurrentMonitor(monitor);
94
						try {*/
95
							lkr.deleteType(t);
96
							//TODO: For each corpus, get AnnotationManager and deleteAnnotations
97
							//annotManager.deleteAnnotations(t, job);
98
						/*} catch(Exception e) {
99
							Log.severe("Error while deleting annotations "+e);
100
							Log.printStackTrace(e);
101
							return Status.CANCEL_STATUS;
102
						}
103
						return Status.OK_STATUS;
104
					}
105
				};
106
				job.schedule();*/
107
				
108
				
109
				//TODO: must delete corpus possible annotations
110
				KRView.refresh();
111
			}
112
		} else if (selectedItem instanceof TypedValue) {
113
			TypedValue v = (TypedValue) selectedItem;
114
			TreeViewer tree = KRView.getTree();
115
			
116
			if (tree != null) {
117
				TreeItem[] selItems = tree.getTree().getSelection();
118
				if (selItems.length == 0) return;
119
				TreeItem first = selItems[0];
120
				Object o = first.getData();
121
				if (o instanceof TypedValue) {
122
					TypedValue selectedTypedValue = (TypedValue)o;
123
					if (selectedTypedValue.getId().equals(v.getId())) {
124
						TreeItem parentTreeItem = first.getParentItem();
125
						Object o2 = parentTreeItem.getData();
126
						if (o2 instanceof AnnotationType) {
127
							AnnotationType t = (AnnotationType)o2;
128
							KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(t.getKnowledgeRepository());
129
							kr.deleteValue(v);
130
							tree.refresh();
131
						}
132
					}
133
				}
134
			}
135
		}
136
	}
137
}
0 138

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/preferences/AnnotationPreferencePage.java (revision 501)
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.annotation.rcp.preferences;
29

  
30
import org.eclipse.jface.preference.RadioGroupFieldEditor;
31
import org.eclipse.ui.IWorkbench;
32
import org.txm.annotation.core.preferences.AnnotationPreferences;
33
import org.txm.rcp.IImageKeys;
34
import org.txm.rcp.Messages;
35
import org.txm.rcp.preferences.RCPPreferences;
36
import org.txm.rcp.preferences.RCPPreferencesPage;
37
import org.txm.rcp.preferences.TXMPreferencePage;
38
import org.txm.rcp.preferences.TXMPreferenceStore;
39
/**
40
 * This class represents a preference page that is contributed to the
41
 * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we
42
 * can use the field support built into JFace that allows us to create a page
43
 * that is small and knows how to save, restore and apply itself.
44
 * <p>
45
 * This page is used to modif y preferences only. They are stored in the
46
 * preference store that belongs to the main plug-in class. That way,
47
 * preferences can be accessed directly via the preference store.
48
 */
49

  
50
public class AnnotationPreferencePage extends TXMPreferencePage {
51

  
52
	//private BooleanFieldEditor mode_expert;
53
	private RadioGroupFieldEditor mode_annotation;
54

  
55
	/**
56
	 * Instantiates a new cAH preference page.
57
	 */
58
	public AnnotationPreferencePage() {
59
		super();
60
	}
61

  
62
	/**
63
	 * Creates the field editors. Field editors are abstractions of the common
64
	 * GUI blocks needed to manipulate various types of preferences. Each field
65
	 * editor knows how to save and restore itself.
66
	 */
67
	@Override
68
	public void createFieldEditors() {
69

  
70
		/*BooleanFieldEditor mode_expert = new BooleanFieldEditor(MODE,
71
				Messages.AnnotationPreferences_0, getFieldEditorParent());	
72
		addField(mode_expert);*/
73
		
74
		String[][] labelAndValues = {
75
				{Messages.AnnotationPreferences_1, "simple"},
76
				{Messages.AnnotationPreferences_2, "advanced"}}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
77
		
78
		mode_annotation = new RadioGroupFieldEditor(AnnotationPreferences.ANNOTATION_MODE, Messages.AnnotationPreferences_0, 2, labelAndValues, getFieldEditorParent());
79
		addField(mode_annotation);
80
		//mode_annotation.setPreferenceStore(store);
81
	}
82
	
83
	
84
	/*
85
	 * (non-Javadoc)
86
	 * 
87
	 * @see
88
	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
89
	 */
90
	@Override
91
	public void init(IWorkbench workbench) {
92
		this.setPreferenceStore(new TXMPreferenceStore(AnnotationPreferences.PREFERENCES_NODE));
93
		//this.setTitle("WordCloud");
94
		this.setImageDescriptor(IImageKeys.getImageDescriptor(IImageKeys.PENCIL));
95
	}
96
}
0 97

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editors/imports/sections/AnnotationSection.java (revision 501)
1
package org.txm.annotation.rcp.editors.imports.sections;
2

  
3
import java.util.List;
4

  
5
import org.eclipse.swt.SWT;
6
import org.eclipse.swt.widgets.Composite;
7
import org.eclipse.swt.widgets.Label;
8
import org.eclipse.swt.widgets.Text;
9
import org.eclipse.ui.forms.events.ExpansionAdapter;
10
import org.eclipse.ui.forms.events.ExpansionEvent;
11
import org.eclipse.ui.forms.widgets.FormToolkit;
12
import org.eclipse.ui.forms.widgets.ScrolledForm;
13
import org.eclipse.ui.forms.widgets.TableWrapData;
14
import org.eclipse.ui.forms.widgets.TableWrapLayout;
15
import org.txm.annotation.core.KRAnnotationEngine;
16
import org.txm.objects.BaseParameters;
17
import org.txm.rcp.editors.imports.sections.ImportEditorSection;
18

  
19
public class AnnotationSection extends ImportEditorSection {
20
	
21
	private static final int SECTION_SIZE = 1;
22
	public static final String DEFAULTNAMESUFFIX = "KR";
23
	
24
	Text nameText;
25
	
26
	public AnnotationSection(FormToolkit toolkit2, ScrolledForm form2, Composite parent, int style) {
27
		super(toolkit2, form2, parent, style);
28

  
29
		this.section.setText("Annotation");
30
		TableWrapLayout layout = new TableWrapLayout();
31
		layout.makeColumnsEqualWidth = true;
32
		this.section.setLayout(layout);
33
		this.section.setLayoutData(getSectionGridData(SECTION_SIZE));
34
		this.section.setEnabled(false);
35

  
36
		this.section.addExpansionListener(new ExpansionAdapter() {
37
			@Override
38
			public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
39
		});
40

  
41
		//filesection.setDescription("Select how to find source files");
42
		Composite sectionClient = toolkit.createComposite(this.section);
43
		TableWrapLayout slayout = new TableWrapLayout();
44
		slayout.makeColumnsEqualWidth = false;
45
		slayout.numColumns = 2;
46
		sectionClient.setLayout(slayout);
47
		this.section.setClient(sectionClient);
48

  
49
		Label l = toolkit.createLabel(sectionClient, "Knowledge repository name", SWT.WRAP);
50
		l.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
51

  
52
		nameText = new Text(sectionClient, SWT.BORDER);
53
	}
54

  
55
	@Override
56
	public void update(BaseParameters params) {
57
		if (this.section.isDisposed()) return;
58
		if (params == null) return;
59
		List<String> values = KRAnnotationEngine.getKnowledgeRepositoryNames(params);
60
		
61
		String value = params.getCorpusName()+DEFAULTNAMESUFFIX;
62
		if (values.size() > 0) {
63
			value = values.get(0);
64
		}
65
		nameText.setText(value);
66
	}
67

  
68
	@Override
69
	public boolean save(BaseParameters params) {
70
		if (!this.section.isDisposed()) {
71
			String value = nameText.getText();
72
						
73
			return true;
74
		}
75
		return false;
76
	}
77

  
78
	@Override
79
	public boolean checkFields() {
80
		return true;
81
	}
82

  
83
	@Override
84
	public int getSectionSize() {
85
		return SECTION_SIZE;
86
	}
87
}
0 88

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/views/knowledgerepositories/KRView.java (revision 501)
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.annotation.rcp.views.knowledgerepositories;
29

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

  
34

  
35

  
36

  
37

  
38

  
39

  
40

  
41

  
42

  
43
import org.eclipse.jface.action.MenuManager;
44
import org.eclipse.jface.viewers.AbstractTreeViewer;
45
import org.eclipse.jface.viewers.DoubleClickEvent;
46
import org.eclipse.jface.viewers.IDoubleClickListener;
47
import org.eclipse.jface.viewers.ITreeContentProvider;
48
import org.eclipse.jface.viewers.LabelProvider;
49
import org.eclipse.jface.viewers.StructuredSelection;
50
import org.eclipse.jface.viewers.TreeSelection;
51
import org.eclipse.jface.viewers.TreeViewer;
52
import org.eclipse.jface.viewers.TreeViewerColumn;
53
import org.eclipse.jface.viewers.Viewer;
54
import org.eclipse.osgi.util.NLS;
55
import org.eclipse.swt.SWT;
56
import org.eclipse.swt.events.KeyEvent;
57
import org.eclipse.swt.events.KeyListener;
58
import org.eclipse.swt.events.SelectionEvent;
59
import org.eclipse.swt.events.SelectionListener;
60
import org.eclipse.swt.graphics.Image;
61
import org.eclipse.swt.layout.GridData;
62
import org.eclipse.swt.layout.GridLayout;
63
import org.eclipse.swt.widgets.Button;
64
import org.eclipse.swt.widgets.Composite;
65
import org.eclipse.swt.widgets.Control;
66
import org.eclipse.swt.widgets.Menu;
67
import org.eclipse.ui.PlatformUI;
68
import org.eclipse.ui.contexts.IContextService;
69
import org.eclipse.ui.part.ViewPart;
70
import org.txm.annotation.core.repository.AnnotationType;
71
import org.txm.annotation.core.repository.KnowledgeRepository;
72
import org.txm.annotation.core.repository.KnowledgeRepositoryManager;
73
import org.txm.annotation.core.repository.LocalKnowledgeRepository;
74
import org.txm.annotation.core.repository.SQLKnowledgeRepository;
75
import org.txm.annotation.core.repository.TypedValue;
76
import org.txm.annotation.rcp.commands.InitializeKnowledgeRepository;
77
import org.txm.annotation.rcp.commands.krview.Copy;
78
import org.txm.annotation.rcp.commands.krview.Informations;
79
import org.txm.annotation.rcp.commands.krview.Reload;
80
import org.txm.rcp.IImageKeys;
81
import org.txm.rcp.Messages;
82
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
83
import org.txm.searchengine.cqp.corpus.CorpusManager;
84
import org.txm.searchengine.cqp.corpus.MainCorpus;
85
import org.txm.utils.logger.Log;
86

  
87
/**
88
 * Display the Knowledge repositories currently loaded
89
 * 
90
 * author mdecorde.
91
 */
92
public class KRView extends ViewPart {
93

  
94
	/** The empty list to filled the view at startup. */
95
	ArrayList<Object> empty = new ArrayList<Object>();
96

  
97
	/** The composites. */
98
	Control[] composites = new Control[3];
99

  
100
	/** The tv. */
101
	TreeViewer tv;
102

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

Formats disponibles : Unified diff