Révision 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 |
<TXM Software User Agreement> |
|
36 |
|
|
37 |
TXM 0.7.8 Copyright © 2010-2016 ENS de Lyon, University of Franche-Comté, CNRS |
|
38 |
|
|
39 |
<English version below> |
|
40 |
|
|
41 |
EN ACCEPTANT CETTE MISE À JOUR ET EN UTILISANT TXM, VOUS VOUS ENGAGEZ À CITER L'ARTICLE DE RÉFÉRENCE DE LA PLATEFORME* DANS VOS PUBLICATIONS DE RÉSULTATS OBTENUS À PARTIR D'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'espoir qu'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'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. <halshs-00549779> |
|
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. <halshs-00549764> |
|
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/.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/commands/BackToText.java (revision 64) | ||
---|---|---|
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.rcp.synoptic.commands; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.HashMap; |
|
32 |
import java.util.HashSet; |
|
33 |
import java.util.List; |
|
34 |
|
|
35 |
import org.eclipse.core.commands.ExecutionEvent; |
|
36 |
import org.eclipse.core.commands.ExecutionException; |
|
37 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
38 |
import org.eclipse.jface.viewers.ISelection; |
|
39 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
40 |
import org.eclipse.osgi.util.NLS; |
|
41 |
import org.eclipse.ui.IEditorPart; |
|
42 |
import org.eclipse.ui.IWorkbenchPage; |
|
43 |
import org.eclipse.ui.IWorkbenchWindow; |
|
44 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
45 |
import org.txm.Toolbox; |
|
46 |
import org.txm.functions.concordances.Concordance; |
|
47 |
import org.txm.functions.concordances.Line; |
|
48 |
import org.txm.objects.Text; |
|
49 |
import org.txm.rcp.synoptic.editor.EditionPanel.RGBA; |
|
50 |
import org.txm.rcp.synoptic.editor.SynopticEditionEditor; |
|
51 |
import org.txm.rcpapplication.StatusLine; |
|
52 |
import org.txm.rcpapplication.commands.BackToTextCommand; |
|
53 |
import org.txm.rcpapplication.editors.concordances.ConcordancesEditor; |
|
54 |
import org.txm.rcpapplication.utils.SWTEditorsUtils; |
|
55 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
|
56 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
57 |
import org.txm.searchengine.cqp.corpus.Property; |
|
58 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
|
59 |
import org.txm.utils.logger.Log; |
|
60 |
|
|
61 |
import synopticeditor.SynopticMessages; |
|
62 |
import cern.colt.Arrays; |
|
63 |
|
|
64 |
/** |
|
65 |
* Open a text edition from: a concordance Line |
|
66 |
* @author mdecorde. |
|
67 |
*/ |
|
68 |
public class BackToText extends BackToTextCommand { |
|
69 |
|
|
70 |
/** The Constant ID. */ |
|
71 |
public final static String ID = "org.txm.rcp.synoptic.commands.BackToText"; //$NON-NLS-1$ |
|
72 |
public final static RGBA lightred = new RGBA(249,208,208); |
|
73 |
public final static RGBA red = new RGBA(249, 160, 160); |
|
74 |
private static HashMap<ConcordancesEditor, SynopticEditionEditor> associatedEditors = new HashMap<ConcordancesEditor, SynopticEditionEditor>(); |
|
75 |
private static HashMap<ConcordancesEditor, List<String>> associatedEditorsPreviousOtherWordIDs = new HashMap<ConcordancesEditor, List<String>>(); |
|
76 |
private static HashMap<ConcordancesEditor, List<String>> associatedEditorsPreviousLineids = new HashMap<ConcordancesEditor, List<String>>(); |
|
77 |
|
|
78 |
|
|
79 |
/* (non-Javadoc) |
|
80 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
81 |
*/ |
|
82 |
@Override |
|
83 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
84 |
IWorkbenchWindow wb = HandlerUtil.getActiveWorkbenchWindow(event); |
|
85 |
IEditorPart ieditor = wb.getActivePage().getActiveEditor(); |
|
86 |
if (!(ieditor instanceof ConcordancesEditor)) { |
|
87 |
return null; |
|
88 |
} |
|
89 |
ConcordancesEditor concordanceEditor = (ConcordancesEditor)ieditor; |
|
90 |
ISelection sel = wb.getSelectionService().getSelection(); |
|
91 |
if (sel instanceof IStructuredSelection) { |
|
92 |
IStructuredSelection selection = (IStructuredSelection) sel; |
|
93 |
if (selection.getFirstElement() instanceof Line) { |
|
94 |
backToText(concordanceEditor, (Line)(selection.getFirstElement())); |
|
95 |
} else { |
|
96 |
System.out.println(SynopticMessages.BackToText_1+selection); |
|
97 |
} |
|
98 |
} else { |
|
99 |
System.out.println(SynopticMessages.BackToText_2); |
|
100 |
} |
|
101 |
return null; |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* Open edition. |
|
106 |
* |
|
107 |
* @param corpus the corpus |
|
108 |
* @return the object |
|
109 |
*/ |
|
110 |
@Override |
|
111 |
public boolean backToText(ConcordancesEditor editor, Line line) { |
|
112 |
Concordance conc = line.getConcordance(); |
|
113 |
Corpus corpus = conc.getCorpus(); |
|
114 |
|
|
115 |
try { |
|
116 |
if (line == null) return false; |
|
117 |
|
|
118 |
StructuralUnit textS = null; |
|
119 |
String textid = ""; //$NON-NLS-1$ |
|
120 |
String baseid = ""; //$NON-NLS-1$ |
|
121 |
|
|
122 |
Property xProperty = corpus.getProperty("x"), yProperty, wProperty, hProperty; |
|
123 |
String x="0",y="0",w="0",h="0"; |
|
124 |
int[] pos = null; |
|
125 |
if (xProperty != null) { |
|
126 |
yProperty = corpus.getProperty("y"); |
|
127 |
if (yProperty != null) { |
|
128 |
wProperty = corpus.getProperty("w"); |
|
129 |
if (wProperty != null) { |
|
130 |
AbstractCqiClient CQI = Toolbox.getCqiClient(); |
|
131 |
int[] cpos = {line.getMatch().getStart()}; |
|
132 |
hProperty = corpus.getProperty("h"); |
|
133 |
if (hProperty != null) { |
|
134 |
x = CQI.cpos2Str(xProperty.getQualifiedName(), cpos)[0]; |
|
135 |
y = CQI.cpos2Str(yProperty.getQualifiedName(), cpos)[0]; |
|
136 |
w = CQI.cpos2Str(wProperty.getQualifiedName(), cpos)[0]; |
|
137 |
h = CQI.cpos2Str(hProperty.getQualifiedName(), cpos)[0]; |
|
138 |
|
|
139 |
pos = new int[4]; |
|
140 |
pos[0] = Integer.parseInt(x); |
|
141 |
pos[1] = Integer.parseInt(y); |
|
142 |
pos[2] = Integer.parseInt(w); |
|
143 |
pos[3] = Integer.parseInt(h); |
|
144 |
} |
|
145 |
} |
|
146 |
} |
|
147 |
} |
|
148 |
|
|
149 |
|
|
150 |
String projectid = ""; //$NON-NLS-1$ |
|
151 |
try { |
|
152 |
textS = corpus.getStructuralUnit("text"); //$NON-NLS-1$ |
|
153 |
Property textP = textS.getProperty("id"); //$NON-NLS-1$ |
|
154 |
textid = line.getMatch().getValueForProperty(textP);// get text via text struct property id |
|
155 |
} catch (Exception e2) { |
|
156 |
System.out.println("The corpus has no text_id property" + e2); //$NON-NLS-1$ |
|
157 |
org.txm.rcpapplication.utils.Logger.printStackTrace(e2); |
|
158 |
return false; |
|
159 |
} |
|
160 |
|
|
161 |
Log.info("Loading line informations..."); //$NON-NLS-1$ |
|
162 |
|
|
163 |
SynopticEditionEditor attachedBrowserEditor = associatedEditors.get(editor); |
|
164 |
if (attachedBrowserEditor!= null && attachedBrowserEditor.isDisposed()) { |
|
165 |
associatedEditorsPreviousOtherWordIDs.put(editor, new ArrayList<String>()); |
|
166 |
associatedEditorsPreviousLineids.put(editor, new ArrayList<String>()); |
|
167 |
} |
|
168 |
List<String> previousOtherWordIDs = associatedEditorsPreviousOtherWordIDs.get(editor); |
|
169 |
List<String> previousLineids = associatedEditorsPreviousLineids.get(editor); |
|
170 |
|
|
171 |
if (attachedBrowserEditor == null || attachedBrowserEditor.isDisposed()) { |
|
172 |
String[] editionsToOpen = OpenEdition.getDefaultEditions(corpus); |
|
173 |
|
|
174 |
if (editionsToOpen.length == 0) { // the defaultEdition parameter is not set |
|
175 |
ArrayList<String> editionNames = corpus.getEditionNames(); |
|
176 |
if (editionNames.size() > 0) { // use the first edition declared |
|
177 |
editionsToOpen = new String[1]; |
|
178 |
editionsToOpen[0] = editionNames.get(0); |
|
179 |
Log.info(SynopticMessages.BackToText_0+editionNames.get(0)); |
|
180 |
} else { // no edition in the corpus |
|
181 |
Log.info(SynopticMessages.BackToText_4); |
|
182 |
editionsToOpen = new String[0]; |
|
183 |
return false; |
|
184 |
} |
|
185 |
} else { |
|
186 |
Log.info(SynopticMessages.BackToText_5+Arrays.toString(editionsToOpen)); |
|
187 |
} |
|
188 |
|
|
189 |
attachedBrowserEditor = OpenEdition.openEdition(corpus, editionsToOpen); |
|
190 |
associatedEditors.put(editor, attachedBrowserEditor); |
|
191 |
SWTEditorsUtils.addEditor(editor, attachedBrowserEditor, EModelService.ABOVE); |
|
192 |
} |
|
193 |
|
|
194 |
// remove previous highlighted words |
|
195 |
if (previousOtherWordIDs != null) { |
|
196 |
//System.out.println("remove previousOtherWordIDs="+previousOtherWordIDs); |
|
197 |
attachedBrowserEditor.removeHighlightWordsById(lightred, previousOtherWordIDs); |
|
198 |
associatedEditorsPreviousOtherWordIDs.remove(editor); // free mem |
|
199 |
} |
|
200 |
if (previousLineids != null) { |
|
201 |
//System.out.println("remove previousLineids="+previousLineids); |
|
202 |
attachedBrowserEditor.removeHighlightWordsById(red, previousLineids); |
|
203 |
associatedEditorsPreviousLineids.remove(editor); // free mem |
|
204 |
} |
|
205 |
|
|
206 |
//System.out.println("getKeywordsId from "+editor.getTopLine()+" to "+editor.getBottomLine() + 1); |
|
207 |
List<String> otherWordIDs = conc.getKeywordsId(textid, editor.getTopLine(), editor.getBottomLine() + 1); |
|
208 |
//System.out.println("getKeywordsId="+otherWordIDs); |
|
209 |
List<String> lineids = null; |
|
210 |
try { |
|
211 |
lineids = line.getMatch().getValuesForProperty(corpus.getProperty("id")); //$NON-NLS-1$ |
|
212 |
} catch (Exception e1) { |
|
213 |
org.txm.rcpapplication.utils.Logger.printStackTrace(e1); |
|
214 |
return false; |
|
215 |
} |
|
216 |
Log.info(NLS.bind("Project id {0} Corpus (Base) id {1} Text id {2}", //$NON-NLS-1$ |
|
217 |
new Object[]{projectid, baseid, textid})); |
|
218 |
|
|
219 |
otherWordIDs.removeAll(lineids); // remove the pivot from others words |
|
220 |
|
|
221 |
Text text = corpus.getMainCorpus().getText(textid); |
|
222 |
if (text == null) { |
|
223 |
System.out.println(NLS.bind("BackToText: Text {0} is missing", textid)); //$NON-NLS-1$ |
|
224 |
StatusLine.setMessage(NLS.bind("BackToText: Text {0} is missing", textid)); //$NON-NLS-1$ |
|
225 |
Log.severe(NLS.bind("BackToText: Text {0} is missing", textid)); //$NON-NLS-1$ |
|
226 |
return false; |
|
227 |
} |
|
228 |
|
|
229 |
String line_wordid = lineids.get(0); |
|
230 |
if (line_wordid == null) { |
|
231 |
System.out.println(SynopticMessages.BackToText_3); |
|
232 |
return false; |
|
233 |
} |
|
234 |
|
|
235 |
|
|
236 |
String focusid = null; |
|
237 |
if (lineids.size() > 0) focusid = lineids.get(0); |
|
238 |
|
|
239 |
//System.out.println("add otherWordIDs="+otherWordIDs); |
|
240 |
attachedBrowserEditor.addHighlightWordsById(lightred, otherWordIDs); |
|
241 |
|
|
242 |
//System.out.println("add linesids="+lineids); |
|
243 |
attachedBrowserEditor.addHighlightWordsById(red, lineids); |
|
244 |
|
|
245 |
associatedEditorsPreviousOtherWordIDs.put(editor, otherWordIDs); |
|
246 |
associatedEditorsPreviousLineids.put(editor, lineids); |
|
247 |
|
|
248 |
attachedBrowserEditor.setFocusedWordID(focusid); |
|
249 |
|
|
250 |
HashSet<int[]> posses = new HashSet<int[]>(); |
|
251 |
posses.add(pos); |
|
252 |
attachedBrowserEditor.setHighlightedArea(posses); |
|
253 |
|
|
254 |
// reload the page and styles |
|
255 |
attachedBrowserEditor.backToText(text, line_wordid);// open the page(S) containing the word with id=line_wordid |
|
256 |
|
|
257 |
IWorkbenchPage attachedPage = attachedBrowserEditor.getEditorSite().getPage(); |
|
258 |
attachedPage.activate(attachedBrowserEditor); |
|
259 |
|
|
260 |
return true; |
|
261 |
|
|
262 |
} catch (Exception err) { |
|
263 |
Log.severe(NLS.bind("Full text display failed: {0}", err)); //$NON-NLS-1$ |
|
264 |
Log.printStackTrace(err); |
|
265 |
} |
|
266 |
return false; |
|
267 |
} |
|
268 |
} |
|
0 | 269 |
tmp/org.txm.synopticeditor.rcp/src/org/txm/rcp/synoptic/commands/OpenEdition.java (revision 64) | ||
---|---|---|
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.rcp.synoptic.commands; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.eclipse.core.commands.AbstractHandler; |
|
34 |
import org.eclipse.core.commands.ExecutionEvent; |
|
35 |
import org.eclipse.core.commands.ExecutionException; |
|
36 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
37 |
import org.eclipse.jface.window.Window; |
|
38 |
import org.eclipse.swt.widgets.Shell; |
|
39 |
import org.eclipse.ui.IWorkbenchPage; |
|
40 |
import org.eclipse.ui.IWorkbenchWindow; |
|
41 |
import org.eclipse.ui.PlatformUI; |
|
42 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
43 |
import org.txm.objects.BaseParameters; |
|
44 |
import org.txm.objects.Text; |
|
45 |
import org.txm.rcp.synoptic.editor.EditionSelectorDialog; |
|
46 |
import org.txm.rcp.synoptic.editor.SynopticEditionEditor; |
|
47 |
import org.txm.rcp.synoptic.editor.SynopticEditorInput; |
|
48 |
import org.txm.rcpapplication.Messages; |
|
49 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
50 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
51 |
import org.txm.searchengine.cqp.corpus.Property; |
|
52 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
|
53 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
54 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
55 |
import org.txm.utils.logger.Log; |
|
56 |
import org.w3c.dom.Element; |
|
57 |
import org.w3c.dom.NodeList; |
|
58 |
|
|
59 |
import cern.colt.Arrays; |
|
60 |
import synopticeditor.SynopticMessages; |
|
61 |
// TODO: Auto-generated Javadoc |
|
62 |
/** |
|
63 |
* Open a text edition from: a main corpus : the first text of the maincorpus a |
|
64 |
* sub-corpus : the first text of the subcorpus a partition : the user must |
|
65 |
* choose one of the text used in the partition @ author mdecorde. |
|
66 |
*/ |
|
67 |
public class OpenEdition extends AbstractHandler { |
|
68 |
|
|
69 |
/** The Constant ID. */ |
|
70 |
public final static String ID = "org.txm.rcp.synoptic.commands.OpenEdition"; //$NON-NLS-1$ |
|
71 |
|
|
72 |
/** The lastopenedfile. */ |
|
73 |
public static String lastopenedfile; |
|
74 |
|
|
75 |
/* (non-Javadoc) |
|
76 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
77 |
*/ |
|
78 |
@Override |
|
79 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
80 |
|
|
81 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
82 |
if (selection.getFirstElement() instanceof Corpus) { |
|
83 |
try { |
|
84 |
Corpus c = (Corpus) selection.getFirstElement(); |
|
85 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
|
86 |
|
|
87 |
EditionSelectorDialog d = new EditionSelectorDialog(shell, c, null); |
|
88 |
SynopticEditionEditor editor = null; |
|
89 |
// if (c.getEditionNames().size() > 1 && d.open() == Window.OK) { |
|
90 |
// Object[] rez = d.getResult(); |
|
91 |
// String[] rezS = new String[rez.length]; |
|
92 |
// for (int i =0 ; i < rez.length ; i++) rezS[i] = rez[i].toString(); |
|
93 |
// editor = openEdition(c, rezS); |
|
94 |
// } else |
|
95 |
String[] editionsToOpen = getDefaultEditions(c); |
|
96 |
|
|
97 |
if (editionsToOpen.length == 0) { // the defaultEdition parameter is not set |
|
98 |
ArrayList<String> editionNames = c.getEditionNames(); |
|
99 |
if (editionNames.size() > 0) { // use the first edition declared |
|
100 |
editionsToOpen = new String[1]; |
|
101 |
editionsToOpen[0] = editionNames.get(0); |
|
102 |
Log.info(SynopticMessages.OpenEdition_0+editionNames.get(0)); |
|
103 |
} else { // no edition in the corpus |
|
104 |
Log.info(SynopticMessages.OpenEdition_1); |
|
105 |
editionsToOpen = new String[0]; |
|
106 |
return false; |
|
107 |
} |
|
108 |
} else { |
|
109 |
Log.info(SynopticMessages.OpenEdition_3+Arrays.toString(editionsToOpen)); |
|
110 |
} |
|
111 |
|
|
112 |
editor = openEdition(c, editionsToOpen); |
|
113 |
|
|
114 |
if (editor != null) |
|
115 |
editor.firstPage(); |
|
116 |
|
|
117 |
} catch (Exception e) { |
|
118 |
System.out.println(SynopticMessages.OpenEdition_4+e); |
|
119 |
org.txm.rcpapplication.utils.Logger.printStackTrace(e); |
|
120 |
} |
|
121 |
} else { |
|
122 |
System.out.println(SynopticMessages.OpenEdition_9); |
|
123 |
} |
|
124 |
return null; |
|
125 |
} |
|
126 |
public static String[] getDefaultEditions(Corpus c) { |
|
127 |
BaseParameters params = c.getBase().getBaseParameters(); |
|
128 |
Element editionsElement = params.getEditionsElement(params.getCorpusElement()); |
|
129 |
return editionsElement.getAttribute("default").split(","); //$NON-NLS-1$ //$NON-NLS-2$ |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* Open edition, but don't show a page |
|
134 |
* |
|
135 |
* @param corpus the corpus |
|
136 |
* @return the object |
|
137 |
*/ |
|
138 |
public static SynopticEditionEditor openEdition(Corpus corpus, String[] editions) { |
|
139 |
String textid = null; |
|
140 |
|
|
141 |
System.out.println("Opening edition of "+corpus); //$NON-NLS-1$ |
|
142 |
try { |
|
143 |
Text text = null; |
|
144 |
if (corpus instanceof Subcorpus) { |
|
145 |
Subcorpus sub = (Subcorpus)corpus; |
|
146 |
List<Match> matches = sub.getMatches(); |
|
147 |
if (matches.size() > 0) { |
|
148 |
StructuralUnit text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$ |
|
149 |
Property text_id = text_su.getProperty("id"); //$NON-NLS-1$ |
|
150 |
|
|
151 |
textid = matches.get(0).getValueForProperty(text_id); |
|
152 |
if (textid != null) text = corpus.getMainCorpus().getText(textid); |
|
153 |
} |
|
154 |
} |
|
155 |
// QueryResult result = corpus.query(new Query("<text> []"), "get_edition", false); //$NON-NLS-1$ //$NON-NLS-2$ |
|
156 |
// StructuralUnit text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$ |
|
157 |
// Property text_id = text_su.getProperty("id"); //$NON-NLS-1$ |
|
158 |
|
|
159 |
// if (result.getNMatch() > 0) textid = result.getMatches(0, 1).get(0).getValueForProperty(text_id); |
|
160 |
MainCorpus maincorpus = corpus.getMainCorpus(); |
|
161 |
|
|
162 |
// if (textid != null) text = maincorpus.getText(textid); |
|
163 |
|
|
164 |
if (text == null) { |
|
165 |
text = maincorpus.getFirstText(); |
|
166 |
|
|
167 |
if (text == null) { |
|
168 |
System.out.println("** Could not find first text of ID "+textid+SynopticMessages.OpenEdition_7); //$NON-NLS-1$ //$NON-NLS-1$ |
|
169 |
return null; |
|
170 |
} |
|
171 |
|
|
172 |
textid = text.getName(); |
|
173 |
} |
|
174 |
|
|
175 |
//String[] editions = {maincorpus.getDefaultEdition()}; |
|
176 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
|
177 |
IWorkbenchPage page = window.getActivePage(); |
|
178 |
|
|
179 |
SynopticEditorInput editorInput = new SynopticEditorInput(corpus, text.getName(), editions); |
|
180 |
SynopticEditionEditor editor = (SynopticEditionEditor) page.openEditor(editorInput, |
|
181 |
SynopticEditionEditor.ID, true); |
|
182 |
|
|
183 |
return editor; |
|
184 |
|
|
185 |
} catch (Exception e) { |
|
186 |
Log.printStackTrace(e); |
|
187 |
System.out.println(SynopticMessages.OpenEdition_10+e); |
|
188 |
return null; |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
0 | 192 |
tmp/org.txm.synopticeditor.rcp/src/org/txm/rcp/synoptic/preferences/EditionPreferencePage.java (revision 64) | ||
---|---|---|
1 |
package org.txm.rcp.synoptic.preferences; |
|
2 |
|
|
3 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
|
4 |
import org.eclipse.jface.preference.FieldEditorPreferencePage; |
|
5 |
import org.eclipse.ui.IWorkbench; |
|
6 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
|
7 |
import org.eclipse.ui.preferences.ScopedPreferenceStore; |
|
8 |
import org.txm.rcpapplication.Application; |
|
9 |
|
|
10 |
public class EditionPreferencePage extends FieldEditorPreferencePage |
|
11 |
implements IWorkbenchPreferencePage { |
|
12 |
ScopedPreferenceStore preferences; |
|
13 |
|
|
14 |
private BooleanFieldEditor slow_highlight; |
|
15 |
|
|
16 |
public static String SLOW_HIGHLIGHT = "org.txm.rcp.synoptic.slow_highlight"; |
|
17 |
|
|
18 |
public EditionPreferencePage() { |
|
19 |
super(); |
|
20 |
preferences = new ScopedPreferenceStore(org.eclipse.core.runtime.preferences.InstanceScope.INSTANCE, |
|
21 |
Application.PLUGIN_ID); |
|
22 |
setPreferenceStore(preferences); |
|
23 |
setTitle("Analec"); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public void init(IWorkbench workbench) { } |
|
28 |
|
|
29 |
@Override |
|
30 |
protected void createFieldEditors() { |
|
31 |
slow_highlight = new BooleanFieldEditor(SLOW_HIGHLIGHT, |
|
32 |
"Enable slow but robust word highlight", getFieldEditorParent()); |
|
33 |
addField(slow_highlight); |
|
34 |
} |
|
35 |
} |
|
0 | 36 |
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 }" |
Formats disponibles : Unified diff