Révision 3253
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMBrowserEditor.java (revision 3253) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.rcp.editors; |
29 | 29 |
|
30 |
import java.util.List; |
|
31 |
|
|
32 | 30 |
import org.eclipse.jface.action.MenuManager; |
33 | 31 |
import org.eclipse.jface.text.ITextSelection; |
34 | 32 |
import org.eclipse.jface.viewers.ISelection; |
35 | 33 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
36 | 34 |
import org.eclipse.jface.viewers.ISelectionProvider; |
37 |
import org.eclipse.swt.SWT; |
|
38 | 35 |
import org.eclipse.swt.browser.Browser; |
39 |
import org.eclipse.swt.browser.ProgressEvent; |
|
40 |
import org.eclipse.swt.browser.ProgressListener; |
|
41 |
import org.eclipse.swt.events.SelectionEvent; |
|
42 |
import org.eclipse.swt.events.SelectionListener; |
|
43 | 36 |
import org.eclipse.swt.graphics.Image; |
44 |
import org.eclipse.swt.layout.FormAttachment; |
|
45 |
import org.eclipse.swt.layout.FormData; |
|
46 |
import org.eclipse.swt.layout.FormLayout; |
|
47 |
import org.eclipse.swt.layout.RowData; |
|
48 |
import org.eclipse.swt.layout.RowLayout; |
|
49 |
import org.eclipse.swt.widgets.Button; |
|
50 | 37 |
import org.eclipse.swt.widgets.Composite; |
51 |
import org.eclipse.swt.widgets.Label; |
|
52 | 38 |
import org.eclipse.swt.widgets.Menu; |
53 | 39 |
import org.eclipse.ui.internal.browser.BrowserViewer; |
54 | 40 |
import org.eclipse.ui.internal.browser.WebBrowserEditor; |
55 |
import org.txm.objects.Edition; |
|
56 |
import org.txm.objects.Page; |
|
57 |
import org.txm.objects.Project; |
|
58 |
import org.txm.objects.Text; |
|
59 |
import org.txm.rcp.IImageKeys; |
|
60 |
import org.txm.rcp.StatusLine; |
|
61 | 41 |
import org.txm.rcp.messages.TXMUIMessages; |
62 | 42 |
|
63 | 43 |
/** |
... | ... | |
71 | 51 |
public class TXMBrowserEditor extends WebBrowserEditor { |
72 | 52 |
|
73 | 53 |
/** The Constant ID. */ |
74 |
public final static String ID = "org.txm.rcp.editors.TXMBrowser"; //$NON-NLS-1$
|
|
54 |
public final static String ID = TXMBrowserEditor.class.getName(); //$NON-NLS-1$
|
|
75 | 55 |
|
76 |
private ProgressListener progresslistener; |
|
77 |
|
|
78 |
private List<String> wordids; |
|
79 |
|
|
80 |
private List<String> lineids; |
|
81 |
|
|
82 |
/** The edition. */ |
|
83 |
Edition edition; |
|
84 |
|
|
85 |
/** The current page. */ |
|
86 |
Page currentPage; |
|
87 |
|
|
88 |
/** The page_label. */ |
|
89 |
Label page_label; |
|
90 |
|
|
91 | 56 |
/** |
92 | 57 |
* Instantiates a new txm browser. |
93 | 58 |
*/ |
... | ... | |
115 | 80 |
super.setTitleImage(titleImage); |
116 | 81 |
} |
117 | 82 |
|
118 |
/** |
|
119 |
* |
|
120 |
* @param wordids2 all the words to highlight |
|
121 |
* @param lineids2 the words to highlight better and to scroll to |
|
122 |
*/ |
|
123 |
public void setWordsIds(List<String> wordids2, List<String> lineids2) { |
|
124 |
this.wordids = wordids2; |
|
125 |
this.lineids = lineids2; |
|
126 |
|
|
127 |
if (progresslistener != null) { |
|
128 |
this.getBrowser().removeProgressListener(progresslistener); |
|
129 |
} |
|
130 |
|
|
131 |
progresslistener = new ProgressListener() { |
|
132 |
|
|
133 |
@Override |
|
134 |
public void changed(ProgressEvent event) {} |
|
135 |
|
|
136 |
@Override |
|
137 |
public void completed(ProgressEvent event) { |
|
138 |
Page currentpage = getCurrentPage(); |
|
139 |
// System.out.println("Highlight ! "+currentpage.getEdition().getText()+" wordids ="+wordids); |
|
140 |
|
|
141 |
for (String wordid : wordids) { |
|
142 |
String highlightscript = "try { var elt = document.getElementById(\"" + wordid + "\");" + //$NON-NLS-1$ //$NON-NLS-2$ |
|
143 |
"elt.style.backgroundColor=\"#F9D0D0\";" //$NON-NLS-1$ |
|
144 |
+ |
|
145 |
"elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$ |
|
146 |
"elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$ |
|
147 |
"elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$ |
|
148 |
"elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$ |
|
149 |
"} catch (e) { };"; //$NON-NLS-1$ |
|
150 |
|
|
151 |
getBrowser().execute(highlightscript); |
|
152 |
} |
|
153 |
|
|
154 |
for (String wordid : lineids) { |
|
155 |
String highlightscript = "try { var elt = document.getElementById(\"" + wordid + "\");" + //$NON-NLS-1$ //$NON-NLS-2$ |
|
156 |
"elt.style.backgroundColor=\"#F9A0A0\";" + //$NON-NLS-1$ |
|
157 |
"elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$ |
|
158 |
"elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$ |
|
159 |
"elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$ |
|
160 |
"elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$ |
|
161 |
"} catch (e) { };"; //$NON-NLS-1$ |
|
162 |
|
|
163 |
getBrowser().execute(highlightscript); |
|
164 |
} |
|
165 |
if (lineids.size() > 0) { |
|
166 |
String script = "try { document.getElementById(\"" + lineids.get(0) + "\").scrollIntoView(true); } catch (e) { };"; //$NON-NLS-1$ //$NON-NLS-2$ |
|
167 |
getBrowser().execute(script); |
|
168 |
} |
|
169 |
} |
|
170 |
}; |
|
171 |
getBrowser().addProgressListener(progresslistener); |
|
172 |
new CommandLink(this, getBrowser()); |
|
173 |
} |
|
83 |
// /**
|
|
84 |
// *
|
|
85 |
// * @param wordids2 all the words to highlight
|
|
86 |
// * @param lineids2 the words to highlight better and to scroll to
|
|
87 |
// */
|
|
88 |
// public void setWordsIds(List<String> wordids2, List<String> lineids2) {
|
|
89 |
// this.wordids = wordids2;
|
|
90 |
// this.lineids = lineids2;
|
|
91 |
// |
|
92 |
// if (progresslistener != null) {
|
|
93 |
// this.getBrowser().removeProgressListener(progresslistener);
|
|
94 |
// }
|
|
95 |
// |
|
96 |
// progresslistener = new ProgressListener() {
|
|
97 |
// |
|
98 |
// @Override
|
|
99 |
// public void changed(ProgressEvent event) {}
|
|
100 |
// |
|
101 |
// @Override
|
|
102 |
// public void completed(ProgressEvent event) {
|
|
103 |
// Page currentpage = getCurrentPage();
|
|
104 |
// // System.out.println("Highlight ! "+currentpage.getEdition().getText()+" wordids ="+wordids);
|
|
105 |
// |
|
106 |
// for (String wordid : wordids) {
|
|
107 |
// String highlightscript = "try { var elt = document.getElementById(\"" + wordid + "\");" + //$NON-NLS-1$ //$NON-NLS-2$
|
|
108 |
// "elt.style.backgroundColor=\"#F9D0D0\";" //$NON-NLS-1$
|
|
109 |
// +
|
|
110 |
// "elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
|
|
111 |
// "elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$
|
|
112 |
// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
|
|
113 |
// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
|
|
114 |
// "} catch (e) { };"; //$NON-NLS-1$
|
|
115 |
// |
|
116 |
// getBrowser().execute(highlightscript);
|
|
117 |
// }
|
|
118 |
// |
|
119 |
// for (String wordid : lineids) {
|
|
120 |
// String highlightscript = "try { var elt = document.getElementById(\"" + wordid + "\");" + //$NON-NLS-1$ //$NON-NLS-2$
|
|
121 |
// "elt.style.backgroundColor=\"#F9A0A0\";" + //$NON-NLS-1$
|
|
122 |
// "elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
|
|
123 |
// "elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$
|
|
124 |
// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
|
|
125 |
// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
|
|
126 |
// "} catch (e) { };"; //$NON-NLS-1$
|
|
127 |
// |
|
128 |
// getBrowser().execute(highlightscript);
|
|
129 |
// }
|
|
130 |
// if (lineids.size() > 0) {
|
|
131 |
// String script = "try { document.getElementById(\"" + lineids.get(0) + "\").scrollIntoView(true); } catch (e) { };"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
132 |
// getBrowser().execute(script);
|
|
133 |
// }
|
|
134 |
// }
|
|
135 |
// };
|
|
136 |
// getBrowser().addProgressListener(progresslistener);
|
|
137 |
// new CommandLink(this, getBrowser());
|
|
138 |
// }
|
|
174 | 139 |
|
175 |
/** |
|
176 |
* Sets the edition. |
|
177 |
* |
|
178 |
* @param edition the new edition |
|
179 |
*/ |
|
180 |
public void setEdition(Edition edition) { |
|
181 |
this.edition = edition; |
|
182 |
} |
|
140 |
// /**
|
|
141 |
// * Sets the edition.
|
|
142 |
// *
|
|
143 |
// * @param edition the new edition
|
|
144 |
// */
|
|
145 |
// public void setEdition(Edition edition) {
|
|
146 |
// this.edition = edition;
|
|
147 |
// }
|
|
183 | 148 |
|
184 |
/** |
|
185 |
* Make page label. |
|
186 |
* |
|
187 |
* @return the string |
|
188 |
*/ |
|
189 |
public String makePageLabel() { |
|
190 |
return currentPage.getName() |
|
191 |
+ " / " + currentPage.getEdition().getNumPages(); //$NON-NLS-1$ |
|
192 |
} |
|
149 |
// /** |
|
150 |
// * Make page label. |
|
151 |
// * |
|
152 |
// * @return the string |
|
153 |
// */ |
|
154 |
// public String makePageLabel() { |
|
155 |
// return currentPage.getName() |
|
156 |
// + " / " + currentPage.getEdition().getNumPages(); //$NON-NLS-1$ |
|
157 |
// } |
|
158 |
// |
|
159 |
// /** |
|
160 |
// * Show page. |
|
161 |
// * |
|
162 |
// * @param page the page |
|
163 |
// */ |
|
164 |
// public void showPage(Page page) { |
|
165 |
// edition = page.getEdition(); |
|
166 |
// currentPage = page; |
|
167 |
// this.webBrowser.setURL(currentPage.toURL()); |
|
168 |
// page_label.setText(makePageLabel()); |
|
169 |
// } |
|
193 | 170 |
|
194 |
/** |
|
195 |
* Show page. |
|
196 |
* |
|
197 |
* @param page the page |
|
198 |
*/ |
|
199 |
public void showPage(Page page) { |
|
200 |
edition = page.getEdition(); |
|
201 |
currentPage = page; |
|
202 |
this.webBrowser.setURL(currentPage.toURL()); |
|
203 |
page_label.setText(makePageLabel()); |
|
204 |
} |
|
171 |
// /** |
|
172 |
// * First text. |
|
173 |
// */ |
|
174 |
// public void firstText() { |
|
175 |
// Text current = this.currentPage.getEdition().getText(); |
|
176 |
// Project corpus = current.getProject(); |
|
177 |
// Text firstText = corpus.getFirstText(); |
|
178 |
// |
|
179 |
// if (firstText != null) { |
|
180 |
// String editionName = corpus.getDefaultEditionName(); |
|
181 |
// currentPage = firstText.getEdition(editionName).getFirstPage(); |
|
182 |
// if (currentPage == null) { |
|
183 |
// StatusLine.setMessage(TXMUIMessages.noPreviousText); |
|
184 |
// return; |
|
185 |
// } |
|
186 |
// this.setEdition(firstText.getEdition(editionName)); |
|
187 |
// this.webBrowser.setURL(currentPage.toURL()); |
|
188 |
// page_label.setText(makePageLabel()); |
|
189 |
// } |
|
190 |
// } |
|
191 |
// |
|
192 |
// /** |
|
193 |
// * Last text. |
|
194 |
// */ |
|
195 |
// public void lastText() { |
|
196 |
// Text current = this.currentPage.getEdition().getText(); |
|
197 |
// Project b = current.getProject(); |
|
198 |
// Text lastText = b.getLastText(); |
|
199 |
// |
|
200 |
// if (lastText != null) { |
|
201 |
// currentPage = lastText.getEdition(b.getDefaultEditionName()).getFirstPage(); |
|
202 |
// if (currentPage == null) { |
|
203 |
// StatusLine.setMessage(TXMUIMessages.noTextNext); |
|
204 |
// return; |
|
205 |
// } |
|
206 |
// this.setEdition(lastText.getEdition(b.getDefaultEditionName())); |
|
207 |
// this.webBrowser.setURL(currentPage.toURL()); |
|
208 |
// page_label.setText(makePageLabel()); |
|
209 |
// } |
|
210 |
// } |
|
211 |
// |
|
212 |
// /** |
|
213 |
// * First page. |
|
214 |
// */ |
|
215 |
// public void firstPage() { |
|
216 |
// // System.out.println(Messages.TxmBrowser_1+currentPage); |
|
217 |
// currentPage = edition.getFirstPage(); |
|
218 |
// this.webBrowser.setURL(currentPage.toURL()); |
|
219 |
// page_label.setText(makePageLabel()); |
|
220 |
// } |
|
221 |
// |
|
222 |
// /** |
|
223 |
// * Last page. |
|
224 |
// */ |
|
225 |
// public void lastPage() { |
|
226 |
// // System.out.println(Messages.TxmBrowser_2+currentPage); |
|
227 |
// |
|
228 |
// if (currentPage != null && currentPage.getFile().equals(edition.getLastPage().getFile())) |
|
229 |
// return; |
|
230 |
// currentPage = edition.getLastPage(); |
|
231 |
// this.webBrowser.setURL(currentPage.toURL()); |
|
232 |
// page_label.setText(makePageLabel()); |
|
233 |
// } |
|
234 |
// |
|
235 |
// /** |
|
236 |
// * Previous page. |
|
237 |
// */ |
|
238 |
// public void previousPage() { |
|
239 |
// // System.out.println(Messages.TxmBrowser_3+currentPage); |
|
240 |
// if (currentPage != null) { |
|
241 |
// Page previous = edition.getPreviousPage(currentPage); |
|
242 |
// if (previous == currentPage) { |
|
243 |
// previousText(true); |
|
244 |
// } |
|
245 |
// else { |
|
246 |
// currentPage = previous; |
|
247 |
// this.webBrowser.setURL(currentPage.toURL()); |
|
248 |
// } |
|
249 |
// } |
|
250 |
// else |
|
251 |
// firstPage(); |
|
252 |
// page_label.setText(makePageLabel()); |
|
253 |
// } |
|
254 |
// |
|
255 |
// /** |
|
256 |
// * Next page. |
|
257 |
// */ |
|
258 |
// public void nextPage() { |
|
259 |
// // System.out.println(Messages.TxmBrowser_4+currentPage); |
|
260 |
// if (currentPage != null) { |
|
261 |
// Page next = edition.getNextPage(currentPage); |
|
262 |
// if (currentPage == next) { |
|
263 |
// nextText(); |
|
264 |
// } |
|
265 |
// else { |
|
266 |
// currentPage = next; |
|
267 |
// this.webBrowser.setURL(currentPage.toURL()); |
|
268 |
// } |
|
269 |
// |
|
270 |
// } |
|
271 |
// else |
|
272 |
// firstPage(); |
|
273 |
// page_label.setText(makePageLabel()); |
|
274 |
// } |
|
275 |
// |
|
276 |
// /** |
|
277 |
// * Previous text. |
|
278 |
// * |
|
279 |
// * @param fromNextText |
|
280 |
// */ |
|
281 |
// public void previousText(boolean fromNextText) { |
|
282 |
// |
|
283 |
// Text current = this.currentPage.getEdition().getText(); |
|
284 |
// Project corpus = current.getProject(); |
|
285 |
// Text previousText = corpus.getPreviousText(current); |
|
286 |
// |
|
287 |
// if (previousText != null) { |
|
288 |
// String editionName = corpus.getDefaultEditionName(); |
|
289 |
// if (fromNextText) { |
|
290 |
// currentPage = previousText.getEdition(editionName).getLastPage(); |
|
291 |
// } |
|
292 |
// else { |
|
293 |
// currentPage = previousText.getEdition(editionName).getFirstPage(); |
|
294 |
// } |
|
295 |
// if (currentPage == null) { |
|
296 |
// StatusLine.setMessage(TXMUIMessages.noPreviousText); |
|
297 |
// return; |
|
298 |
// } |
|
299 |
// this.setEdition(previousText.getEdition(editionName)); |
|
300 |
// this.webBrowser.setURL(currentPage.toURL()); |
|
301 |
// page_label.setText(makePageLabel()); |
|
302 |
// } |
|
303 |
// // System.out.println("Previous texts "+previousText); |
|
304 |
// } |
|
305 |
// |
|
306 |
// /** |
|
307 |
// * Next text. |
|
308 |
// */ |
|
309 |
// public void nextText() { |
|
310 |
// Text current = this.currentPage.getEdition().getText(); |
|
311 |
// Project b = current.getProject(); |
|
312 |
// Text nextText = b.getNextText(current); |
|
313 |
// |
|
314 |
// if (nextText != null) { |
|
315 |
// currentPage = nextText.getEdition(b.getDefaultEditionName()).getFirstPage(); |
|
316 |
// if (currentPage == null) { |
|
317 |
// StatusLine.setMessage(TXMUIMessages.noTextNext); |
|
318 |
// return; |
|
319 |
// } |
|
320 |
// this.setEdition(nextText.getEdition(b.getDefaultEditionName())); |
|
321 |
// this.webBrowser.setURL(currentPage.toURL()); |
|
322 |
// page_label.setText(makePageLabel()); |
|
323 |
// } |
|
324 |
// // System.out.println("Next texts "+nextText); |
|
325 |
// } |
|
205 | 326 |
|
206 |
/** |
|
207 |
* First text. |
|
208 |
*/ |
|
209 |
public void firstText() { |
|
210 |
Text current = this.currentPage.getEdition().getText(); |
|
211 |
Project corpus = current.getProject(); |
|
212 |
Text firstText = corpus.getFirstText(); |
|
213 |
|
|
214 |
if (firstText != null) { |
|
215 |
String editionName = corpus.getDefaultEditionName(); |
|
216 |
currentPage = firstText.getEdition(editionName).getFirstPage(); |
|
217 |
if (currentPage == null) { |
|
218 |
StatusLine.setMessage(TXMUIMessages.noPreviousText); |
|
219 |
return; |
|
220 |
} |
|
221 |
this.setEdition(firstText.getEdition(editionName)); |
|
222 |
this.webBrowser.setURL(currentPage.toURL()); |
|
223 |
page_label.setText(makePageLabel()); |
|
224 |
} |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* Last text. |
|
229 |
*/ |
|
230 |
public void lastText() { |
|
231 |
Text current = this.currentPage.getEdition().getText(); |
|
232 |
Project b = current.getProject(); |
|
233 |
Text lastText = b.getLastText(); |
|
234 |
|
|
235 |
if (lastText != null) { |
|
236 |
currentPage = lastText.getEdition(b.getDefaultEditionName()).getFirstPage(); |
|
237 |
if (currentPage == null) { |
|
238 |
StatusLine.setMessage(TXMUIMessages.noTextNext); |
|
239 |
return; |
|
240 |
} |
|
241 |
this.setEdition(lastText.getEdition(b.getDefaultEditionName())); |
|
242 |
this.webBrowser.setURL(currentPage.toURL()); |
|
243 |
page_label.setText(makePageLabel()); |
|
244 |
} |
|
245 |
} |
|
246 |
|
|
247 |
/** |
|
248 |
* First page. |
|
249 |
*/ |
|
250 |
public void firstPage() { |
|
251 |
// System.out.println(Messages.TxmBrowser_1+currentPage); |
|
252 |
currentPage = edition.getFirstPage(); |
|
253 |
this.webBrowser.setURL(currentPage.toURL()); |
|
254 |
page_label.setText(makePageLabel()); |
|
255 |
} |
|
256 |
|
|
257 |
/** |
|
258 |
* Last page. |
|
259 |
*/ |
|
260 |
public void lastPage() { |
|
261 |
// System.out.println(Messages.TxmBrowser_2+currentPage); |
|
262 |
|
|
263 |
if (currentPage != null && currentPage.getFile().equals(edition.getLastPage().getFile())) |
|
264 |
return; |
|
265 |
currentPage = edition.getLastPage(); |
|
266 |
this.webBrowser.setURL(currentPage.toURL()); |
|
267 |
page_label.setText(makePageLabel()); |
|
268 |
} |
|
269 |
|
|
270 |
/** |
|
271 |
* Previous page. |
|
272 |
*/ |
|
273 |
public void previousPage() { |
|
274 |
// System.out.println(Messages.TxmBrowser_3+currentPage); |
|
275 |
if (currentPage != null) { |
|
276 |
Page previous = edition.getPreviousPage(currentPage); |
|
277 |
if (previous == currentPage) { |
|
278 |
previousText(true); |
|
279 |
} |
|
280 |
else { |
|
281 |
currentPage = previous; |
|
282 |
this.webBrowser.setURL(currentPage.toURL()); |
|
283 |
} |
|
284 |
} |
|
285 |
else |
|
286 |
firstPage(); |
|
287 |
page_label.setText(makePageLabel()); |
|
288 |
} |
|
289 |
|
|
290 |
/** |
|
291 |
* Next page. |
|
292 |
*/ |
|
293 |
public void nextPage() { |
|
294 |
// System.out.println(Messages.TxmBrowser_4+currentPage); |
|
295 |
if (currentPage != null) { |
|
296 |
Page next = edition.getNextPage(currentPage); |
|
297 |
if (currentPage == next) { |
|
298 |
nextText(); |
|
299 |
} |
|
300 |
else { |
|
301 |
currentPage = next; |
|
302 |
this.webBrowser.setURL(currentPage.toURL()); |
|
303 |
} |
|
304 |
|
|
305 |
} |
|
306 |
else |
|
307 |
firstPage(); |
|
308 |
page_label.setText(makePageLabel()); |
|
309 |
} |
|
310 |
|
|
311 |
/** |
|
312 |
* Previous text. |
|
313 |
* |
|
314 |
* @param fromNextText |
|
315 |
*/ |
|
316 |
public void previousText(boolean fromNextText) { |
|
317 |
|
|
318 |
Text current = this.currentPage.getEdition().getText(); |
|
319 |
Project corpus = current.getProject(); |
|
320 |
Text previousText = corpus.getPreviousText(current); |
|
321 |
|
|
322 |
if (previousText != null) { |
|
323 |
String editionName = corpus.getDefaultEditionName(); |
|
324 |
if (fromNextText) { |
|
325 |
currentPage = previousText.getEdition(editionName).getLastPage(); |
|
326 |
} |
|
327 |
else { |
|
328 |
currentPage = previousText.getEdition(editionName).getFirstPage(); |
|
329 |
} |
|
330 |
if (currentPage == null) { |
|
331 |
StatusLine.setMessage(TXMUIMessages.noPreviousText); |
|
332 |
return; |
|
333 |
} |
|
334 |
this.setEdition(previousText.getEdition(editionName)); |
|
335 |
this.webBrowser.setURL(currentPage.toURL()); |
|
336 |
page_label.setText(makePageLabel()); |
|
337 |
} |
|
338 |
// System.out.println("Previous texts "+previousText); |
|
339 |
} |
|
340 |
|
|
341 |
/** |
|
342 |
* Next text. |
|
343 |
*/ |
|
344 |
public void nextText() { |
|
345 |
Text current = this.currentPage.getEdition().getText(); |
|
346 |
Project b = current.getProject(); |
|
347 |
Text nextText = b.getNextText(current); |
|
348 |
|
|
349 |
if (nextText != null) { |
|
350 |
currentPage = nextText.getEdition(b.getDefaultEditionName()).getFirstPage(); |
|
351 |
if (currentPage == null) { |
|
352 |
StatusLine.setMessage(TXMUIMessages.noTextNext); |
|
353 |
return; |
|
354 |
} |
|
355 |
this.setEdition(nextText.getEdition(b.getDefaultEditionName())); |
|
356 |
this.webBrowser.setURL(currentPage.toURL()); |
|
357 |
page_label.setText(makePageLabel()); |
|
358 |
} |
|
359 |
// System.out.println("Next texts "+nextText); |
|
360 |
} |
|
361 |
|
|
362 | 327 |
/* |
363 | 328 |
* (non-Javadoc) |
364 | 329 |
* @see org.eclipse.ui.internal.browser.WebBrowserEditor#createPartControl(org.eclipse.swt.widgets.Composite) |
... | ... | |
373 | 338 |
return; |
374 | 339 |
} |
375 | 340 |
|
376 |
RowLayout navigLayout = new RowLayout(SWT.HORIZONTAL); |
|
377 |
navigLayout.justify = true; |
|
378 |
Composite panneau = new Composite(parent, SWT.NONE); |
|
379 |
panneau.setLayout(navigLayout); |
|
341 |
// RowLayout navigLayout = new RowLayout(SWT.HORIZONTAL); |
|
342 |
// navigLayout.justify = true; |
|
343 |
// Composite panneau = new Composite(parent, SWT.NONE); |
|
344 |
// panneau.setLayout(navigLayout); |
|
345 |
// |
|
346 |
// RowLayout subLayout = new RowLayout(SWT.HORIZONTAL); |
|
347 |
// subLayout.pack = true; |
|
348 |
// subLayout.center = true; |
|
349 |
// subLayout.marginBottom = subLayout.marginHeight = 0; |
|
350 |
// subLayout.marginTop = subLayout.marginWidth = 0; |
|
351 |
// Composite subPanneau = new Composite(panneau, SWT.NONE); |
|
352 |
// subPanneau.setLayout(subLayout); |
|
353 |
// subPanneau.setLayoutData(new RowData(450, 22)); |
|
354 |
// |
|
355 |
// Button firstText = new Button(subPanneau, SWT.FLAT); |
|
356 |
// Button previousText = new Button(subPanneau, SWT.FLAT); |
|
357 |
// Button first = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
358 |
// Button previous = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
359 |
// page_label = new Label(subPanneau, SWT.NONE); |
|
360 |
// Button next = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
361 |
// Button last = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
362 |
// Button nextText = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
363 |
// Button lastText = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
364 |
// |
|
365 |
// // set sizes |
|
366 |
// page_label.setLayoutData(new RowData(50, 20)); |
|
367 |
// firstText.setLayoutData(new RowData(30, 20)); |
|
368 |
// first.setLayoutData(new RowData(30, 20)); |
|
369 |
// previous.setLayoutData(new RowData(30, 20)); |
|
370 |
// next.setLayoutData(new RowData(30, 20)); |
|
371 |
// last.setLayoutData(new RowData(30, 20)); |
|
372 |
// nextText.setLayoutData(new RowData(30, 20)); |
|
373 |
// previousText.setLayoutData(new RowData(30, 20)); |
|
374 |
// lastText.setLayoutData(new RowData(30, 20)); |
|
380 | 375 |
|
381 |
RowLayout subLayout = new RowLayout(SWT.HORIZONTAL); |
|
382 |
subLayout.pack = true; |
|
383 |
subLayout.center = true; |
|
384 |
subLayout.marginBottom = subLayout.marginHeight = 0; |
|
385 |
subLayout.marginTop = subLayout.marginWidth = 0; |
|
386 |
Composite subPanneau = new Composite(panneau, SWT.NONE); |
|
387 |
subPanneau.setLayout(subLayout); |
|
388 |
subPanneau.setLayoutData(new RowData(450, 22)); |
|
389 | 376 |
|
390 |
Button firstText = new Button(subPanneau, SWT.FLAT); |
|
391 |
Button previousText = new Button(subPanneau, SWT.FLAT); |
|
392 |
Button first = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
393 |
Button previous = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
394 |
page_label = new Label(subPanneau, SWT.NONE); |
|
395 |
Button next = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
396 |
Button last = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
397 |
Button nextText = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
398 |
Button lastText = new Button(subPanneau, SWT.FLAT | SWT.PUSH); |
|
377 |
// // set labels |
|
378 |
// page_label.setText(""); //$NON-NLS-1$ |
|
379 |
// firstText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWINDSTART)); |
|
380 |
// firstText.setToolTipText("|<<"); |
|
381 |
// previousText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWIND)); |
|
382 |
// previousText.setToolTipText(TXMUIMessages.previousText); |
|
383 |
// first.setImage(IImageKeys.getImage(IImageKeys.CTRLSTART)); |
|
384 |
// first.setToolTipText(TXMUIMessages.common_beginning); |
|
385 |
// previous.setImage(IImageKeys.getImage(IImageKeys.CTRLREVERSE)); |
|
386 |
// previous.setToolTipText(TXMUIMessages.previousPage); |
|
387 |
// next.setImage(IImageKeys.getImage(IImageKeys.CTRLPLAY)); |
|
388 |
// next.setToolTipText(TXMUIMessages.nextPage); |
|
389 |
// last.setImage(IImageKeys.getImage(IImageKeys.CTRLEND)); |
|
390 |
// last.setToolTipText(TXMUIMessages.common_end); |
|
391 |
// nextText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARD)); |
|
392 |
// nextText.setToolTipText(TXMUIMessages.nextText); |
|
393 |
// lastText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARDEND)); |
|
394 |
// lastText.setToolTipText(">>|"); |
|
395 |
// |
|
396 |
// |
|
397 |
// // set listeners |
|
398 |
// first.addSelectionListener(new SelectionListener() { |
|
399 |
// |
|
400 |
// @Override |
|
401 |
// public void widgetDefaultSelected(SelectionEvent e) { |
|
402 |
// firstPage(); |
|
403 |
// } |
|
404 |
// |
|
405 |
// @Override |
|
406 |
// public void widgetSelected(SelectionEvent e) { |
|
407 |
// firstPage(); |
|
408 |
// } |
|
409 |
// }); |
|
410 |
// previous.addSelectionListener(new SelectionListener() { |
|
411 |
// |
|
412 |
// @Override |
|
413 |
// public void widgetDefaultSelected(SelectionEvent e) { |
|
414 |
// previousPage(); |
|
415 |
// } |
|
416 |
// |
|
417 |
// @Override |
|
418 |
// public void widgetSelected(SelectionEvent e) { |
|
419 |
// previousPage(); |
|
420 |
// } |
|
421 |
// }); |
|
422 |
// next.addSelectionListener(new SelectionListener() { |
|
423 |
// |
|
424 |
// @Override |
|
425 |
// public void widgetDefaultSelected(SelectionEvent e) { |
|
426 |
// nextPage(); |
|
427 |
// } |
|
428 |
// |
|
429 |
// @Override |
|
430 |
// public void widgetSelected(SelectionEvent e) { |
|
431 |
// nextPage(); |
|
432 |
// } |
|
433 |
// }); |
|
434 |
// last.addSelectionListener(new SelectionListener() { |
|
435 |
// |
|
436 |
// @Override |
|
437 |
// public void widgetDefaultSelected(SelectionEvent e) { |
|
438 |
// lastPage(); |
|
439 |
// } |
|
440 |
// |
|
441 |
// @Override |
|
442 |
// public void widgetSelected(SelectionEvent e) { |
|
443 |
// lastPage(); |
|
444 |
// } |
|
445 |
// }); |
|
446 |
// nextText.addSelectionListener(new SelectionListener() { |
|
447 |
// |
|
448 |
// @Override |
|
449 |
// public void widgetDefaultSelected(SelectionEvent e) { |
|
450 |
// nextText(); |
|
451 |
// } |
|
452 |
// |
|
453 |
// @Override |
|
454 |
// public void widgetSelected(SelectionEvent e) { |
|
455 |
// nextText(); |
|
456 |
// } |
|
457 |
// }); |
|
458 |
// // set listeners |
|
459 |
// previousText.addSelectionListener(new SelectionListener() { |
|
460 |
// |
|
461 |
// @Override |
|
462 |
// public void widgetDefaultSelected(SelectionEvent e) { |
|
463 |
// previousText(false); |
|
464 |
// } |
|
465 |
// |
|
466 |
// @Override |
|
467 |
// public void widgetSelected(SelectionEvent e) { |
|
468 |
// previousText(false); |
|
469 |
// } |
|
470 |
// }); |
|
471 |
// lastText.addSelectionListener(new SelectionListener() { |
|
472 |
// |
|
473 |
// @Override |
|
474 |
// public void widgetDefaultSelected(SelectionEvent e) { |
|
475 |
// lastText(); |
|
476 |
// } |
|
477 |
// |
|
478 |
// @Override |
|
479 |
// public void widgetSelected(SelectionEvent e) { |
|
480 |
// lastText(); |
|
481 |
// } |
|
482 |
// }); |
|
483 |
// // set listeners |
|
484 |
// firstText.addSelectionListener(new SelectionListener() { |
|
485 |
// |
|
486 |
// @Override |
|
487 |
// public void widgetDefaultSelected(SelectionEvent e) { |
|
488 |
// firstText(); |
|
489 |
// } |
|
490 |
// |
|
491 |
// @Override |
|
492 |
// public void widgetSelected(SelectionEvent e) { |
|
493 |
// firstText(); |
|
494 |
// } |
|
495 |
// }); |
|
496 |
// |
|
497 |
// subPanneau.pack(); |
|
498 |
// panneau.pack(); |
|
399 | 499 |
|
400 |
// set sizes |
|
401 |
page_label.setLayoutData(new RowData(50, 20)); |
|
402 |
firstText.setLayoutData(new RowData(30, 20)); |
|
403 |
first.setLayoutData(new RowData(30, 20)); |
|
404 |
previous.setLayoutData(new RowData(30, 20)); |
|
405 |
next.setLayoutData(new RowData(30, 20)); |
|
406 |
last.setLayoutData(new RowData(30, 20)); |
|
407 |
nextText.setLayoutData(new RowData(30, 20)); |
|
408 |
previousText.setLayoutData(new RowData(30, 20)); |
|
409 |
lastText.setLayoutData(new RowData(30, 20)); |
|
500 |
// FormLayout parentLayout = new FormLayout(); |
|
410 | 501 |
|
502 |
// FormData datatop = new FormData(); |
|
503 |
// datatop.top = new FormAttachment(0, 0); |
|
504 |
// datatop.left = new FormAttachment(0, 0); |
|
505 |
// datatop.right = new FormAttachment(100, 0); |
|
506 |
// datatop.bottom = new FormAttachment(panneau, 0); |
|
507 |
// webBrowser.setLayoutData(datatop); |
|
508 |
// |
|
509 |
// FormData databottom = new FormData(200, 30); |
|
510 |
// databottom.bottom = new FormAttachment(100, 0); |
|
511 |
// databottom.left = new FormAttachment(30, -100); |
|
512 |
// databottom.right = new FormAttachment(80, 100); |
|
513 |
// panneau.setLayoutData(databottom); |
|
514 |
// |
|
515 |
// parent.setLayout(parentLayout); |
|
516 |
// parent.pack(); |
|
411 | 517 |
|
412 |
// set labels |
|
413 |
page_label.setText(""); //$NON-NLS-1$ |
|
414 |
firstText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWINDSTART)); |
|
415 |
firstText.setToolTipText("|<<"); |
|
416 |
previousText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWIND)); |
|
417 |
previousText.setToolTipText(TXMUIMessages.previousText); |
|
418 |
first.setImage(IImageKeys.getImage(IImageKeys.CTRLSTART)); |
|
419 |
first.setToolTipText(TXMUIMessages.common_beginning); |
|
420 |
previous.setImage(IImageKeys.getImage(IImageKeys.CTRLREVERSE)); |
|
421 |
previous.setToolTipText(TXMUIMessages.previousPage); |
|
422 |
next.setImage(IImageKeys.getImage(IImageKeys.CTRLPLAY)); |
|
423 |
next.setToolTipText(TXMUIMessages.nextPage); |
|
424 |
last.setImage(IImageKeys.getImage(IImageKeys.CTRLEND)); |
|
425 |
last.setToolTipText(TXMUIMessages.common_end); |
|
426 |
nextText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARD)); |
|
427 |
nextText.setToolTipText(TXMUIMessages.nextText); |
|
428 |
lastText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARDEND)); |
|
429 |
lastText.setToolTipText(">>|"); |
|
430 |
|
|
431 |
|
|
432 |
// set listeners |
|
433 |
first.addSelectionListener(new SelectionListener() { |
|
434 |
|
|
435 |
@Override |
|
436 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
437 |
firstPage(); |
|
438 |
} |
|
439 |
|
|
440 |
@Override |
|
441 |
public void widgetSelected(SelectionEvent e) { |
|
442 |
firstPage(); |
|
443 |
} |
|
444 |
}); |
|
445 |
previous.addSelectionListener(new SelectionListener() { |
|
446 |
|
|
447 |
@Override |
|
448 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
449 |
previousPage(); |
|
450 |
} |
|
451 |
|
|
452 |
@Override |
|
453 |
public void widgetSelected(SelectionEvent e) { |
|
454 |
previousPage(); |
|
455 |
} |
|
456 |
}); |
|
457 |
next.addSelectionListener(new SelectionListener() { |
|
458 |
|
|
459 |
@Override |
|
460 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
461 |
nextPage(); |
|
462 |
} |
|
463 |
|
|
464 |
@Override |
|
465 |
public void widgetSelected(SelectionEvent e) { |
|
466 |
nextPage(); |
|
467 |
} |
|
468 |
}); |
|
469 |
last.addSelectionListener(new SelectionListener() { |
|
470 |
|
|
471 |
@Override |
|
472 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
473 |
lastPage(); |
|
474 |
} |
|
475 |
|
|
476 |
@Override |
|
477 |
public void widgetSelected(SelectionEvent e) { |
|
478 |
lastPage(); |
|
479 |
} |
|
480 |
}); |
|
481 |
nextText.addSelectionListener(new SelectionListener() { |
|
482 |
|
|
483 |
@Override |
|
484 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
485 |
nextText(); |
|
486 |
} |
|
487 |
|
|
488 |
@Override |
|
489 |
public void widgetSelected(SelectionEvent e) { |
|
490 |
nextText(); |
|
491 |
} |
|
492 |
}); |
|
493 |
// set listeners |
|
494 |
previousText.addSelectionListener(new SelectionListener() { |
|
495 |
|
|
496 |
@Override |
|
497 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
498 |
previousText(false); |
|
499 |
} |
|
500 |
|
|
501 |
@Override |
|
502 |
public void widgetSelected(SelectionEvent e) { |
|
503 |
previousText(false); |
|
504 |
} |
|
505 |
}); |
|
506 |
lastText.addSelectionListener(new SelectionListener() { |
|
507 |
|
|
508 |
@Override |
|
509 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
510 |
lastText(); |
|
511 |
} |
|
512 |
|
|
513 |
@Override |
|
514 |
public void widgetSelected(SelectionEvent e) { |
|
515 |
lastText(); |
|
516 |
} |
|
517 |
}); |
|
518 |
// set listeners |
|
519 |
firstText.addSelectionListener(new SelectionListener() { |
|
520 |
|
|
521 |
@Override |
|
522 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
523 |
firstText(); |
|
524 |
} |
|
525 |
|
|
526 |
@Override |
|
527 |
public void widgetSelected(SelectionEvent e) { |
|
528 |
firstText(); |
|
529 |
} |
|
530 |
}); |
|
531 |
|
|
532 |
subPanneau.pack(); |
|
533 |
panneau.pack(); |
|
534 |
|
|
535 |
FormLayout parentLayout = new FormLayout(); |
|
536 |
|
|
537 |
FormData datatop = new FormData(); |
|
538 |
datatop.top = new FormAttachment(0, 0); |
|
539 |
datatop.left = new FormAttachment(0, 0); |
|
540 |
datatop.right = new FormAttachment(100, 0); |
|
541 |
datatop.bottom = new FormAttachment(panneau, 0); |
|
542 |
webBrowser.setLayoutData(datatop); |
|
543 |
|
|
544 |
FormData databottom = new FormData(200, 30); |
|
545 |
databottom.bottom = new FormAttachment(100, 0); |
|
546 |
databottom.left = new FormAttachment(30, -100); |
|
547 |
databottom.right = new FormAttachment(80, 100); |
|
548 |
panneau.setLayoutData(databottom); |
|
549 |
|
|
550 |
parent.setLayout(parentLayout); |
|
551 |
parent.pack(); |
|
552 |
|
|
553 | 518 |
MenuManager menuManager = new MenuManager(); |
554 | 519 |
Menu menu = menuManager.createContextMenu(getBrowser()); |
555 | 520 |
|
... | ... | |
606 | 571 |
getSite().registerContextMenu(menuManager, selProvider); |
607 | 572 |
getSite().setSelectionProvider(selProvider); |
608 | 573 |
|
574 |
new CommandLink(this, getBrowser()); |
|
609 | 575 |
// System.out.println("Browser menu: "+getBrowser().getMenu()); |
610 | 576 |
} |
611 | 577 |
|
... | ... | |
659 | 625 |
return ((String) getBrowser().evaluate(SCRIPT01)); |
660 | 626 |
} |
661 | 627 |
|
662 |
public Object getWordIDsSelection() { |
|
663 |
System.out.println("WORDS IDS " + getBrowser().evaluate(SCRIPT02)); |
|
664 |
return getBrowser().evaluate(SCRIPT02); |
|
665 |
} |
|
628 |
// public Object getWordIDsSelection() {
|
|
629 |
// System.out.println("WORDS IDS " + getBrowser().evaluate(SCRIPT02));
|
|
630 |
// return getBrowser().evaluate(SCRIPT02);
|
|
631 |
// }
|
|
666 | 632 |
|
667 | 633 |
public String getTextSelection() { |
668 | 634 |
System.out.println("DOM=" + getTextSelectionDOM()); |
... | ... | |
671 | 637 |
return rez; |
672 | 638 |
} |
673 | 639 |
|
674 |
/** |
|
675 |
* Gets the current page. |
|
676 |
* |
|
677 |
* @return the current page |
|
678 |
*/ |
|
679 |
public Page getCurrentPage() { |
|
680 |
return currentPage; |
|
681 |
} |
|
640 |
// /**
|
|
641 |
// * Gets the current page.
|
|
642 |
// *
|
|
643 |
// * @return the current page
|
|
644 |
// */
|
|
645 |
// public Page getCurrentPage() {
|
|
646 |
// return currentPage;
|
|
647 |
// }
|
|
682 | 648 |
} |
Formats disponibles : Unified diff