Revision 702

tmp/org.txm.information.rcp/src/org/txm/information/rcp/preferences/InformationPreferencePage.java (revision 702)
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.information.rcp.preferences;
29

  
30
import org.eclipse.jface.preference.IntegerFieldEditor;
31
import org.eclipse.ui.IWorkbench;
32
import org.txm.core.messages.TXMCoreMessages;
33
import org.txm.information.core.preferences.InformationPreferences;
34
import org.txm.information.rcp.messages.InformationUIMessages;
35
import org.txm.rcp.preferences.TXMPreferencePage;
36
import org.txm.rcp.preferences.TXMPreferenceStore;
37
import org.txm.searchengine.cqp.CQPPreferences;
38

  
39
/**
40
 * Information preferences page.
41
 * 
42
 * @author mdecorde
43
 * @author sjacquot
44
 *
45
 */
46
public class InformationPreferencePage extends TXMPreferencePage {
47

  
48
		
49
	@Override
50
	public void init(IWorkbench workbench) {
51
		this.setPreferenceStore(new TXMPreferenceStore(InformationPreferences.PREFERENCES_NODE));
52
		this.setTitle(TXMCoreMessages.common_description);
53
	}
54
	
55

  
56
	@Override
57
	public void createFieldEditors() {
58
		
59
		// The maximum number of word property values to display
60
		IntegerFieldEditor maxValue = new IntegerFieldEditor(InformationPreferences.MAX_VALUE, InformationUIMessages.DiagnosticPreferencePage_2, this.getFieldEditorParent());
61
		maxValue.setValidRange(1, 9999);
62
		this.addField(maxValue);
63
	}
64
}
0 65

  
tmp/org.txm.information.rcp/src/org/txm/information/rcp/adapters/InformationAdapterFactory.java (revision 702)
1
// Copyright © 2010-2013 ENS de Lyon.
2
package org.txm.information.rcp.adapters;
3

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

  
12

  
13
/**
14
 * 
15
 *  
16
 * @author mdecorde
17
 * @author sjacquot
18
 */
19
public class InformationAdapterFactory extends TXMResultAdapterFactory {
20

  
21
	public static final ImageDescriptor ICON =
22
			AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(InformationAdapterFactory.class).getSymbolicName(),
23
					"platform:/plugin/"+ FrameworkUtil.getBundle(InformationAdapterFactory.class).getSymbolicName() + "/icons/functions/information.png"); //$NON-NLS-1$ //$NON-NLS-2$
24

  
25
	@Override
26
	public Object getAdapter(Object adaptableObject, Class adapterType) {
27
		if(adapterType == IWorkbenchAdapter.class && adaptableObject instanceof Information)	{
28
			return new TXMResultAdapter() {
29
				@Override
30
				public ImageDescriptor getImageDescriptor(Object object) {
31
					if (object instanceof Information) {
32
							return ICON;
33
					}
34
					return null;
35
				}
36
			};
37
		}
38
		return null;
39
	}
40
}
0 41

  
tmp/org.txm.information.rcp/src/org/txm/information/rcp/messages/messages.properties (revision 702)
1

  
2
CQPPreferencePage_0  = CQPlib path
3
CQPPreferencePage_1  = Use network protocol
4
CQPPreferencePage_10 = &Remote CWB server address:
5
CQPPreferencePage_11 = CWB server: &host:
6
CQPPreferencePage_12 = CWB server: &port:
7
CQPPreferencePage_13 = CWB server: &login:
8
CQPPreferencePage_14 = CWB server: &password:
9
CQPPreferencePage_15 = Path to CWB server binary
10
CQPPreferencePage_17 = Path to CWB server initialization file
11
CQPPreferencePage_18 = Additional &options for the CWB server:
12

  
13
ComputeDiagnostic_0 = Selection is not structured
14

  
15
DiagnosticPreferencePage_2 = Maximum values to display
0 16

  
tmp/org.txm.information.rcp/src/org/txm/information/rcp/messages/messages_ru.properties (revision 702)
1

  
2
CQPPreferencePage_0  = 
3
CQPPreferencePage_1  = Использовать сетевой протокол
4
CQPPreferencePage_10 = Удаленный &сервер CWB
5
CQPPreferencePage_11 = Удаленный сервер: &имя машины
6
CQPPreferencePage_12 = Удаленный сервер: &номер порта
7
CQPPreferencePage_13 = Удаленный сервер: &логин
8
CQPPreferencePage_14 = Удаленный сервер: &пароль
9
CQPPreferencePage_15 = Путь к исполняемому &файлу 'cqpserver'
10
CQPPreferencePage_17 = Путь к файлу инициализации сервера CWB
11
CQPPreferencePage_18 = Дополнительные опции сервера CWB: 
12

  
13
DiagnosticPreferencePage_2 = Число отображаемых значений свойства
0 14

  
tmp/org.txm.information.rcp/src/org/txm/information/rcp/messages/messages_fr.properties (revision 702)
1

2
CQPPreferencePage_0  = Chemin vers CQPlib
3
CQPPreferencePage_1  = Utiliser le protocole réseau
4
CQPPreferencePage_10 = &Serveur CWB distant
5
CQPPreferencePage_11 = Serveur distant : nom de machine
6
CQPPreferencePage_12 = Serveur distant : numéro de &port
7
CQPPreferencePage_13 = Serveur distant : &login
8
CQPPreferencePage_14 = Serveur distant : &mot de passe
9
CQPPreferencePage_15 = Chemin vers le fichier &exécutable 'cqpserver'
10
CQPPreferencePage_17 = Chemin vers le fichier d'initialisation du serveur CWB
11
CQPPreferencePage_18 = Options additionnelles pour le serveur CWB : 
12

  
13
DiagnosticPreferencePage_2 = Nombre de valeurs de propriété affiché
0 14

  
tmp/org.txm.information.rcp/src/org/txm/information/rcp/messages/InformationUIMessages.java (revision 702)
1
package org.txm.information.rcp.messages;
2

  
3
import org.eclipse.osgi.util.NLS;
4
import org.txm.utils.messages.Utf8NLS;
5

  
6
/**
7
 * CAP UI messages.
8
 * 
9
 * @author mdecorde
10
 * @author sjacquot
11
 *
12
 */
13
public class InformationUIMessages extends NLS {
14
	
15
	private static final String BUNDLE_NAME = "org.txm.searchengine.cqp.rcp.messages.messages"; //$NON-NLS-1$
16
	
17
	public static String CQPPreferencePage_0;
18
	public static String CQPPreferencePage_1;
19
	public static String CQPPreferencePage_10;
20
	public static String CQPPreferencePage_11;
21
	public static String CQPPreferencePage_12;
22
	public static String CQPPreferencePage_13;
23
	public static String CQPPreferencePage_14;
24
	public static String CQPPreferencePage_15;
25
	public static String CQPPreferencePage_17;
26
	public static String CQPPreferencePage_18;
27
	
28
	
29
	public static String ComputeDiagnostic_0;
30

  
31
	public static String DiagnosticPreferencePage_2;
32

  
33
	
34
	static {
35
		// initialize resource bundle
36
		Utf8NLS.initializeMessages(BUNDLE_NAME, InformationUIMessages.class);
37
	}
38
}
0 39

  
tmp/org.txm.information.rcp/src/org/txm/information/rcp/editors/InformationEditor.java (revision 702)
1
package org.txm.information.rcp.editors;
2

  
3
import java.io.File;
4

  
5
import org.eclipse.swt.SWT;
6
import org.eclipse.swt.browser.Browser;
7
import org.eclipse.swt.layout.GridData;
8
import org.eclipse.swt.layout.GridLayout;
9
import org.eclipse.swt.layout.RowData;
10
import org.eclipse.swt.widgets.Composite;
11
import org.eclipse.swt.widgets.Label;
12
import org.eclipse.swt.widgets.Spinner;
13
import org.txm.core.results.Parameter;
14
import org.txm.information.core.functions.Information;
15
import org.txm.information.core.preferences.InformationPreferences;
16
import org.txm.rcp.editors.TXMEditor;
17
import org.txm.rcp.editors.listeners.ComputeSelectionListener;
18
import org.txm.utils.logger.Log;
19

  
20
/**
21
 * Corpus, Subcorpus or Partition information editor.
22
 * 
23
 * @author mdecorde
24
 * @author sjacquot
25
 *
26
 */
27
public class InformationEditor extends TXMEditor<Information> {
28

  
29

  
30
	/**
31
	 * The browser to display the HTML file.
32
	 */
33
	private Browser browser;
34
	
35
	
36
	/**
37
	 * The maximum number of word property values to display.
38
	 */
39
	@Parameter(key=InformationPreferences.MAX_VALUE)
40
	protected Spinner maxPropertiesToDisplay;
41

  
42

  
43

  
44
	@Override
45
	public void _createPartControl(Composite parent) {
46
		
47
		Composite parametersArea = this.getCommandParametersGroup();
48
		
49
		// label
50
		new Label(parametersArea, SWT.NONE).setText("V max");
51

  
52
		// spinner
53
		this.maxPropertiesToDisplay = new Spinner(parametersArea, SWT.BORDER);
54
		this.maxPropertiesToDisplay.setToolTipText("The maximum number of word property values to show");
55
		this.maxPropertiesToDisplay.setMinimum(0);
56
		RowData gdata = new RowData();
57
		gdata.width = 100;
58
		this.maxPropertiesToDisplay.setLayoutData(gdata);
59
		this.maxPropertiesToDisplay.addSelectionListener(new ComputeSelectionListener(this));
60
		
61
		// browser
62
		Composite displayArea = this.getResultArea();
63
		displayArea.setLayout(new GridLayout(1, true));
64
		this.browser = new Browser(displayArea, SWT.NONE);
65
		this.browser.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
66
	}
67
	
68
	@Override
69
	public void updateEditorFromResult(boolean update) {
70
		File file = this.getResult().getHTMLFile();
71
		if (file.exists()) {
72
			this.browser.setUrl(file.getAbsolutePath());
73
		}
74
		else	{
75
			Log.severe("Information HTML file doesn't exist."); //$NON-NLS-1$
76
		}
77
	}
78

  
79
	@Override
80
	public void updateResultFromEditor() {
81
		// nothing to do
82
	}
83

  
84
}
0 85

  
tmp/org.txm.information.rcp/src/org/txm/information/rcp/handlers/ComputeInformation.java (revision 702)
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.information.rcp.handlers;
29

  
30
import org.eclipse.core.commands.ExecutionEvent;
31
import org.eclipse.core.commands.ExecutionException;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.swt.SWT;
34
import org.eclipse.ui.PartInitException;
35
import org.eclipse.ui.handlers.HandlerUtil;
36
import org.txm.information.core.functions.Information;
37
import org.txm.information.rcp.editors.InformationEditor;
38
import org.txm.information.rcp.messages.InformationUIMessages;
39
import org.txm.rcp.editors.TXMEditor;
40
import org.txm.rcp.handlers.BaseAbstractHandler;
41
import org.txm.rcp.views.corpora.CorporaView;
42
import org.txm.searchengine.cqp.CQPEngine;
43
import org.txm.searchengine.cqp.corpus.Corpus;
44
import org.txm.utils.logger.Log;
45

  
46
/**
47
 * Calls the function Information on a MainCorpus, a SubCorpus or a Partition.
48
 * Displays basic statistics and gives some properties values. 
49
 * 
50
 * @author mdecorde
51
 * @author sjacquot
52
 */
53
public class ComputeInformation extends BaseAbstractHandler {
54
	
55
	// adds a double click listener to the Corpus View
56
	static	{
57
		CorporaView.addDoubleClickListener(Information.class, ComputeInformation.class);
58
	}
59
	
60
	/** The selection. */
61
	private IStructuredSelection selection;
62
	
63
	/** The response. */
64
	int response = SWT.YES;
65

  
66

  
67
	@Override
68
	public Object execute(ExecutionEvent event) throws ExecutionException {
69
		if (!CQPEngine.isInitialized()) {
70
			System.out.println("SearchEngine is not ready. Aborting.");
71
			return false;
72
		}
73
		
74
		Object sel = HandlerUtil.getCurrentSelection(event);
75
		if (!(sel instanceof IStructuredSelection)) {
76
			Log.warning(InformationUIMessages.ComputeDiagnostic_0);
77
			return null;
78
		}
79
		
80
		selection = (IStructuredSelection) sel;
81
		Object s = selection.getFirstElement();
82
		Information diag = null;
83
		if (s instanceof Corpus) {
84
			diag = new Information((Corpus)s);
85
		} else if (s instanceof Information) {
86
			diag = (Information)s;
87
		} else {
88
			Log.severe("Selection not managed: " + s);
89
		}
90
		try {
91
			open(diag);
92
		} catch (PartInitException e) {
93
			System.out.println("Error while opening editor: "+e.getLocalizedMessage());
94
			Log.printStackTrace(e);
95
		}
96
		return null;
97
	}
98
	
99
	public static void open(Information diag) throws PartInitException {
100
		TXMEditor.openEditor(diag, InformationEditor.class.getName());
101
	}
102
}
0 103

  
tmp/org.txm.information.rcp/build.properties (revision 702)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .,\
5
               plugin.xml
0 6

  
tmp/org.txm.information.rcp/OSGI-INF/l10n/bundle.properties (revision 702)
1
command.label.49=Information
2
command.label.48=Information
3

  
4
page.name.9=Information
0 5

  
tmp/org.txm.information.rcp/OSGI-INF/l10n/bundle_ru.properties (revision 702)
1
page.name.9=Описание
0 2

  
tmp/org.txm.information.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 702)
1
command.label.49=Information
2
command.label.48=Information
3

  
4
page.name.9=Information
0 5

  
tmp/org.txm.information.rcp/plugin.xml (revision 702)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.ui.preferencePages">
6
      <page
7
            category="org.txm.rcp.preferences.UserPreferencePage"
8
            class="org.txm.information.rcp.preferences.InformationPreferencePage"
9
            id="org.txm.information.rcp.preferences.InformationPreferencePage"
10
            name="%page.name.9">
11
      </page>
12
   </extension>
13
   <extension
14
         point="org.eclipse.ui.commands">
15
      <command
16
            defaultHandler="org.txm.information.rcp.handlers.ComputeInformation"
17
            id="org.txm.information.rcp.handlers.ComputeInformation"
18
            name="Information">
19
      </command>
20
   </extension>
21
   <extension
22
         point="org.eclipse.ui.editors">
23
      <editor
24
            class="org.txm.information.rcp.editors.InformationEditor"
25
            default="false"
26
            icon="icons/functions/information.png"
27
            id="org.txm.information.rcp.editors.InformationEditor"
28
            name="Information">
29
      </editor>
30
   </extension>
31
   <extension
32
         point="org.eclipse.core.runtime.adapters">
33
      <factory
34
            adaptableType="org.txm.information.core.functions.Information"
35
            class="org.txm.information.rcp.adapters.InformationAdapterFactory">
36
         <adapter
37
               type="org.eclipse.ui.model.IWorkbenchAdapter">
38
         </adapter>
39
      </factory>
40
   </extension>
41
   <extension
42
         point="org.eclipse.ui.menus">
43
      <menuContribution
44
            locationURI="toolbar:org.txm.rcp.toolbarcorpus">
45
         <command
46
               commandId="org.txm.information.rcp.handlers.ComputeInformation"
47
               icon="icons/functions/information.png"
48
               style="push"
49
               tooltip="Information">
50
            <visibleWhen
51
                  checkEnabled="false">
52
               <reference
53
                     definitionId="OneCorpusSelected">
54
               </reference>
55
            </visibleWhen>
56
         </command>
57
      </menuContribution>
58
      <menuContribution
59
            locationURI="popup:org.txm.rcp.views.corpora.CorporaView">
60
         <command
61
               commandId="org.txm.information.rcp.handlers.ComputeInformation"
62
               icon="icons/functions/information.png"
63
               style="push">
64
            <visibleWhen
65
                  checkEnabled="false">
66
               <reference
67
                     definitionId="OneCorpusSelected">
68
               </reference>
69
            </visibleWhen>
70
         </command>
71
      </menuContribution>
72
      <menuContribution
73
            locationURI="menu:menu.corpus">
74
         <command
75
               commandId="org.txm.information.rcp.handlers.ComputeInformation"
76
               icon="icons/functions/information.png"
77
               style="push">
78
            <visibleWhen
79
                  checkEnabled="false">
80
               <reference
81
                     definitionId="OneCorpusSelected">
82
               </reference>
83
            </visibleWhen>
84
         </command>
85
      </menuContribution>
86
   </extension>
87
</plugin>
0 88

  
tmp/org.txm.information.rcp/.settings/org.eclipse.jdt.core.prefs (revision 702)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4
org.eclipse.jdt.core.compiler.compliance=1.6
5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7
org.eclipse.jdt.core.compiler.source=1.6
0 8

  
tmp/org.txm.information.rcp/.classpath (revision 702)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
0 8

  
tmp/org.txm.information.rcp/META-INF/MANIFEST.MF (revision 702)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Information RCP
4
Bundle-SymbolicName: org.txm.information.rcp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Vendor: Textometrie.org
7
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
8
Require-Bundle: org.eclipse.ui;bundle-version="3.106.1",
9
 org.txm.utils,
10
 org.txm.searchengine.cqp.core;bundle-version="1.1.0",
11
 org.txm.information.core;bundle-version="1.0.0",
12
 org.eclipse.core.runtime;bundle-version="3.10.0",
13
 org.txm.rcp;bundle-version="0.8.0"
0 14

  
tmp/org.txm.information.rcp/.project (revision 702)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.information.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

  

Also available in: Unified diff