Author: koen.aers(a)jboss.com
Date: 2009-06-02 22:52:03 -0400 (Tue, 02 Jun 2009)
New Revision: 15665
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Logger.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/java/
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/java/JavaUtil.java
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF
Log:
support java attributes and elements (GPD-328)
Modified: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF 2009-06-03
02:51:37 UTC (rev 15664)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF 2009-06-03
02:52:03 UTC (rev 15665)
@@ -7,6 +7,10 @@
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.jface;bundle-version="3.4.2",
org.eclipse.ui;bundle-version="3.4.2",
- org.eclipse.core.runtime;bundle-version="3.4.0"
-Export-Package: org.jboss.tools.jbpm.preferences,
+ org.eclipse.core.runtime;bundle-version="3.4.0",
+ org.eclipse.jdt.core;bundle-version="3.4.4",
+ org.eclipse.core.resources;bundle-version="3.4.2",
+ org.eclipse.ui.ide;bundle-version="3.4.2"
+Export-Package: org.jboss.tools.jbpm.java,
+ org.jboss.tools.jbpm.preferences,
org.jboss.tools.jbpm.util
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java 2009-06-03
02:52:03 UTC (rev 15665)
@@ -0,0 +1,50 @@
+package org.jboss.tools.jbpm;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.jbpm.preferences.PreferencesManager;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.jboss.tools.jbpm.common";
+
+ private static Activator plugin;
+
+ public Activator() {
+ }
+
+ public PreferencesManager getPreferencesManager() {
+ return PreferencesManager.getPreferencesManager(this);
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Logger.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Logger.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Logger.java 2009-06-03
02:52:03 UTC (rev 15665)
@@ -0,0 +1,37 @@
+package org.jboss.tools.jbpm;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public class Logger {
+
+ public static void logInfo(String message) {
+ log(IStatus.INFO, IStatus.OK, message, null);
+ }
+
+ public static void logError(Throwable exception) {
+ logError("Unexpected Exception", exception);
+ }
+
+ public static void logError(String message, Throwable exception) {
+ log(IStatus.ERROR, IStatus.OK, message, exception);
+ }
+
+ public static void log(int severity, int code, String message, Throwable exception) {
+ log(createStatus(severity, code, message, exception));
+ }
+
+ public static IStatus createStatus(int severity, int code, String message, Throwable
exception) {
+ return new Status(
+ severity,
+ Activator.getDefault().getBundle().getSymbolicName(),
+ code,
+ message,
+ exception);
+ }
+
+ public static void log(IStatus status) {
+ Activator.getDefault().getLog().log(status);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Logger.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/java/JavaUtil.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/java/JavaUtil.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/java/JavaUtil.java 2009-06-03
02:52:03 UTC (rev 15665)
@@ -0,0 +1,91 @@
+package org.jboss.tools.jbpm.java;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.jbpm.Logger;
+
+public class JavaUtil {
+
+ private static IEditorPart getActiveEditor() {
+ return (IEditorPart)PlatformUI
+ .getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage()
+ .getActiveEditor();
+ }
+
+ private static IFile getCurrentFile() {
+ return ((IFileEditorInput)getActiveEditor().getEditorInput()).getFile();
+ }
+
+ private static IType getClassFor(String className) throws JavaModelException {
+ if (className == null || getCurrentProject() == null) {
+ return null;
+ } else {
+ return getCurrentProject().findType(className);
+ }
+ }
+
+ private static IMethod getMethodFor(String className, String methodName) throws
JavaModelException {
+ IType type = getClassFor(className);
+ if (type != null) {
+ IMethod[] methods = type.getMethods();
+ for (IMethod method : methods) {
+ if (method.getElementName().equals(methodName)) return method;
+ }
+ }
+ return null;
+ }
+
+ public static IJavaProject getCurrentProject() {
+ IJavaProject result = null;
+ IProject project = getCurrentFile().getProject();
+ try {
+ result = project.hasNature("org.eclipse.jdt.core.javanature") ?
JavaCore.create(project) : null;
+ } catch (CoreException e) {
+ Logger.logError("Problem while getting current project.", e);
+ }
+ return result;
+ }
+
+ public static String[] getFields(String className) {
+ ArrayList<String> list = new ArrayList<String>();
+ try {
+ IType type = getClassFor(className);
+ if (type != null ) {
+ IField[] fields = type.getFields();
+ for (IField field : fields) {
+ list.add(field.getElementName());
+ }
+ }
+ } catch (JavaModelException e) {
+ Logger.logError("Error while retrieving fields for " + className, e);
+ }
+ return list.toArray(new String[list.size()]);
+ }
+
+ public static String[] getArguments(String methodName, String className) {
+ ArrayList<String> list = new ArrayList<String>();
+ try {
+ IMethod method = getMethodFor(className, methodName);
+ if (method != null) {
+ return method.getParameterNames();
+ }
+ } catch (JavaModelException e) {
+ Logger.logError("Error while retrieving arguments for " + className +
"." + methodName, e);
+ }
+ return list.toArray(new String[list.size()]);
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/java/JavaUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain