Révision 3260
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java (revision 3260) | ||
---|---|---|
173 | 173 |
* @param sel current selection, might be null |
174 | 174 |
*/ |
175 | 175 |
public static void executeScript(String scriptpath, final IWorkbenchPart page, final ISelection selection, String stringArgs) { |
176 |
executeScript(scriptpath, page, selection, false, null);
|
|
176 |
executeScript(scriptpath, page, selection, false, stringArgs);
|
|
177 | 177 |
} |
178 | 178 |
|
179 | 179 |
/** |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMBrowserEditor.java (revision 3260) | ||
---|---|---|
33 | 33 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
34 | 34 |
import org.eclipse.jface.viewers.ISelectionProvider; |
35 | 35 |
import org.eclipse.swt.browser.Browser; |
36 |
import org.eclipse.swt.browser.ProgressEvent; |
|
37 |
import org.eclipse.swt.browser.ProgressListener; |
|
36 | 38 |
import org.eclipse.swt.graphics.Image; |
37 | 39 |
import org.eclipse.swt.widgets.Composite; |
38 | 40 |
import org.eclipse.swt.widgets.Menu; |
39 | 41 |
import org.eclipse.ui.internal.browser.BrowserViewer; |
40 | 42 |
import org.eclipse.ui.internal.browser.WebBrowserEditor; |
43 |
import org.eclipse.ui.part.Page; |
|
41 | 44 |
import org.txm.rcp.messages.TXMUIMessages; |
42 | 45 |
|
43 | 46 |
/** |
... | ... | |
52 | 55 |
|
53 | 56 |
/** The Constant ID. */ |
54 | 57 |
public final static String ID = TXMBrowserEditor.class.getName(); //$NON-NLS-1$ |
58 |
|
|
59 |
private ProgressListener progresslistener; |
|
55 | 60 |
|
56 | 61 |
/** |
57 | 62 |
* Instantiates a new txm browser. |
... | ... | |
80 | 85 |
super.setTitleImage(titleImage); |
81 | 86 |
} |
82 | 87 |
|
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 |
// } |
|
88 |
CommandLink cmdLink; |
|
139 | 89 |
|
90 |
/** |
|
91 |
* |
|
92 |
* @param wordids2 all the words to highlight |
|
93 |
* @param lineids2 the words to highlight better and to scroll to |
|
94 |
*/ |
|
95 |
public void initializeProgressListener() { |
|
96 |
|
|
97 |
|
|
98 |
ProgressListener progresslistener = new ProgressListener() { |
|
99 |
|
|
100 |
@Override |
|
101 |
public void changed(ProgressEvent event) {} |
|
102 |
|
|
103 |
@Override |
|
104 |
public void completed(ProgressEvent event) { |
|
105 |
cmdLink = new CommandLink(TXMBrowserEditor.this, TXMBrowserEditor.this.getBrowser()); |
|
106 |
} |
|
107 |
}; |
|
108 |
getBrowser().addProgressListener(progresslistener); |
|
109 |
|
|
110 |
} |
|
111 |
|
|
140 | 112 |
// /** |
141 | 113 |
// * Sets the edition. |
142 | 114 |
// * |
... | ... | |
571 | 543 |
getSite().registerContextMenu(menuManager, selProvider); |
572 | 544 |
getSite().setSelectionProvider(selProvider); |
573 | 545 |
|
574 |
new CommandLink(this, getBrowser()); |
|
546 |
initializeProgressListener(); |
|
547 |
|
|
575 | 548 |
// System.out.println("Browser menu: "+getBrowser().getMenu()); |
576 | 549 |
} |
577 | 550 |
|
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/CommandLink.java (revision 3260) | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import org.txm.utils.logger.Log; |
22 | 22 |
|
23 |
import cern.colt.Arrays; |
|
24 |
|
|
23 | 25 |
public class CommandLink extends BrowserFunction { |
24 | 26 |
|
25 | 27 |
String data = ""; |
... | ... | |
38 | 40 |
|
39 | 41 |
@Override |
40 | 42 |
public synchronized Object function(Object[] arguments) { |
43 |
|
|
44 |
Log.finer("txmcommand() called: "+Arrays.toString(arguments)); |
|
41 | 45 |
if (editor != null) { |
42 | 46 |
try { // TODO add option (or another browser command) to not force activated editor |
43 | 47 |
editor.getSite().getPage().activate(editor); |
... | ... | |
73 | 77 |
params.put(arguments[i].toString(), arguments[i + 1].toString()); |
74 | 78 |
} |
75 | 79 |
|
80 |
Log.finer("txmcommand parameters: "+params); |
|
76 | 81 |
String id = params.get("id"); //$NON-NLS-1$ |
77 | 82 |
if (id != null) { |
78 | 83 |
params.remove("id"); //$NON-NLS-1$ |
79 | 84 |
// System.out.println("CALLING CMD with id="+id+" and parameters="+params); |
80 | 85 |
// get the command from plugin.xml |
81 |
callTXMCommand(id, params); |
|
86 |
return callTXMCommand(id, params);
|
|
82 | 87 |
} |
83 | 88 |
else { |
84 |
System.out.println(NLS.bind("Cannot call a TXM command without ID (parameters={0}).", params));
|
|
89 |
Log.warning(NLS.bind("Cannot call a TXM command without ID (parameters={0}).", params));
|
|
85 | 90 |
} |
86 | 91 |
return arguments; |
87 | 92 |
} |
... | ... | |
92 | 97 |
* |
93 | 98 |
*/ |
94 | 99 |
public static Object callTXMCommand(String id, HashMap<String, String> params) { |
100 |
Log.finer(NLS.bind("Calling the {0} command with {1}", id, params)); |
|
101 |
|
|
95 | 102 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
96 | 103 |
ICommandService cmdService = window.getService(ICommandService.class); |
97 | 104 |
Command cmd = cmdService.getCommand(id); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/p2/plugins/TXMUpdateHandler.java (revision 3260) | ||
---|---|---|
60 | 60 |
@Override |
61 | 61 |
public Object execute(ExecutionEvent event) { |
62 | 62 |
|
63 |
if (OSDetector.isFamilyWindows() && !isWindowsAdministratorUser()) { |
|
64 |
TXMMessageBox.show(HandlerUtil.getActiveShell(event), TXMUIMessages.updateWarning, TXMUIMessages.abortingWindowsUpdate, SWT.ICON_WARNING); |
|
65 |
Log.warning("Update canceled"); |
|
66 |
return null; |
|
67 |
} |
|
63 |
// // disabled since java is no more shipped within TXM feature file copy commands |
|
64 |
// if (OSDetector.isFamilyWindows() && !isWindowsAdministratorUser()) { |
|
65 |
// TXMMessageBox.show(HandlerUtil.getActiveShell(event), TXMUIMessages.updateWarning, TXMUIMessages.abortingWindowsUpdate, SWT.ICON_WARNING); |
|
66 |
// Log.warning("Update canceled"); |
|
67 |
// return null; |
|
68 |
// } |
|
68 | 69 |
|
69 | 70 |
String key = event.getParameter("org.txm.rcp.parameters.update"); //$NON-NLS-1$ |
70 | 71 |
if ("true".equals(key)) { |
tmp/org.txm.rcp/plugin.xml (revision 3260) | ||
---|---|---|
250 | 250 |
class="org.txm.rcp.editors.TXMBrowserEditor" |
251 | 251 |
default="false" |
252 | 252 |
icon="icons/objects/edition.png" |
253 |
id="org.txm.rcp.editors.TXMBrowser" |
|
253 |
id="org.txm.rcp.editors.TXMBrowserEditor"
|
|
254 | 254 |
name="%editor.name.5"> |
255 | 255 |
</editor> |
256 | 256 |
<editor |
Formats disponibles : Unified diff