Revision 64

tmp/org.txm.synopticeditor.feature/.project (revision 64)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.synopticeditor.feature</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.pde.FeatureBuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.pde.FeatureNature</nature>
16
	</natures>
17
</projectDescription>
0 18

  
tmp/org.txm.synopticeditor.feature/build.properties (revision 64)
1
bin.includes = feature.xml
0 2

  
tmp/org.txm.synopticeditor.feature/feature.xml (revision 64)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<feature
3
      id="SynopticEditor.feature"
4
      label="Edition"
5
      version="1.0.0.qualifier"
6
      provider-name="Textometrie.org">
7

  
8
   <description url="http://www.example.com/description">
9
      Edition editor for multi-edition corpora
10
   </description>
11

  
12
   <copyright url="http://www.example.com/copyright">
13
      TXM 0.7.8 BETA
14
Copyright © 2013-2016 ENS de Lyon, University of Franche-Comté.
15
Copyright © 2010-2013 ENS de Lyon.
16
Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
17
Lyon 2, University of Franche-Comté, University of Nice
18
Sophia Antipolis, University of Paris 3.
19
The TXM platform is free software: you can redistribute it
20
and/or modify it under the terms of the GNU General Public
21
License as published by the Free Software Foundation,
22
either version 2 of the License, or (at your option) any
23
later version.
24
The TXM platform is distributed in the hope that it will be
25
useful, but WITHOUT ANY WARRANTY; without even the implied
26
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
27
PURPOSE. See the GNU General Public License for more
28
details.
29
You should have received a copy of the GNU General
30
Public License along with the TXM platform. If not, see
31
http://www.gnu.org/licenses
32
   </copyright>
33

  
34
   <license url="">
35
      &lt;TXM Software User Agreement&gt;
36

  
37
TXM 0.7.8 Copyright © 2010-2016 ENS de Lyon, University of Franche-Comté, CNRS
38

  
39
&lt;English version below&gt;
40

  
41
EN ACCEPTANT CETTE MISE À JOUR ET EN UTILISANT TXM, VOUS VOUS ENGAGEZ À CITER L&apos;ARTICLE DE RÉFÉRENCE DE LA PLATEFORME* DANS VOS PUBLICATIONS DE RÉSULTATS OBTENUS À PARTIR D&apos;ELLE. CELA EST ESSENTIEL POUR NOUS PERMETTRE DE JUSTIFIER LE BESOIN DE PÉRENNISATION DE CET INSTRUMENT DE TRAVAIL POUR LA COMMUNAUTÉ SCIENTIFIQUE.
42

  
43
Le logiciel TXM est un logiciel libre ; vous pouvez le redistribuer et/ou le modifier suivant les termes de la Licence publique générale GNU telle que publiée par la Free Software Foundation, soit la version 2 de cette License, soit une version ultérieure.
44

  
45
Le logiciel TXM est distribué dans l&apos;espoir qu&apos;il sera utile, mais sans aucune garantie, y compris mais non de façon limitative les garanties implicites de qualité marchande et de convenance à un usage particulier. Consultez la version 2 et la version 3 de la Licence publique générale GNU pour plus de détails.
46

  
47
Vous devriez avoir reçu une copie de la Licence publique générale GNU en accompagnement du logiciel TXM ; si ce n&apos;est pas le cas, veuillez consulter la page http://www.gnu.org/licenses/gpl-2.0.html.
48
_______________
49
* Serge Heiden, Jean-Philippe Magué, Bénédicte Pincemin.
50
TXM : Une plateforme logicielle open-source pour la textométrie - conception et développement. Sergio Bolasco, Isabella Chiari, Luca Giuliano. 10th International Conference on the Statistical Analysis of Textual Data - JADT 2010, Jun 2010, Rome, Italie.
51
Edizioni Universitarie di Lettere Economia Diritto, 2 (3), pp.1021-1032, 2010. &lt;halshs-00549779&gt;
52

  
53

  
54
ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH ENGLISH
55

  
56

  
57
By accepting this update and by using TXM, you agree to cite the TXM platform reference article** in your publications of results obtained from it. That is essential for us to justify the need for sustainability of this instrument for the scientific community.
58

  
59
The TXM platform is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
60

  
61
The TXM platform is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
62

  
63
You should have received a copy of the GNU General Public License along with the TXM platform. If not, see http://www.gnu.org/licenses/gpl-2.0.html.
64
_______________
65
** Serge Heiden. The TXM Platform: Building Open-Source Textual
66
Analysis Software Compatible with the TEI Encoding Scheme. Ryo Otoguro, Kiyoshi Ishikawa, Hiroshi Umemoto, Kei Yoshimoto and Yasunari Harada. 24th Pacific Asia Conference on Language, Information and Computation, Nov 2010, Sendai, Japan. Institute for Digital Enhancement of Cognitive Development, Waseda University, pp.389-398, 2010. &lt;halshs-00549764&gt;
67
   </license>
68

  
69
   <requires>
70
      <import plugin="org.eclipse.ui"/>
71
      <import plugin="org.eclipse.core.runtime"/>
72
      <import plugin="org.txm.rcpapplication" version="0.7.5" match="greaterOrEqual"/>
73
      <import plugin="org.txm.toolbox" version="0.7.0" match="greaterOrEqual"/>
74
      <import plugin="org.eclipse.ui.browser" version="3.4.100" match="greaterOrEqual"/>
75
   </requires>
76

  
77
   <plugin
78
         id="SynopticEditorRCP"
79
         download-size="0"
80
         install-size="0"
81
         version="0.0.0"
82
         unpack="false"/>
83

  
84
</feature>
0 85

  
tmp/org.txm.synopticeditor.rcp/build.properties (revision 64)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .,\
5
               plugin.xml,\
6
               icons/,\
7
               OSGI-INF/l10n/bundle.properties
0 8

  
tmp/org.txm.synopticeditor.rcp/OSGI-INF/l10n/bundle.properties (revision 64)
1
#Properties file for SynopticEditorRCP
2
command.label = Edition
3
command.tooltip = Read corpus texts
4
command.tooltip.0 = Read corpus texts
5
command.name = Edition
6
command.name.0 = Display in full text
7
editor.name = Edition
8
Bundle-Name = SynopticEditor
9
menu.label.1 = Corpus
0 10

  
tmp/org.txm.synopticeditor.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 64)
1
#Properties file for SynopticEditorRCP
2
command.label = ?dition
3
command.tooltip = Lire l'?dition
4
command.tooltip.0 = Lire l'?dition
5
command.name = ?dition
6
command.name.0 = Lire en plein texte
7
editor.name = ?dition
8
Bundle-Name = SynopticEditor
9
menu.label.1 = Corpus
0 10

  
tmp/org.txm.synopticeditor.rcp/plugin.xml (revision 64)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension-point id="org.txm.synopticeditor.toolbarbutton" name="Synoptic Editor toolbar button" schema="schema/org.txm.synopticeditor.toolbarbutton.exsd"/>
5
   <extension
6
         point="org.eclipse.ui.menus">
7
      <menuContribution
8
            locationURI="popup:org.txm.rcpapplication.editors.ConcordancesEditor">
9
         <command
10
               commandId="org.txm.rcp.synoptic.commands.BackToText"
11
               icon="icons/objects/edition.png"
12
               style="push">
13
         </command>
14
      </menuContribution>
15
      <menuContribution
16
            locationURI="menu:menu.help.plugins">
17
         <command
18
               commandId="org.txm.rcpapplication.commands.OpenBrowser"
19
               icon="icons/objects/edition.png"
20
               label="%command.label"
21
               style="push">
22
            <parameter
23
                  name="org.txm.rcpapplication.commands.commandParameter2"
24
                  value="https://groupes.renater.fr/wiki/txm-users/public/extensions#synoptic_editor">
25
            </parameter>
26
         </command>
27
      </menuContribution>
28
      <menuContribution
29
            allPopups="true"
30
            locationURI="toolbar:org.txm.rcpapplication.toolbarcorpus?before=org.txm.rcpapplication.toolbarcorpus.description">
31
         <command
32
               commandId="org.txm.rcp.synoptic.commands.OpenEdition"
33
               icon="icons/objects/edition.png"
34
               style="push"
35
               tooltip="%command.tooltip.0">
36
            <visibleWhen
37
                  checkEnabled="false">
38
               <or>
39
                  <reference
40
                        definitionId="OneCorpusSelected">
41
                  </reference>
42
               </or>
43
            </visibleWhen>
44
         </command>
45
      </menuContribution>
46
      <menuContribution
47
            locationURI="popup:org.txm.rcpapplication.views.CorporaView?before=corporaview.description">
48
         <command
49
               commandId="org.txm.rcp.synoptic.commands.OpenEdition"
50
               icon="icons/objects/edition.png"
51
               style="push"
52
               tooltip="%command.tooltip.0">
53
            <visibleWhen
54
                  checkEnabled="false">
55
               <or>
56
                  <reference
57
                        definitionId="OneCorpusSelected">
58
                  </reference>
59
               </or>
60
            </visibleWhen>
61
         </command>
62
      </menuContribution>
63
      <menuContribution
64
            locationURI="menu:menu.corpus?before=menu.corpus.description">
65
         <command
66
               commandId="org.txm.rcp.synoptic.commands.OpenEdition"
67
               icon="icons/objects/edition.png"
68
               style="push"
69
               tooltip="%command.tooltip.0">
70
            <visibleWhen
71
                  checkEnabled="false">
72
               <or>
73
                  <reference
74
                        definitionId="OneCorpusSelected">
75
                  </reference>
76
               </or>
77
            </visibleWhen>
78
         </command>
79
      </menuContribution>
80
      <menuContribution
81
            locationURI="popup:org.txm.rcp.synoptic.editor.SynopticEditionEditor">
82
         <command
83
               commandId="org.txm.rcpapplication.commands.link.TextToConcordance"
84
               label="Send to concordances..."
85
               style="push">
86
         </command>
87
      </menuContribution>
88
   </extension>
89
   <extension
90
         point="org.eclipse.ui.commands">
91
      <command
92
            defaultHandler="org.txm.rcp.synoptic.commands.OpenEdition"
93
            id="org.txm.rcp.synoptic.commands.OpenEdition"
94
            name="%command.name">
95
      </command>
96
      <command
97
            defaultHandler="org.txm.rcp.synoptic.commands.BackToText"
98
            id="org.txm.rcp.synoptic.commands.BackToText"
99
            name="%command.name.0">
100
      </command>
101
   </extension>
102
   <extension
103
         point="org.eclipse.ui.editors">
104
      <editor
105
            class="org.txm.rcp.synoptic.editor.SynopticEditionEditor"
106
            default="false"
107
            icon="icons/objects/edition.png"
108
            id="org.txm.rcp.synoptic.editor.SynopticEditionEditor"
109
            name="%editor.name">
110
      </editor>
111
   </extension>
112
   <extension
113
         point="org.eclipse.ui.bindings">
114
      <key
115
            commandId="org.txm.rcp.synoptic.commands.BackToText"
116
            contextId="org.eclipse.ui.contexts.window"
117
            schemeId="org.txm.rcp.scheme"
118
            sequence="M1+E">
119
      </key>
120
   </extension>
121
   <extension
122
         point="org.txm.rcp.extensionpoint.backtotext">
123
      <command
124
            class="org.txm.rcp.synoptic.commands.BackToText"
125
            name="Synoptic">
126
      </command>
127
   </extension>
128
   <extension
129
         point="org.eclipse.ui.preferencePages">
130
      <page
131
            category="org.txm.rcpapplication.preferences.UserPreferencePage"
132
            class="org.txm.rcp.synoptic.preferences.EditionPreferencePage"
133
            id="org.txm.rcp.synoptic.preferences.EditionPreferencePage"
134
            name="Edition">
135
      </page>
136
   </extension>
137

  
138
</plugin>
0 139

  
tmp/org.txm.synopticeditor.rcp/.settings/org.eclipse.jdt.core.prefs (revision 64)
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.synopticeditor.rcp/.classpath (revision 64)
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
		<accessrules>
6
			<accessrule kind="accessible" pattern="**"/>
7
		</accessrules>
8
	</classpathentry>
9
	<classpathentry kind="src" path="src"/>
10
	<classpathentry kind="output" path="bin"/>
11
</classpath>
0 12

  
tmp/org.txm.synopticeditor.rcp/META-INF/MANIFEST.MF (revision 64)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Bundle-Name
4
Bundle-SymbolicName: org.txm.synopticeditor.rcp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: synopticeditor.Activator
7
Require-Bundle: org.txm.toolbox;bundle-version="0.7.0",
8
 org.eclipse.ui,
9
 org.eclipse.core.runtime,
10
 org.txm.rcpapplication;bundle-version="0.7.5",
11
 org.eclipse.ui.browser;bundle-version="3.4.100",
12
 org.eclipse.jface.databinding;bundle-version="1.6.200",
13
 org.eclipse.jface.text;bundle-version="3.9.2"
14
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
15
Bundle-ActivationPolicy: lazy
16
Export-Package: org.txm.rcp.synoptic.commands,
17
 org.txm.rcp.synoptic.editor,
18
 org.txm.rcp.synoptic.editor.ext,
19
 synopticeditor
20
Bundle-Vendor: Textometrie.org
0 21

  
tmp/org.txm.synopticeditor.rcp/schema/org.txm.synopticeditor.toolbarbutton.exsd (revision 64)
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="SynopticEditorRCP" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="SynopticEditorRCP" id="org.txm.synopticeditor.bottombutton" name="Synoptic Editor bottom button"/>
7
      </appinfo>
8
      <documentation>
9
         Add a button in the SynapticEditor bottom toolbar
10
      </documentation>
11
   </annotation>
12

  
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
19
      <complexType>
20
         <choice minOccurs="1" maxOccurs="unbounded">
21
            <element ref="Button"/>
22
         </choice>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appinfo>
43
                  <meta.attribute translatable="true"/>
44
               </appinfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49

  
50
   <element name="Button">
51
      <complexType>
52
         <attribute name="class" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  
56
               </documentation>
57
               <appinfo>
58
                  <meta.attribute kind="java" basedOn="org.txm.rcp.synoptic.editor.ext.ToolbarButton:"/>
59
               </appinfo>
60
            </annotation>
61
         </attribute>
62
      </complexType>
63
   </element>
64

  
65
   <annotation>
66
      <appinfo>
67
         <meta.section type="since"/>
68
      </appinfo>
69
      <documentation>
70
         TXM 0.7.8
71
      </documentation>
72
   </annotation>
73

  
74
   <annotation>
75
      <appinfo>
76
         <meta.section type="examples"/>
77
      </appinfo>
78
      <documentation>
79
         [Enter extension point usage example here.]
80
      </documentation>
81
   </annotation>
82

  
83
   <annotation>
84
      <appinfo>
85
         <meta.section type="apiinfo"/>
86
      </appinfo>
87
      <documentation>
88
         [Enter API information here.]
89
      </documentation>
90
   </annotation>
91

  
92
   <annotation>
93
      <appinfo>
94
         <meta.section type="implementation"/>
95
      </appinfo>
96
      <documentation>
97
         [Enter information about supplied implementation of this extension point.]
98
      </documentation>
99
   </annotation>
100

  
101

  
102
</schema>
0 103

  
tmp/org.txm.synopticeditor.rcp/.project (revision 64)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.synopticeditor.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.synopticeditor.rcp/src/org/txm/rcp/synoptic/editor/SashPanel.java (revision 64)
1
package org.txm.rcp.synoptic.editor;
2

  
3
import java.util.ArrayList;
4

  
5
import org.eclipse.swt.SWT;
6
import org.eclipse.swt.layout.FormAttachment;
7
import org.eclipse.swt.layout.FormData;
8
import org.eclipse.swt.layout.FormLayout;
9
import org.eclipse.swt.layout.GridLayout;
10
import org.eclipse.swt.widgets.Composite;
11
import org.eclipse.swt.widgets.Control;
12
import org.eclipse.swt.widgets.Event;
13
import org.eclipse.swt.widgets.Listener;
14
import org.eclipse.swt.widgets.Sash;
15

  
16
public class SashPanel extends Composite {
17

  
18
	//Composite parent;
19
	ArrayList<Composite> cells;
20

  
21
	public SashPanel(Composite parent, int style) {
22
		super(parent, style);
23
		//this.parent = parent;
24
		this.setLayout(new FormLayout());
25
	}
26

  
27
	public void init(int ncolumns) {
28
		if (cells != null) {
29
			for(Control c : this.getChildren())
30
				c.dispose();
31
			cells.clear();
32
			cells = new ArrayList<Composite>();
33
		}
34

  
35
		cells = new ArrayList<Composite>();
36
		Sash sash = null;
37
		FormData sashData = null;
38
		for (int i = 0 ; i < ncolumns ; i++) {
39
			Composite container = new Composite(this, SWT.NONE);
40
			container.setLayout(new GridLayout());
41
			cells.add(container);
42

  
43
			FormData containerData = new FormData();
44
			containerData.width = 100;
45
			containerData.top = new FormAttachment(0, 0);
46
			containerData.bottom = new FormAttachment(100, 0);
47
			container.setLayoutData(containerData);// set new layout data
48

  
49
			if (sash != null) { // attached FormData to previous sash and vice-versa
50
				sashData.right = new FormAttachment(container, 0);
51
				containerData.left = new FormAttachment(sash, 0);
52
			} else if (i == 0) {
53
				containerData.left = new FormAttachment(0, 0); // first cell
54
			}
55

  
56
			if (i == ncolumns -1 ) {
57
				containerData.right = new FormAttachment(100, 0); // last cell
58
			} else {
59
				sash = new Sash(this, SWT.VERTICAL);
60
				containerData.right = new FormAttachment(sash, 0);
61

  
62
				sashData = new FormData();
63
				sashData.left = new FormAttachment(container, 0);
64
				sashData.top = new FormAttachment(0, 0);
65
				sashData.bottom = new FormAttachment(100, 0);
66
				sash.setLayoutData(sashData);
67
			}
68
			sash.addListener(SWT.Selection, new Listener() {
69
				@Override
70
				public void handleEvent(Event e) {
71
					SashPanel.this.layout();
72
					//								e.getBounds()
73
					//								Rectangle sashRect = sash.getBounds();
74
					//								Rectangle shellRect = SashPanel.this.getClientArea();
75
					//								int right = shellRect.width - sashRect.width;
76
					//								e.x = Math.max(Math.min(e.x, right), 0);
77
					//								if (e.x != sashRect.x) {
78
					//									sashData.left = new FormAttachment(0, e.x);
79
					//									parentContainer.layout();
80
					//								}
81
				}
82
			});
83
		}
84

  
85
	}
86

  
87
	public Composite getContainer(int i) {
88
		return cells.get(i);
89
	}
90
}
0 91

  
tmp/org.txm.synopticeditor.rcp/src/org/txm/rcp/synoptic/editor/SynopticEditorInput.java (revision 64)
1
package org.txm.rcp.synoptic.editor;
2

  
3
import org.eclipse.jface.resource.ImageDescriptor;
4
import org.eclipse.ui.IEditorInput;
5
import org.eclipse.ui.IPersistableElement;
6
import org.eclipse.ui.plugin.AbstractUIPlugin;
7
import org.txm.objects.Text;
8
import org.txm.rcpapplication.Application;
9
import org.txm.rcpapplication.IImageKeys;
10
import org.txm.searchengine.cqp.corpus.Corpus;
11

  
12
import cern.colt.Arrays;
13

  
14
public class SynopticEditorInput implements IEditorInput {
15

  
16
	private Corpus corpus;
17
	private Text text;
18
	private String[] editions;
19

  
20
	/**
21
	 * Instantiates a new SynopticEditorInput
22
	 *
23
	 * @param corpus, the corpus
24
	 * @param text, the text to show
25
	 * @param editions, the editions to show
26
	 */
27
	public SynopticEditorInput(Corpus corpus, String text, String[] editions) {
28
		this.corpus = corpus;
29
		corpus = corpus.getMainCorpus();
30
		this.editions = editions;
31
		
32
		if (text == null) {
33
			this.text = corpus.getFirstText();
34
		} else {
35
			this.text = corpus.getText(text);
36
		}
37
		
38
		if (editions == null) {
39
			String[] defaultEditions = {corpus.getDefaultEdition()};
40
			this.editions = defaultEditions;
41
		}
42
	}
43

  
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
46
	 */
47
	@Override
48
	public ImageDescriptor getImageDescriptor() {
49
		return AbstractUIPlugin.imageDescriptorFromPlugin(
50
				Application.PLUGIN_ID, IImageKeys.EDITION);
51
	}
52

  
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.ui.IEditorInput#getName()
55
	 */
56
	@Override
57
	public String getName() {
58
		return corpus.getName()+ " - "+text+ " - "+Arrays.toString(editions);  //$NON-NLS-1$ //$NON-NLS-2$
59
	}
60

  
61
	/* (non-Javadoc)
62
	 * @see org.eclipse.ui.IEditorInput#getPersistable()
63
	 */
64
	@Override
65
	public IPersistableElement getPersistable() {
66
		return null;
67
	}
68

  
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
71
	 */
72
	@Override
73
	public String getToolTipText() {
74
		return getName();
75
	}
76

  
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
79
	 */
80
	@Override
81
	public Object getAdapter(Class adapter) {
82
		return null;
83
	}
84

  
85
	/**
86
	 * Gets the corpus.
87
	 *
88
	 * @return the corpus
89
	 */
90
	public Corpus getCorpus() {
91
		return corpus;
92
	}
93

  
94
	public Text getText() {
95
		return text;
96
	}
97
	
98
	public String[] getEditions() {
99
		return editions;
100
	}
101

  
102
	/* (non-Javadoc)
103
	 * @see org.eclipse.ui.IEditorInput#exists()
104
	 */
105
	@Override
106
	public boolean exists() {
107
		return false;
108
	}
109
}
0 110

  
tmp/org.txm.synopticeditor.rcp/src/org/txm/rcp/synoptic/editor/ext/ToolbarButton.java (revision 64)
1
package org.txm.rcp.synoptic.editor.ext;
2

  
3
import org.eclipse.swt.widgets.Button;
4
import org.eclipse.swt.widgets.Composite;
5
import org.txm.rcp.synoptic.editor.SynopticEditionEditor;
6

  
7
public class ToolbarButton {
8

  
9
	protected SynopticEditionEditor editor;
10

  
11
	public ToolbarButton() {}
12
	
13
	/**
14
	 * 
15
	 * @param parent
16
	 * @param editor
17
	 * @return the button to dislay in the bottom toolbar
18
	 */
19
	public Button getToolbarButton(Composite parent, SynopticEditionEditor editor) {
20
		this.editor = editor;
21
		return null;
22
	}
23
	
24
	/**
25
	 * Called when the editor is disposed
26
	 * 
27
	 * @return true is the editor can be closed
28
	 */
29
	public boolean onClose() {
30
		return true;
31
	}
32
}
0 33

  
tmp/org.txm.synopticeditor.rcp/src/org/txm/rcp/synoptic/editor/EditionPanel.java (revision 64)
1
package org.txm.rcp.synoptic.editor;
2

  
3
import java.util.Arrays;
4
import java.util.Collection;
5
import java.util.HashMap;
6
import java.util.HashSet;
7

  
8
import org.apache.batik.bridge.CSSUtilities;
9
import org.eclipse.jface.action.MenuManager;
10
import org.eclipse.jface.text.ITextSelection;
11
import org.eclipse.jface.viewers.ISelection;
12
import org.eclipse.jface.viewers.ISelectionChangedListener;
13
import org.eclipse.jface.viewers.ISelectionProvider;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.browser.Browser;
16
import org.eclipse.swt.browser.ProgressEvent;
17
import org.eclipse.swt.browser.ProgressListener;
18
import org.eclipse.swt.events.MenuEvent;
19
import org.eclipse.swt.events.MenuListener;
20
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.events.SelectionListener;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Listener;
24
import org.eclipse.swt.widgets.Menu;
25
import org.eclipse.swt.widgets.MenuItem;
26
import org.eclipse.ui.internal.browser.BrowserViewer;
27
import org.txm.objects.Corpus;
28
import org.txm.objects.Edition;
29
import org.txm.objects.Page;
30
import org.txm.objects.Text;
31
import org.txm.rcp.synoptic.preferences.EditionPreferencePage;
32
import org.txm.rcpapplication.StatusLine;
33
import org.txm.rcpapplication.TxmPreferences;
34
import org.txm.rcpapplication.utils.IOClipboard;
35
import org.txm.utils.logger.Log;
36

  
37
import synopticeditor.SynopticMessages;
38

  
39
public class EditionPanel extends BrowserViewer implements ISelectionProvider {
40

  
41
	public static class RGBA {
42
		public int a = 0, r=0, g=0, b=0;
43
		public RGBA(int r, int g, int b) {
44
			this.r =r;this.g=g; this.b =b;
45
		}
46
		public RGBA(int r, int g, int b, int a) {
47
			this.r =r;this.g=g; this.b =b;this.a =a;
48
		}
49

  
50
		public String toString() {return "{"+r+", "+g+","+b+", "+a+"}";}
51
	}
52

  
53
	private ProgressListener progresslistener;
54
	//	private List<String> wordids;
55
	//	private List<String> lineids;
56
	/** The edition. */
57
	Text currentText;
58
	Edition currentEdition;
59
	Page currentPage;
60
	protected SynopticEditionEditor synopticEditionEditor;
61
	private ISelectionProvider selProvider;
62
	private MenuManager menuManager;
63

  
64
	private HashSet<int[]> highlightedAreas = null;
65

  
66
	HashMap<String, HashSet<RGBA>> highlightedColorPerWordIDS = new HashMap<String, HashSet<RGBA>>();
67
	String focusedWordID = null;
68

  
69
	public static final String highlightscript = "try { var elt = document.getElementById(\"%s\");" + //$NON-NLS-1$ //$NON-NLS-2$
70
			"elt.style.backgroundColor=\"rgb(%s,%s,%s)\";" + //$NON-NLS-1$
71
			"elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
72
			"elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$
73
			"elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
74
			"elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
75
			"} catch (e) { };"; //$NON-NLS-1$
76
	public static final String highlightscriptRuleFast = "sheet.insertRule(\"#%s {background-color:rgb(%s,%s,%s);}\", 0);";
77
	public static final String highlightscriptRule = "sheet.insertRule(\"span[id=\\\"%s\\\"] {background-color:rgb(%s,%s,%s); }\", 0);";
78

  
79
	public static final String clearhighlightscript = "try { var elt = document.getElementById(\"%s\");" + //$NON-NLS-1$ //$NON-NLS-2$
80
			"elt.style.backgroundColor=\"white\";" + //$NON-NLS-1$
81
			"elt.style.paddingLeft=\"\";" + //$NON-NLS-1$
82
			"elt.style.paddingRight=\"\";" + //$NON-NLS-1$
83
			"elt.style.paddingTop=\"\";" + //$NON-NLS-1$
84
			"elt.style.paddingBottom=\"\";" + //$NON-NLS-1$
85
			"} catch (e) { };"; //$NON-NLS-1$
86

  
87
	public String functions = 
88
			""//"alert(\"loading functions\");"
89
					+"\nfunction getNodeText(node) {"
90
					+"\n	if (typeof node == 'string') return 'STRING HTML';"
91
					+"\n	else if (typeof  node.innerText != 'undefined') return node.innerText;"
92
					+"\n	else if (typeof  node.InnerText != 'undefined') return node.InnerText;"
93
					+"\n	else if (typeof  node.textContent != 'undefined') return node.textContent;"
94
					+"\n	else return null;"
95
					+"\n}"
96
					+"\nfunction txmGetParent(node) {"
97
					+"\n	if (typeof  node.parentNode != 'undefined') return node.parentNode;"
98
					+"\n	else return null;"
99
					+"\n}"
100
					+"\nfunction txmGetChildren(node) {"
101
					+"\n	if (typeof node == 'string') return 'STRING HTML';"
102
					+"\n	else if (typeof  node.children != 'undefined') return node.children;"
103
					+"\n	else if (typeof  node.ChildNodes != 'undefined') return node.ChildNodes;"
104
					+"\n	else if (typeof  node.childNodes != 'undefined') return node.childNodes;"
105
					+"\n	else return null;"
106
					+"\n}"
107
					+"\nfunction txmGetSelection() {"
108
					+"\n	if (typeof window.getSelection != 'undefined') {return window.getSelection();}"
109
					+"\n	else if (typeof document.selection != 'undefined') { return document.selection;}"
110
					+"\n	else return 'NO SELECTION';"
111
					+"\n}"
112
					+"\nfunction txmGetRange(selection, i) {"
113
					+"\n	if (typeof selection.getRangeAt != 'undefined') {return selection.getRangeAt(i);}"
114
					+"\n	else if (typeof selection.createRange != 'undefined') { return selection.createRange();} // IE5 has no multiple selection"
115
					+"\n	else return 'NO RANGE';"
116
					+"\n}"
117
					+"\nfunction txmGetParentElementRange(range) {"
118
					+"\n	if (typeof range.parentElement != 'undefined') {return range.parentElement();}"
119
					+"\n	else if (typeof range.startContainer != 'undefined') { return range.startContainer.parentNode;}"
120
					+"\n	else return 'NO PARENT';"
121
					+"\n}"
122
					+"\nfunction txmGetFragment(range) {"
123
					+"\n	if (typeof range.cloneContents != 'undefined') { return range.cloneContents();}"
124
					+"\n	else if (typeof range.htmlText != 'undefined') {var node = document.createElement('sel'); node.innerHTML = range.htmlText; 		return node;"
125
					+"\n	} else return 'NO FRAG';"
126
					+"\n}"
127
					+"\nfunction txmGetTagName(node) {"
128
					+"\n	if (typeof node.tagName != 'undefined') {return node.tagName;}"
129
					+"\n	else if (typeof node.nodeName != 'undefined') { return node.nodeName;}"
130
					+"\n	else return 'NO TAGNAME';"
131
					+"\n}"
132
					+"\nfunction findSpans(children, all) {"
133
					+"\n    for (var i = 0 ; i < children.length ; i++) {"
134
					+"\n    	var node = children.item(i);"
135
					+"\n		if (node.nodeType == 1) {"
136
					+"\n    	var id = node.getAttribute('id');"
137
					+"\n       		if (node.tagName == 'SPAN' && id != null && id.indexOf('w_') == 0 && getNodeText(node).length > 0) {"
138
					+"\n            	all.push(id);"
139
					+"\n        	} else {"
140
					+"\n        		findSpans(txmGetChildren(node), all)"
141
					+"\n        	}"
142
					+"\n		}"
143
					+"\n	}"
144
					+"\n}"
145
					+"\nfunction get_type(thing){if(thing===null)return \"[object Null]\";  return Object.prototype.toString.call(thing);}\n"
146
					+"\nfunction getDetailedObject(inputObject) { var detailedObject = {}; var properties; \n   do {        properties = Object.getOwnPropertyNames( inputObject );        for (var o in properties) {detailedObject[properties[o]] = inputObject[properties[o]];}} while ( inputObject = Object.getPrototypeOf(inputObject) );return detailedObject;}\n"
147
					+"\nvar style = document.createElement(\"style\");"
148
					+"\nstyle.appendChild(document.createTextNode(\"\"));"//webkit hack
149
					+"\ndocument.head.appendChild(style);"
150
					+"\nvar sheet = style.sheet;"
151
					//+"\nalert(\"create sheet:\"+sheet);"
152
					+"\n";
153

  
154
	protected boolean slowWordHighLight = TxmPreferences.getBoolean(EditionPreferencePage.SLOW_HIGHLIGHT, false);
155
	
156
	protected boolean firstLoad = true;
157
	public EditionPanel(SynopticEditionEditor synopticEditionEditor, Composite parent, int style, Edition edition) {
158
		super(parent, style);
159
		this.synopticEditionEditor = synopticEditionEditor;
160
		this.currentEdition = edition;
161
		this.currentText = currentEdition.getText();
162

  
163
		progresslistener = new ProgressListener() {
164
			
165
			@Override
166
			public void changed(ProgressEvent event) { }
167

  
168
			@Override
169
			public void completed(ProgressEvent event) {
170
				if (firstLoad) {
171
					//System.out.println(functions);
172
					getBrowser().execute(functions); // loads selection Javascript functions
173
					firstLoad = false;
174
				}
175
				
176
				//System.out.println("highlight: "+highlightedColorPerWordIDS);
177
				StringBuilder buffer = new StringBuilder();
178
				//buffer.append("alert(\"\"+sheet);\n");
179
				buffer.append("try { while(sheet.cssRules.length > 0) sheet.deleteRule(0); } catch (e) {};\n"); // empty style
180
				for (String wordid : highlightedColorPerWordIDS.keySet()) {
181
					RGBA composite = new RGBA(0,0,0);
182
					int size = highlightedColorPerWordIDS.get(wordid).size();
183
					
184
					for (RGBA color : highlightedColorPerWordIDS.get(wordid)) {
185
						composite.r += color.r;
186
						composite.g += color.g;
187
						composite.b += color.b;
188
					}
189
					
190
					composite.r /= size;
191
					composite.g /= size;
192
					composite.b /= size;
193
					
194
					String s = null;
195
					if (slowWordHighLight) {
196
						s = String.format(highlightscriptRule, wordid, composite.r, composite.g, composite.b);
197
					} else {
198
						s = String.format(highlightscriptRuleFast, wordid.replace(" ", "\\ "), composite.r, composite.g, composite.b);
199
					}
200
					
201
					buffer.append(s+"\n");
202
				}
203

  
204
				if (focusedWordID != null) {
205
					//System.out.println("Focus on: "+focusedWordID);
206
					String s = "try { document.getElementById(\"" + focusedWordID + "\").scrollIntoView(true); } catch (e) { };"; //$NON-NLS-1$ //$NON-NLS-2$
207
					buffer.append(s+"\n");
208
				}
209

  
210
				if (highlightedAreas != null) {
211
					for (int[] pos : highlightedAreas ) {
212
						if (pos == null || pos.length != 4) continue;
213
						String s = "try {v.setFocusOn("+pos[0]+", "+pos[1]+", "+pos[2]+", "+pos[3]+");} catch (e) { };"; //$NON-NLS-1$
214
						buffer.append(s+"\n");
215
						break;// one word only for now
216
					}
217
				}
218
				
219
				//System.out.println(buffer);
220
				if (buffer.length() > 0) getBrowser().execute(buffer.toString());
221
			}
222
		};
223
		getBrowser().addProgressListener(progresslistener);
224
	}
225

  
226
	/**
227
	 * Bypass BrowserViewer restriction on the getBrowser method
228
	 */
229
	public Browser getBrowser() {
230
		return super.getBrowser();
231
	}
232

  
233
	public ISelectionProvider getSelectionProvider() {
234
		return selProvider;
235
	}
236

  
237
	public void setHighlightWordsById(RGBA color, HashSet<String> wordids) {
238
		for (String wordid : wordids) {
239
			if (this.highlightedColorPerWordIDS.get(wordid) != null) {
240
				removeHighlightWordsById(color, wordid);
241
			}
242
			HashSet<RGBA> hs = new HashSet<RGBA>();
243
			this.highlightedColorPerWordIDS.put(wordid, hs);
244
			hs.add(color);
245
		}
246

  
247
	}
248

  
249
	public void addHighlightWordsById(RGBA color, String wordid) {
250
		if (!this.highlightedColorPerWordIDS.containsKey(wordid)) {
251
			this.highlightedColorPerWordIDS.put(wordid, new HashSet<RGBA>());
252
		}
253
		this.highlightedColorPerWordIDS.get(wordid).add(color);
254
	}
255

  
256
	/**
257
	 * Can be called to refresh the page word styles but only when the page is loaded
258
	 */
259
	public void updateWordStyles() {
260
		progresslistener.completed(null);
261
	}
262

  
263
	public void addHighlightWordsById(RGBA color, Collection<String> wordids) {
264
		for (String wordid : wordids) {
265
			addHighlightWordsById(color, wordid);
266
		}
267
	}
268

  
269
	public void removeHighlightWordsById(RGBA color, Collection<String> wordids) {
270
		//System.out.println("Call removeHighlightWordsById: "+wordids+" color="+color);
271
		for (String wordid : wordids) {
272
			removeHighlightWordsById(color, wordid);
273
		}
274
	}
275

  
276
	public void removeHighlightWordsById(RGBA color, String wordid) {
277
		if (highlightedColorPerWordIDS.get(wordid) == null) return; // nothing to do
278

  
279
		//System.out.println("remove color="+color+" from id="+wordid);
280
		this.highlightedColorPerWordIDS.get(wordid).remove(color);
281

  
282
		if (this.highlightedColorPerWordIDS.get(wordid).size() == 0) {
283
			this.highlightedColorPerWordIDS.remove(wordid);
284
		}
285
	}
286

  
287
	/**
288
	 * Open the page containing the word with ID=$line_wordid
289
	 * @param line_wordid
290
	 * @return true if the page changed
291
	 */
292
	public boolean backToText(Text text, String line_wordid) {
293

  
294
		String name = currentEdition.getName();
295
		Edition edition = text.getEdition(name);
296

  
297
		if (edition == null) {
298
			String s = SynopticMessages.EditionPanel_0+text+SynopticMessages.EditionPanel_5+name;
299
			System.out.println(s);
300
			StatusLine.setMessage(s);
301
			Log.severe(s);
302
		} else {
303
			Page openedPage = edition.getPageForWordId(line_wordid);
304
			if (openedPage != null && openedPage != currentPage) {
305
				this.showPage(openedPage);
306
				return true;
307
			}
308
		}
309
		updateWordStyles(); // update styles if any new one
310
		return false;
311
	}
312

  
313
	/**
314
	 * First page.
315
	 */
316
	public void firstPage() {
317
		// System.out.println(Messages.TxmBrowser_1+currentPage);
318
		currentPage = currentEdition.getFirstPage();
319
		currentText = currentEdition.getText();
320
		if (currentPage == null) {
321
			System.out.println(SynopticMessages.EditionPanel_1+currentEdition.getName()+SynopticMessages.EditionPanel_2+currentText.getName());
322
		}
323
		
324
		this.setURL(currentPage.toURL());
325
		
326
		//page_label.setText(makePageLabel());
327
	}
328
	
329
	public void setURL(String url) {
330
		firstLoad = true;
331
		super.setURL(url);
332
	}
333

  
334
	/**
335
	 * Last page.
336
	 */
337
	public void lastPage() {
338
		// System.out.println(Messages.TxmBrowser_2+currentPage);
339

  
340
		if (currentPage != null && currentPage.getFile().equals(currentEdition.getLastPage()))
341
			return;
342
		currentPage = currentEdition.getLastPage();
343
		currentText = currentEdition.getText();
344
		this.setURL(currentPage.toURL());
345
	}
346

  
347
	/**
348
	 * Previous page.
349
	 */
350
	public void previousPage() {
351
		// System.out.println(Messages.TxmBrowser_3+currentPage);
352
		if (currentPage != null) {
353
			Page previous = currentEdition.getPreviousPage(currentPage);
354

  
355
			if (previous == currentPage) {
356
				previousText(true);
357
			} else {
358
				currentPage = previous;
359
				this.setURL(currentPage.toURL());
360
			}
361
			currentText = currentEdition.getText();
362
		} else
363
			firstPage();
364
		//page_label.setText(makePageLabel());
365
	}
366

  
367

  
368

  
369
	/**
370
	 * Next page.
371
	 */
372
	public void nextPage() {
373
		// System.out.println(Messages.TxmBrowser_4+currentPage);
374
		if (currentPage != null) {
375
			Page next = currentEdition.getNextPage(currentPage);
376
			if (next == currentPage) {
377
				nextText();
378
			} else {
379
				currentPage = next;
380
				this.setURL(currentPage.toURL());
381
			}
382
			currentText = currentEdition.getText();
383
		} else
384
			firstPage();
385
		//page_label.setText(makePageLabel());
386
	}
387

  
388

  
389
	public void firstText() {
390
		//Text current = this.currentPage.getEdition().getText();
391
		Corpus corpus = currentText.getCorpus();
392
		Text firstText = corpus.getFirstText();
393

  
394
		if (firstText != null) {
395
			String editionName = currentEdition.getName();
396
			Edition tmp = firstText.getEdition(editionName);
397
			if (tmp == null) {
398
				System.out.println(SynopticMessages.EditionPanel_6+editionName+SynopticMessages.EditionPanel_7+firstText.getName());
399
				return;
400
			}
401
			currentEdition = tmp;
402
			currentPage = currentEdition.getFirstPage(); 
403
			currentText = firstText;
404
			if (currentPage == null) {
405
				StatusLine.setMessage("No previous text"); //$NON-NLS-1$
406
				return;
407
			}
408
			this.setURL(currentPage.toURL());
409
		}
410
	}
411

  
412
	/**
413
	 * Next text.
414
	 */
415
	public void lastText() {
416
		//Text current = this.currentPage.getEdition().getText();
417
		Corpus b = currentText.getCorpus();
418
		Text lastText = b.getLastText();
419

  
420
		if (lastText != null) {
421
			String editionName = currentEdition.getName();
422
			Edition tmp = lastText.getEdition(editionName);
423
			if (tmp == null) {
424
				System.out.println(SynopticMessages.EditionPanel_6+editionName+SynopticMessages.EditionPanel_7+lastText.getName());
425
				return;
426
			}
427

  
428
			currentEdition = tmp;
429
			currentPage = currentEdition.getFirstPage(); 
430
			currentText = lastText;
431
			if (currentPage == null) {
432
				StatusLine.setMessage("No text next"); //$NON-NLS-1$
433
				return;
434
			}
435

  
436
			this.setURL(currentPage.toURL());
437
			//page_label.setText(makePageLabel());
438
		}
439
		// System.out.println("Next texts "+nextText);
440
	}
441

  
442
	/**
443
	 * Previous text.
444
	 * @param fromNextText if true  it means the user was reading the next text and then we show the last page of the previous text
445
	 */
446
	public void previousText(boolean fromNextText) {
447

  
448
		//Text current = this.currentPage.getEdition().getText();
449
		Corpus corpus = currentText.getCorpus();
450
		Text previousText = corpus.getPreviousText(currentText);
451

  
452
		if (previousText != null) {
453
			String editionName = currentEdition.getName();
454

  
455
			Edition tmp = previousText.getEdition(editionName);
456
			if (tmp == null) {
457
				System.out.println(SynopticMessages.EditionPanel_6+editionName+SynopticMessages.EditionPanel_7+previousText.getName());
458
			}
459
			currentEdition = tmp;
460
			currentText = previousText;
461
			if (fromNextText) {
462
				currentPage = currentEdition.getLastPage(); 
463
			} else {
464
				currentPage = currentEdition.getFirstPage(); 
465
			}
466

  
467
			if (currentPage == null) {
468
				StatusLine.setMessage("No previous text"); //$NON-NLS-1$
469
				return;
470
			}
471
			this.setURL(currentPage.toURL());
472
		}
473
		// System.out.println("Previous texts "+previousText);
474
	}
475

  
476
	/**
477
	 * Next text.
478
	 */
479
	public void nextText() {
480
		//Text current = this.currentPage.getEdition().getText();
481
		Corpus b = currentText.getCorpus();
482
		Text nextText = b.getNextText(currentText);
483

  
484
		if (nextText != null) {
485
			String editionName = currentEdition.getName();
486
			Edition tmp = nextText.getEdition(editionName);
487
			if (tmp == null) {
488
				System.out.println(SynopticMessages.EditionPanel_6+editionName+SynopticMessages.EditionPanel_7+nextText.getName());
489
				return;
490
			}
491
			currentEdition = tmp;
492

  
493
			currentPage = currentEdition.getFirstPage(); 
494
			currentText = nextText;
495
			if (currentPage == null) {
496
				StatusLine.setMessage("No text next"); //$NON-NLS-1$
497
				return;
498
			}
499

  
500
			this.setURL(currentPage.toURL());
501
			//page_label.setText(makePageLabel());
502
		}
503
		// System.out.println("Next texts "+nextText);
504
	}
505

  
506

  
507
	public void setText(Text text, boolean refresh) {
508
		String editionName = currentEdition.getName();
509
		Edition tmp = text.getEdition(editionName);
510
		if (tmp == null) {
511
			System.out.println(SynopticMessages.EditionPanel_6+editionName+SynopticMessages.EditionPanel_7+text.getName());
512
			return;
513
		}
514

  
515
		currentEdition = tmp;
516
		currentPage = currentEdition.getFirstPage(); 
517
		currentText = text;
518
		if (currentPage == null) {
519
			StatusLine.setMessage("No text next"); //$NON-NLS-1$
520
			return;
521
		}
522

  
523
		if (refresh) this.setURL(currentPage.toURL());
524
		//page_label.setText(makePageLabel());
525
	}
526

  
527
	/**
528
	 * Gets the current page.
529
	 *
530
	 * @return the current page
531
	 */
532
	public Page getCurrentPage() {
533
		return currentPage;
534
	}
535

  
536
	/**
537
	 * Gets the current text.
538
	 *
539
	 * @return the current page
540
	 */
541
	public Text getCurrentText() {
542
		return currentText;
543
	}
544

  
545
	/**
546
	 * Make page label.
547
	 *
548
	 * @return the string
549
	 */
550
	public String makePageLabel() {
551
		return currentPage.getName()
552
				+ " / " + currentPage.getEdition().getNumPages(); //$NON-NLS-1$
553
	}
554

  
555
	/**
556
	 * Show page.
557
	 *
558
	 * @param page the page
559
	 */
560
	public void showPage(Page page) {
561
		//System.out.println("SHOW PAGE "+page);
562
		currentEdition = page.getEdition();
563
		currentText = currentEdition.getText();
564
		currentPage = page;
565
		this.setURL(currentPage.toURL());
566
	}
567

  
568
	public void reloadPage() {
569
		this.setURL(currentPage.toURL());
570
	}
571

  
572
	//	/**
573
	//	 * Sets the edition.
574
	//	 *
575
	//	 * @param edition the new edition
576
	//	 */
577
	//	public void setEdition(Edition edition) {
578
	//		this.currentEdition = edition;
579
	//	}
580

  
581
	static String SCRIPT01 = "var html = \"\";"+
582
			"if (typeof window.getSelection != \"undefined\") {"+ // modern Web browsers
583
			"var sel = window.getSelection();"+
584
			"if (sel.rangeCount) {"+
585
			"var container = document.createElement(\"div\");"+
586
			"for (var i = 0, len = sel.rangeCount; i < len; ++i) {"+
587
			"container.appendChild(sel.getRangeAt(i).cloneContents());"+
588
			"}"+
589
			"html = container.innerHTML;"+
590
			"}"+
591
			"} else if (typeof document.selection != \"undefined\") {"+ // for IE < 11
592
			"if (document.selection.type == \"Text\") {"+
593
			"html = document.selection.createRange().htmlText;"+
594
			"}" +
595
			"}" +
596
			"return html";
597

  
598
	public String getTextSelectionDOM() {
599
		return ((String) getBrowser().evaluate(SCRIPT01));
600
	}
601

  
602
	public String[] getWordSelection() {
603
		
604
		//System.out.println("getWordSelection");
605
		String SCRIPT02_getspans = ""//functions
606
				+"var all = [];"
607
				+"\nvar sel = txmGetSelection();"
608
				+"\nif (sel.rangeCount == 0) {return all;}"
609
				//+"\nalert('sel='+sel);"
610
				+"\nvar range = txmGetRange(sel, 0);"
611
				//+"\nalert('range='+range);"
612
				+"\nvar frag = txmGetFragment(range);"
613
				//+"\nalert('frag='+frag);"
614
				+"\nvar children = txmGetChildren(frag);"
615
				//+"\nalert('children='+children);"
616
				//+"\nalert('children.length='+children.length);"
617
				+"\nif ((children.length == 0) || (children.length == 1 && children.item(0).nodeType == 3)) {"
618
				+"\n	var parent = txmGetParentElementRange(range);"
619
				//+"\n	alert('text selection, parent='+txmGetTagName(parent))"
620
				+"\n	var id = parent.getAttribute('id');"
621
				+"\n	if (txmGetTagName(parent) == 'SPAN' && id != null && id.indexOf('w_') == 0) {"
622
				+"\n		all.push(id);"
623
				+"\n	}"
624
				+"\n	var parent = txmGetParent(parent);"
625
				//+"\n	alert('text selection, parent='+txmGetTagName(parent))"
626
				+"\n	var id = parent.getAttribute('id');"
627
				+"\n	if (txmGetTagName(parent) == 'SPAN' && id != null && id.indexOf('w_') == 0) {"
628
				+"\n		all.push(id);"
629
				+"\n	}"
630
				+"\n} else {"
631
				+"\n	findSpans(children, all);"
632
				+"\n}"
633
				//+"alert('result='+all)"
634
				+"\nreturn all;";
635

  
636
//		System.out.println(functions);
637
//		System.out.println(SCRIPT02_getspans);
638
		
639
		Object ret = getBrowser().evaluate(SCRIPT02_getspans);
640
		if (ret instanceof Object[]) {
641
			Log.warning("selection word ids="+Arrays.toString((Object[])ret));
642
			Object[] array = (Object[])ret;
643
			String[] sel = new String[2];
644
			if (array.length == 0) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff