Author: koen.aers(a)jboss.com
Date: 2009-11-11 15:57:45 -0500 (Wed, 11 Nov 2009)
New Revision: 18627
Added:
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.properties
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.xml
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/xml/
Removed:
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.properties
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.xml
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java
Log:
Copied: tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage (from rev 16344,
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage)
Deleted: tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF 2009-07-02
15:15:08 UTC (rev 16344)
+++
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF 2009-11-11
20:57:45 UTC (rev 18627)
@@ -1,23 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.jboss.tools.flow.jpdl4.multipage;singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.jboss.tools.flow.jpdl4.multipage.MultiPageEditorPlugin
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.jface.text,
- org.eclipse.core.resources,
- org.eclipse.ui.editors,
- org.eclipse.ui.ide,
- org.jboss.tools.flow.jpdl4;bundle-version="1.0.0",
- org.eclipse.wst.sse.ui;bundle-version="1.1.3",
- org.eclipse.ui.views.properties.tabbed;bundle-version="3.4.1",
- org.jboss.tools.flow.common;bundle-version="1.0.0",
- org.eclipse.gef;bundle-version="3.4.1",
- org.eclipse.wst.validation;bundle-version="1.2.6",
- org.jboss.tools.jbpm.common;bundle-version="1.0.0"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-ActivationPolicy: lazy
Copied: tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF (from
rev 18321, trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF)
===================================================================
--- tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF
(rev 0)
+++
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF 2009-11-11
20:57:45 UTC (rev 18627)
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.jboss.tools.flow.jpdl4.multipage;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.jboss.tools.flow.jpdl4.multipage.MultiPageEditorPlugin
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text,
+ org.eclipse.core.resources,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.ide,
+ org.jboss.tools.flow.jpdl4;bundle-version="1.0.0",
+ org.eclipse.wst.sse.ui;bundle-version="1.1.3",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.4.1",
+ org.jboss.tools.flow.common;bundle-version="1.0.0",
+ org.eclipse.gef;bundle-version="3.4.1",
+ org.eclipse.wst.validation;bundle-version="1.2.6",
+ org.jboss.tools.jbpm.common;bundle-version="1.0.0",
+ org.eclipse.wst.xml.core;bundle-version="1.1.400"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
Deleted: tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.properties
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/plugin.properties 2009-07-02
15:15:08 UTC (rev 16344)
+++ tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.properties 2009-11-11
20:57:45 UTC (rev 18627)
@@ -1,2 +0,0 @@
-pluginName=Jpdl4 Multipage Editor Plug-in
-providerName=JBoss by Red Hat
\ No newline at end of file
Copied: tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.properties (from
rev 16468, trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/plugin.properties)
===================================================================
--- tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.properties
(rev 0)
+++ tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.properties 2009-11-11
20:57:45 UTC (rev 18627)
@@ -0,0 +1,2 @@
+pluginName=Jpdl4 Multipage Editor
+providerName=JBoss by Red Hat
\ No newline at end of file
Deleted: tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.xml
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/plugin.xml 2009-07-02 15:15:08
UTC (rev 16344)
+++ tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.xml 2009-11-11 20:57:45
UTC (rev 18627)
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<plugin>
-
-
- <extension
- point="org.eclipse.ui.editors">
- <editor
-
class="org.jboss.tools.flow.jpdl4.multipage.editors.MultiPageEditor"
-
contributorClass="org.jboss.tools.flow.jpdl4.multipage.editors.MultiPageEditorContributor"
- icon="icons/process.gif"
- id="org.jboss.tools.flow.jpdl4.multipage.editors.MultiPageEditor"
- name="jBPM jPDL4 Editor">
- <contentTypeBinding
- contentTypeId="org.jboss.tools.flow.jpdl4">
- </contentTypeBinding>
- </editor>
- </extension>
- <extension
- id="org.jboss.tools.flow.jpdl4"
- name="jPDL 4 Validator"
- point="org.eclipse.wst.validation.validatorV2">
- <validator
-
class="org.jboss.tools.flow.jpdl4.multipage.validator.Jpdl4Validator">
- <include>
- <rules>
- <contentType
- id="org.jboss.tools.flow.jpdl4">
- </contentType>
- </rules>
- </include>
- </validator>
- </extension>
-
-</plugin>
Copied: tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.xml (from rev
16834, trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/plugin.xml)
===================================================================
--- tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.xml
(rev 0)
+++ tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/plugin.xml 2009-11-11 20:57:45
UTC (rev 18627)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+
class="org.jboss.tools.flow.jpdl4.multipage.editors.MultiPageEditor"
+
contributorClass="org.jboss.tools.flow.jpdl4.multipage.editors.MultiPageEditorContributor"
+ icon="icons/process.gif"
+ id="org.jboss.tools.flow.jpdl4.multipage.editors.MultiPageEditor"
+ name="jBPM jPDL4 Editor">
+ <contentTypeBinding
+ contentTypeId="org.jboss.tools.flow.jpdl4">
+ </contentTypeBinding>
+ </editor>
+ </extension>
+ <extension
+ id="org.jboss.tools.flow.jpdl4"
+ name="jPDL 4 Validator"
+ point="org.eclipse.wst.validation.validatorV2">
+ <validator
+
class="org.jboss.tools.flow.jpdl4.multipage.validator.Jpdl4Validator">
+ <include>
+ <rules>
+ <contentType
+ id="org.jboss.tools.flow.jpdl4">
+ </contentType>
+ </rules>
+ </include>
+ </validator>
+ </extension>
+ <extension id="org.jboss.tools.flow.jpdl4.problem"
point="org.eclipse.core.resources.markers" name="jPDL4 Problem">
+ <super type="org.eclipse.core.resources.problemmarker"/>
+ </extension>
+</plugin>
Deleted:
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java 2009-07-02
15:15:08 UTC (rev 16344)
+++
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java 2009-11-11
20:57:45 UTC (rev 18627)
@@ -1,185 +0,0 @@
-package org.jboss.tools.flow.jpdl4.multipage.validator;
-
-import java.io.File;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.validation.AbstractValidator;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.ValidationState;
-import org.eclipse.wst.validation.ValidatorMessage;
-import org.jboss.tools.flow.jpdl4.Activator;
-import org.jboss.tools.flow.jpdl4.multipage.Logger;
-import org.jboss.tools.jbpm.Constants;
-import org.jboss.tools.jbpm.preferences.JbpmInstallation;
-import org.jboss.tools.jbpm.preferences.PreferencesManager;
-
-public class Jpdl4Validator extends AbstractValidator {
-
- public ValidationResult validate(
- IResource resource,
- int kind,
- ValidationState state,
- IProgressMonitor monitor) {
- clearMarkers((IFile)resource);
- ValidationResult validationResult = super.validate(resource, kind, state, monitor);
- if (!(resource instanceof IFile) || resource == null) return validationResult;
- PreferencesManager manager =
PreferencesManager.getPreferencesManager(Activator.getDefault());
- if (manager == null) return validationResult;
- String jbpmName =
Activator.getDefault().getPluginPreferences().getString(Constants.JBPM_NAME);
- if (jbpmName == null) return validationResult;
- JbpmInstallation jbpmInstallation = manager.getJbpmInstallation(jbpmName);
- if (jbpmInstallation == null) return validationResult;
- String location = jbpmInstallation.location;
- if (location == null) return validationResult;
- File installdir = new File(location);
- if (!installdir.exists() || !installdir.isDirectory()) return validationResult;
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- ArrayList<URL> urlList = getUrls(installdir);
- ClassLoader newClassLoader = new URLClassLoader(urlList.toArray(new
URL[urlList.size()]), oldClassLoader);
- Thread.currentThread().setContextClassLoader(newClassLoader);
- List problemList = parse((IFile)resource);
- if (!problemList.isEmpty()) {
- validationResult = addToValidationResult((IFile)resource, problemList,
validationResult);
-
- }
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- return validationResult;
- }
-
- private void clearMarkers(IFile file) {
- try {
- IMarker[] markers = file.findMarkers(null, true,
- IResource.DEPTH_ZERO);
- IMarker[] deleteMarkers = new IMarker[markers.length];
- int deleteindex = 0;
- Object owner;
- for (int i = markers.length - 1; i >= 0; i--) {
- IMarker marker = markers[i];
- owner = marker.getAttribute("owner");
-
- if ("org.jboss.tools.jbpm.jpdl4".equals(owner)) {
- deleteMarkers[deleteindex++] = markers[i];
- }
- }
- if (deleteindex > 0) {
- IMarker[] todelete = new IMarker[deleteindex];
- System.arraycopy(deleteMarkers, 0, todelete, 0, deleteindex);
- file.getWorkspace().deleteMarkers(todelete);
- }
- } catch (CoreException e) {
- }
- }
-
- @SuppressWarnings("unchecked")
- private ValidationResult addToValidationResult(IFile file, List problems,
ValidationResult validationResult) {
- if (validationResult == null) {
- validationResult = new ValidationResult();
- }
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
- Class problemClass = cl.loadClass("org.jbpm.api.Problem");
- Method getMsgMethod = problemClass.getMethod("getMsg", new Class[] {});
- Method getLineMethod = problemClass.getMethod("getLine", new Class[] {});
- Method getSeverityMethod = problemClass.getMethod("getSeverity", new Class[]
{});
- for (int i = 0; i < problems.size(); i++) {
- Object target = problems.get(i);
- if (target == null || !problemClass.isInstance(target)) continue;
- String msg = (String)getMsgMethod.invoke(target, new Object[] {});
- String severity = (String)getSeverityMethod.invoke(target, new Object[] {});
- Integer line = getLineNumber(getLineMethod, target);
- String[] attNames = new String[3];
- Object[] attValues = new Object[3];
- attNames[0] = "owner";
- attValues[0] = "org.jboss.tools.jbpm.jpdl4";
- attNames[1] = IMarker.LINE_NUMBER;
- attValues[1] = line;
- attNames[2] = IMarker.SEVERITY;
- attValues[2] = new Integer("error".equals(severity) ?
IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
- ValidatorMessage validatorMessage = ValidatorMessage.create(msg, file);
- validatorMessage.setType(IMarker.PROBLEM);
- validatorMessage.setAttributes(attNames, attValues);
- validationResult.add(validatorMessage);
- }
- } catch (Exception e) {
- Logger.logError("An error occured while creating the problem markers.", e);
- }
- return validationResult;
- }
-
- Integer getLineNumber(Method method, Object target) throws Exception {
- try {
- return (Integer)method.invoke(target, new Object[] {});
- } catch (InvocationTargetException e) {
- if (e.getCause() instanceof NullPointerException) {
- return null;
- } else {
- throw e;
- }
- }
- }
-
- private ArrayList<URL> getUrls(File installdir) {
- ArrayList<URL> urlList = new ArrayList<URL>();
- File jbpmJar = new File(installdir, "jbpm.jar");
- if (!jbpmJar.exists()) {
- Logger.logInfo("jbpm.jar could not be found in the jBPM 4 runtime.");
- } else {
- try {
- urlList.add(jbpmJar.toURL());
- } catch (MalformedURLException e) {
- Logger.logError("Error while adding jbpm.jar to classloader.", e);
- }
- }
- File libdir = new File(installdir, "lib");
- if (!libdir.exists() || !libdir.isDirectory()) {
- Logger.logInfo("lib folder could not be found in the jBPM 4 runtime.");
- } else {
- File[] libfiles = libdir.listFiles();
- for (int i = 0; i < libfiles.length; i++) {
- if (libfiles[i].getName().endsWith(".jar")) {
- try {
- urlList.add(libfiles[i].toURL());
- } catch (MalformedURLException e) {
- Logger.logError("Error while adding " + libfiles[i].getName() + " to
classloader", e);
- }
- }
- }
- }
- return urlList;
- }
-
- @SuppressWarnings("unchecked")
- private List parse(IFile resource) {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
- Class jpdlParserClass =
cl.loadClass("org.jbpm.jpdl.internal.xml.JpdlParser");
- Class parseClass = cl.loadClass("org.jbpm.pvm.internal.xml.Parse");
- Object parserObject = jpdlParserClass.newInstance();
- Method createParseMethod = jpdlParserClass.getMethod("createParse", new
Class[] {});
- Object parse = createParseMethod.invoke(parserObject, new Object[] {});
- Method setInputStreamMethod = parseClass.getMethod("setInputStream", new
Class[] { InputStream.class });
- setInputStreamMethod.invoke(parse, new Object[] { resource.getContents() });
- Method executeMethod = parseClass.getMethod("execute", new Class[] {});
- executeMethod.invoke(parse, new Object[] {});
- Method getProblemsMethod = parseClass.getMethod("getProblems", new Class[]
{});
- return (List)getProblemsMethod.invoke(parse, new Object[] {});
- } catch (Exception e) {
- Logger.logError("An error occurred while attempting to parse the file " +
resource.getName() +".", e);
- return Collections.EMPTY_LIST;
- }
- }
-
-}
Copied:
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java
(from rev 16833,
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java)
===================================================================
---
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java
(rev 0)
+++
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java 2009-11-11
20:57:45 UTC (rev 18627)
@@ -0,0 +1,185 @@
+package org.jboss.tools.flow.jpdl4.multipage.validator;
+
+import java.io.File;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.validation.AbstractValidator;
+import org.eclipse.wst.validation.ValidationResult;
+import org.eclipse.wst.validation.ValidationState;
+import org.eclipse.wst.validation.ValidatorMessage;
+import org.jboss.tools.flow.jpdl4.Activator;
+import org.jboss.tools.flow.jpdl4.multipage.Logger;
+import org.jboss.tools.jbpm.Constants;
+import org.jboss.tools.jbpm.preferences.JbpmInstallation;
+import org.jboss.tools.jbpm.preferences.PreferencesManager;
+
+public class Jpdl4Validator extends AbstractValidator {
+
+ public ValidationResult validate(
+ IResource resource,
+ int kind,
+ ValidationState state,
+ IProgressMonitor monitor) {
+ clearMarkers((IFile)resource);
+ ValidationResult validationResult = super.validate(resource, kind, state, monitor);
+ if (!(resource instanceof IFile) || resource == null) return validationResult;
+ PreferencesManager manager =
PreferencesManager.getPreferencesManager(Activator.getDefault());
+ if (manager == null) return validationResult;
+ String jbpmName =
Activator.getDefault().getPluginPreferences().getString(Constants.JBPM_NAME);
+ if (jbpmName == null) return validationResult;
+ JbpmInstallation jbpmInstallation = manager.getJbpmInstallation(jbpmName);
+ if (jbpmInstallation == null) return validationResult;
+ String location = jbpmInstallation.location;
+ if (location == null) return validationResult;
+ File installdir = new File(location);
+ if (!installdir.exists() || !installdir.isDirectory()) return validationResult;
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ ArrayList<URL> urlList = getUrls(installdir);
+ ClassLoader newClassLoader = new URLClassLoader(urlList.toArray(new
URL[urlList.size()]), oldClassLoader);
+ Thread.currentThread().setContextClassLoader(newClassLoader);
+ List problemList = parse((IFile)resource);
+ if (!problemList.isEmpty()) {
+ validationResult = addToValidationResult((IFile)resource, problemList,
validationResult);
+
+ }
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ return validationResult;
+ }
+
+ private void clearMarkers(IFile file) {
+ try {
+ IMarker[] markers = file.findMarkers(null, true,
+ IResource.DEPTH_ZERO);
+ IMarker[] deleteMarkers = new IMarker[markers.length];
+ int deleteindex = 0;
+ Object owner;
+ for (int i = markers.length - 1; i >= 0; i--) {
+ IMarker marker = markers[i];
+ owner = marker.getAttribute("owner");
+
+ if ("org.jboss.tools.jbpm.jpdl4".equals(owner)) {
+ deleteMarkers[deleteindex++] = markers[i];
+ }
+ }
+ if (deleteindex > 0) {
+ IMarker[] todelete = new IMarker[deleteindex];
+ System.arraycopy(deleteMarkers, 0, todelete, 0, deleteindex);
+ file.getWorkspace().deleteMarkers(todelete);
+ }
+ } catch (CoreException e) {
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private ValidationResult addToValidationResult(IFile file, List problems,
ValidationResult validationResult) {
+ if (validationResult == null) {
+ validationResult = new ValidationResult();
+ }
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Class problemClass = cl.loadClass("org.jbpm.pvm.internal.xml.Problem");
+ Method getMsgMethod = problemClass.getMethod("getMsg", new Class[] {});
+ Method getLineMethod = problemClass.getMethod("getLine", new Class[] {});
+ Method getSeverityMethod = problemClass.getMethod("getSeverity", new Class[]
{});
+ for (int i = 0; i < problems.size(); i++) {
+ Object target = problems.get(i);
+ if (target == null || !problemClass.isInstance(target)) continue;
+ String msg = (String)getMsgMethod.invoke(target, new Object[] {});
+ String severity = (String)getSeverityMethod.invoke(target, new Object[] {});
+ Integer line = getLineNumber(getLineMethod, target);
+ String[] attNames = new String[3];
+ Object[] attValues = new Object[3];
+ attNames[0] = "owner";
+ attValues[0] = "org.jboss.tools.jbpm.jpdl4";
+ attNames[1] = IMarker.LINE_NUMBER;
+ attValues[1] = line;
+ attNames[2] = IMarker.SEVERITY;
+ attValues[2] = new Integer("error".equals(severity) ?
IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
+ ValidatorMessage validatorMessage = ValidatorMessage.create(msg, file);
+ validatorMessage.setType("org.jboss.tools.flow.jpdl4.problem");
+ validatorMessage.setAttributes(attNames, attValues);
+ validationResult.add(validatorMessage);
+ }
+ } catch (Exception e) {
+ Logger.logError("An error occured while creating the problem markers.", e);
+ }
+ return validationResult;
+ }
+
+ Integer getLineNumber(Method method, Object target) throws Exception {
+ try {
+ return (Integer)method.invoke(target, new Object[] {});
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof NullPointerException) {
+ return null;
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ private ArrayList<URL> getUrls(File installdir) {
+ ArrayList<URL> urlList = new ArrayList<URL>();
+ File jbpmJar = new File(installdir, "jbpm.jar");
+ if (!jbpmJar.exists()) {
+ Logger.logInfo("jbpm.jar could not be found in the jBPM 4 runtime.");
+ } else {
+ try {
+ urlList.add(jbpmJar.toURL());
+ } catch (MalformedURLException e) {
+ Logger.logError("Error while adding jbpm.jar to classloader.", e);
+ }
+ }
+ File libdir = new File(installdir, "lib");
+ if (!libdir.exists() || !libdir.isDirectory()) {
+ Logger.logInfo("lib folder could not be found in the jBPM 4 runtime.");
+ } else {
+ File[] libfiles = libdir.listFiles();
+ for (int i = 0; i < libfiles.length; i++) {
+ if (libfiles[i].getName().endsWith(".jar")) {
+ try {
+ urlList.add(libfiles[i].toURL());
+ } catch (MalformedURLException e) {
+ Logger.logError("Error while adding " + libfiles[i].getName() + " to
classloader", e);
+ }
+ }
+ }
+ }
+ return urlList;
+ }
+
+ @SuppressWarnings("unchecked")
+ private List parse(IFile resource) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Class jpdlParserClass =
cl.loadClass("org.jbpm.jpdl.internal.xml.JpdlParser");
+ Class parseClass = cl.loadClass("org.jbpm.pvm.internal.xml.Parse");
+ Object parserObject = jpdlParserClass.newInstance();
+ Method createParseMethod = jpdlParserClass.getMethod("createParse", new
Class[] {});
+ Object parse = createParseMethod.invoke(parserObject, new Object[] {});
+ Method setInputStreamMethod = parseClass.getMethod("setInputStream", new
Class[] { InputStream.class });
+ setInputStreamMethod.invoke(parse, new Object[] { resource.getContents() });
+ Method executeMethod = parseClass.getMethod("execute", new Class[] {});
+ executeMethod.invoke(parse, new Object[] {});
+ Method getProblemsMethod = parseClass.getMethod("getProblems", new Class[]
{});
+ return (List)getProblemsMethod.invoke(parse, new Object[] {});
+ } catch (Exception e) {
+ Logger.logError("An error occurred while attempting to parse the file " +
resource.getName() +".", e);
+ return Collections.EMPTY_LIST;
+ }
+ }
+
+}
Copied:
tags/jbpm-jpdl-4.2/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/xml
(from rev 16833,
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/xml)