27 |
27 |
//
|
28 |
28 |
package org.txm.rcp.editors;
|
29 |
29 |
|
|
30 |
import java.io.File;
|
|
31 |
|
30 |
32 |
import org.eclipse.jface.action.MenuManager;
|
31 |
33 |
import org.eclipse.jface.text.ITextSelection;
|
32 |
34 |
import org.eclipse.jface.viewers.ISelection;
|
33 |
35 |
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
34 |
36 |
import org.eclipse.jface.viewers.ISelectionProvider;
|
|
37 |
import org.eclipse.swt.SWT;
|
35 |
38 |
import org.eclipse.swt.browser.Browser;
|
36 |
39 |
import org.eclipse.swt.browser.ProgressEvent;
|
37 |
40 |
import org.eclipse.swt.browser.ProgressListener;
|
|
41 |
import org.eclipse.swt.events.DisposeEvent;
|
|
42 |
import org.eclipse.swt.events.DisposeListener;
|
|
43 |
import org.eclipse.swt.events.MenuEvent;
|
|
44 |
import org.eclipse.swt.events.MenuListener;
|
|
45 |
import org.eclipse.swt.events.SelectionEvent;
|
|
46 |
import org.eclipse.swt.events.SelectionListener;
|
38 |
47 |
import org.eclipse.swt.graphics.Image;
|
39 |
48 |
import org.eclipse.swt.widgets.Composite;
|
40 |
49 |
import org.eclipse.swt.widgets.Menu;
|
|
50 |
import org.eclipse.swt.widgets.MenuItem;
|
41 |
51 |
import org.eclipse.ui.internal.browser.BrowserViewer;
|
42 |
52 |
import org.eclipse.ui.internal.browser.WebBrowserEditor;
|
|
53 |
import org.txm.rcp.commands.ShowSelected;
|
43 |
54 |
import org.txm.rcp.messages.TXMUIMessages;
|
|
55 |
import org.txm.rcp.utils.IOClipboard;
|
44 |
56 |
|
45 |
57 |
/**
|
46 |
58 |
* Call the internal browser of RCP specialized for TXM editions.
|
... | ... | |
53 |
65 |
|
54 |
66 |
/** The Constant ID. */
|
55 |
67 |
public final static String ID = TXMBrowserEditor.class.getName(); //$NON-NLS-1$
|
56 |
|
|
|
68 |
|
57 |
69 |
/**
|
58 |
70 |
* Instantiates a new TXM browser.
|
59 |
71 |
*/
|
... | ... | |
83 |
95 |
|
84 |
96 |
CommandLink cmdLink;
|
85 |
97 |
|
|
98 |
private MenuManager menuManager;
|
|
99 |
|
86 |
100 |
/**
|
87 |
101 |
*
|
88 |
102 |
* @param wordids2 all the words to highlight
|
... | ... | |
98 |
112 |
|
99 |
113 |
@Override
|
100 |
114 |
public void completed(ProgressEvent event) {
|
101 |
|
cmdLink = new CommandLink(TXMBrowserEditor.this, TXMBrowserEditor.this.getBrowser());
|
|
115 |
|
|
116 |
Object o = TXMBrowserEditor.this.getBrowser().evaluate("return typeof " + CommandLink.FCT + ";");
|
|
117 |
if ("undefined".equals(o)) {
|
|
118 |
if (cmdLink != null) {
|
|
119 |
cmdLink.dispose();
|
|
120 |
}
|
|
121 |
cmdLink = new CommandLink(TXMBrowserEditor.this, TXMBrowserEditor.this.getBrowser());
|
|
122 |
}
|
102 |
123 |
}
|
103 |
124 |
};
|
104 |
125 |
getBrowser().addProgressListener(progresslistener);
|
|
126 |
}
|
|
127 |
|
|
128 |
public void initMenu() {
|
105 |
129 |
|
|
130 |
// create a new menu
|
|
131 |
menuManager = new MenuManager();
|
|
132 |
|
|
133 |
Menu menu = menuManager.createContextMenu(this.getBrowser());
|
|
134 |
|
|
135 |
menu.addMenuListener(new MenuListener() {
|
|
136 |
|
|
137 |
@Override
|
|
138 |
public void menuShown(MenuEvent e) {
|
|
139 |
|
|
140 |
Menu menu = menuManager.getMenu();
|
|
141 |
if (menu == null) return;
|
|
142 |
new MenuItem(menu, SWT.SEPARATOR);
|
|
143 |
|
|
144 |
MenuItem copyItem = new MenuItem(menu, SWT.NONE);
|
|
145 |
copyItem.setText("Copy");
|
|
146 |
copyItem.addSelectionListener(new SelectionListener() {
|
|
147 |
|
|
148 |
@Override
|
|
149 |
public void widgetSelected(SelectionEvent e) {
|
|
150 |
|
|
151 |
String text = TXMBrowserEditor.this.getTextSelection();
|
|
152 |
if (text != null && text.length() > 0) {
|
|
153 |
IOClipboard.write(text);
|
|
154 |
}
|
|
155 |
}
|
|
156 |
|
|
157 |
@Override
|
|
158 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
159 |
});
|
|
160 |
String text = TXMBrowserEditor.this.getTextSelection();
|
|
161 |
copyItem.setEnabled(text != null && text.length() > 0);
|
|
162 |
|
|
163 |
MenuItem reloadItem = new MenuItem(menu, SWT.NONE);
|
|
164 |
reloadItem.setText("Reload");
|
|
165 |
reloadItem.addSelectionListener(new SelectionListener() {
|
|
166 |
|
|
167 |
@Override
|
|
168 |
public void widgetSelected(SelectionEvent e) {
|
|
169 |
|
|
170 |
TXMBrowserEditor.this.getBrowser().refresh();
|
|
171 |
}
|
|
172 |
|
|
173 |
@Override
|
|
174 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
175 |
});
|
|
176 |
MenuItem backItem = new MenuItem(menu, SWT.NONE);
|
|
177 |
backItem.setText("Back");
|
|
178 |
backItem.addSelectionListener(new SelectionListener() {
|
|
179 |
|
|
180 |
@Override
|
|
181 |
public void widgetSelected(SelectionEvent e) {
|
|
182 |
|
|
183 |
TXMBrowserEditor.this.getBrowser().back();
|
|
184 |
}
|
|
185 |
|
|
186 |
@Override
|
|
187 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
188 |
});
|
|
189 |
MenuItem forwardItem = new MenuItem(menu, SWT.NONE);
|
|
190 |
forwardItem.setText("Forward");
|
|
191 |
forwardItem.addSelectionListener(new SelectionListener() {
|
|
192 |
|
|
193 |
@Override
|
|
194 |
public void widgetSelected(SelectionEvent e) {
|
|
195 |
|
|
196 |
TXMBrowserEditor.this.getBrowser().forward();
|
|
197 |
}
|
|
198 |
|
|
199 |
@Override
|
|
200 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
201 |
});
|
|
202 |
|
|
203 |
MenuItem propertiesItem = new MenuItem(menu, SWT.NONE);
|
|
204 |
propertiesItem.setText("Properties");
|
|
205 |
propertiesItem.addSelectionListener(new SelectionListener() {
|
|
206 |
|
|
207 |
@Override
|
|
208 |
public void widgetSelected(SelectionEvent e) {
|
|
209 |
|
|
210 |
ShowSelected.print(new File(TXMBrowserEditor.this.getBrowser().getUrl()));
|
|
211 |
}
|
|
212 |
|
|
213 |
@Override
|
|
214 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
215 |
});
|
|
216 |
}
|
|
217 |
|
|
218 |
@Override
|
|
219 |
public void menuHidden(MenuEvent e) {
|
|
220 |
// TODO Auto-generated method stub
|
|
221 |
}
|
|
222 |
});
|
|
223 |
// // restore old listeners
|
|
224 |
// Menu origMenu = this.browser.getMenu();
|
|
225 |
// if (origMenu != null) {
|
|
226 |
// if (origMenu.getListeners(SWT.Hide) != null)
|
|
227 |
// for (Listener listener : origMenu.getListeners(SWT.Hide)) menu.addListener(SWT.Hide, listener);
|
|
228 |
// if (origMenu.getListeners(SWT.Show) != null)
|
|
229 |
// for (Listener listener : origMenu.getListeners(SWT.Show)) menu.addListener(SWT.Show, listener);
|
|
230 |
// for (MenuItem origItem : origMenu.getItems()) { // restore old menu items
|
|
231 |
// MenuItem item = new MenuItem(menu, origItem.getStyle());
|
|
232 |
// item.setText(origItem.getText());
|
|
233 |
// item.setImage(origItem.getImage());
|
|
234 |
// if (origItem.getListeners(SWT.Selection) != null && origItem.getListeners(SWT.Selection).length > 0)
|
|
235 |
// item.addListener(SWT.Selection, origItem.getListeners(SWT.Selection)[0]);
|
|
236 |
// }
|
|
237 |
// }
|
|
238 |
// replace the menu
|
|
239 |
this.getBrowser().setMenu(menu);
|
106 |
240 |
}
|
107 |
241 |
|
108 |
|
// /**
|
109 |
|
// * Sets the edition.
|
110 |
|
// *
|
111 |
|
// * @param edition the new edition
|
112 |
|
// */
|
113 |
|
// public void setEdition(Edition edition) {
|
114 |
|
// this.edition = edition;
|
115 |
|
// }
|
|
242 |
// /**
|
|
243 |
// * Sets the edition.
|
|
244 |
// *
|
|
245 |
// * @param edition the new edition
|
|
246 |
// */
|
|
247 |
// public void setEdition(Edition edition) {
|
|
248 |
// this.edition = edition;
|
|
249 |
// }
|
116 |
250 |
|
117 |
|
// /**
|
118 |
|
// * Make page label.
|
119 |
|
// *
|
120 |
|
// * @return the string
|
121 |
|
// */
|
122 |
|
// public String makePageLabel() {
|
123 |
|
// return currentPage.getName()
|
124 |
|
// + " / " + currentPage.getEdition().getNumPages(); //$NON-NLS-1$
|
125 |
|
// }
|
126 |
|
//
|
127 |
|
// /**
|
128 |
|
// * Show page.
|
129 |
|
// *
|
130 |
|
// * @param page the page
|
131 |
|
// */
|
132 |
|
// public void showPage(Page page) {
|
133 |
|
// edition = page.getEdition();
|
134 |
|
// currentPage = page;
|
135 |
|
// this.webBrowser.setURL(currentPage.toURL());
|
136 |
|
// page_label.setText(makePageLabel());
|
137 |
|
// }
|
|
251 |
// /**
|
|
252 |
// * Make page label.
|
|
253 |
// *
|
|
254 |
// * @return the string
|
|
255 |
// */
|
|
256 |
// public String makePageLabel() {
|
|
257 |
// return currentPage.getName()
|
|
258 |
// + " / " + currentPage.getEdition().getNumPages(); //$NON-NLS-1$
|
|
259 |
// }
|
|
260 |
//
|
|
261 |
// /**
|
|
262 |
// * Show page.
|
|
263 |
// *
|
|
264 |
// * @param page the page
|
|
265 |
// */
|
|
266 |
// public void showPage(Page page) {
|
|
267 |
// edition = page.getEdition();
|
|
268 |
// currentPage = page;
|
|
269 |
// this.webBrowser.setURL(currentPage.toURL());
|
|
270 |
// page_label.setText(makePageLabel());
|
|
271 |
// }
|
138 |
272 |
|
139 |
|
// /**
|
140 |
|
// * First text.
|
141 |
|
// */
|
142 |
|
// public void firstText() {
|
143 |
|
// Text current = this.currentPage.getEdition().getText();
|
144 |
|
// Project corpus = current.getProject();
|
145 |
|
// Text firstText = corpus.getFirstText();
|
146 |
|
//
|
147 |
|
// if (firstText != null) {
|
148 |
|
// String editionName = corpus.getDefaultEditionName();
|
149 |
|
// currentPage = firstText.getEdition(editionName).getFirstPage();
|
150 |
|
// if (currentPage == null) {
|
151 |
|
// StatusLine.setMessage(TXMUIMessages.noPreviousText);
|
152 |
|
// return;
|
153 |
|
// }
|
154 |
|
// this.setEdition(firstText.getEdition(editionName));
|
155 |
|
// this.webBrowser.setURL(currentPage.toURL());
|
156 |
|
// page_label.setText(makePageLabel());
|
157 |
|
// }
|
158 |
|
// }
|
159 |
|
//
|
160 |
|
// /**
|
161 |
|
// * Last text.
|
162 |
|
// */
|
163 |
|
// public void lastText() {
|
164 |
|
// Text current = this.currentPage.getEdition().getText();
|
165 |
|
// Project b = current.getProject();
|
166 |
|
// Text lastText = b.getLastText();
|
167 |
|
//
|
168 |
|
// if (lastText != null) {
|
169 |
|
// currentPage = lastText.getEdition(b.getDefaultEditionName()).getFirstPage();
|
170 |
|
// if (currentPage == null) {
|
171 |
|
// StatusLine.setMessage(TXMUIMessages.noTextNext);
|
172 |
|
// return;
|
173 |
|
// }
|
174 |
|
// this.setEdition(lastText.getEdition(b.getDefaultEditionName()));
|
175 |
|
// this.webBrowser.setURL(currentPage.toURL());
|
176 |
|
// page_label.setText(makePageLabel());
|
177 |
|
// }
|
178 |
|
// }
|
179 |
|
//
|
180 |
|
// /**
|
181 |
|
// * First page.
|
182 |
|
// */
|
183 |
|
// public void firstPage() {
|
184 |
|
// // System.out.println(Messages.TxmBrowser_1+currentPage);
|
185 |
|
// currentPage = edition.getFirstPage();
|
186 |
|
// this.webBrowser.setURL(currentPage.toURL());
|
187 |
|
// page_label.setText(makePageLabel());
|
188 |
|
// }
|
189 |
|
//
|
190 |
|
// /**
|
191 |
|
// * Last page.
|
192 |
|
// */
|
193 |
|
// public void lastPage() {
|
194 |
|
// // System.out.println(Messages.TxmBrowser_2+currentPage);
|
195 |
|
//
|
196 |
|
// if (currentPage != null && currentPage.getFile().equals(edition.getLastPage().getFile()))
|
197 |
|
// return;
|
198 |
|
// currentPage = edition.getLastPage();
|
199 |
|
// this.webBrowser.setURL(currentPage.toURL());
|
200 |
|
// page_label.setText(makePageLabel());
|
201 |
|
// }
|
202 |
|
//
|
203 |
|
// /**
|
204 |
|
// * Previous page.
|
205 |
|
// */
|
206 |
|
// public void previousPage() {
|
207 |
|
// // System.out.println(Messages.TxmBrowser_3+currentPage);
|
208 |
|
// if (currentPage != null) {
|
209 |
|
// Page previous = edition.getPreviousPage(currentPage);
|
210 |
|
// if (previous == currentPage) {
|
211 |
|
// previousText(true);
|
212 |
|
// }
|
213 |
|
// else {
|
214 |
|
// currentPage = previous;
|
215 |
|
// this.webBrowser.setURL(currentPage.toURL());
|
216 |
|
// }
|
217 |
|
// }
|
218 |
|
// else
|
219 |
|
// firstPage();
|
220 |
|
// page_label.setText(makePageLabel());
|
221 |
|
// }
|
222 |
|
//
|
223 |
|
// /**
|
224 |
|
// * Next page.
|
225 |
|
// */
|
226 |
|
// public void nextPage() {
|
227 |
|
// // System.out.println(Messages.TxmBrowser_4+currentPage);
|
228 |
|
// if (currentPage != null) {
|
229 |
|
// Page next = edition.getNextPage(currentPage);
|
230 |
|
// if (currentPage == next) {
|
231 |
|
// nextText();
|
232 |
|
// }
|
233 |
|
// else {
|
234 |
|
// currentPage = next;
|
235 |
|
// this.webBrowser.setURL(currentPage.toURL());
|
236 |
|
// }
|
237 |
|
//
|
238 |
|
// }
|
239 |
|
// else
|
240 |
|
// firstPage();
|
241 |
|
// page_label.setText(makePageLabel());
|
242 |
|
// }
|
243 |
|
//
|
244 |
|
// /**
|
245 |
|
// * Previous text.
|
246 |
|
// *
|
247 |
|
// * @param fromNextText
|
248 |
|
// */
|
249 |
|
// public void previousText(boolean fromNextText) {
|
250 |
|
//
|
251 |
|
// Text current = this.currentPage.getEdition().getText();
|
252 |
|
// Project corpus = current.getProject();
|
253 |
|
// Text previousText = corpus.getPreviousText(current);
|
254 |
|
//
|
255 |
|
// if (previousText != null) {
|
256 |
|
// String editionName = corpus.getDefaultEditionName();
|
257 |
|
// if (fromNextText) {
|
258 |
|
// currentPage = previousText.getEdition(editionName).getLastPage();
|
259 |
|
// }
|
260 |
|
// else {
|
261 |
|
// currentPage = previousText.getEdition(editionName).getFirstPage();
|
262 |
|
// }
|
263 |
|
// if (currentPage == null) {
|
264 |
|
// StatusLine.setMessage(TXMUIMessages.noPreviousText);
|
265 |
|
// return;
|
266 |
|
// }
|
267 |
|
// this.setEdition(previousText.getEdition(editionName));
|
268 |
|
// this.webBrowser.setURL(currentPage.toURL());
|
269 |
|
// page_label.setText(makePageLabel());
|
270 |
|
// }
|
271 |
|
// // System.out.println("Previous texts "+previousText);
|
272 |
|
// }
|
273 |
|
//
|
274 |
|
// /**
|
275 |
|
// * Next text.
|
276 |
|
// */
|
277 |
|
// public void nextText() {
|
278 |
|
// Text current = this.currentPage.getEdition().getText();
|
279 |
|
// Project b = current.getProject();
|
280 |
|
// Text nextText = b.getNextText(current);
|
281 |
|
//
|
282 |
|
// if (nextText != null) {
|
283 |
|
// currentPage = nextText.getEdition(b.getDefaultEditionName()).getFirstPage();
|
284 |
|
// if (currentPage == null) {
|
285 |
|
// StatusLine.setMessage(TXMUIMessages.noTextNext);
|
286 |
|
// return;
|
287 |
|
// }
|
288 |
|
// this.setEdition(nextText.getEdition(b.getDefaultEditionName()));
|
289 |
|
// this.webBrowser.setURL(currentPage.toURL());
|
290 |
|
// page_label.setText(makePageLabel());
|
291 |
|
// }
|
292 |
|
// // System.out.println("Next texts "+nextText);
|
293 |
|
// }
|
|
273 |
// /**
|
|
274 |
// * First text.
|
|
275 |
// */
|
|
276 |
// public void firstText() {
|
|
277 |
// Text current = this.currentPage.getEdition().getText();
|
|
278 |
// Project corpus = current.getProject();
|
|
279 |
// Text firstText = corpus.getFirstText();
|
|
280 |
//
|
|
281 |
// if (firstText != null) {
|
|
282 |
// String editionName = corpus.getDefaultEditionName();
|
|
283 |
// currentPage = firstText.getEdition(editionName).getFirstPage();
|
|
284 |
// if (currentPage == null) {
|
|
285 |
// StatusLine.setMessage(TXMUIMessages.noPreviousText);
|
|
286 |
// return;
|
|
287 |
// }
|
|
288 |
// this.setEdition(firstText.getEdition(editionName));
|
|
289 |
// this.webBrowser.setURL(currentPage.toURL());
|
|
290 |
// page_label.setText(makePageLabel());
|
|
291 |
// }
|
|
292 |
// }
|
|
293 |
//
|
|
294 |
// /**
|
|
295 |
// * Last text.
|
|
296 |
// */
|
|
297 |
// public void lastText() {
|
|
298 |
// Text current = this.currentPage.getEdition().getText();
|
|
299 |
// Project b = current.getProject();
|
|
300 |
// Text lastText = b.getLastText();
|
|
301 |
//
|
|
302 |
// if (lastText != null) {
|
|
303 |
// currentPage = lastText.getEdition(b.getDefaultEditionName()).getFirstPage();
|
|
304 |
// if (currentPage == null) {
|
|
305 |
// StatusLine.setMessage(TXMUIMessages.noTextNext);
|
|
306 |
// return;
|
|
307 |
// }
|
|
308 |
// this.setEdition(lastText.getEdition(b.getDefaultEditionName()));
|
|
309 |
// this.webBrowser.setURL(currentPage.toURL());
|
|
310 |
// page_label.setText(makePageLabel());
|
|
311 |
// }
|
|
312 |
// }
|
|
313 |
//
|
|
314 |
// /**
|
|
315 |
// * First page.
|
|
316 |
// */
|
|
317 |
// public void firstPage() {
|
|
318 |
// // System.out.println(Messages.TxmBrowser_1+currentPage);
|
|
319 |
// currentPage = edition.getFirstPage();
|
|
320 |
// this.webBrowser.setURL(currentPage.toURL());
|
|
321 |
// page_label.setText(makePageLabel());
|
|
322 |
// }
|
|
323 |
//
|
|
324 |
// /**
|
|
325 |
// * Last page.
|
|
326 |
// */
|
|
327 |
// public void lastPage() {
|
|
328 |
// // System.out.println(Messages.TxmBrowser_2+currentPage);
|
|
329 |
//
|
|
330 |
// if (currentPage != null && currentPage.getFile().equals(edition.getLastPage().getFile()))
|
|
331 |
// return;
|
|
332 |
// currentPage = edition.getLastPage();
|
|
333 |
// this.webBrowser.setURL(currentPage.toURL());
|
|
334 |
// page_label.setText(makePageLabel());
|
|
335 |
// }
|
|
336 |
//
|
|
337 |
// /**
|
|
338 |
// * Previous page.
|
|
339 |
// */
|
|
340 |
// public void previousPage() {
|
|
341 |
// // System.out.println(Messages.TxmBrowser_3+currentPage);
|
|
342 |
// if (currentPage != null) {
|
|
343 |
// Page previous = edition.getPreviousPage(currentPage);
|
|
344 |
// if (previous == currentPage) {
|
|
345 |
// previousText(true);
|
|
346 |
// }
|
|
347 |
// else {
|
|
348 |
// currentPage = previous;
|
|
349 |
// this.webBrowser.setURL(currentPage.toURL());
|
|
350 |
// }
|
|
351 |
// }
|
|
352 |
// else
|
|
353 |
// firstPage();
|
|
354 |
// page_label.setText(makePageLabel());
|
|
355 |
// }
|
|
356 |
//
|
|
357 |
// /**
|
|
358 |
// * Next page.
|
|
359 |
// */
|
|
360 |
// public void nextPage() {
|
|
361 |
// // System.out.println(Messages.TxmBrowser_4+currentPage);
|
|
362 |
// if (currentPage != null) {
|
|
363 |
// Page next = edition.getNextPage(currentPage);
|
|
364 |
// if (currentPage == next) {
|
|
365 |
// nextText();
|
|
366 |
// }
|
|
367 |
// else {
|
|
368 |
// currentPage = next;
|
|
369 |
// this.webBrowser.setURL(currentPage.toURL());
|
|
370 |
// }
|
|
371 |
//
|
|
372 |
// }
|
|
373 |
// else
|
|
374 |
// firstPage();
|
|
375 |
// page_label.setText(makePageLabel());
|
|
376 |
// }
|
|
377 |
//
|
|
378 |
// /**
|
|
379 |
// * Previous text.
|
|
380 |
// *
|
|
381 |
// * @param fromNextText
|
|
382 |
// */
|
|
383 |
// public void previousText(boolean fromNextText) {
|
|
384 |
//
|
|
385 |
// Text current = this.currentPage.getEdition().getText();
|
|
386 |
// Project corpus = current.getProject();
|
|
387 |
// Text previousText = corpus.getPreviousText(current);
|
|
388 |
//
|
|
389 |
// if (previousText != null) {
|
|
390 |
// String editionName = corpus.getDefaultEditionName();
|
|
391 |
// if (fromNextText) {
|
|
392 |
// currentPage = previousText.getEdition(editionName).getLastPage();
|
|
393 |
// }
|
|
394 |
// else {
|
|
395 |
// currentPage = previousText.getEdition(editionName).getFirstPage();
|
|
396 |
// }
|
|
397 |
// if (currentPage == null) {
|
|
398 |
// StatusLine.setMessage(TXMUIMessages.noPreviousText);
|
|
399 |
// return;
|
|
400 |
// }
|
|
401 |
// this.setEdition(previousText.getEdition(editionName));
|
|
402 |
// this.webBrowser.setURL(currentPage.toURL());
|
|
403 |
// page_label.setText(makePageLabel());
|
|
404 |
// }
|
|
405 |
// // System.out.println("Previous texts "+previousText);
|
|
406 |
// }
|
|
407 |
//
|
|
408 |
// /**
|
|
409 |
// * Next text.
|
|
410 |
// */
|
|
411 |
// public void nextText() {
|
|
412 |
// Text current = this.currentPage.getEdition().getText();
|
|
413 |
// Project b = current.getProject();
|
|
414 |
// Text nextText = b.getNextText(current);
|
|
415 |
//
|
|
416 |
// if (nextText != null) {
|
|
417 |
// currentPage = nextText.getEdition(b.getDefaultEditionName()).getFirstPage();
|
|
418 |
// if (currentPage == null) {
|
|
419 |
// StatusLine.setMessage(TXMUIMessages.noTextNext);
|
|
420 |
// return;
|
|
421 |
// }
|
|
422 |
// this.setEdition(nextText.getEdition(b.getDefaultEditionName()));
|
|
423 |
// this.webBrowser.setURL(currentPage.toURL());
|
|
424 |
// page_label.setText(makePageLabel());
|
|
425 |
// }
|
|
426 |
// // System.out.println("Next texts "+nextText);
|
|
427 |
// }
|
294 |
428 |
|
295 |
429 |
/*
|
296 |
430 |
* (non-Javadoc)
|
... | ... | |
300 |
434 |
public void createPartControl(Composite parent) {
|
301 |
435 |
try {
|
302 |
436 |
super.createPartControl(parent);
|
|
437 |
|
|
438 |
cmdLink = new CommandLink(TXMBrowserEditor.this, TXMBrowserEditor.this.getBrowser());
|
|
439 |
|
|
440 |
parent.addDisposeListener(new DisposeListener() {
|
|
441 |
|
|
442 |
@Override
|
|
443 |
public void widgetDisposed(DisposeEvent e) {
|
|
444 |
|
|
445 |
cmdLink.dispose();
|
|
446 |
}
|
|
447 |
});
|
|
448 |
|
303 |
449 |
}
|
304 |
450 |
catch (Exception e) {
|
305 |
451 |
System.err.println(TXMUIMessages.couldNotLaunchTheInternalWebBrowserYouMustSetThatParameterInThePreferencesMenuColonGeneralSupWebNavigator);
|
306 |
452 |
return;
|
307 |
453 |
}
|
308 |
454 |
|
309 |
|
// RowLayout navigLayout = new RowLayout(SWT.HORIZONTAL);
|
310 |
|
// navigLayout.justify = true;
|
311 |
|
// Composite panneau = new Composite(parent, SWT.NONE);
|
312 |
|
// panneau.setLayout(navigLayout);
|
313 |
|
//
|
314 |
|
// RowLayout subLayout = new RowLayout(SWT.HORIZONTAL);
|
315 |
|
// subLayout.pack = true;
|
316 |
|
// subLayout.center = true;
|
317 |
|
// subLayout.marginBottom = subLayout.marginHeight = 0;
|
318 |
|
// subLayout.marginTop = subLayout.marginWidth = 0;
|
319 |
|
// Composite subPanneau = new Composite(panneau, SWT.NONE);
|
320 |
|
// subPanneau.setLayout(subLayout);
|
321 |
|
// subPanneau.setLayoutData(new RowData(450, 22));
|
322 |
|
//
|
323 |
|
// Button firstText = new Button(subPanneau, SWT.FLAT);
|
324 |
|
// Button previousText = new Button(subPanneau, SWT.FLAT);
|
325 |
|
// Button first = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
326 |
|
// Button previous = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
327 |
|
// page_label = new Label(subPanneau, SWT.NONE);
|
328 |
|
// Button next = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
329 |
|
// Button last = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
330 |
|
// Button nextText = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
331 |
|
// Button lastText = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
332 |
|
//
|
333 |
|
// // set sizes
|
334 |
|
// page_label.setLayoutData(new RowData(50, 20));
|
335 |
|
// firstText.setLayoutData(new RowData(30, 20));
|
336 |
|
// first.setLayoutData(new RowData(30, 20));
|
337 |
|
// previous.setLayoutData(new RowData(30, 20));
|
338 |
|
// next.setLayoutData(new RowData(30, 20));
|
339 |
|
// last.setLayoutData(new RowData(30, 20));
|
340 |
|
// nextText.setLayoutData(new RowData(30, 20));
|
341 |
|
// previousText.setLayoutData(new RowData(30, 20));
|
342 |
|
// lastText.setLayoutData(new RowData(30, 20));
|
|
455 |
// RowLayout navigLayout = new RowLayout(SWT.HORIZONTAL);
|
|
456 |
// navigLayout.justify = true;
|
|
457 |
// Composite panneau = new Composite(parent, SWT.NONE);
|
|
458 |
// panneau.setLayout(navigLayout);
|
|
459 |
//
|
|
460 |
// RowLayout subLayout = new RowLayout(SWT.HORIZONTAL);
|
|
461 |
// subLayout.pack = true;
|
|
462 |
// subLayout.center = true;
|
|
463 |
// subLayout.marginBottom = subLayout.marginHeight = 0;
|
|
464 |
// subLayout.marginTop = subLayout.marginWidth = 0;
|
|
465 |
// Composite subPanneau = new Composite(panneau, SWT.NONE);
|
|
466 |
// subPanneau.setLayout(subLayout);
|
|
467 |
// subPanneau.setLayoutData(new RowData(450, 22));
|
|
468 |
//
|
|
469 |
// Button firstText = new Button(subPanneau, SWT.FLAT);
|
|
470 |
// Button previousText = new Button(subPanneau, SWT.FLAT);
|
|
471 |
// Button first = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
|
472 |
// Button previous = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
|
473 |
// page_label = new Label(subPanneau, SWT.NONE);
|
|
474 |
// Button next = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
|
475 |
// Button last = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
|
476 |
// Button nextText = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
|
477 |
// Button lastText = new Button(subPanneau, SWT.FLAT | SWT.PUSH);
|
|
478 |
//
|
|
479 |
// // set sizes
|
|
480 |
// page_label.setLayoutData(new RowData(50, 20));
|
|
481 |
// firstText.setLayoutData(new RowData(30, 20));
|
|
482 |
// first.setLayoutData(new RowData(30, 20));
|
|
483 |
// previous.setLayoutData(new RowData(30, 20));
|
|
484 |
// next.setLayoutData(new RowData(30, 20));
|
|
485 |
// last.setLayoutData(new RowData(30, 20));
|
|
486 |
// nextText.setLayoutData(new RowData(30, 20));
|
|
487 |
// previousText.setLayoutData(new RowData(30, 20));
|
|
488 |
// lastText.setLayoutData(new RowData(30, 20));
|
343 |
489 |
|
344 |
490 |
|
345 |
|
// // set labels
|
346 |
|
// page_label.setText(""); //$NON-NLS-1$
|
347 |
|
// firstText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWINDSTART));
|
348 |
|
// firstText.setToolTipText("|<<");
|
349 |
|
// previousText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWIND));
|
350 |
|
// previousText.setToolTipText(TXMUIMessages.previousText);
|
351 |
|
// first.setImage(IImageKeys.getImage(IImageKeys.CTRLSTART));
|
352 |
|
// first.setToolTipText(TXMUIMessages.common_beginning);
|
353 |
|
// previous.setImage(IImageKeys.getImage(IImageKeys.CTRLREVERSE));
|
354 |
|
// previous.setToolTipText(TXMUIMessages.previousPage);
|
355 |
|
// next.setImage(IImageKeys.getImage(IImageKeys.CTRLPLAY));
|
356 |
|
// next.setToolTipText(TXMUIMessages.nextPage);
|
357 |
|
// last.setImage(IImageKeys.getImage(IImageKeys.CTRLEND));
|
358 |
|
// last.setToolTipText(TXMUIMessages.common_end);
|
359 |
|
// nextText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARD));
|
360 |
|
// nextText.setToolTipText(TXMUIMessages.nextText);
|
361 |
|
// lastText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARDEND));
|
362 |
|
// lastText.setToolTipText(">>|");
|
363 |
|
//
|
364 |
|
//
|
365 |
|
// // set listeners
|
366 |
|
// first.addSelectionListener(new SelectionListener() {
|
367 |
|
//
|
368 |
|
// @Override
|
369 |
|
// public void widgetDefaultSelected(SelectionEvent e) {
|
370 |
|
// firstPage();
|
371 |
|
// }
|
372 |
|
//
|
373 |
|
// @Override
|
374 |
|
// public void widgetSelected(SelectionEvent e) {
|
375 |
|
// firstPage();
|
376 |
|
// }
|
377 |
|
// });
|
378 |
|
// previous.addSelectionListener(new SelectionListener() {
|
379 |
|
//
|
380 |
|
// @Override
|
381 |
|
// public void widgetDefaultSelected(SelectionEvent e) {
|
382 |
|
// previousPage();
|
383 |
|
// }
|
384 |
|
//
|
385 |
|
// @Override
|
386 |
|
// public void widgetSelected(SelectionEvent e) {
|
387 |
|
// previousPage();
|
388 |
|
// }
|
389 |
|
// });
|
390 |
|
// next.addSelectionListener(new SelectionListener() {
|
391 |
|
//
|
392 |
|
// @Override
|
393 |
|
// public void widgetDefaultSelected(SelectionEvent e) {
|
394 |
|
// nextPage();
|
395 |
|
// }
|
396 |
|
//
|
397 |
|
// @Override
|
398 |
|
// public void widgetSelected(SelectionEvent e) {
|
399 |
|
// nextPage();
|
400 |
|
// }
|
401 |
|
// });
|
402 |
|
// last.addSelectionListener(new SelectionListener() {
|
403 |
|
//
|
404 |
|
// @Override
|
405 |
|
// public void widgetDefaultSelected(SelectionEvent e) {
|
406 |
|
// lastPage();
|
407 |
|
// }
|
408 |
|
//
|
409 |
|
// @Override
|
410 |
|
// public void widgetSelected(SelectionEvent e) {
|
411 |
|
// lastPage();
|
412 |
|
// }
|
413 |
|
// });
|
414 |
|
// nextText.addSelectionListener(new SelectionListener() {
|
415 |
|
//
|
416 |
|
// @Override
|
417 |
|
// public void widgetDefaultSelected(SelectionEvent e) {
|
418 |
|
// nextText();
|
419 |
|
// }
|
420 |
|
//
|
421 |
|
// @Override
|
422 |
|
// public void widgetSelected(SelectionEvent e) {
|
423 |
|
// nextText();
|
424 |
|
// }
|
425 |
|
// });
|
426 |
|
// // set listeners
|
427 |
|
// previousText.addSelectionListener(new SelectionListener() {
|
428 |
|
//
|
429 |
|
// @Override
|
430 |
|
// public void widgetDefaultSelected(SelectionEvent e) {
|
431 |
|
// previousText(false);
|
432 |
|
// }
|
433 |
|
//
|
434 |
|
// @Override
|
435 |
|
// public void widgetSelected(SelectionEvent e) {
|
436 |
|
// previousText(false);
|
437 |
|
// }
|
438 |
|
// });
|
439 |
|
// lastText.addSelectionListener(new SelectionListener() {
|
440 |
|
//
|
441 |
|
// @Override
|
442 |
|
// public void widgetDefaultSelected(SelectionEvent e) {
|
443 |
|
// lastText();
|
444 |
|
// }
|
445 |
|
//
|
446 |
|
// @Override
|
447 |
|
// public void widgetSelected(SelectionEvent e) {
|
448 |
|
// lastText();
|
449 |
|
// }
|
450 |
|
// });
|
451 |
|
// // set listeners
|
452 |
|
// firstText.addSelectionListener(new SelectionListener() {
|
453 |
|
//
|
454 |
|
// @Override
|
455 |
|
// public void widgetDefaultSelected(SelectionEvent e) {
|
456 |
|
// firstText();
|
457 |
|
// }
|
458 |
|
//
|
459 |
|
// @Override
|
460 |
|
// public void widgetSelected(SelectionEvent e) {
|
461 |
|
// firstText();
|
462 |
|
// }
|
463 |
|
// });
|
464 |
|
//
|
465 |
|
// subPanneau.pack();
|
466 |
|
// panneau.pack();
|
|
491 |
// // set labels
|
|
492 |
// page_label.setText(""); //$NON-NLS-1$
|
|
493 |
// firstText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWINDSTART));
|
|
494 |
// firstText.setToolTipText("|<<");
|
|
495 |
// previousText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWIND));
|
|
496 |
// previousText.setToolTipText(TXMUIMessages.previousText);
|
|
497 |
// first.setImage(IImageKeys.getImage(IImageKeys.CTRLSTART));
|
|
498 |
// first.setToolTipText(TXMUIMessages.common_beginning);
|
|
499 |
// previous.setImage(IImageKeys.getImage(IImageKeys.CTRLREVERSE));
|
|
500 |
// previous.setToolTipText(TXMUIMessages.previousPage);
|
|
501 |
// next.setImage(IImageKeys.getImage(IImageKeys.CTRLPLAY));
|
|
502 |
// next.setToolTipText(TXMUIMessages.nextPage);
|
|
503 |
// last.setImage(IImageKeys.getImage(IImageKeys.CTRLEND));
|
|
504 |
// last.setToolTipText(TXMUIMessages.common_end);
|
|
505 |
// nextText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARD));
|
|
506 |
// nextText.setToolTipText(TXMUIMessages.nextText);
|
|
507 |
// lastText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARDEND));
|
|
508 |
// lastText.setToolTipText(">>|");
|
|
509 |
//
|
|
510 |
//
|
|
511 |
// // set listeners
|
|
512 |
// first.addSelectionListener(new SelectionListener() {
|
|
513 |
//
|
|
514 |
// @Override
|
|
515 |
// public void widgetDefaultSelected(SelectionEvent e) {
|
|
516 |
// firstPage();
|
|
517 |
// }
|
|
518 |
//
|
|
519 |
// @Override
|
|
520 |
// public void widgetSelected(SelectionEvent e) {
|
|
521 |
// firstPage();
|
|
522 |
// }
|
|
523 |
// });
|
|
524 |
// previous.addSelectionListener(new SelectionListener() {
|
|
525 |
//
|
|
526 |
// @Override
|
|
527 |
// public void widgetDefaultSelected(SelectionEvent e) {
|
|
528 |
// previousPage();
|
|
529 |
// }
|
|
530 |
//
|
|
531 |
// @Override
|
|
532 |
// public void widgetSelected(SelectionEvent e) {
|
|
533 |
// previousPage();
|
|
534 |
// }
|
|
535 |
// });
|
|
536 |
// next.addSelectionListener(new SelectionListener() {
|
|
537 |
//
|
|
538 |
// @Override
|
|
539 |
// public void widgetDefaultSelected(SelectionEvent e) {
|
|
540 |
// nextPage();
|
|
541 |
// }
|
|
542 |
//
|
|
543 |
// @Override
|
|
544 |
// public void widgetSelected(SelectionEvent e) {
|
|
545 |
// nextPage();
|
|
546 |
// }
|
|
547 |
// });
|
|
548 |
// last.addSelectionListener(new SelectionListener() {
|
|
549 |
//
|
|
550 |
// @Override
|
|
551 |
// public void widgetDefaultSelected(SelectionEvent e) {
|
|
552 |
// lastPage();
|
|
553 |
// }
|
|
554 |
//
|
|
555 |
// @Override
|
|
556 |
// public void widgetSelected(SelectionEvent e) {
|
|
557 |
// lastPage();
|
|
558 |
// }
|
|
559 |
// });
|
|
560 |
// nextText.addSelectionListener(new SelectionListener() {
|
|
561 |
//
|
|
562 |
// @Override
|
|
563 |
// public void widgetDefaultSelected(SelectionEvent e) {
|
|
564 |
// nextText();
|
|
565 |
// }
|
|
566 |
//
|
|
567 |
// @Override
|
|
568 |
// public void widgetSelected(SelectionEvent e) {
|
|
569 |
// nextText();
|
|
570 |
// }
|
|
571 |
// });
|
|
572 |
// // set listeners
|
|
573 |
// previousText.addSelectionListener(new SelectionListener() {
|
|
574 |
//
|
|
575 |
// @Override
|
|
576 |
// public void widgetDefaultSelected(SelectionEvent e) {
|
|
577 |
// previousText(false);
|
|
578 |
// }
|
|
579 |
//
|
|
580 |
// @Override
|
|
581 |
// public void widgetSelected(SelectionEvent e) {
|
|
582 |
// previousText(false);
|
|
583 |
// }
|
|
584 |
// });
|
|
585 |
// lastText.addSelectionListener(new SelectionListener() {
|
|
586 |
//
|
|
587 |
// @Override
|
|
588 |
// public void widgetDefaultSelected(SelectionEvent e) {
|
|
589 |
// lastText();
|
|
590 |
// }
|
|
591 |
//
|
|
592 |
// @Override
|
|
593 |
// public void widgetSelected(SelectionEvent e) {
|
|
594 |
// lastText();
|
|
595 |
// }
|
|
596 |
// });
|
|
597 |
// // set listeners
|
|
598 |
// firstText.addSelectionListener(new SelectionListener() {
|
|
599 |
//
|
|
600 |
// @Override
|
|
601 |
// public void widgetDefaultSelected(SelectionEvent e) {
|
|
602 |
// firstText();
|
|
603 |
// }
|
|
604 |
//
|
|
605 |
// @Override
|
|
606 |
// public void widgetSelected(SelectionEvent e) {
|
|
607 |
// firstText();
|
|
608 |
// }
|
|
609 |
// });
|
|
610 |
//
|
|
611 |
// subPanneau.pack();
|
|
612 |
// panneau.pack();
|
467 |
613 |
|
468 |
|
// FormLayout parentLayout = new FormLayout();
|
|
614 |
// FormLayout parentLayout = new FormLayout();
|
469 |
615 |
|
470 |
|
// FormData datatop = new FormData();
|
471 |
|
// datatop.top = new FormAttachment(0, 0);
|
472 |
|
// datatop.left = new FormAttachment(0, 0);
|
473 |
|
// datatop.right = new FormAttachment(100, 0);
|
474 |
|
// datatop.bottom = new FormAttachment(panneau, 0);
|
475 |
|
// webBrowser.setLayoutData(datatop);
|
|
616 |
// FormData datatop = new FormData();
|
|
617 |
// datatop.top = new FormAttachment(0, 0);
|
|
618 |
// datatop.left = new FormAttachment(0, 0);
|
|
619 |
// datatop.right = new FormAttachment(100, 0);
|
|
620 |
// datatop.bottom = new FormAttachment(panneau, 0);
|
|
621 |
// webBrowser.setLayoutData(datatop);
|
|
622 |
//
|
|
623 |
// FormData databottom = new FormData(200, 30);
|
|
624 |
// databottom.bottom = new FormAttachment(100, 0);
|
|
625 |
// databottom.left = new FormAttachment(30, -100);
|
|
626 |
// databottom.right = new FormAttachment(80, 100);
|
|
627 |
// panneau.setLayoutData(databottom);
|
|
628 |
//
|
|
629 |
// parent.setLayout(parentLayout);
|
|
630 |
// parent.pack();
|
|
631 |
|
|
632 |
// MenuManager menuManager = new MenuManager();
|
|
633 |
// Menu menu = menuManager.createContextMenu(getBrowser());
|
476 |
634 |
//
|
477 |
|
// FormData databottom = new FormData(200, 30);
|
478 |
|
// databottom.bottom = new FormAttachment(100, 0);
|
479 |
|
// databottom.left = new FormAttachment(30, -100);
|
480 |
|
// databottom.right = new FormAttachment(80, 100);
|
481 |
|
// panneau.setLayoutData(databottom);
|
482 |
|
//
|
483 |
|
// parent.setLayout(parentLayout);
|
484 |
|
// parent.pack();
|
|
635 |
// // Set the MenuManager
|
|
636 |
// getBrowser().setMenu(menu);
|
485 |
637 |
|
486 |
|
MenuManager menuManager = new MenuManager();
|
487 |
|
Menu menu = menuManager.createContextMenu(getBrowser());
|
|
638 |
initMenu();
|
488 |
639 |
|
489 |
|
// Set the MenuManager
|
490 |
|
getBrowser().setMenu(menu);
|
491 |
640 |
ISelectionProvider selProvider = new ISelectionProvider() {
|
492 |
641 |
|
493 |
642 |
@Override
|
... | ... | |
594 |
743 |
return ((String) getBrowser().evaluate(SCRIPT01));
|
595 |
744 |
}
|
596 |
745 |
|
597 |
|
// public Object getWordIDsSelection() {
|
598 |
|
// System.out.println("WORDS IDS " + getBrowser().evaluate(SCRIPT02));
|
599 |
|
// return getBrowser().evaluate(SCRIPT02);
|
600 |
|
// }
|
|
746 |
// public Object getWordIDsSelection() {
|
|
747 |
// System.out.println("WORDS IDS " + getBrowser().evaluate(SCRIPT02));
|
|
748 |
// return getBrowser().evaluate(SCRIPT02);
|
|
749 |
// }
|
601 |
750 |
|
602 |
751 |
public String getTextSelection() {
|
603 |
|
System.out.println("DOM=" + getTextSelectionDOM());
|
|
752 |
//System.out.println("DOM=" + getTextSelectionDOM());
|
604 |
753 |
String rez = getTextSelectionDOM().replaceAll("<[^>]+>", "");
|
605 |
|
System.out.println("STR=" + rez);
|
|
754 |
//System.out.println("STR=" + rez);
|
606 |
755 |
return rez;
|
607 |
756 |
}
|
608 |
757 |
|
609 |
|
// /**
|
610 |
|
// * Gets the current page.
|
611 |
|
// *
|
612 |
|
// * @return the current page
|
613 |
|
// */
|
614 |
|
// public Page getCurrentPage() {
|
615 |
|
// return currentPage;
|
616 |
|
// }
|
|
758 |
// /**
|
|
759 |
// * Gets the current page.
|
|
760 |
// *
|
|
761 |
// * @return the current page
|
|
762 |
// */
|
|
763 |
// public Page getCurrentPage() {
|
|
764 |
// return currentPage;
|
|
765 |
// }
|
617 |
766 |
}
|