JBoss Tools SVN: r24822 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core: META-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjohnstn
Date: 2010-09-08 16:50:06 -0400 (Wed, 08 Sep 2010)
New Revision: 24822
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/.classpath
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
Log:
2010-09-08 Jeff Johnston <jjohnstn(a)redhat.com>
* .classpath: Fix to remove error messages.
* META-INF/MANIFEST.MF: Move deltaclient.jar to end of dependencies.
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getActionJob): New method.
(registerActionJob): Ditto.
(removeActionJob): Ditto.
* src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (removeCloud): Use cached
username and url.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/.classpath
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/.classpath 2010-09-08 19:11:58 UTC (rev 24821)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/.classpath 2010-09-08 20:50:06 UTC (rev 24822)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/deltacloudclient-1.0.jar" sourcepath="/home/cygnus/jjohnstn/deltacloud-tools/DeltaCloudClient/src"/>
<classpathentry exported="true" kind="lib" path="lib/httpclient-4.0.1.jar"/>
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-09-08 19:11:58 UTC (rev 24821)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-09-08 20:50:06 UTC (rev 24822)
@@ -1,3 +1,13 @@
+2010-09-08 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * .classpath: Fix to remove error messages.
+ * META-INF/MANIFEST.MF: Move deltaclient.jar to end of dependencies.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getActionJob): New method.
+ (registerActionJob): Ditto.
+ (removeActionJob): Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (removeCloud): Use cached
+ username and url.
+
2010-09-03 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java (addReplaceInstance): New method.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF 2010-09-08 19:11:58 UTC (rev 24821)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF 2010-09-08 20:50:06 UTC (rev 24822)
@@ -12,7 +12,6 @@
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.deltacloud.core;x-friends:="org.jboss.tools.deltacloud.ui"
Bundle-ClassPath: .,
- lib/deltacloudclient-1.0.jar,
lib/apache-mime4j-0.6.jar,
lib/commons-codec-1.3.jar,
lib/commons-logging-1.1.1.jar,
@@ -20,4 +19,5 @@
lib/httpcore-4.0.1.jar,
lib/httpcore-nio-4.0.1.jar,
lib/httpmime-4.0.1.jar,
- lib/log4j-1.2.14.jar
+ lib/log4j-1.2.14.jar,
+ lib/deltacloudclient-1.0.jar
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-09-08 19:11:58 UTC (rev 24821)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-09-08 20:50:06 UTC (rev 24822)
@@ -13,10 +13,13 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.security.storage.EncodingUtils;
import org.eclipse.equinox.security.storage.ISecurePreferences;
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
@@ -38,8 +41,10 @@
private DeltaCloudClient client;
private ArrayList<DeltaCloudInstance> instances;
private ArrayList<DeltaCloudImage> images;
+ private Map<String, Job> actionJobs;
private Object imageLock = new Object();
private Object instanceLock = new Object();
+ private Object actionLock = new Object();
ListenerList instanceListeners = new ListenerList();
ListenerList imageListeners = new ListenerList();
@@ -129,6 +134,31 @@
((IImageListListener)listeners[i]).listChanged(this, array);
}
+ public Job getActionJob(String id) {
+ synchronized (actionLock) {
+ Job j = null;
+ if (actionJobs != null) {
+ return actionJobs.get(id);
+ }
+ return j;
+ }
+ }
+
+ public void registerActionJob(String id, Job j) {
+ synchronized (actionLock) {
+ if (actionJobs == null)
+ actionJobs = new HashMap<String, Job>();
+ actionJobs.put(id, j);
+ }
+ }
+
+ public void removeActionJob(String id, Job j) {
+ synchronized (actionLock) {
+ if (actionJobs != null && actionJobs.get(id) == j)
+ actionJobs.remove(id);
+ }
+ }
+
public DeltaCloudInstance[] getInstances() {
synchronized (instanceLock) {
instances = new ArrayList<DeltaCloudInstance>();
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java 2010-09-08 19:11:58 UTC (rev 24821)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java 2010-09-08 20:50:06 UTC (rev 24822)
@@ -156,7 +156,7 @@
// includes the password.
if (!found) {
ISecurePreferences root = SecurePreferencesFactory.getDefault();
- String key = DeltaCloud.getPreferencesKey(d.getURL(), d.getUsername());
+ String key = DeltaCloud.getPreferencesKey(url, userName);
ISecurePreferences node = root.node(key);
node.clear();
}
15 years, 7 months
JBoss Tools SVN: r24821 - in trunk/ws/plugins: org.jboss.tools.ws.ui and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: bfitzpat
Date: 2010-09-08 15:11:58 -0400 (Wed, 08 Sep 2010)
New Revision: 24821
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RSServiceCreationCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceCreationCommand.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizard.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizardPage.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossRSGenerateWizard.java
Log:
OPEN - issue JBIDE-6904: Provide simple wizard for creating JAX-WS and JAX-RS services from annotated class files
https://jira.jboss.org/browse/JBIDE-6904
Adds the new "Simple Web Service" wizard that users can use to both create samples and create service projects from their own annotated classes.
Added: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RSServiceCreationCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RSServiceCreationCommand.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RSServiceCreationCommand.java 2010-09-08 19:11:58 UTC (rev 24821)
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.creation.core.commands;
+
+import java.io.File;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+import org.jboss.tools.ws.creation.core.JBossWSCreationCorePlugin;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+
+/**
+ * @author Brian Fitzpatrick
+ *
+ */
+public class RSServiceCreationCommand extends AbstractDataModelOperation {
+
+ private ServiceModel model;
+ private IResource annotatedClassResource;
+ private IResource applicationClassResource;
+ private static String JAVA = ".java"; //$NON-NLS-1$
+
+ public static final String LINE_SEPARATOR = System
+ .getProperty("line.separator"); //$NON-NLS-1$
+
+ public RSServiceCreationCommand(ServiceModel model) {
+ this.model = model;
+ }
+
+ public IResource getAnnotatedClassResource() {
+ return this.annotatedClassResource;
+ }
+
+ public IResource getApplicationClassResource() {
+ return this.applicationClassResource;
+ }
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ IJavaProject project = null;
+ try {
+ project = JBossWSCreationUtils.getJavaProjectByName(model
+ .getWebProjectName());
+ } catch (JavaModelException e) {
+ JBossWSCreationCorePlugin.getDefault().logError(e);
+ return StatusUtils
+ .errorStatus(JBossWSCreationCoreMessages.Error_Create_Client_Sample);
+ }
+
+ // find the class, make sure it's in the project and open if we find it
+ if (model.getServiceClasses() != null && model.getServiceClasses().size() == 1) {
+ String clazzName = model.getServiceClasses().get(0);
+ File file = JBossWSCreationUtils.findFileByPath(clazzName + JAVA, project.getProject()
+ .getLocation().toOSString());
+ if (file == null) {
+ ICompilationUnit rsAnnotatedClass =
+ createRESTAnnotatedJavaClass (model.getCustomPackage(), JBossWSCreationUtils
+ .classNameFromQualifiedName(model.getServiceClasses().get(0)),
+ project);
+ if (rsAnnotatedClass != null) {
+ this.annotatedClassResource = rsAnnotatedClass.getResource();
+ }
+ } else {
+ IResource test = findClass(project, clazzName);
+ if (test != null) {
+ this.annotatedClassResource = test;
+ }
+ }
+ }
+
+ File file = JBossWSCreationUtils.findFileByPath(model.getApplicationClassName() + JAVA, project.getProject()
+ .getLocation().toOSString());
+
+ if (file == null) {
+ ICompilationUnit appClass = createRESTApplicationClass (model.getCustomPackage(), model.getApplicationClassName(),
+ project);
+ if (appClass != null) {
+ this.applicationClassResource = appClass.getResource();
+ } else {
+ IResource test = findClass(project, model.getApplicationClassName());
+ if (test != null) {
+ this.applicationClassResource = test;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public IResource findClass(IJavaProject project, String className) {
+ try {
+ IType type = project.findType(className);
+ if (type != null) {
+ final IPackageFragment fragment = type.getPackageFragment();
+ return fragment.getResource();
+ }
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private ICompilationUnit createRESTApplicationClass(String packageName,
+ String className, IJavaProject project) {
+ try {
+ IPath srcPath = new Path(JBossWSCreationUtils
+ .getJavaProjectSrcLocation(project.getProject()));
+ srcPath = project.getPath().append(
+ srcPath.makeRelativeTo(project.getProject()
+ .getLocation()));
+ IPackageFragmentRoot root = project
+ .findPackageFragmentRoot(srcPath);
+ if (packageName == null) {
+ packageName = ""; //$NON-NLS-1$
+ }
+ IPackageFragment pkg = root.createPackageFragment(packageName,
+ false, null);
+ ICompilationUnit wrapperCls = pkg.createCompilationUnit(className
+ + ".java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
+ if (!packageName.equals("")) { //$NON-NLS-1$
+ wrapperCls.createPackageDeclaration(packageName, null);
+ }
+
+ StringBuffer clsContent = new StringBuffer();
+ clsContent.append("public class ").append(className).append(" extends Application").append(" {" + LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ clsContent.append("}").append(LINE_SEPARATOR); //$NON-NLS-1$
+ wrapperCls.createType(clsContent.toString(), null, true, null);
+
+ wrapperCls.createImport("java.util.Set", null,null); //$NON-NLS-1$
+ wrapperCls.createImport("java.util.HashSet", null,null); //$NON-NLS-1$
+ wrapperCls.createImport("javax.ws.rs.core.Application", null,null); //$NON-NLS-1$
+
+ IType serviceClsType = wrapperCls.findPrimaryType();
+ clsContent = new StringBuffer();
+ clsContent.append("private Set<Object> singletons = new HashSet<Object>();" + LINE_SEPARATOR); //$NON-NLS-1$
+ serviceClsType.createField(clsContent.toString(), null, false, null);
+
+ clsContent = new StringBuffer();
+ clsContent.append("private Set<Class<?>> empty = new HashSet<Class<?>>();" + LINE_SEPARATOR); //$NON-NLS-1$
+ serviceClsType.createField(clsContent.toString(), null, false, null);
+
+ clsContent = new StringBuffer();
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("public " + className + "(){" + LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$
+ clsContent.append(" singletons.add(new " + JBossWSCreationUtils //$NON-NLS-1$
+ .classNameFromQualifiedName(model.getServiceClasses().get(0)) + "());" + LINE_SEPARATOR); //$NON-NLS-1$
+ clsContent.append("}" + LINE_SEPARATOR); //$NON-NLS-1$
+ serviceClsType.createMethod(clsContent.toString(), null, true, null);
+
+ clsContent = new StringBuffer();
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("@Override" + LINE_SEPARATOR); //$NON-NLS-1$
+ clsContent.append("public Set<Class<?>> getClasses() {" + LINE_SEPARATOR); //$NON-NLS-1$
+ clsContent.append(" return empty;" + LINE_SEPARATOR); //$NON-NLS-1$
+ clsContent.append("}" + LINE_SEPARATOR); //$NON-NLS-1$
+ serviceClsType.createMethod(clsContent.toString(), null, true, null);
+
+ clsContent = new StringBuffer();
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("@Override" + LINE_SEPARATOR); //$NON-NLS-1$
+ clsContent.append("public Set<Object> getSingletons() {" + LINE_SEPARATOR); //$NON-NLS-1$
+ clsContent.append(" return singletons;" + LINE_SEPARATOR); //$NON-NLS-1$
+ clsContent.append("}" + LINE_SEPARATOR); //$NON-NLS-1$
+ serviceClsType.createMethod(clsContent.toString(), null, true, null);
+
+ wrapperCls.save(null, true);
+ return wrapperCls;
+ } catch (Exception e) {
+ JBossWSCreationCorePlugin.getDefault().logError(e);
+ return null;
+ }
+ }
+
+ private ICompilationUnit createRESTAnnotatedJavaClass(String packageName,
+ String className, IJavaProject project) {
+ try {
+ IPath srcPath = new Path(JBossWSCreationUtils
+ .getJavaProjectSrcLocation(project.getProject()));
+ srcPath = project.getPath().append(
+ srcPath.makeRelativeTo(project.getProject()
+ .getLocation()));
+ IPackageFragmentRoot root = project
+ .findPackageFragmentRoot(srcPath);
+ if (packageName == null) {
+ packageName = ""; //$NON-NLS-1$
+ }
+ IPackageFragment pkg = root.createPackageFragment(packageName,
+ false, null);
+ ICompilationUnit wrapperCls = pkg.createCompilationUnit(className
+ + ".java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
+ if (!packageName.equals("")) { //$NON-NLS-1$
+ wrapperCls.createPackageDeclaration(packageName, null);
+ }
+
+ StringBuffer clsContent = new StringBuffer();
+ clsContent.append("@Path(\"/" + model.getServiceName() + "\")").append(LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$
+ clsContent.append("public class ").append(className).append(" {" + LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$
+ clsContent.append("}").append(LINE_SEPARATOR); //$NON-NLS-1$
+ wrapperCls.createType(clsContent.toString(), null, true, null);
+
+ wrapperCls.createImport("javax.ws.rs.Produces", null,null); //$NON-NLS-1$
+ wrapperCls.createImport("javax.ws.rs.GET", null,null); //$NON-NLS-1$
+ wrapperCls.createImport("javax.ws.rs.Path", null,null); //$NON-NLS-1$
+
+ IType serviceClsType = wrapperCls.findPrimaryType();
+ clsContent = new StringBuffer();
+ clsContent.append("@GET()"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("@Produces(\"text/plain\")"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("public String sayHello() {"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append(" return \"Hello World!\";"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("}"); //$NON-NLS-1$
+ serviceClsType.createMethod(clsContent.toString(), null, true, null);
+ wrapperCls.save(null, true);
+ return wrapperCls;
+ } catch (Exception e) {
+ JBossWSCreationCorePlugin.getDefault().logError(e);
+ return null;
+ }
+ }
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RSServiceCreationCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceCreationCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceCreationCommand.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceCreationCommand.java 2010-09-08 19:11:58 UTC (rev 24821)
@@ -0,0 +1,134 @@
+package org.jboss.tools.ws.creation.core.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+import org.jboss.tools.ws.creation.core.JBossWSCreationCorePlugin;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+
+public class ServiceCreationCommand extends AbstractDataModelOperation {
+
+ private ServiceModel model;
+ private IResource resource;
+
+ public static final String LINE_SEPARATOR = System
+ .getProperty("line.separator"); //$NON-NLS-1$
+
+ public ServiceCreationCommand(ServiceModel model) {
+ this.model = model;
+ }
+
+ public IResource getResource() {
+ return this.resource;
+ }
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ IJavaProject project = null;
+ try {
+ project = JBossWSCreationUtils.getJavaProjectByName(model
+ .getWebProjectName());
+ } catch (JavaModelException e) {
+ JBossWSCreationCorePlugin.getDefault().logError(e);
+ return StatusUtils
+ .errorStatus(JBossWSCreationCoreMessages.Error_Create_Client_Sample);
+ }
+
+ // find the class, make sure it's in the project and open if we find it
+ if (model.getServiceClasses() != null && model.getServiceClasses().size() == 1) {
+ String clazzName = model.getServiceClasses().get(0);
+ IResource test = findClass(project, clazzName);
+ if (test != null) {
+ this.resource = test;
+ } else {
+ ICompilationUnit createdClass =
+ createJavaClass(model.getCustomPackage(), JBossWSCreationUtils
+ .classNameFromQualifiedName(model.getServiceClasses().get(0)),
+ project);
+ if (createdClass != null) {
+ this.resource = createdClass.getResource();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public IResource findClass(IJavaProject project, String className) {
+ try {
+ IType type = project.findType(className);
+ if (type != null) {
+ if (type.getResource() != null)
+ return type.getResource();
+ }
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private ICompilationUnit createJavaClass(String packageName,
+ String className, IJavaProject project) {
+ try {
+ IPath srcPath = new Path(JBossWSCreationUtils
+ .getJavaProjectSrcLocation(project.getProject()));
+ srcPath = project.getPath().append(
+ srcPath.makeRelativeTo(project.getProject()
+ .getLocation()));
+ IPackageFragmentRoot root = project
+ .findPackageFragmentRoot(srcPath);
+ if (packageName == null) {
+ packageName = ""; //$NON-NLS-1$
+ }
+ IPackageFragment pkg = root.createPackageFragment(packageName,
+ false, null);
+ ICompilationUnit wrapperCls = pkg.createCompilationUnit(className
+ + ".java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
+ if (!packageName.equals("")) { //$NON-NLS-1$
+ wrapperCls.createPackageDeclaration(packageName, null);
+ }
+
+ StringBuffer clsContent = new StringBuffer();
+ clsContent.append("@WebService()").append(LINE_SEPARATOR); //$NON-NLS-1$
+ clsContent.append("public class ").append(className).append(" {" + LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$
+ clsContent.append("}").append(LINE_SEPARATOR); //$NON-NLS-1$
+ wrapperCls.createType(clsContent.toString(), null, true, null);
+
+ wrapperCls.createImport("javax.jws.WebMethod", null,null); //$NON-NLS-1$
+ wrapperCls.createImport("javax.jws.WebService", null,null); //$NON-NLS-1$
+
+ IType serviceClsType = wrapperCls.findPrimaryType();
+ clsContent = new StringBuffer();
+ clsContent.append("@WebMethod()"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("public String sayHello(String name) {"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append(" System.out.println(\"Hello: \" + name);"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append(" return \"Hello \" + name + \"!\";"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("}"); //$NON-NLS-1$
+ serviceClsType.createMethod(clsContent.toString(), null, true, null);
+ wrapperCls.save(null, true);
+ return wrapperCls;
+ } catch (Exception e) {
+ JBossWSCreationCorePlugin.getDefault().logError(e);
+ return null;
+ }
+ }
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceCreationCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties 2010-09-08 18:09:18 UTC (rev 24820)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties 2010-09-08 19:11:58 UTC (rev 24821)
@@ -5,4 +5,9 @@
PLUGIN_PROVIDER=JBoss by Red Hat
JBOSSWS_WIZARD_DESC=Create a sample web service
test.view.category.name = JBoss Tools Web Services
-test.view.name = Web Service Tester
\ No newline at end of file
+test.view.name = Web Service Tester
+restful.wizard.name = Create a Sample RESTful Web Service
+restful.wizard.description = Create a Sample RESTful Web Service
+ws_bottom_up.wizard.name = Simple Web Service
+ws_bottom_up.wizard.description = Create a Sample RESTful Web Service
+jbossws.page.name = JBossWS Runtime
\ No newline at end of file
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2010-09-08 18:09:18 UTC (rev 24820)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2010-09-08 19:11:58 UTC (rev 24821)
@@ -43,12 +43,12 @@
hasPages="true"
icon="icons/obj16/new_webserv_wiz.gif"
id="org.jboss.tools.ws.ui.wizard.rsgenerate"
- name="Create a Sample RESTful Web Service">
+ name="%restful.wizard.name">
<selection
class="org.eclipse.core.resources.IProject">
</selection>
<description>
- Create a Sample RESTful Web Service
+ %restful.wizard.description
</description>
</wizard>
<wizard
@@ -57,14 +57,42 @@
hasPages="true"
icon="icons/obj16/new_webserv_wiz.gif"
id="org.jboss.tools.ws.ui.wizard.rsgenerate2"
- name="Create a Sample RESTful Web Service">
+ name="%restful.wizard.name">
<selection
class="org.eclipse.core.resources.IProject">
</selection>
<description>
- Create a Sample RESTful Web Service
+ %restful.wizard.description
</description>
</wizard>
+ <wizard
+ category="org.eclipse.jst.ws.ui.new"
+ class="org.jboss.tools.ws.ui.wizards.JBossWSAnnotatedClassWizard"
+ hasPages="true"
+ icon="icons/obj16/new_webserv_wiz.gif"
+ id="org.jboss.tools.ws.ui.wizard.wsclass2"
+ name="%ws_bottom_up.wizard.name">
+ <selection
+ class="org.eclipse.core.resources.IProject">
+ </selection>
+ <description>
+ %ws_bottom_up.wizard.description
+ </description>
+ </wizard>
+ <wizard
+ category="org.jboss.ide.eclipse.ui.wizards"
+ class="org.jboss.tools.ws.ui.wizards.JBossWSAnnotatedClassWizard"
+ hasPages="true"
+ icon="icons/obj16/new_webserv_wiz.gif"
+ id="org.jboss.tools.ws.ui.wizard.wsclass"
+ name="%ws_bottom_up.wizard.name">
+ <selection
+ class="org.eclipse.core.resources.IProject">
+ </selection>
+ <description>
+ %ws_bottom_up.wizard.description
+ </description>
+ </wizard>
</extension>
<extension point="org.eclipse.wst.common.project.facet.ui.images">
<image facet="jbossws.core" path="icons/obj16/new_webserv_wiz.gif"/>
@@ -83,7 +111,7 @@
<page
class="org.jboss.tools.ws.ui.project.facet.JBossWSPropertyPage"
id="org.jboss.tools.ws.ui.page"
- name="JBossWS Runtime">
+ name="%jbossws.page.name">
<enabledWhen>
<adapt
type="org.eclipse.core.resources.IProject">
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-09-08 18:09:18 UTC (rev 24820)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-09-08 19:11:58 UTC (rev 24821)
@@ -82,24 +82,24 @@
JBossWS_DelimitedStringList_EditValue_Dialog_Title=Edit Value
JBossWS_DelimitedStringList_EditValue_Dialog_Message=Specify the updated value below.
-JBossWSAnnotatedClassWizard_Annotated_Class_WS_Wizard_Title=Create a Web Service (Botom-up)
+JBossWSAnnotatedClassWizard_Annotated_Class_WS_Wizard_Title=Simple Web Service
JBossWSAnnotatedClassWizardPage_Application_Class_Browse_btn=...
-JBossWSAnnotatedClassWizardPage_Application_Class_field=Application class (JAX-RS only)
+JBossWSAnnotatedClassWizardPage_Application_Class_field=Application class
JBossWSAnnotatedClassWizardPage_JAXRS_Button=JAX-RS (REST)
JBossWSAnnotatedClassWizardPage_JAXWS_Button=JAX-WS (WSDL-based)
JBossWSAnnotatedClassWizardPage_package_browse_btn=...
-JBossWSAnnotatedClassWizardPage_package_name_field=Package name
+JBossWSAnnotatedClassWizardPage_package_name_field=Package
JBossWSAnnotatedClassWizardPage_PageDescription=Select the details for the new web service below. If a class does not yet exist, a sample will be created.
JBossWSAnnotatedClassWizardPage_PageTitle=Project and Web Service Details
JBossWSAnnotatedClassWizardPage_Project_Group=Dynamic web project
JBossWSAnnotatedClassWizardPage_Projects_Combo_Tooltip=If no Dynamic Web Project exists, you must create one before creating your web service.
JBossWSAnnotatedClassWizardPage_Service_class_Browse_btn=...
-JBossWSAnnotatedClassWizardPage_Service_class_field=Service class
+JBossWSAnnotatedClassWizardPage_Service_class_field=Class
JBossWSAnnotatedClassWizardPage_Service_implementation_group=Service implementation
JBossWSAnnotatedClassWizardPage_Service_Name_field=Service name
JBossWSAnnotatedClassWizardPage_Update_Web_xml_checkbox=Update web.xml
-JBossWSAnnotatedClassWizardPage_Web_Service_Group=Web service
-JBossWSAnnotatedClassWizardPage_WS_Tech_Group=Web service technology:
+JBossWSAnnotatedClassWizardPage_Web_Service_Group=Service details
+JBossWSAnnotatedClassWizardPage_WS_Tech_Group=Technology
JAXRSWSTestView_Action_URL_Label=Action URL:
JAXRSWSTestView_Button_Get_From_WSDL=Get from WSDL...
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossRSGenerateWizard.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossRSGenerateWizard.java 2010-09-08 18:09:18 UTC (rev 24820)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossRSGenerateWizard.java 2010-09-08 19:11:58 UTC (rev 24821)
@@ -91,10 +91,8 @@
model.setWebProjectName(project.getName());
model.addServiceClasses(new StringBuffer().append(getPackageName())
.append(".").append(getClassName()).toString()); //$NON-NLS-1$
-// model.addServiceClasses(new StringBuffer().append(getPackageName())
-// .append(".").append(getAppClassName()).toString()); //$NON-NLS-1$
model.setServiceName(getServiceName());
- model.setUpdateWebxml(true);
+ model.setUpdateWebxml(getUpdateWebXML());
model.setCustomPackage(getPackageName());
model.setApplicationClassName( getAppClassName());
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizard.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizard.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizard.java 2010-09-08 19:11:58 UTC (rev 24821)
@@ -0,0 +1,334 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.wizards;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.jboss.tools.ws.creation.core.commands.AddRestEasyJarsCommand;
+import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
+import org.jboss.tools.ws.creation.core.commands.RSMergeWebXMLCommand;
+import org.jboss.tools.ws.creation.core.commands.RSServiceCreationCommand;
+import org.jboss.tools.ws.creation.core.commands.ServiceCreationCommand;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+import org.jboss.tools.ws.ui.JBossWSUIPlugin;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+/**
+ * @author Brian Fitzpatrick
+ *
+ */
+public class JBossWSAnnotatedClassWizard extends Wizard implements INewWizard {
+
+ private static final String JDT_EDITOR =
+ "org.eclipse.jdt.ui.CompilationUnitEditor"; //$NON-NLS-1$
+
+ public static String WSNAMEDEFAULT = "HelloWorld"; //$NON-NLS-1$
+ public static String PACKAGEDEFAULT = "org.jboss.samples.webservices"; //$NON-NLS-1$
+ public static String WSCLASSDEFAULT = "HelloWorld"; //$NON-NLS-1$
+
+ public static String RSNAMEDEFAULT = "MyRESTApplication"; //$NON-NLS-1$
+ public static String RSCLASSDEFAULT = "HelloWorldResource"; //$NON-NLS-1$
+ public static String RSAPPCLASSDEFAULT = "MyRESTApplication"; //$NON-NLS-1$
+
+ private String serviceName = WSNAMEDEFAULT;
+ private String packageName = PACKAGEDEFAULT;
+ private String className = WSCLASSDEFAULT;
+ private String appClassName = ""; //$NON-NLS-1$
+ private boolean useDefaultServiceName = true;
+ private boolean useDefaultClassName = true;
+ private boolean updateWebXML = true;
+ private boolean isJAXWS = true;
+
+ private IStructuredSelection selection;
+ private IProject project;
+
+ private static String WEB = "web.xml"; //$NON-NLS-1$
+ private static String WEBINF = "WEB-INF"; //$NON-NLS-1$
+ private IFile webFile;
+
+ public JBossWSAnnotatedClassWizard() {
+ super();
+ super.setWindowTitle(JBossWSUIMessages.JBossWSAnnotatedClassWizard_Annotated_Class_WS_Wizard_Title);
+ super.setHelpAvailable(false);
+ }
+
+ public void addPages() {
+ super.addPages();
+ JBossWSAnnotatedClassWizardPage onePage =
+ new JBossWSAnnotatedClassWizardPage("onePage"); //$NON-NLS-1$
+ addPage(onePage);
+ }
+
+ @Override
+ public boolean performFinish() {
+ if (canFinish()) {
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(project.getName());
+ model.addServiceClasses(new StringBuffer().append(getPackageName())
+ .append(".").append(getClassName()).toString()); //$NON-NLS-1$
+ model.setServiceName(getServiceName());
+ model.setUpdateWebxml(getUpdateWebXML());
+ model.setCustomPackage(getPackageName());
+ model.setApplicationClassName( getAppClassName());
+
+ AbstractDataModelOperation mergeCommand = null;
+ if (isJAXWS()) {
+ mergeCommand = new MergeWebXMLCommand(model);
+ } else {
+ mergeCommand = new RSMergeWebXMLCommand(model);
+ }
+
+ IStatus status = null;
+ if (getUpdateWebXML()) {
+ try {
+ status = mergeCommand.execute(null, null);
+ } catch (ExecutionException e) {
+ JBossWSUIPlugin.log(e);
+ }
+ if (status != null && status.getSeverity() == Status.ERROR) {
+ MessageDialog
+ .openError(
+ this.getShell(),
+ JBossWSUIMessages.JBossWS_GenerateWizard_MessageDialog_Title,
+ status.getMessage());
+ return false;
+ }
+ }
+
+ AbstractDataModelOperation addJarsCommand = null;
+ AbstractDataModelOperation addClassesCommand = null;
+ if (!isJAXWS()) {
+ addJarsCommand = new AddRestEasyJarsCommand(model);
+ addClassesCommand = new RSServiceCreationCommand(model);
+ } else {
+ addClassesCommand = new ServiceCreationCommand(model);
+ }
+ try {
+ if (addJarsCommand != null) {
+ addJarsCommand.execute(null, null);
+ }
+ if (addClassesCommand != null) {
+ addClassesCommand.execute(null, null);
+ }
+ getProject().refreshLocal(IProject.DEPTH_INFINITE, new NullProgressMonitor());
+ IFile openFile1 = null;
+ IFile openFile2 = null;
+ if (addClassesCommand instanceof ServiceCreationCommand) {
+ ServiceCreationCommand cmd = (ServiceCreationCommand) addClassesCommand;
+ if (cmd.getResource() != null && cmd.getResource() instanceof IFile) {
+ openFile1 = (IFile) cmd.getResource();
+ }
+ } else if (addClassesCommand instanceof RSServiceCreationCommand) {
+ RSServiceCreationCommand cmd = (RSServiceCreationCommand) addClassesCommand;
+ if (cmd.getAnnotatedClassResource() != null && cmd.getAnnotatedClassResource() instanceof IFile) {
+ openFile1 = (IFile) cmd.getAnnotatedClassResource();
+ }
+ if (cmd.getApplicationClassResource() != null && cmd.getApplicationClassResource() instanceof IFile) {
+ openFile2 = (IFile) cmd.getApplicationClassResource();
+ }
+ }
+ if (openFile1 != null) {
+ openResource(openFile1);
+ }
+ if (openFile2 != null) {
+ openResource(openFile2);
+ }
+ } catch (ExecutionException e) {
+ JBossWSUIPlugin.log(e);
+ MessageDialog
+ .openError(
+ this.getShell(),
+ JBossWSUIMessages.JBossWS_GenerateWizard_MessageDialog_Title,
+ e.getMessage());
+ } catch (CoreException e) {
+ JBossWSUIPlugin.log(e);
+ MessageDialog
+ .openError(
+ this.getShell(),
+ JBossWSUIMessages.JBossWS_GenerateWizard_MessageDialog_Title,
+ e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ if (this.selection.getFirstElement() instanceof IProject) {
+ project = (IProject) this.selection.getFirstElement();
+ }
+ if (project != null
+ && JavaEEProjectUtilities.isDynamicWebProject(project)) {
+ webFile = project.getParent().getFolder(
+ JBossWSCreationUtils.getWebContentRootPath(project).append(WEBINF))
+ .getFile(WEB);
+ }
+ }
+
+ @Override
+ public boolean canFinish() {
+ return super.canFinish();
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getAppClassName() {
+ return appClassName;
+ }
+
+ public void setAppClassName(String className) {
+ this.appClassName = className;
+ }
+
+ public boolean isUseDefaultServiceName() {
+ return useDefaultServiceName;
+ }
+
+ public void setUseDefaultServiceName(boolean useDefaultServiceName) {
+ this.useDefaultServiceName = useDefaultServiceName;
+ }
+
+ public boolean isUseDefaultClassName() {
+ return useDefaultClassName;
+ }
+
+ public void setUseDefaultClassName(boolean useDefaultClassName) {
+ this.useDefaultClassName = useDefaultClassName;
+ }
+
+ public void setUpdateWebXML(boolean updateWebXML) {
+ this.updateWebXML = updateWebXML;
+ }
+
+ public boolean getUpdateWebXML() {
+ return updateWebXML;
+ }
+
+ public void setJAXWS(boolean isJAXWS) {
+ this.isJAXWS = isJAXWS;
+ }
+
+ public boolean isJAXWS() {
+ return isJAXWS;
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public ServiceModel getServiceModel() {
+ ServiceModel model = new ServiceModel();
+ if (project != null) {
+ model.setWebProjectName(project.getName());
+ }
+ if (getPackageName() != null) {
+ model.addServiceClasses(new StringBuffer().append(getPackageName())
+ .append(".").append(getClassName()).toString()); //$NON-NLS-1$
+ }
+ model.setServiceName(getServiceName());
+ model.setUpdateWebxml(true);
+ model.setCustomPackage(getPackageName());
+ model.setCustomClassName(getClassName());
+ return model;
+ }
+
+ public void setProject (String projectName) {
+ if (projectName != null && projectName.trim().length() > 0) {
+ IProject test =
+ ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (test != null) {
+ this.project = test;
+ if (project != null
+ && JavaEEProjectUtilities.isDynamicWebProject(project)) {
+ webFile = project.getParent().getFolder(
+ JBossWSCreationUtils.getWebContentRootPath(project).append(WEBINF))
+ .getFile(WEB);
+ }
+ }
+ }
+ }
+
+
+ public IFile getWebFile() {
+ return webFile;
+ }
+
+ protected void openResource(final IFile resource) {
+ if (resource.getType() != IResource.FILE) {
+ return;
+ }
+
+ IWorkbenchWindow window = JBossWSUIPlugin.getActiveWorkbenchWindow();
+ if (window == null) {
+ return;
+ }
+
+ final IWorkbenchPage activePage = window.getActivePage();
+ if (activePage != null) {
+ final Display display = getShell().getDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ try {
+ IDE.openEditor(activePage, resource, JDT_EDITOR, true);
+ } catch (PartInitException e) {
+ JBossWSUIPlugin.log(e);
+ }
+ }
+ });
+ BasicNewResourceWizard.selectAndReveal(resource, activePage
+ .getWorkbenchWindow());
+ }
+ }
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizardPage.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizardPage.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizardPage.java 2010-09-08 19:11:58 UTC (rev 24821)
@@ -0,0 +1,707 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.wizards;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.PackageFragment;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+import org.jboss.tools.ws.creation.core.utils.RestEasyLibUtils;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+@SuppressWarnings("restriction")
+public class JBossWSAnnotatedClassWizardPage extends WizardPage {
+
+ private JBossWSAnnotatedClassWizard wizard;
+ private Combo projects;
+ private boolean bHasChanged = false;
+ private Button optJAXWS;
+ private Button optJAXRS;
+ private Text packageName;
+ private Text className;
+ private Text appClassName;
+ private Text name;
+ private Button updateWebXML;
+ private Button btnPackageBrowse;
+ private Button btnServiceClassBrowse;
+ private Button btnAppClassBrowse;
+
+ protected JBossWSAnnotatedClassWizardPage(String pageName) {
+ super(pageName);
+ this
+ .setTitle(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_PageTitle);
+ this
+ .setDescription(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_PageDescription);
+ }
+
+ private void createWsTechComposite(Composite parent) {
+ Group wsTechGroup = new Group(parent, SWT.NONE);
+ wsTechGroup
+ .setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_WS_Tech_Group);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ wsTechGroup.setLayout(new GridLayout(2, false));
+ wsTechGroup.setLayoutData(gd);
+
+ Composite wsTechComposite = new Composite (wsTechGroup, SWT.NONE);
+ GridLayout gl = new GridLayout(2, true);
+ gl.marginTop = -5;
+ gl.marginBottom = -5;
+ wsTechComposite.setLayout(gl);
+ GridData gridData = new GridData();
+ gridData.horizontalIndent = -5;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
+ wsTechComposite.setLayoutData(gridData);
+
+ optJAXWS = new Button(wsTechComposite, SWT.RADIO);
+ optJAXWS.setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_JAXWS_Button);
+ optJAXWS.setLayoutData(new GridData(SWT.FILL, SWT.NULL, true, false));
+
+ optJAXRS = new Button(wsTechComposite, SWT.RADIO);
+ optJAXRS.setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_JAXRS_Button);
+ optJAXRS.setLayoutData(new GridData(SWT.FILL, SWT.NULL, true, false));
+
+ //default
+ optJAXWS.setSelection(true);
+
+ optJAXWS.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ wizard.setJAXWS(true);
+ appClassName.setEnabled(!wizard.isJAXWS());
+ btnAppClassBrowse.setEnabled(!wizard.isJAXWS());
+ updateDefaultValues();
+ setPageComplete(isPageComplete());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ optJAXRS.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ wizard.setJAXWS(false);
+ appClassName.setEnabled(!wizard.isJAXWS());
+ btnAppClassBrowse.setEnabled(!wizard.isJAXWS());
+ updateDefaultValues();
+ setPageComplete(isPageComplete());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ }
+
+ private String testDefaultServiceName( String currentName) {
+ ServiceModel model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ IStatus status = JBossWSGenerateWizardValidator.isWSNameValid();
+ try {
+ if (status.getSeverity() == IStatus.ERROR
+ && !JavaEEProjectUtilities.isDynamicWebProject(wizard
+ .getProject())) {
+ return currentName;
+ }
+ } catch (NullPointerException npe) {
+ return currentName;
+ }
+ String testName = currentName;
+ int i = 1;
+ while (status != null) {
+ testName = currentName + i;
+ wizard.setServiceName(testName);
+ model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ status = JBossWSGenerateWizardValidator.isWSNameValid();
+ i++;
+ }
+ return testName;
+ }
+
+ private String testDefaultAppClassName(String currentName) {
+ ServiceModel model = wizard.getServiceModel();
+ JBossRSGenerateWizardValidator.setServiceModel(model);
+ if (wizard.getProject() == null) {
+ return currentName;
+ } else {
+ boolean isDynamicWebProject = false;
+ try {
+ if (wizard.getProject().getNature(
+ "org.eclipse.wst.common.project.facet.core.nature") != null) { //$NON-NLS-1$
+ isDynamicWebProject = true;
+ }
+ } catch (CoreException e) {
+ // ignore
+ }
+ if (!isDynamicWebProject) {
+ return currentName;
+ }
+ }
+ String testName = currentName;
+ IStatus status = JBossRSGenerateWizardValidator.isAppClassNameValid(
+ model.getCustomPackage() + '.' + currentName);
+ int i = 1;
+ while (status != null && status.getSeverity() == IStatus.ERROR) {
+ testName = currentName + i;
+ wizard.setClassName(testName);
+ model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ status = JBossWSGenerateWizardValidator.isWSClassValid(testName,
+ wizard.getProject());
+ i++;
+ }
+ return testName;
+ }
+
+ private String testDefaultClassName(String currentName) {
+ ServiceModel model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ if (wizard.getProject() == null) {
+ return currentName;
+ } else {
+ boolean isDynamicWebProject = false;
+ try {
+ if (wizard.getProject().getNature(
+ "org.eclipse.wst.common.project.facet.core.nature") != null) { //$NON-NLS-1$
+ isDynamicWebProject = true;
+ }
+ } catch (CoreException e) {
+ // ignore
+ }
+ if (!isDynamicWebProject) {
+ return currentName;
+ }
+ }
+ String testName = currentName;
+ IStatus status = JBossWSGenerateWizardValidator.isWSClassValid(
+ testName, wizard.getProject());
+ int i = 1;
+ while (status != null && status.getSeverity() == IStatus.ERROR) {
+ testName = currentName + i;
+ wizard.setClassName(testName);
+ model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ status = JBossWSGenerateWizardValidator.isWSClassValid(testName,
+ wizard.getProject());
+ i++;
+ }
+ return testName;
+ }
+
+ private void updateDefaultValues() {
+
+ String testName = null;
+ if (wizard.isJAXWS()) {
+ if (className != null && className.getText().trim().length() == 0) {
+ testName = testDefaultClassName(JBossWSAnnotatedClassWizard.WSCLASSDEFAULT);
+ className.setText(testName);
+ wizard.setClassName(testName);
+ }
+
+ if (name != null && name.getText().trim().length() == 0) {
+ testName = testDefaultServiceName(JBossWSAnnotatedClassWizard.WSNAMEDEFAULT);
+ name.setText(testName);
+ wizard.setServiceName(testName);
+ }
+ appClassName.setText(""); //$NON-NLS-1$
+ wizard.setAppClassName(""); //$NON-NLS-1$
+ } else {
+ if (className != null && className.getText().trim().length() == 0) {
+ testName = testDefaultClassName(JBossWSAnnotatedClassWizard.RSCLASSDEFAULT);
+ className.setText(testName);
+ wizard.setClassName(testName);
+ }
+ if (name != null && name.getText().trim().length() == 0) {
+ testName = testDefaultServiceName(JBossWSAnnotatedClassWizard.RSNAMEDEFAULT);
+ name.setText(testName);
+ wizard.setServiceName(testName);
+ }
+ if (appClassName != null && appClassName.getText().trim().length() == 0) {
+ testName = testDefaultAppClassName(JBossWSAnnotatedClassWizard.RSAPPCLASSDEFAULT);
+ appClassName.setText(testName);
+ wizard.setAppClassName(testName);
+ }
+ }
+ if (packageName != null && packageName.getText().trim().length() == 0) {
+ packageName.setText(JBossWSAnnotatedClassWizard.PACKAGEDEFAULT);
+ wizard.setPackageName(packageName.getText());
+ }
+ }
+
+ private void createProjectGroup ( Composite parent ) {
+ Group group = new Group(parent, SWT.NONE);
+ group
+ .setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Project_Group);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ group.setLayout(new GridLayout(2, false));
+ group.setLayoutData(gd);
+
+ projects = new Combo(group, SWT.BORDER | SWT.DROP_DOWN);
+ projects
+ .setToolTipText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Projects_Combo_Tooltip);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ projects.setLayoutData(gd);
+ refreshProjectList(wizard.getServiceModel().getWebProjectName());
+
+ projects.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ wizard.setProject(projects.getText());
+ bHasChanged = true;
+ setPageComplete(isPageComplete());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ }
+
+ private void createApplicationGroup(Composite parent) {
+ GridData gd = new GridData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ gd.horizontalIndent = -5;
+ gd.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout(2, false));
+ group.setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Web_Service_Group);
+ group.setLayoutData(gd);
+
+ new Label(group, SWT.NONE)
+ .setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Service_Name_field);
+ name = new Text(group, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ name.setLayoutData(gd);
+// name.setText(wizard.getServiceName());
+ name.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ wizard.setServiceName(name.getText());
+ bHasChanged = true;
+ setPageComplete(isPageComplete());
+ }
+
+ });
+
+ updateWebXML = new Button(group, SWT.CHECK);
+ updateWebXML.setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Update_Web_xml_checkbox);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ updateWebXML.setLayoutData(gd);
+ updateWebXML.setSelection(wizard.getUpdateWebXML());
+ updateWebXML.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ wizard.setUpdateWebXML(updateWebXML.getSelection());
+ name.setEnabled(wizard.getUpdateWebXML());
+ setPageComplete(isPageComplete());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ }
+
+ private void createImplementationGroup(Composite parent) {
+ GridData gd = new GridData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ gd.horizontalIndent = -5;
+ gd.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout(3, false));
+ group.setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Service_implementation_group);
+ group.setLayoutData(gd);
+
+ new Label(group, SWT.NONE)
+ .setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_package_name_field);
+ packageName = new Text(group, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ packageName.setLayoutData(gd);
+ packageName.setText(wizard.getPackageName());
+ packageName.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ wizard.setPackageName(packageName.getText());
+ setPageComplete(isPageComplete());
+ }
+
+ });
+
+ btnPackageBrowse = new Button(group, SWT.PUSH);
+ btnPackageBrowse.setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_package_browse_btn);
+ btnPackageBrowse.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ if (wizard.getProject() == null) {
+ return;
+ }
+
+ IJavaProject project = JavaCore.create( wizard.getProject());
+ if (project == null) {
+ return;
+ }
+
+ try {
+ SelectionDialog dialog =
+ JavaUI.createPackageDialog(
+ getShell(),
+ project,
+ IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS);
+ if (dialog.open() == Window.OK) {
+ if (dialog.getResult() != null && dialog.getResult().length == 1) {
+ String fqClassName = ((PackageFragment) dialog.getResult()[0]).getElementName();
+ packageName.setText(fqClassName);
+ setPageComplete(isPageComplete());
+ }
+ }
+ } catch (JavaModelException e1) {
+ e1.printStackTrace();
+ }
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ new Label(group, SWT.NONE)
+ .setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Service_class_field);
+ className = new Text(group, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ className.setLayoutData(gd);
+// className.setText(wizard.getClassName());
+ className.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ wizard.setClassName(className.getText());
+ setPageComplete(isPageComplete());
+ }
+
+ });
+
+ btnServiceClassBrowse = new Button(group, SWT.PUSH);
+ btnServiceClassBrowse.setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Service_class_Browse_btn);
+ btnServiceClassBrowse.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ if (wizard.getProject() == null) {
+ return;
+ }
+
+ try {
+ SelectionDialog dialog =
+ JavaUI.createTypeDialog(
+ getShell(),
+ null,
+ wizard.getProject(),
+ IJavaElementSearchConstants.CONSIDER_CLASSES,
+ false);
+ if (dialog.open() == Window.OK) {
+ if (dialog.getResult() != null && dialog.getResult().length == 1) {
+ String fqClassName = ((IType) dialog.getResult()[0]).getElementName();
+ className.setText(fqClassName);
+ setPageComplete(isPageComplete());
+ }
+ }
+ } catch (JavaModelException e1) {
+ e1.printStackTrace();
+ }
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ new Label(group, SWT.NONE)
+ .setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Application_Class_field);
+ appClassName = new Text(group, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ appClassName.setLayoutData(gd);
+// appClassName.setText(wizard.getAppClassName());
+ appClassName.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ wizard.setAppClassName(appClassName.getText());
+ setPageComplete(isPageComplete());
+ }
+
+ });
+
+ btnAppClassBrowse = new Button(group, SWT.PUSH);
+ btnAppClassBrowse.setText(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_Application_Class_Browse_btn);
+ btnAppClassBrowse.addSelectionListener(new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ if (wizard.getProject() == null) {
+ return;
+ }
+
+ try {
+ SelectionDialog dialog =
+ JavaUI.createTypeDialog(
+ getShell(),
+ null,
+ wizard.getProject(),
+ IJavaElementSearchConstants.CONSIDER_CLASSES,
+ false);
+ if (dialog.open() == Window.OK) {
+ if (dialog.getResult() != null && dialog.getResult().length == 1) {
+ String fqClassName = ((IType) dialog.getResult()[0]).getElementName();
+ appClassName.setText(fqClassName);
+ setPageComplete(isPageComplete());
+ }
+ }
+ } catch (JavaModelException e1) {
+ e1.printStackTrace();
+ }
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+ this.wizard = (JBossWSAnnotatedClassWizard) this.getWizard();
+
+ createWsTechComposite(composite);
+ createProjectGroup(composite);
+ createApplicationGroup(composite);
+ createImplementationGroup(composite);
+ appClassName.setEnabled(!wizard.isJAXWS());
+ btnAppClassBrowse.setEnabled(!wizard.isJAXWS());
+ updateDefaultValues();
+
+ setControl(composite);
+ }
+
+ private void refreshProjectList(String projectName) {
+ String[] projectNames = getProjects();
+ boolean foundInitialProject = false;
+ projects.removeAll();
+ for (int i = 0; i < projectNames.length; i++) {
+ projects.add(projectNames[i]);
+ if (projectNames[i].equals(projectName)) {
+ foundInitialProject = true;
+ }
+ }
+ if (foundInitialProject)
+ projects.setText(projectName);
+ }
+
+ public IWizardPage getNextPage() {
+ return super.getNextPage();
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return validate();
+ }
+
+ private boolean validate() {
+ ServiceModel model = wizard.getServiceModel();
+ if (wizard.isJAXWS()) {
+ setMessage(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Description);
+ setErrorMessage(null);
+
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+
+ if (!projects.isDisposed() && projects.getText().length() > 0) {
+ model.setWebProjectName(projects.getText());
+ }
+
+ if (((JBossWSAnnotatedClassWizard) this.getWizard()).getProject() == null) {
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NoProjectSelected);
+ return false;
+ }
+
+ IFile web = ((JBossWSAnnotatedClassWizard) this.getWizard()).getWebFile();
+ if (web == null || !web.exists()) {
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NotDynamicWebProject);
+ return false;
+ }
+
+ try {
+ if ("" .equals(JBossWSCreationUtils.getJavaProjectSrcLocation(((JBossWSAnnotatedClassWizard) this.getWizard()).getProject()))) { //$NON-NLS-1$
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NoSrcInProject);
+ return false;
+ }
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ }
+
+ IStatus status = JBossWSGenerateWizardValidator.isWSNameValid();
+ if (status != null) {
+ setErrorMessage(status.getMessage());
+ return false;
+ }
+
+ IStatus classNameStatus = JBossWSGenerateWizardValidator.isWSClassValid(model
+ .getCustomClassName(), wizard.getProject());
+ if (classNameStatus != null) {
+ if (classNameStatus.getSeverity() == IStatus.ERROR) {
+ setErrorMessage(classNameStatus.getMessage());
+ return false;
+ } else if (classNameStatus.getSeverity() == IStatus.WARNING) {
+ setMessage(classNameStatus.getMessage(), DialogPage.WARNING);
+ setErrorMessage(null);
+ return true;
+ }
+ }
+
+ setMessage(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Description);
+ setErrorMessage(null);
+ return true;
+ } else {
+ setMessage(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Description);
+ setErrorMessage(null);
+
+ JBossRSGenerateWizardValidator.setServiceModel(model);
+ if (!projects.isDisposed() && projects.getText().length() > 0) {
+ model.setWebProjectName(projects.getText());
+ }
+
+ // no project selected
+ if (((JBossWSAnnotatedClassWizard) this.getWizard()).getProject() == null) {
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NoProjectSelected);
+ return false;
+ }
+
+ // project not a dynamic web project
+ IFile web = ((JBossWSAnnotatedClassWizard) this.getWizard()).getWebFile();
+ if (web == null || !web.exists()) {
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NotDynamicWebProject);
+ return false;
+ }
+
+ IStatus reInstalledStatus =
+ RestEasyLibUtils.doesRuntimeSupportRestEasy(((JBossWSAnnotatedClassWizard) this.getWizard()).getProject());
+ if (reInstalledStatus.getSeverity() != IStatus.OK){
+ setErrorMessage(JBossWSUIMessages.JBossRSGenerateWizardPage_Error_RestEasyJarsNotFoundInRuntime);
+ return false;
+ }
+
+ // no source folder in web project
+ try {
+ if ("" .equals(JBossWSCreationUtils.getJavaProjectSrcLocation(((JBossWSAnnotatedClassWizard) this.getWizard()).getProject()))) { //$NON-NLS-1$
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NoSrcInProject);
+ return false;
+ }
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ }
+
+ // already has a REST sample installed - can't use wizard again
+ if (wizard.getUpdateWebXML()) {
+ IStatus alreadyHasREST = JBossRSGenerateWizardValidator.RESTAppExists();
+ if (alreadyHasREST != null) {
+ if (alreadyHasREST.getSeverity() == IStatus.ERROR) {
+ setErrorMessage(alreadyHasREST.getMessage());
+ return false;
+ } else if (alreadyHasREST.getSeverity() == IStatus.WARNING) {
+ setMessage(alreadyHasREST.getMessage(), DialogPage.WARNING);
+ setErrorMessage(null);
+ return true;
+ }
+ }
+ }
+
+ // Check the service class name
+ IStatus classNameStatus = JBossRSGenerateWizardValidator.isWSClassValid(model
+ .getCustomClassName(), wizard.getProject());
+ if (classNameStatus != null) {
+ if (classNameStatus.getSeverity() == IStatus.ERROR) {
+ setErrorMessage(classNameStatus.getMessage());
+ return false;
+ } else if (classNameStatus.getSeverity() == IStatus.WARNING) {
+ setMessage(classNameStatus.getMessage(), DialogPage.WARNING);
+ setErrorMessage(null);
+ return true;
+ }
+ }
+
+ // check the application class name
+ IStatus appClassNameStatus = JBossRSGenerateWizardValidator.isAppClassNameValid(
+ model.getCustomPackage() + '.' + model.getApplicationClassName());
+ if (appClassNameStatus != null) {
+ if (appClassNameStatus.getSeverity() == IStatus.ERROR) {
+ setMessage(appClassNameStatus.getMessage(), DialogPage.ERROR);
+ return false;
+ } else if (appClassNameStatus.getSeverity() == IStatus.WARNING) {
+ setMessage(appClassNameStatus.getMessage(), DialogPage.WARNING);
+ return true;
+ }
+ }
+ }
+ setMessage(JBossWSUIMessages.JBossWSAnnotatedClassWizardPage_PageDescription);
+ setErrorMessage(null);
+ return true;
+ }
+
+ private String[] getProjects() {
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
+ .getProjects();
+ ArrayList<String> dynamicProjects = new ArrayList<String>();
+ for (int i = 0; i < projects.length; i++) {
+ boolean isDynamicWebProject = JavaEEProjectUtilities
+ .isDynamicWebProject(projects[i]);
+ if (isDynamicWebProject) {
+ dynamicProjects.add(projects[i].getName());
+ }
+ }
+ return dynamicProjects.toArray(new String[dynamicProjects.size()]);
+ }
+
+ protected boolean hasChanged() {
+ return bHasChanged;
+ }
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSAnnotatedClassWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 7 months
JBoss Tools SVN: r24820 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/internal/deltacloud/ui/wizards and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: jjohnstn
Date: 2010-09-08 14:09:18 -0400 (Wed, 08 Sep 2010)
New Revision: 24820
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
Log:
2010-09-08 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java: Fix warning.
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (PerformInstanceActionThread.run): Register
action Job with cloud and cancel any currently running action Job.
(PerformDestroyInstanceActionThread.run): Ditto.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java (createControl): Perform
initial validate call.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java (WatchCreateJob.run): Register
action Job with cloud.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-09-08 18:07:48 UTC (rev 24819)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-09-08 18:09:18 UTC (rev 24820)
@@ -1,5 +1,6 @@
2010-09-08 Jeff Johnston <jjohnstn(a)redhat.com>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java: Fix warning.
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (PerformInstanceActionThread.run): Register
action Job with cloud and cancel any currently running action Job.
(PerformDestroyInstanceActionThread.run): Ditto.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-09-08 18:07:48 UTC (rev 24819)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-09-08 18:09:18 UTC (rev 24820)
@@ -14,8 +14,6 @@
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogPage;
-import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
@@ -61,8 +59,6 @@
private static final String MANAGE_BUTTON_LABEL = "ManageButton.label"; //$NON-NLS-1$
private static final String PROPERTIES_LABEL = "Properties.label"; //$NON-NLS-1$
- private static final String PEM_NAME = "Pem.name"; //$NON-NLS-1$
-
private static final String NONE_RESPONSE = "None.response"; //$NON-NLS-1$
@SuppressWarnings("unused")
private static final String NAME_ALREADY_IN_USE = "ErrorNameInUse.text"; //$NON-NLS-1$
15 years, 7 months
JBoss Tools SVN: r24819 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/deltacloud/ui/views and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjohnstn
Date: 2010-09-08 14:07:48 -0400 (Wed, 08 Sep 2010)
New Revision: 24819
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java
Log:
2010-09-08 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (PerformInstanceActionThread.run): Register
action Job with cloud and cancel any currently running action Job.
(PerformDestroyInstanceActionThread.run): Ditto.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java (createControl): Perform
initial validate call.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java (WatchCreateJob.run): Register
action Job with cloud.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-09-08 17:26:55 UTC (rev 24818)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-09-08 18:07:48 UTC (rev 24819)
@@ -1,3 +1,13 @@
+2010-09-08 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (PerformInstanceActionThread.run): Register
+ action Job with cloud and cancel any currently running action Job.
+ (PerformDestroyInstanceActionThread.run): Ditto.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java (createControl): Perform
+ initial validate call.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java (WatchCreateJob.run): Register
+ action Job with cloud.
+
2010-09-03 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java: Add constants
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-09-08 17:26:55 UTC (rev 24818)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-09-08 18:07:48 UTC (rev 24819)
@@ -348,12 +348,13 @@
@Override
public IStatus run(IProgressMonitor pm) {
+ String id = instance.getId();
try {
pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
pm.worked(1);
// To handle the user starting a new action when we haven't confirmed the last one yet,
// cancel the previous job and then go on performing this action
- Job job = currentPerformingActions.get(instance.getId());
+ Job job = cloud.getActionJob(id);
if (job != null) {
job.cancel();
try {
@@ -362,8 +363,8 @@
// do nothing, this is ok
}
}
- currentPerformingActions.put(instance.getId(), this);
- cloud.performInstanceAction(instance.getId(), action);
+ currentPerformingActions.put(id, this);
+ cloud.performInstanceAction(id, action);
while (instance != null && !(instance.getState().equals(expectedState))
&& !(instance.getState().equals(DeltaCloudInstance.TERMINATED))) {
instance = refreshInstance(instance);
@@ -376,6 +377,7 @@
} catch (DeltaCloudException e) {
// do nothing..action had problem executing..perhaps illegal
} finally {
+ cloud.removeActionJob(id, this);
pm.done();
}
return Status.OK_STATUS;
@@ -397,9 +399,22 @@
@Override
public IStatus run(IProgressMonitor pm) {
+ String id = instance.getId();
try {
pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
pm.worked(1);
+ // To handle the user starting a new action when we haven't confirmed the last one yet,
+ // cancel the previous job and then go on performing this action
+ Job job = cloud.getActionJob(id);
+ if (job != null) {
+ job.cancel();
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ // do nothing, this is ok
+ }
+ }
+ cloud.registerActionJob(id, this);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
@@ -407,6 +422,7 @@
}
});
} finally {
+ cloud.removeActionJob(id, this);
pm.done();
}
return Status.OK_STATUS;
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2010-09-08 17:26:55 UTC (rev 24818)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2010-09-08 18:07:48 UTC (rev 24819)
@@ -287,6 +287,7 @@
setControl(container);
loadFileList();
+ validate();
}
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java 2010-09-08 17:26:55 UTC (rev 24818)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java 2010-09-08 18:07:48 UTC (rev 24819)
@@ -85,6 +85,7 @@
try {
pm.beginTask(WizardMessages.getFormattedString(STARTING_INSTANCE_MSG, new String[] {instanceName}), IProgressMonitor.UNKNOWN);
pm.worked(1);
+ cloud.registerActionJob(instanceId, this);
boolean finished = false;
while (!finished && !pm.isCanceled()) {
instance = cloud.refreshInstance(instanceId);
@@ -96,9 +97,8 @@
} catch (Exception e) {
// do nothing
} finally {
- if (!pm.isCanceled()) {
- cloud.addReplaceInstance(instance);
- }
+ cloud.addReplaceInstance(instance);
+ cloud.removeActionJob(instanceId, this);
pm.done();
}
return Status.OK_STATUS;
15 years, 7 months
JBoss Tools SVN: r24818 - trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2010-09-08 13:26:55 -0400 (Wed, 08 Sep 2010)
New Revision: 24818
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca/BeansXmlCompletionProposalComputer.java
Log:
JBIDE-2704: Code completion of annotations in beans.xml
CDI Class computer is fixed to have the possibility to calculate correct queries and match strings.
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca/BeansXmlCompletionProposalComputer.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca/BeansXmlCompletionProposalComputer.java 2010-09-08 17:07:38 UTC (rev 24817)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca/BeansXmlCompletionProposalComputer.java 2010-09-08 17:26:55 UTC (rev 24818)
@@ -3,7 +3,9 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
@@ -13,24 +15,30 @@
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.contentassist.computers.XmlTagCompletionProposalComputer;
import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
+import org.w3c.dom.Text;
+@SuppressWarnings("restriction")
public class BeansXmlCompletionProposalComputer extends XmlTagCompletionProposalComputer {
@Override
protected void addTagInsertionProposals(
ContentAssistRequest contentAssistRequest, int childPosition,
CompletionProposalInvocationContext context) {
- // TODO Auto-generated method stub
- System.out.println("addTagInsertionProposals: CDI Beans.xml proposals are to be placed here!");
-
String prefix = getTagPrefix();
String uri = getTagUri();
- String query = contentAssistRequest.getMatchString();
+ String query = null;
+ IndexedRegion treeNode = ContentAssistUtils.getNodeAt(context.getViewer(), context.getInvocationOffset());
+ int nodeStartOffset = treeNode == null ? -1 : treeNode.getStartOffset();
+ int localInvocationOffset = nodeStartOffset == -1 ? -1 : context.getInvocationOffset() - nodeStartOffset;
+ String nodeText = treeNode instanceof Text ? ((Text)treeNode).getData() : "";
+ if (localInvocationOffset > 0 && localInvocationOffset <= nodeText.length()) {
+ query = nodeText.substring(0, localInvocationOffset);
+ }
+
if (query == null)
query = ""; //$NON-NLS-1$
String stringQuery = query; //$NON-NLS-1$
@@ -47,23 +55,8 @@
for (int i = 0; proposals != null && i < proposals.length; i++) {
TextProposal textProposal = proposals[i];
- boolean useAutoActivation = true;
String replacementString = textProposal.getReplacementString();
- String closingTag = textProposal.getLabel();
-// if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
-// closingTag = closingTag.substring(1);
-// }
-
-// if (!insertTagOpenningCharacter && replacementString.startsWith("<")) { //$NON-NLS-1$
- // Because the tag starting char is already in the text
-// replacementString = replacementString.substring(1);
-// }
-// if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
-// replacementString += "</" + closingTag + ">"; //$NON-NLS-1$ //$NON-NLS-2$
-// useAutoActivation = false; // JBIDE-6285: Don't invoke code assist automaticly if user inserts <tag></tag>.
-// }
-
int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
int replacementLength = contentAssistRequest.getReplacementLength();
@@ -73,15 +66,15 @@
image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
- String displayString = closingTag;
+ String displayString = textProposal.getLabel();
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
int relevance = textProposal.getRelevance();
if (relevance == TextProposal.R_NONE) {
-// relevance = defaultRelevance == TextProposal.R_NONE? TextProposal.R_TAG_INSERTION : defaultRelevance;
+ relevance = TextProposal.R_TAG_INSERTION;
}
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(useAutoActivation, replacementString,
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(false, replacementString,
replacementOffset, replacementLength, cursorPosition, image, displayString,
contextInformation, additionalProposalInfo, relevance);
15 years, 7 months
JBoss Tools SVN: r24817 - in trunk/hibernatetools/plugins/org.hibernate.eclipse.console: src/org/hibernate/eclipse/codegen and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2010-09-08 13:07:38 -0400 (Wed, 08 Sep 2010)
New Revision: 24817
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationProcessListener.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationUtils.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java
Log:
https://jira.jboss.org/browse/JBIDE-6423 - fixed; https://jira.jboss.org/browse/JBIDE-6648 - fixed
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF 2010-09-08 16:02:20 UTC (rev 24816)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF 2010-09-08 17:07:38 UTC (rev 24817)
@@ -76,6 +76,11 @@
org.eclipse.datatools.connectivity,
org.eclipse.jpt.core,
org.eclipse.jpt.db,
- org.eclipse.jdt
+ org.eclipse.jdt,
+ org.apache.ant;bundle-version="1.7.1",
+ org.eclipse.ant.core;bundle-version="3.2.200",
+ org.eclipse.ant.launching;bundle-version="1.0.0",
+ org.eclipse.ant.ui;bundle-version="3.5.0",
+ org.eclipse.core.externaltools;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java 2010-09-08 16:02:20 UTC (rev 24816)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java 2010-09-08 17:07:38 UTC (rev 24817)
@@ -214,8 +214,7 @@
return null;
}
codeGenXMLFactory = new CodeGenXMLFactory(lc);
- String externalPropFileName = CodeGenXMLFactory.propFileNameSuffix;
- externalPropFileName = getFileName() + "." + externalPropFileName; //$NON-NLS-1$
+ String externalPropFileName = CodeGenXMLFactory.getExternalPropFileNameStandard(getFileName());
codeGenXMLFactory.setExternalPropFileName(externalPropFileName);
codeGenXMLFactory.setPlace2Generate(getContainerFullPath().toString());
IWorkspace workspace = ResourcesPlugin.getWorkspace();
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2010-09-08 16:02:20 UTC (rev 24816)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2010-09-08 17:07:38 UTC (rev 24817)
@@ -166,6 +166,36 @@
IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
return variableManager.performStringSubstitution(expression, false);
}
+
+ /**
+ * ExporterFactory update a collection of output directories,
+ * true if new output directory was added into the set of outputDirs.
+ *
+ * @param defOutDir
+ * @param globalProps
+ * @param outputDirs
+ * @return true if new output directory added
+ * @throws CoreException
+ */
+ public boolean collectOutputDirectories(String defOutDir, final Properties globalProps,
+ Set<String> outputDirs) throws CoreException {
+ Properties extract = new Properties();
+ Properties props = new Properties();
+ props.putAll(globalProps);
+ props.putAll(getProperties());
+ extractExporterProperties(exporterId, props, extract);
+ String outputPath = defOutDir;
+ if (extract.containsKey(ExporterFactoryStrings.OUTPUTDIR)) {
+ outputPath = extract.getProperty(ExporterFactoryStrings.OUTPUTDIR);
+ }
+ String resolvedOutputDir = resolve(outputPath);
+ String loc = PathHelper.getLocationAsStringPath(resolvedOutputDir);
+ boolean res = false;
+ if (StringHelper.isNotEmpty(loc)) { // only set if something valid found
+ res = outputDirs.add(loc);
+ }
+ return res;
+ }
/**
* Creates exporter with the specified settings; also resolves any relevant properties via Eclipse VariablesPlugin.
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java 2010-09-08 16:02:20 UTC (rev 24816)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java 2010-09-08 17:07:38 UTC (rev 24817)
@@ -516,4 +516,9 @@
return workspacePath;
}
+ public static String getExternalPropFileNameStandard(String fileName) {
+ String externalPropFileName = CodeGenXMLFactory.propFileNameSuffix;
+ externalPropFileName = fileName + "." + externalPropFileName; //$NON-NLS-1$
+ return externalPropFileName;
+ }
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2010-09-08 16:02:20 UTC (rev 24816)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2010-09-08 17:07:38 UTC (rev 24817)
@@ -22,6 +22,9 @@
package org.hibernate.eclipse.launch;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.Constructor;
import java.util.HashSet;
import java.util.Iterator;
@@ -30,12 +33,16 @@
import java.util.Properties;
import java.util.Set;
+import org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate;
+import org.eclipse.ant.launching.IAntLaunchConstants;
+import org.eclipse.core.externaltools.internal.IExternalToolConstants;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.manipulation.FileBufferOperationRunner;
import org.eclipse.core.filebuffers.manipulation.MultiTextEditWithProgress;
import org.eclipse.core.filebuffers.manipulation.TextFileBufferOperation;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
@@ -46,14 +53,17 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.ui.RefreshTab;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.formatter.CodeFormatter;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jface.text.DocumentRewriteSessionType;
import org.eclipse.jface.text.IDocument;
import org.eclipse.osgi.util.NLS;
@@ -77,8 +87,10 @@
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
-public class CodeGenerationLaunchDelegate extends
- LaunchConfigurationDelegate {
+@SuppressWarnings("restriction")
+public class CodeGenerationLaunchDelegate extends AntLaunchDelegate {
+
+ protected IPath path2GenBuildXml = null;
private static final class FormatGeneratedCode extends TextFileBufferOperation {
private FormatGeneratedCode(String name) {
@@ -115,28 +127,136 @@
}
}
+ /**
+ * Create file with file name fileName and content fileContent
+ *
+ * @param fileName - file name
+ * @param fileContent - file content
+ * @throws IOException
+ */
+ protected void createFile(String fileName, String fileContent) throws IOException {
+ FileOutputStream fos = null;
+ try {
+ File ff = new File(fileName);
+ if (!ff.exists()) {
+ ff.createNewFile();
+ }
+ fos = new FileOutputStream(fileName);
+ fos.write(fileContent.getBytes());
+ fos.flush();
+ } finally {
+ if (fos != null) {
+ try {
+ fos.close();
+ } catch (IOException e) {}
+ }
+ }
+ }
+
+ /**
+ * Create temporary build.xml and then erase it after code generation complete
+ *
+ * @param lc
+ * @throws IOException
+ * @throws UnsupportedEncodingException
+ */
+ protected void createBuildXmlFile(ILaunchConfiguration lc, String fileName) throws UnsupportedEncodingException, IOException {
+ CodeGenXMLFactory codeGenXMLFactory = new CodeGenXMLFactory(lc);
+ String externalPropFileName = CodeGenXMLFactory.getExternalPropFileNameStandard(fileName);
+ codeGenXMLFactory.setExternalPropFileName(externalPropFileName);
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ if (workspace != null && workspace.getRoot() != null && workspace.getRoot().getLocation() != null) {
+ codeGenXMLFactory.setWorkspacePath(workspace.getRoot().getLocation().toString());
+ }
+ String buildXml = codeGenXMLFactory.createCodeGenXML();
+ createFile(fileName, buildXml);
+ final String propFileContentPreSave = codeGenXMLFactory.getPropFileContentPreSave();
+ createFile(externalPropFileName, propFileContentPreSave);
+ }
+
+ /**
+ * Update launch configuration with attributes required for external process codegen.
+ *
+ * @param lc
+ * @return
+ * @throws CoreException
+ */
+ public ILaunchConfiguration updateLaunchConfig(ILaunchConfiguration lc) throws CoreException {
+ ILaunchConfigurationWorkingCopy lcwc = lc.getWorkingCopy();
+ String fileName = null;
+ try {
+ fileName = getPath2GenBuildXml().toString();
+ } catch (IOException e) {
+ throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
+ }
+ // setup location of Ant build.xml file
+ lcwc.setAttribute(IExternalToolConstants.ATTR_LOCATION, fileName);
+ // setup Ant runner main type
+ lcwc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
+ IAntLaunchConstants.MAIN_TYPE_NAME);
+ // setup ant remote process factory
+ lcwc.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, "org.eclipse.ant.ui.remoteAntProcessFactory"); //$NON-NLS-1$
+ // refresh whole workspace
+ //lcwc.setAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, RefreshUtil.MEMENTO_WORKSPACE);
+ return lcwc;
+ }
+ public ILaunch getLaunch(ILaunchConfiguration configuration, String mode)
+ throws CoreException {
+ configuration = updateLaunchConfig(configuration);
+ return super.getLaunch(configuration, mode);
+ }
+
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
Assert.isNotNull(configuration);
Assert.isNotNull(monitor);
- try {
- ExporterAttributes attributes = new ExporterAttributes(configuration);
-
- List<ExporterFactory> exporterFactories = attributes.getExporterFactories();
- for (Iterator<ExporterFactory> iter = exporterFactories.iterator(); iter.hasNext();) {
+ ExporterAttributes attributes = new ExporterAttributes(configuration);
+ List<ExporterFactory> exporterFactories = attributes.getExporterFactories();
+ for (Iterator<ExporterFactory> iter = exporterFactories.iterator(); iter.hasNext();) {
+ ExporterFactory exFactory = iter.next();
+ if (!exFactory.isEnabled(configuration)) {
+ iter.remove();
+ }
+ }
+ if (attributes.isUseExternalProcess()) {
+ // create temporary build.xml and then erase it after code generation complete
+ String fileName = null;
+ try {
+ fileName = getPath2GenBuildXml().toString();
+ createBuildXmlFile(configuration, fileName);
+ } catch (UnsupportedEncodingException e) {
+ throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
+ } catch (IOException e) {
+ throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
+ }
+ configuration = updateLaunchConfig(configuration);
+ super.launch(configuration, mode, launch, monitor);
+ //
+ final Properties props = new Properties();
+ props.put(CodeGenerationStrings.EJB3, "" + attributes.isEJB3Enabled()); //$NON-NLS-1$
+ props.put(CodeGenerationStrings.JDK5, "" + attributes.isJDK5Enabled()); //$NON-NLS-1$
+ Set<String> outputDirs = new HashSet<String>();
+ for (Iterator<ExporterFactory> iter = exporterFactories.iterator(); iter.hasNext();) {
ExporterFactory exFactory = iter.next();
- if(!exFactory.isEnabled(configuration)) {
- iter.remove();
- }
+ exFactory.collectOutputDirectories(attributes.getOutputPath(),
+ props, outputDirs);
}
-
+ //
+ final IProcess[] processes = launch.getProcesses();
+ // codegen listener to erase build.xml file after codegen process complete
+ CodeGenerationProcessListener refresher = new CodeGenerationProcessListener(
+ processes[0], fileName, outputDirs);
+ refresher.startBackgroundRefresh();
+ return;
+ }
+ try {
Set<String> outputDirectories = new HashSet<String>();
ExporterFactory[] exporters = exporterFactories.toArray( new ExporterFactory[exporterFactories.size()] );
ArtifactCollector collector = runExporters(attributes, exporters, outputDirectories, monitor);
for (String path : outputDirectories) {
- refreshOutputDir( path );
+ CodeGenerationUtils.refreshOutputDir(path);
}
RefreshTab.refreshResources(configuration, monitor);
@@ -186,18 +306,6 @@
}
- private void refreshOutputDir(String outputdir) {
- IResource bufferRes = PathHelper.findMember(ResourcesPlugin.getWorkspace().getRoot(), outputdir);
-
- if (bufferRes != null && bufferRes.isAccessible()) {
- try {
- bufferRes.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- //ignore, maybe merge into possible existing status.
- }
- }
- }
-
private ArtifactCollector runExporters (final ExporterAttributes attributes, final ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final IProgressMonitor monitor)
throws CoreException
{
@@ -381,4 +489,12 @@
throws CoreException {
throw new CoreException(new Status(IStatus.ERROR, HibernateConsolePlugin.ID, code, message, exception));
}
+
+ public IPath getPath2GenBuildXml() throws IOException {
+ if (path2GenBuildXml != null) {
+ return path2GenBuildXml;
+ }
+ path2GenBuildXml = new Path(File.createTempFile("build_", "xml").getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
+ return path2GenBuildXml;
+ }
}
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationProcessListener.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationProcessListener.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationProcessListener.java 2010-09-08 17:07:38 UTC (rev 24817)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.launch;
+
+import java.io.File;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IProcess;
+
+/**
+ * Refreshes resources as specified by a launch configuration, when
+ * an associated process terminates.
+ *
+ * Here the listener intended to delete temporary generated Ant build.xml file.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class CodeGenerationProcessListener implements IDebugEventSetListener {
+
+ protected IProcess process;
+ protected String fileName;
+ protected Set<String> outputDirs;
+
+ public CodeGenerationProcessListener(IProcess process, String fileName,
+ Set<String> outputDirs) {
+ this.process = process;
+ this.fileName = fileName;
+ this.outputDirs = outputDirs;
+ }
+
+ /**
+ * If the process has already terminated, resource refreshing is done
+ * immediately in the current thread. Otherwise, refreshing is done when the
+ * process terminates.
+ */
+ public void startBackgroundRefresh() {
+ synchronized (process) {
+ if (process.isTerminated()) {
+ refresh();
+ } else {
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
+ */
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ if (event.getSource() == process && event.getKind() == DebugEvent.TERMINATE) {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ refresh();
+ break;
+ }
+ }
+ }
+
+ /**
+ * Submits a job to do the refresh, i.e. delete temporary build.xml and
+ * it's parent directory.
+ */
+ protected void refresh() {
+ // erase file fileName
+ IPath path2File = new Path(fileName);
+ File file = path2File.toFile();
+ file.delete();
+ //
+ String externalPropFileName = CodeGenXMLFactory.getExternalPropFileNameStandard(fileName);
+ path2File = new Path(externalPropFileName);
+ file = path2File.toFile();
+ file.delete();
+ for (String path : outputDirs) {
+ CodeGenerationUtils.refreshOutputDir(path);
+ }
+ }
+}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2010-09-08 16:02:20 UTC (rev 24816)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2010-09-08 17:07:38 UTC (rev 24817)
@@ -92,8 +92,8 @@
private SelectionButtonDialogField useOwnTemplates;
private DirectoryBrowseField templatedir;
+ private SelectionButtonDialogField useExternalProcess;
-
public CodeGenerationSettingsTab() {
super();
}
@@ -113,6 +113,16 @@
layout.numColumns = 4;
layout.verticalSpacing = 10;
+ IDialogFieldListener fieldlistener = new IDialogFieldListener() {
+ public void dialogFieldChanged(DialogField field) {
+ dialogChanged();
+ }
+ };
+
+ useExternalProcess = new SelectionButtonDialogField(SWT.CHECK);
+ useExternalProcess.setDialogFieldListener(fieldlistener);
+ useExternalProcess.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_use_generation_in_external_process);
+
consoleConfigurationName = new ComboDialogField(SWT.READ_ONLY);
consoleConfigurationName.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_console_configuration);
ConsoleConfiguration[] cfg = LaunchHelper.findFilteredSortedConsoleConfigs();
@@ -124,12 +134,6 @@
}
consoleConfigurationName.setItems(names);
- IDialogFieldListener fieldlistener = new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- dialogChanged();
- }
- };
-
consoleConfigurationName.setDialogFieldListener(fieldlistener);
outputdir = new StringButtonDialogField(new IStringButtonAdapter() {
@@ -242,6 +246,7 @@
useOwnTemplates.attachDialogField(templatedir);
reverseengineer.attachDialogFields(new DialogField[] { packageName, preferRawCompositeIds, reverseEngineeringSettings, reverseEngineeringStrategy, autoManyToMany, autoOneToOne, autoVersioning });
+ useExternalProcess.doFillIntoGrid(container, 4);
consoleConfigurationName.doFillIntoGrid(container, 4);
Control[] controls = outputdir.doFillIntoGrid(container, 4);
// Hack to tell the text field to stretch!
@@ -280,12 +285,20 @@
outputdir.setEnabled(!configSelected);
reverseengineer.setEnabled(!configSelected);
useOwnTemplates.setEnabled(!configSelected);
+ useExternalProcess.setEnabled(!configSelected);
+ boolean useExternalProcessFlag = useExternalProcess.isSelected();
+ preferRawCompositeIds.setEnabled(reverseengineer.isSelected() &&
+ !configSelected && !useExternalProcessFlag);
+ if (useExternalProcessFlag) {
+ preferRawCompositeIds.setSelection(true);
+ }
+
if (configSelected) {
updateStatus(HibernateConsoleMessages.CodeGenerationSettingsTab_console_cfg_must_be_specified);
return;
}
-
+
String msg = PathHelper.checkDirectory(outputdir.getText(), HibernateConsoleMessages.CodeGenerationSettingsTab_output_directory, true);
if (msg!=null) {
@@ -377,7 +390,7 @@
public String getConfigurationName() {
String text = consoleConfigurationName.getText();
- return NULL_CONFIG.equals(text) ? "" : text;
+ return NULL_CONFIG.equals(text) ? "" : text; //$NON-NLS-1$
}
@@ -424,27 +437,29 @@
}
public void initializeFrom(ILaunchConfiguration configuration) {
+ ExporterAttributes attributes = null;
try {
- ExporterAttributes attributes = new ExporterAttributes(configuration);
- if ( consoleConfigurationName.getText() != attributes.getConsoleConfigurationName()){
- consoleConfigurationName.selectItem(0);//NULL_CONFIG
- consoleConfigurationName.setText(attributes.getConsoleConfigurationName());
- }
-
- preferRawCompositeIds.setSelection(attributes.isPreferBasicCompositeIds());
- autoManyToMany.setSelection( attributes.detectManyToMany() );
- autoVersioning.setSelection( attributes.detectOptimisticLock() );
- autoOneToOne.setSelection( attributes.detectOneToOne());
- outputdir.setText(safeText(attributes.getOutputPath()));
- reverseengineer.setSelection(attributes.isReverseEngineer());
- reverseEngineeringSettings.setText(safeText(attributes.getRevengSettings()));
- reverseEngineeringStrategy.setText(safeText(attributes.getRevengStrategy()));
- useOwnTemplates.setSelection(attributes.isUseOwnTemplates());
- packageName.setText(safeText(attributes.getPackageName()));
- templatedir.setText(safeText(attributes.getTemplatePath()));
+ attributes = new ExporterAttributes(configuration);
} catch (CoreException ce) {
- HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.CodeGenerationSettingsTab_problems_when_reading, ce);
+ HibernateConsolePlugin.getDefault().logErrorMessage(
+ HibernateConsoleMessages.CodeGenerationSettingsTab_problems_when_reading, ce);
}
+ if (attributes == null) {
+ return;
+ }
+ consoleConfigurationName.setText(attributes.getConsoleConfigurationName());
+ preferRawCompositeIds.setSelection(attributes.isPreferBasicCompositeIds());
+ autoManyToMany.setSelection( attributes.detectManyToMany() );
+ autoVersioning.setSelection( attributes.detectOptimisticLock() );
+ autoOneToOne.setSelection( attributes.detectOneToOne());
+ outputdir.setText(safeText(attributes.getOutputPath()));
+ reverseengineer.setSelection(attributes.isReverseEngineer());
+ reverseEngineeringSettings.setText(safeText(attributes.getRevengSettings()));
+ reverseEngineeringStrategy.setText(safeText(attributes.getRevengStrategy()));
+ useOwnTemplates.setSelection(attributes.isUseOwnTemplates());
+ packageName.setText(safeText(attributes.getPackageName()));
+ templatedir.setText(safeText(attributes.getTemplatePath()));
+ useExternalProcess.setSelection(attributes.isUseExternalProcess());
}
private String safeText(String text) {
@@ -453,29 +468,30 @@
private String strOrNull(String text) {
if(text==null || text.trim().length()==0) {
- return null;
- } else {
- return text;
+ text = null;
}
+ return text;
}
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, strOrNull(outputdir.getText()));
- configuration.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, preferRawCompositeIds.isSelected());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, autoManyToMany.isSelected());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_ONE_TO_ONE, autoOneToOne.isSelected());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, autoVersioning.isSelected());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, isReverseEngineerEnabled());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_STRATEGY, strOrNull(reverseEngineeringStrategy.getText()));
- configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_SETTINGS, strOrNull(reverseEngineeringSettings.getText()));
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ config.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, strOrNull(outputdir.getText()));
+ config.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, preferRawCompositeIds.isSelected());
+ config.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, autoManyToMany.isSelected());
+ config.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_ONE_TO_ONE, autoOneToOne.isSelected());
+ config.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, autoVersioning.isSelected());
+ config.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, isReverseEngineerEnabled());
+ config.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_STRATEGY, strOrNull(reverseEngineeringStrategy.getText()));
+ config.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_SETTINGS, strOrNull(reverseEngineeringSettings.getText()));
- configuration.setAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES, useOwnTemplates.isSelected());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR, strOrNull(templatedir.getText()));
+ config.setAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES, useOwnTemplates.isSelected());
+ config.setAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR, strOrNull(templatedir.getText()));
- configuration.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, getConfigurationName());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, getOutputPackage());
+ config.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, getConfigurationName());
+ config.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, getOutputPackage());
+ config.setAttribute(HibernateLaunchConstants.ATTR_USE_EXTERNAL_PROCESS, useExternalProcess.isSelected());
+
}
public String getName() {
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationUtils.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationUtils.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationUtils.java 2010-09-08 17:07:38 UTC (rev 24817)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.launch;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Utility class for code generation.
+ */
+public class CodeGenerationUtils {
+
+ public static void refreshOutputDir(String outputdir) {
+ IResource bufferRes = PathHelper.findMember(ResourcesPlugin.getWorkspace().getRoot(),
+ outputdir);
+
+ if (bufferRes != null && bufferRes.isAccessible()) {
+ try {
+ bufferRes.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ // ignore, maybe merge into possible existing status.
+ }
+ }
+ }
+}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2010-09-08 16:02:20 UTC (rev 24816)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2010-09-08 17:07:38 UTC (rev 24817)
@@ -65,6 +65,7 @@
public class ExporterAttributes
{
private boolean reverseEngineer, useOwnTemplates, enableJDK5, enableEJB3, preferBasicCompositeIds;
+ private boolean useExternalProcess;
private String consoleConfigurationName;
private String revengSettings;
private String revengStrategy;
@@ -95,6 +96,7 @@
revengSettings = configuration.getAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_SETTINGS, ""); //$NON-NLS-1$
revengStrategy = configuration.getAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_STRATEGY, ""); //$NON-NLS-1$
useOwnTemplates = configuration.getAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES,false);
+ useExternalProcess = configuration.getAttribute(HibernateLaunchConstants.ATTR_USE_EXTERNAL_PROCESS, false);
enableJDK5 = configuration.getAttribute(HibernateLaunchConstants.ATTR_ENABLE_JDK5,false);
enableEJB3 = configuration.getAttribute(HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS,false);
packageName = configuration.getAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME,""); //$NON-NLS-1$
@@ -336,6 +338,16 @@
{
this.useOwnTemplates = useOwnTemplates;
}
+
+ public boolean isUseExternalProcess()
+ {
+ return useExternalProcess;
+ }
+
+ public void setUseExternalProcess(boolean useExternalProcess)
+ {
+ this.useExternalProcess = useExternalProcess;
+ }
public List<ExporterFactory> getExporterFactories() {
return exporterFactories;
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java 2010-09-08 16:02:20 UTC (rev 24816)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java 2010-09-08 17:07:38 UTC (rev 24817)
@@ -56,6 +56,7 @@
public static final String ATTR_REVERSE_ENGINEER_SETTINGS = ATTR_PREFIX + ConfigurationXMLStrings.REVENGFILE;
public static final String ATTR_REVERSE_ENGINEER_STRATEGY = ATTR_PREFIX + "revengstrategy"; //$NON-NLS-1$
public static final String ATTR_USE_OWN_TEMPLATES = ATTR_PREFIX + "useOwnTemplates"; //$NON-NLS-1$
+ public static final String ATTR_USE_EXTERNAL_PROCESS = ATTR_PREFIX + "useExternalProcess"; //$NON-NLS-1$
public static final String ATTR_ENABLE_EJB3_ANNOTATIONS = ATTR_PREFIX + CodeGenerationStrings.EJB3;
public static final String ATTR_ENABLE_JDK5 = ATTR_PREFIX + CodeGenerationStrings.JDK5;
public static final String ATTR_PACKAGE_NAME = ATTR_PREFIX + "package"; //$NON-NLS-1$
15 years, 7 months
JBoss Tools SVN: r24816 - branches/jbosstools-3.2.0.M2/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-09-08 12:02:20 -0400 (Wed, 08 Sep 2010)
New Revision: 24816
Modified:
branches/jbosstools-3.2.0.M2/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
Log:
https://jira.jboss.org/browse/JBIDE-7026 Fixed in M2 brunch
Modified: branches/jbosstools-3.2.0.M2/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
===================================================================
--- branches/jbosstools-3.2.0.M2/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2010-09-08 14:29:20 UTC (rev 24815)
+++ branches/jbosstools-3.2.0.M2/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2010-09-08 16:02:20 UTC (rev 24816)
@@ -17,6 +17,7 @@
import org.w3c.dom.*;
import org.xml.sax.Attributes;
+import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
@@ -99,9 +100,14 @@
stream1 = url.openStream();
stream2 = new BufferedInputStream(stream1, 16384);
-
Element g = parse(stream2);
if(g == null) {
+ ModelPlugin.getPluginLog().logError("SAX parser failed to load meta resource " + name);
+ stream1 = url.openStream();
+ stream2 = new BufferedInputStream(stream1, 16384);
+ g = XMLUtilities.getElement(stream2, new EmptyResolver());
+ }
+ if(g == null) {
ModelPlugin.getPluginLog().logInfo("Corrupted meta resource " + name); //$NON-NLS-1$
} else {
load0(g, name, url.toString());
@@ -158,7 +164,9 @@
p.parse(stream);
Element g = p.documentElement;
g = XMLUtilities.getUniqueChild(g, "XModelEntityGroup"); //$NON-NLS-1$
- p.documentElement.removeChild(g);
+ if(g != null) {
+ p.documentElement.removeChild(g);
+ }
return g;
}
@@ -241,14 +249,35 @@
ModelPlugin.getPluginLog().logError(e);
}
}
+
+ XMLReader newInstance() throws SAXException {
+ try {
+ return (XMLReader) ModelPlugin.getDefault().getBundle().loadClass(DEFAULT_SAX_PARSER_CLASS_NAME).newInstance();
+ } catch (ClassNotFoundException e1) {
+ throw new SAXException("SAX2 driver class " + DEFAULT_SAX_PARSER_CLASS_NAME +
+ " not found", e1);
+ } catch (IllegalAccessException e2) {
+ throw new SAXException("SAX2 driver class " + DEFAULT_SAX_PARSER_CLASS_NAME +
+ " found but cannot be loaded", e2);
+ } catch (InstantiationException e3) {
+ throw new SAXException("SAX2 driver class " + DEFAULT_SAX_PARSER_CLASS_NAME +
+ " loaded but cannot be instantiated (no empty public constructor?)",
+ e3);
+ } catch (ClassCastException e4) {
+ throw new SAXException("SAX2 driver class " + DEFAULT_SAX_PARSER_CLASS_NAME +
+ " does not implement XMLReader", e4);
+ }
+ }
XMLReader createParser() {
DefaultHandler handler = new DefaultHandler();
XMLReader parserInstance = null;
try {
- parserInstance = XMLReaderFactory.createXMLReader(DEFAULT_SAX_PARSER_CLASS_NAME);
+ parserInstance = newInstance();
+ //XMLReaderFactory.createXMLReader(DEFAULT_SAX_PARSER_CLASS_NAME);
} catch (SAXException e) {
+ ModelPlugin.getPluginLog().logError("default parser failed: " + e.getMessage());
return null;
}
@@ -260,14 +289,6 @@
SAXValidator.setFeature(parserInstance, VALIDATION_DYNAMIC_FEATURE_ID, false);
SAXValidator.setFeature(parserInstance, FATAL_ERROR_PROCESSING_FEATURE_ID, false);
- class EmptyHandler implements org.apache.xerces.xni.parser.XMLEntityResolver {
-
- public XMLInputSource resolveEntity(XMLResourceIdentifier id)
- throws XNIException, IOException {
- return new XMLInputSource(id.getPublicId(), id.getBaseSystemId(), id.getBaseSystemId(), new StringReader(""), null);
- }
-
- }
try {
if(MetaLibLoader.validateMetaXML) {
parserInstance.setProperty(ENTITY_RESOLVER_PROPERTY_ID, new XMLEntityResolverImpl());
@@ -332,3 +353,18 @@
public void startPrefixMapping(String prefix, String uri) throws SAXException {}
}
+
+class EmptyHandler implements org.apache.xerces.xni.parser.XMLEntityResolver {
+
+ public XMLInputSource resolveEntity(XMLResourceIdentifier id)
+ throws XNIException, IOException {
+ return new XMLInputSource(id.getPublicId(), id.getBaseSystemId(), id.getBaseSystemId(), new StringReader(""), null);
+ }
+
+}
+
+class EmptyResolver implements EntityResolver {
+ public InputSource resolveEntity(String publicID, String systemID) throws SAXException, IOException {
+ return new InputSource(new StringReader("")); //$NON-NLS-1$
+ }
+}
\ No newline at end of file
15 years, 7 months
JBoss Tools SVN: r24815 - trunk/vpe/site.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2010-09-08 10:29:20 -0400 (Wed, 08 Sep 2010)
New Revision: 24815
Modified:
trunk/vpe/site/site.xml
Log:
remove 1.9.1.2 version from VPE's site.xml declaration
Modified: trunk/vpe/site/site.xml
===================================================================
--- trunk/vpe/site/site.xml 2010-09-08 14:20:12 UTC (rev 24814)
+++ trunk/vpe/site/site.xml 2010-09-08 14:29:20 UTC (rev 24815)
@@ -8,8 +8,7 @@
<feature url="features/org.jboss.tools.vpe.feature_0.0.0.jar" id="org.jboss.tools.vpe.feature" version="0.0.0">
<category name="JBoss Tools vpe Nightly Build Update Site"/>
</feature>
- <!-- XulRunner requires version in declaration to avoid include latest 1.9.2 in build -->
- <feature url="features/org.mozilla.xulrunner.feature_1.9.1.2.jar" id="org.mozilla.xulrunner.feature" version="1.9.1.2">
+ <feature url="features/org.mozilla.xulrunner.feature_0.0.0.jar" id="org.mozilla.xulrunner.feature" version="0.0.0">
<category name="JBoss Tools vpe Nightly Build Update Site"/>
</feature>
15 years, 7 months
JBoss Tools SVN: r24814 - branches/jbosstools-3.2.0.M2/vpe/site.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2010-09-08 10:20:12 -0400 (Wed, 08 Sep 2010)
New Revision: 24814
Modified:
branches/jbosstools-3.2.0.M2/vpe/site/site.xml
Log:
remove 1.9.1.2 version from VPE's site.xml declaration
Modified: branches/jbosstools-3.2.0.M2/vpe/site/site.xml
===================================================================
--- branches/jbosstools-3.2.0.M2/vpe/site/site.xml 2010-09-08 13:12:51 UTC (rev 24813)
+++ branches/jbosstools-3.2.0.M2/vpe/site/site.xml 2010-09-08 14:20:12 UTC (rev 24814)
@@ -8,8 +8,7 @@
<feature url="features/org.jboss.tools.vpe.feature_0.0.0.jar" id="org.jboss.tools.vpe.feature" version="0.0.0">
<category name="JBoss Tools vpe Nightly Build Update Site"/>
</feature>
- <!-- XulRunner requires version in declaration to avoid include latest 1.9.2 in build -->
- <feature url="features/org.mozilla.xulrunner.feature_1.9.1.2.jar" id="org.mozilla.xulrunner.feature" version="1.9.1.2">
+ <feature url="features/org.mozilla.xulrunner.feature_0.0.0.jar" id="org.mozilla.xulrunner.feature" version="0.0.0">
<category name="JBoss Tools vpe Nightly Build Update Site"/>
</feature>
15 years, 7 months
JBoss Tools SVN: r24813 - trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2010-09-08 09:12:51 -0400 (Wed, 08 Sep 2010)
New Revision: 24813
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java
Log:
https://jira.jboss.org/browse/JBIDE-7027
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java 2010-09-08 13:10:20 UTC (rev 24812)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java 2010-09-08 13:12:51 UTC (rev 24813)
@@ -61,6 +61,8 @@
IJavaElement element = qs.getElement();
if(element instanceof IMethod || element instanceof IField){
IFile file = (IFile)element.getResource();
+ if(file == null)
+ return;
CDICoreNature cdiNature = CDICorePlugin.getCDI(file.getProject(), true);
15 years, 7 months