protected void readDataInputAssociation( org.w3c.dom.Node xmlNode, WorkItemNode workItemNode, Map<String, String> dataInputs) { // sourceRef org.w3c.dom.Node subNode = xmlNode.getFirstChild(); if ("sourceRef".equals(subNode.getNodeName())) { String source = subNode.getTextContent(); // targetRef subNode = subNode.getNextSibling(); String target = subNode.getTextContent(); subNode = subNode.getNextSibling(); List<Assignment> assignments = new LinkedList<Assignment>(); while (subNode != null) { org.w3c.dom.Node ssubNode = subNode.getFirstChild(); String from = ssubNode.getTextContent(); String to = ssubNode.getNextSibling().getTextContent(); assignments.add(new Assignment("XPath", from, to)); subNode = subNode.getNextSibling(); } workItemNode.addInAssociation( new DataAssociation(source, dataInputs.get(target), assignments, null)); } else { // targetRef String to = subNode.getTextContent(); // assignment subNode = subNode.getNextSibling(); if (subNode != null) { org.w3c.dom.Node subSubNode = subNode.getFirstChild(); NodeList nl = subSubNode.getChildNodes(); if (nl.getLength() > 1) { // not supported ? workItemNode.getWork().setParameter(dataInputs.get(to), subSubNode.getTextContent()); return; } else if (nl.getLength() == 0) { return; } Object result = null; Object from = nl.item(0); if (from instanceof Text) { String text = ((Text) from).getTextContent(); if (text.startsWith("\"") && text.endsWith("\"")) { result = text.substring(1, text.length() - 1); } else { result = text; } } else { result = nl.item(0); } workItemNode.getWork().setParameter(dataInputs.get(to), result); } } }
@SuppressWarnings("unchecked") private Work openEditor(String editorClassName, WorkDefinition workDefinition) { IJavaProject javaProject = getProject(); if (javaProject != null) { try { ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); ClassLoader newLoader = ProjectClassLoader.getProjectClassLoader(javaProject); try { Thread.currentThread().setContextClassLoader(newLoader); Class<WorkEditor> editorClass = (Class<WorkEditor>) newLoader.loadClass(editorClassName); Constructor<WorkEditor> constructor = editorClass.getConstructor(Shell.class); WorkEditor editor = constructor.newInstance(getViewer().getControl().getShell()); editor.setWorkDefinition(workDefinition); WorkItemNode workItemNode = getWorkItemWrapper().getWorkItemNode(); editor.setWork(workItemNode.getWork()); boolean result = editor.show(); return result ? editor.getWork() : null; } finally { Thread.currentThread().setContextClassLoader(oldLoader); } } catch (Exception e) { DroolsEclipsePlugin.log(e); } } return null; }