|
63 | 63 | import org.w3c.dom.NamedNodeMap;
|
64 | 64 | import org.w3c.dom.Node;
|
65 | 65 | import org.w3c.dom.NodeList;
|
| 66 | +import org.jboss.tools.windup.ui.internal.rules.RulesetEditor; |
66 | 67 |
|
67 | 68 | import com.google.common.base.Objects;
|
68 | 69 | import com.google.common.collect.Lists;
|
@@ -105,6 +106,7 @@ public static IFile createLinkedResource(String location) {
|
105 | 106 | try {
|
106 | 107 | op1.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(shell));
|
107 | 108 | } catch (final ExecutionException e) {
|
| 109 | + e.printStackTrace(); |
108 | 110 | WindupUIPlugin.log(e);
|
109 | 111 | }
|
110 | 112 | };
|
@@ -217,17 +219,52 @@ public static IDOMModel getModel(IFile file, boolean edit) {
|
217 | 219 | return (IDOMModel) model;
|
218 | 220 | }
|
219 | 221 | } catch (IOException | CoreException e) {
|
| 222 | + e.printStackTrace(); |
220 | 223 | WindupUIPlugin.log(e);
|
221 | 224 | }
|
222 | 225 | return null;
|
223 | 226 | }
|
224 | 227 |
|
225 |
| - public static void openRuleInEditor(Object provider, Node ruleNode) { |
| 228 | + public static void openSystemRuleInEditor(Object provider, Node ruleNode) { |
226 | 229 | IFile file = XMLRulesetModelUtil.getRuleset(provider);
|
227 | 230 | if (file != null && file.exists()) {
|
228 | 231 | try {
|
229 | 232 | IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
230 |
| - IEditorPart editor = IDE.openEditor(page, file); |
| 233 | +// IEditorPart editor = IDE.openEditor(page, file); |
| 234 | + IEditorPart editor = IDE.openEditor(page, file, RulesetEditor.XML_EDITOR); |
| 235 | + if (editor != null && ruleNode != null) { |
| 236 | + if (editor instanceof RulesetEditorWrapper) { |
| 237 | + ((RulesetEditorWrapper)editor).selectAndReveal((Element)ruleNode); |
| 238 | + } |
| 239 | + else { |
| 240 | + editor.getSite().getSelectionProvider().setSelection(new StructuredSelection(ruleNode)); |
| 241 | + ITextEditor textEditor = editor.getAdapter(ITextEditor.class); |
| 242 | + if (ruleNode instanceof IndexedRegion && textEditor != null) { |
| 243 | + int start = ((IndexedRegion) ruleNode).getStartOffset(); |
| 244 | + int length = ((IndexedRegion) ruleNode).getEndOffset() - start; |
| 245 | + if ((start > -1) && (length > -1)) { |
| 246 | + textEditor.selectAndReveal(start, length); |
| 247 | + } |
| 248 | + } |
| 249 | + } |
| 250 | + } |
| 251 | + } catch (PartInitException e) { |
| 252 | + WindupUIPlugin.log(e); |
| 253 | + MessageDialog.openError( |
| 254 | + Display.getDefault().getActiveShell(), |
| 255 | + Messages.openRuleset, |
| 256 | + Messages.errorOpeningRuleset); |
| 257 | + } |
| 258 | + } |
| 259 | + } |
| 260 | + |
| 261 | + public static void openRuleInEditor(Object provider, Node ruleNode, String editorId) { |
| 262 | + IFile file = XMLRulesetModelUtil.getRuleset(provider); |
| 263 | + if (file != null && file.exists()) { |
| 264 | + try { |
| 265 | + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
| 266 | +// IEditorPart editor = IDE.openEditor(page, file); |
| 267 | + IEditorPart editor = IDE.openEditor(page, file, editorId); |
231 | 268 | if (editor != null && ruleNode != null) {
|
232 | 269 | if (editor instanceof RulesetEditorWrapper) {
|
233 | 270 | ((RulesetEditorWrapper)editor).selectAndReveal((Element)ruleNode);
|
|
0 commit comments