Révision 3195
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java (revision 3195) | ||
---|---|---|
37 | 37 |
import org.apache.commons.lang.StringUtils; |
38 | 38 |
import org.eclipse.core.commands.ExecutionEvent; |
39 | 39 |
import org.eclipse.core.commands.ExecutionException; |
40 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
41 | 40 |
import org.eclipse.osgi.util.NLS; |
42 | 41 |
import org.eclipse.ui.IEditorPart; |
43 | 42 |
import org.eclipse.ui.IWorkbenchPage; |
44 | 43 |
import org.eclipse.ui.IWorkbenchWindow; |
45 | 44 |
import org.eclipse.ui.handlers.HandlerUtil; |
46 |
import org.eclipse.ui.part.EditorPart; |
|
47 | 45 |
import org.txm.concordance.core.functions.Concordance; |
48 | 46 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
49 | 47 |
import org.txm.concordance.rcp.handlers.BackToTextCommand; |
50 |
import org.txm.core.results.TXMResult; |
|
51 | 48 |
import org.txm.edition.rcp.editors.RGBA; |
52 | 49 |
import org.txm.edition.rcp.editors.SynopticEditionEditor; |
53 | 50 |
import org.txm.edition.rcp.messages.EditionUIMessages; |
... | ... | |
55 | 52 |
import org.txm.objects.Match; |
56 | 53 |
import org.txm.objects.Text; |
57 | 54 |
import org.txm.rcp.StatusLine; |
58 |
import org.txm.rcp.editors.TXMEditor; |
|
59 | 55 |
import org.txm.rcp.utils.SWTEditorsUtils; |
60 | 56 |
import org.txm.searchengine.core.SearchEngine; |
61 | 57 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
... | ... | |
109 | 105 |
IWorkbenchWindow wb = HandlerUtil.getActiveWorkbenchWindow(event); |
110 | 106 |
IEditorPart ieditor = wb.getActivePage().getActiveEditor(); |
111 | 107 |
|
112 |
if (!backToText(ieditor, corpusid, Arrays.asList(editionid.split("|")), textid, wordid)) { |
|
108 |
if (!backToText(ieditor, corpusid, Arrays.asList(editionid.split("||")), textid, wordid)) {
|
|
113 | 109 |
System.out.println("Could not open edition for wordid=" + wordid + " textid=" + textid + " edition=" + editionid); |
114 | 110 |
} |
115 | 111 |
} |
... | ... | |
189 | 185 |
|
190 | 186 |
editor.backToText(text, wordid); |
191 | 187 |
if (wordid != null) { |
188 |
editor.removeHighlightWords(); |
|
192 | 189 |
editor.addHighlightWordsById(red, wordid); |
193 | 190 |
} |
194 | 191 |
editor.updateWordStyles(); |
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/CommandLink.java (revision 3195) | ||
---|---|---|
1 |
package org.txm.edition.rcp.editors; |
|
2 |
|
|
3 |
import org.eclipse.swt.browser.Browser; |
|
4 |
import org.eclipse.swt.browser.BrowserFunction; |
|
5 |
import org.txm.core.results.TXMResult; |
|
6 |
import org.txm.edition.rcp.messages.EditionUIMessages; |
|
7 |
import org.txm.rcp.editors.TXMEditor; |
|
8 |
|
|
9 |
public class CommandLink extends BrowserFunction { |
|
10 |
|
|
11 |
String data = EditionUIMessages.CommandLink_empty; |
|
12 |
|
|
13 |
Browser browser; |
|
14 |
|
|
15 |
Object ret; |
|
16 |
|
|
17 |
TXMEditor<? extends TXMResult> editor; |
|
18 |
|
|
19 |
CommandLink(TXMEditor<? extends TXMResult> editor, Browser browser) { |
|
20 |
super(browser, "txmcommand"); //$NON-NLS-1$ |
|
21 |
this.browser = browser; |
|
22 |
this.editor = editor; |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public synchronized Object function(Object[] arguments) { |
|
27 |
if (editor != null) { |
|
28 |
try { // TODO add option (or another browser command) to not force activated editor |
|
29 |
editor.getSite().getPage().activate(editor); |
|
30 |
} |
|
31 |
catch (Exception e) { |
|
32 |
System.out.println(e); |
|
33 |
} |
|
34 |
} |
|
35 |
ret = null; |
|
36 |
browser.getDisplay().asyncExec(new Runnable() { |
|
37 |
|
|
38 |
@Override |
|
39 |
public void run() { |
|
40 |
ret = SynopticEditionEditor.callTXMCommand(arguments); |
|
41 |
} |
|
42 |
}); |
|
43 |
return ret; |
|
44 |
} |
|
45 |
} |
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionLink.java (revision 3195) | ||
---|---|---|
7 | 7 |
import org.txm.core.results.TXMResult; |
8 | 8 |
import org.txm.edition.rcp.handlers.BackToText; |
9 | 9 |
import org.txm.edition.rcp.messages.EditionUIMessages; |
10 |
import org.txm.rcp.editors.CommandLink; |
|
10 | 11 |
import org.txm.rcp.editors.TXMEditor; |
11 | 12 |
|
12 | 13 |
/** |
... | ... | |
64 | 65 |
return null; |
65 | 66 |
} |
66 | 67 |
|
67 |
return SynopticEditionEditor.callTXMCommand(id, params);
|
|
68 |
return CommandLink.callTXMCommand(id, params);
|
|
68 | 69 |
} |
69 | 70 |
} |
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java (revision 3195) | ||
---|---|---|
41 | 41 |
import org.txm.objects.Project; |
42 | 42 |
import org.txm.objects.Text; |
43 | 43 |
import org.txm.rcp.StatusLine; |
44 |
import org.txm.rcp.editors.CommandLink; |
|
44 | 45 |
import org.txm.rcp.utils.IOClipboard; |
45 | 46 |
import org.txm.utils.io.IOUtils; |
46 | 47 |
import org.txm.utils.logger.Log; |
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 3195) | ||
---|---|---|
1034 | 1034 |
this.firstPage(); |
1035 | 1035 |
} |
1036 | 1036 |
|
1037 |
/** |
|
1038 |
* Browser command that opens an edition |
|
1039 |
* |
|
1040 |
* @author mdecorde |
|
1041 |
* |
|
1042 |
*/ |
|
1043 |
public static Object callTXMCommand(String id, HashMap<String, String> params) { |
|
1044 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
|
1045 |
ICommandService cmdService = window.getService(ICommandService.class); |
|
1046 |
Command cmd = cmdService.getCommand(id); |
|
1047 |
|
|
1048 |
// get the parameter |
|
1049 |
ArrayList<Parameterization> parameters = new ArrayList<>(); |
|
1050 |
ArrayList<String> failedParameters = new ArrayList<>(); |
|
1051 |
for (String k : params.keySet()) { |
|
1052 |
try { |
|
1053 |
IParameter iparam = cmd.getParameter(k); |
|
1054 |
Parameterization p = new Parameterization(iparam, params.get(k)); |
|
1055 |
parameters.add(p); |
|
1056 |
} |
|
1057 |
catch (NotDefinedException e) { |
|
1058 |
// Log.warning(NLS.bind(EditionUIMessages.warningColonUnknownedParameterIdEqualsP0, k)); |
|
1059 |
failedParameters.add(k); |
|
1060 |
} |
|
1061 |
} |
|
1062 |
|
|
1063 |
// build the parameterized command |
|
1064 |
ParameterizedCommand pc = new ParameterizedCommand(cmd, parameters.toArray(new Parameterization[parameters.size()])); |
|
1065 |
|
|
1066 |
// execute the command |
|
1067 |
IHandlerService handlerService = window.getService(IHandlerService.class); |
|
1068 |
try { |
|
1069 |
return handlerService.executeCommand(pc, null); |
|
1070 |
} |
|
1071 |
catch (Exception e) { |
|
1072 |
Log.warning(TXMCoreMessages.bind("The ''{0}'' hyperlinked command failed with the ''{1}'' parameters and the not recognized ''{2}'' parameters.", id, parameters, failedParameters)); |
|
1073 |
// Log.printStackTrace(e); |
|
1074 |
} |
|
1075 |
return null; |
|
1076 |
} |
|
1037 |
|
|
1077 | 1038 |
|
1078 |
/** |
|
1079 |
* |
|
1080 |
* @param editor may be null, will be used by the command to display its result |
|
1081 |
* @param arguments array of command id + (parameters+values). |
|
1082 |
* |
|
1083 |
* <pre> |
|
1084 |
* ex: String[] arguments = {"commandid", "paramname", "value", "paramname2", "othervalue"}; |
|
1085 |
* </pre> |
|
1086 |
* |
|
1087 |
* @return |
|
1088 |
*/ |
|
1089 |
public static Object callTXMCommand(Object[] arguments) { |
|
1090 |
HashMap<String, String> params = new HashMap<>(); |
|
1091 |
for (int i = 0; i + 1 < arguments.length; i += 2) { |
|
1092 |
params.put(arguments[i].toString(), arguments[i + 1].toString()); |
|
1093 |
} |
|
1094 |
|
|
1095 |
String id = params.get("id"); //$NON-NLS-1$ |
|
1096 |
if (id != null) { |
|
1097 |
params.remove("id"); //$NON-NLS-1$ |
|
1098 |
// System.out.println("CALLING CMD with id="+id+" and parameters="+params); |
|
1099 |
// get the command from plugin.xml |
|
1100 |
callTXMCommand(id, params); |
|
1101 |
} |
|
1102 |
else { |
|
1103 |
System.out.println(NLS.bind(EditionUIMessages.cannotCallTxmcommandWithoutIdParameterColonP0, params)); |
|
1104 |
} |
|
1105 |
return arguments; |
|
1106 |
} |
|
1107 | 1039 |
|
1040 |
|
|
1108 | 1041 |
public LinkedHashMap<String, EditionPanel> getEditionPanels() { |
1109 | 1042 |
return editionPanels; |
1110 | 1043 |
} |
Formats disponibles : Unified diff