Author: Grid.Qian
Date: 2008-05-21 05:01:58 -0400 (Wed, 21 May 2008)
New Revision: 8250
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/
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/JbossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/UIUtils.java
Removed:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCore.properties
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/UIUtils.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ValidateWSImpl.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java
Log:
JBIDE-2047: improve codes and add validation for jboss ws bottomup
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2008-05-21 08:55:11 UTC
(rev 8249)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2008-05-21 09:01:58 UTC
(rev 8250)
@@ -16,6 +16,8 @@
Eclipse-LazyStart: true
Bundle-Vendor: %PLUGIN_PROVIDER
Export-Package: org.jboss.tools.ws.core,
+ org.jboss.tools.ws.core.classpath,
org.jboss.tools.ws.core.command,
org.jboss.tools.ws.core.facet.delegate,
+ org.jboss.tools.ws.core.messages,
org.jboss.tools.ws.core.utils
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCore.properties 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCore.properties 2008-05-21
09:01:58 UTC (rev 8250)
@@ -1,12 +0,0 @@
-PROGRESS_INSTALL_JBOSSWS_RUNTIME=JBoss Web Service Runtime
-DIR_LIB=lib
-DIR_CLIENT=client
-DIR_WEB_INF=WEB-INF
-DIR_WEB_CONTENT=WebContent
-ERROR_COPY=Exception while copy JBossWS jars
-WS_LOCATION=jbosswsruntimelocation
-JBOSSWS_RUNTIME_LIB=JbossWSRuntimeLib
-JBOSSWS_RUNTIME=JBoss WS Runtime
-JBOSSAS=JBOSS
-ERROR_WS_LOCATION=The JBoss WS Runtime Location is NULL
-ERROR_WS_CLASSPATH=A error comes up when create JBoss WS Classpath
\ No newline at end of file
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCoreMessages.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCoreMessages.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.core;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSCoreMessages {
-
- private static final String BUNDLE_NAME =
"org.jboss.tools.ws.core.JbossWSCore"; //$NON-NLS-1$
-
- private JbossWSCoreMessages() {
- // Do not instantiate
- }
-
- public static String PROGRESS_INSTALL_JBOSSWS_RUNTIME;
- public static String DIR_LIB;
- public static String DIR_CLIENT;
- public static String DIR_WEB_INF;
- public static String DIR_WEB_CONTENT;
- public static String ERROR_COPY;
- public static String WS_LOCATION;
- public static String JBOSSWS_RUNTIME_LIB;
- public static String JBOSSWS_RUNTIME;
- public static String JBOSSAS;
- public static String ERROR_WS_LOCATION;
- public static String ERROR_WS_CLASSPATH;
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JbossWSCoreMessages.class);
- }
-}
\ No newline at end of file
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -11,7 +11,7 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.JavaRuntime;
-import org.jboss.tools.ws.core.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
import org.jboss.tools.ws.core.utils.JbossWSCoreUtils;
/**
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -25,7 +25,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.jboss.tools.ws.core.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
import org.jboss.tools.ws.core.utils.StatusUtils;
/**
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -20,7 +20,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.jboss.tools.ws.core.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
import org.jboss.tools.ws.core.utils.JbossWSCoreUtils;
import org.jboss.tools.ws.core.utils.StatusUtils;
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -16,8 +16,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.common.project.facet.core.IDelegate;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.jboss.tools.ws.core.JbossWSCoreMessages;
import org.jboss.tools.ws.core.command.JbossWSClassPathCommand;
+import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
/**
* @author Grid Qian
Copied:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties
(from rev 8246,
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCore.properties)
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties 2008-05-21
09:01:58 UTC (rev 8250)
@@ -0,0 +1,12 @@
+PROGRESS_INSTALL_JBOSSWS_RUNTIME=JBoss Web Service Runtime
+DIR_LIB=lib
+DIR_CLIENT=client
+DIR_WEB_INF=WEB-INF
+DIR_WEB_CONTENT=WebContent
+ERROR_COPY=Exception while copy JBossWS jars
+WS_LOCATION=jbosswsruntimelocation
+JBOSSWS_RUNTIME_LIB=JbossWSRuntimeLib
+JBOSSWS_RUNTIME=JBoss WS Runtime
+JBOSSAS=JBOSS
+ERROR_WS_LOCATION=The JBoss WS Runtime Location is NULL
+ERROR_WS_CLASSPATH=A error comes up when create JBoss WS Classpath
\ No newline at end of file
Copied:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java
(from rev 8246,
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCoreMessages.java)
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.core.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public class JbossWSCoreMessages {
+
+ private static final String BUNDLE_NAME =
"org.jboss.tools.ws.core.JbossWSCore"; //$NON-NLS-1$
+
+ private JbossWSCoreMessages() {
+ // Do not instantiate
+ }
+
+ public static String PROGRESS_INSTALL_JBOSSWS_RUNTIME;
+ public static String DIR_LIB;
+ public static String DIR_CLIENT;
+ public static String DIR_WEB_INF;
+ public static String DIR_WEB_CONTENT;
+ public static String ERROR_COPY;
+ public static String WS_LOCATION;
+ public static String JBOSSWS_RUNTIME_LIB;
+ public static String JBOSSWS_RUNTIME;
+ public static String JBOSSAS;
+ public static String ERROR_WS_LOCATION;
+ public static String ERROR_WS_CLASSPATH;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JbossWSCoreMessages.class);
+ }
+}
\ No newline at end of file
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -36,8 +36,8 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jst.ws.internal.common.J2EEUtils;
import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.ws.core.JbossWSCoreMessages;
import org.jboss.tools.ws.core.JbossWSCorePlugin;
+import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
/**
* @author Grid Qian
@@ -120,7 +120,6 @@
}
public static IStatus copy(IPath sourcePath, IPath targetPath) {
- System.out.println(sourcePath + " >> " + targetPath);
IStatus status = Status.OK_STATUS;
File sourceDir = sourcePath.toFile();
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.ws.creation.core.commands;
@@ -18,13 +18,14 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.jboss.tools.ws.core.utils.StatusUtils;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.eclipse.wst.ws.internal.wsrt.IWebService;
import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
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;
import org.jboss.tools.ws.creation.core.utils.WSDLPropertyReader;
/**
@@ -35,7 +36,8 @@
private IWebServiceClient wsClient;
private int scenario;
- public InitialClientCommand(ServiceModel model, IWebServiceClient wsClient, int
scenario) {
+ public InitialClientCommand(ServiceModel model, IWebServiceClient wsClient,
+ int scenario) {
this.model = model;
this.wsClient = wsClient;
this.scenario = scenario;
@@ -44,15 +46,22 @@
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
+
+ if (!JBossWSCreationUtils.validateJBossWSLocation()) {
+ return StatusUtils
+ .errorStatus(JBossWSCreationCoreMessages.ERROR_WS_LOCATION);
+ }
model.setTarget(JBossWSCreationCoreMessages.VALUE_TARGET_0);
if (scenario == WebServiceScenario.CLIENT) {
- try{
- model.setWsdlURI(wsClient.getWebServiceClientInfo().getWsdlURL());
- WSDLPropertyReader reader = new WSDLPropertyReader();
- reader.readWSDL(wsClient.getWebServiceClientInfo().getWsdlURL());
- model.setCustomPackage(reader.packageFromTargetNamespace());
- }catch (WSDLException e) {
+ try {
+ model.setWsdlURI(wsClient.getWebServiceClientInfo()
+ .getWsdlURL());
+ WSDLPropertyReader reader = new WSDLPropertyReader();
+ reader
+ .readWSDL(wsClient.getWebServiceClientInfo()
+ .getWsdlURL());
+ model.setCustomPackage(reader.packageFromTargetNamespace());
+ } catch (WSDLException e) {
return StatusUtils.errorStatus(e.getLocalizedMessage(), e);
}
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -7,18 +7,14 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.ws.axis2.consumption.core.utils.DefaultCodegenUtil;
-import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.jboss.tools.ws.core.utils.StatusUtils;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.eclipse.wst.ws.internal.wsrt.IWebService;
import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
-import org.eclipse.wst.wsdl.WSDLFactory;
-import org.eclipse.wst.wsdl.internal.impl.wsdl4j.WSDLFactoryImpl;
-import org.eclipse.wst.wsdl.internal.util.WSDLDefinitionFactory;
-import org.eclipse.wst.wsdl.internal.util.WSDLUtil;
-import org.eclipse.wst.wsdl.util.WSDLParser;
+import org.jboss.tools.ws.core.JbossWSCorePlugin;
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;
import org.jboss.tools.ws.creation.core.utils.WSDLPropertyReader;
public class InitialCommand extends AbstractDataModelOperation {
@@ -36,21 +32,25 @@
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
+
+ if (!JBossWSCreationUtils.validateJBossWSLocation()) {
+ return StatusUtils
+ .errorStatus(JBossWSCreationCoreMessages.ERROR_WS_LOCATION);
+ }
model.setTarget(JBossWSCreationCoreMessages.VALUE_TARGET_0);
if (scenario == WebServiceScenario.TOPDOWN) {
- try{
- model.setWsdlURI(ws.getWebServiceInfo().getWsdlURL());
- WSDLPropertyReader reader = new WSDLPropertyReader();
- reader.readWSDL(ws.getWebServiceInfo().getWsdlURL());
- model.setCustomPackage(reader.packageFromTargetNamespace());
- model.setServiceList(reader.getServiceList());
- model.setPortTypeList(reader.getPortTypeList());
-
- }catch (WSDLException e) {
+ try {
+ model.setWsdlURI(ws.getWebServiceInfo().getWsdlURL());
+ WSDLPropertyReader reader = new WSDLPropertyReader();
+ reader.readWSDL(ws.getWebServiceInfo().getWsdlURL());
+ model.setCustomPackage(reader.packageFromTargetNamespace());
+ model.setServiceList(reader.getServiceList());
+ model.setPortTypeList(reader.getPortTypeList());
+
+ } catch (WSDLException e) {
return StatusUtils.errorStatus(e.getLocalizedMessage(), e);
}
- }else {
+ } else {
model.setServiceClass(ws.getWebServiceInfo().getImplURL());
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ValidateWSImpl.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ValidateWSImpl.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ValidateWSImpl.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.ws.creation.core.commands;
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.jboss.tools.ws.core.utils.StatusUtils;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
@@ -38,22 +39,30 @@
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
+
String implClass = model.getServiceClass();
String project = model.getWebProjectName();
ICompilationUnit unit = null;
try {
- unit = JBossWSCreationUtils.getJavaProjectByName(project).findType(
- implClass).getCompilationUnit();
- } catch (JavaModelException e) {
- e.printStackTrace();
- }
- try {
- if(!unit.getSource().contains(JBossWSCreationCoreMessages.WEBSERVICE_ANNOTATION)){
- return StatusUtils.errorStatus(JBossWSCreationCoreMessages.ERROR_NO_ANNOTATION);
+ if (JBossWSCreationUtils.getJavaProjectByName(project).findType(
+ implClass) != null) {
+ unit = JBossWSCreationUtils.getJavaProjectByName(project)
+ .findType(implClass).getCompilationUnit();
+ } else {
+ return StatusUtils.errorStatus(NLS.bind(
+ JBossWSCreationCoreMessages.ERROR_NO_CLASS,
+ new String[] { implClass, project }));
}
+ if (!unit.getSource().contains(
+ JBossWSCreationCoreMessages.WEBSERVICE_ANNOTATION)) {
+ return StatusUtils
+ .errorStatus(JBossWSCreationCoreMessages.ERROR_NO_ANNOTATION);
+ }
} catch (JavaModelException e) {
- e.printStackTrace();
- }
+ return StatusUtils.errorStatus(NLS.bind(
+ JBossWSCreationCoreMessages.ERROR_NO_CLASS, new String[] {
+ implClass, project }));
+ }
return Status.OK_STATUS;
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.ws.creation.core.commands;
@@ -26,78 +26,95 @@
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.jboss.tools.ws.core.JbossWSCorePlugin;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.utils.JBossStatusUtils;
import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
/**
* @author Grid Qian
*/
-public class WSProviderInvokeCommand extends AbstractDataModelOperation{
+public class WSProviderInvokeCommand extends AbstractDataModelOperation {
private ServiceModel model;
-
-
- public WSProviderInvokeCommand(ServiceModel model){
+
+ public WSProviderInvokeCommand(ServiceModel model) {
this.model = model;
}
-
+
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
- String runtimeLocation =
JbossWSCorePlugin.getDefault().getPreferenceStore().getString("jbosswsruntimelocation");
- String commandLocation = runtimeLocation + Path.SEPARATOR + "bin";
- String command = "sh wsprovide.sh ";
- if(System.getProperty("os.name").toLowerCase().indexOf("win") >=
0){
- command = "cmd.exe /C wsprovide.bat";
- }
- String args = getCommandlineArgs();
+ String runtimeLocation = JbossWSCorePlugin.getDefault()
+ .getPreferenceStore().getString("jbosswsruntimelocation");
+ String commandLocation = runtimeLocation + Path.SEPARATOR + "bin";
+ String command = "sh wsprovide.sh ";
+ if (System.getProperty("os.name").toLowerCase().indexOf("win")
>= 0) {
+ command = "cmd.exe /C wsprovide.bat";
+ }
+ String args = getCommandlineArgs();
command += " -k " + args;
-
+
try {
-
- InputStreamReader ir = new InputStreamReader(Runtime.getRuntime().exec(command, null,
new File(commandLocation)).getInputStream());
- LineNumberReader input = new LineNumberReader(ir);
- String str = input.readLine();
- while(str != null){
- System.out.println(str);
- str = input.readLine();
- }
-
-
+ Runtime rt = Runtime.getRuntime();
+ Process proc = rt.exec(command, null, new File(commandLocation));
+ InputStreamReader ir = new InputStreamReader(proc.getErrorStream());
+ LineNumberReader input = new LineNumberReader(ir);
+ String str = input.readLine();
+ StringBuffer result = new StringBuffer();
+ while (str != null) {
+ result.append(str).append("\t\r");
+ str = input.readLine();
+
+ }
+ int exitValue = proc.waitFor();
+ if (exitValue != 0) {
+ return JBossStatusUtils.errorStatus(result.toString());
+ }
+
} catch (IOException e) {
e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
-
+
refreshProject(model.getWebProjectName(), monitor);
-
+
return Status.OK_STATUS;
}
-
- private void refreshProject(String project, IProgressMonitor monitor){
+
+ private void refreshProject(String project, IProgressMonitor monitor) {
try {
- JBossWSCreationUtils.getProjectByName(project).refreshLocal(2, monitor);
+ JBossWSCreationUtils.getProjectByName(project).refreshLocal(2,
+ monitor);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
-
- private String getCommandlineArgs(){
+
+ private String getCommandlineArgs() {
String commandLine;
String project = model.getWebProjectName();
- String projectRoot = JBossWSCreationUtils.getProjectRoot(project).toOSString();
+ String projectRoot = JBossWSCreationUtils.getProjectRoot(project)
+ .toOSString();
commandLine = "-s " + projectRoot + Path.SEPARATOR + "src";
-
- if(model.isGenWSDL()){
- commandLine += " -w ";
- }
- commandLine += " -r " + projectRoot + Path.SEPARATOR +
"WebContent" + Path.SEPARATOR + "wsdl ";
-
- commandLine += " -c " + projectRoot + Path.SEPARATOR +
"build/classes/ ";
-
- commandLine += model.getServiceClass();
-
+
+ if (model.isGenWSDL()) {
+ commandLine += " -w ";
+ }
+
+ commandLine += " -o " + projectRoot + Path.SEPARATOR
+ + "build/classes/ ";
+
+ commandLine += " -r " + projectRoot + Path.SEPARATOR +
"WebContent"
+ + Path.SEPARATOR + "wsdl ";
+
+ commandLine += " -c " + projectRoot + Path.SEPARATOR
+ + "build/classes/ ";
+
+ commandLine += model.getServiceClass();
+
return commandLine;
-
+
}
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2008-05-21
09:01:58 UTC (rev 8250)
@@ -12,3 +12,5 @@
SEPARATOR_JAVA=/
ERROR_NO_ANNOTATION=This class has not required Annotation!
WEBSERVICE_ANNOTATION=@WebService
+ERROR_NO_CLASS= The class '{0}' cannot be loaded via project {1}.Check that the
project contains the class, or that the class is loadable according to the Java Build Path
of the project.
+ERROR_WS_LOCATION=The JBoss WS Runtime Location is NULL. Please set the location on JBoss
WS preferences page.
\ No newline at end of file
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -20,6 +20,8 @@
public static String ERROR_NO_ANNOTATION;
public static String WEBSERVICE_ANNOTATION;
+ public static String ERROR_NO_CLASS;
+ public static String ERROR_WS_LOCATION;
private JBossWSCreationCoreMessages() {
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -39,6 +39,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.jboss.tools.ws.core.JbossWSCorePlugin;
public class JBossWSCreationUtils {
@@ -259,5 +260,14 @@
return null;
}
}
+
+ public static boolean validateJBossWSLocation() {
+ String location = JbossWSCorePlugin.getDefault().getPreferenceStore()
+ .getString("jbosswsruntimelocation");
+ if (location == null || location.equals("")) {
+ return false;
+ }
+ return true;
+ }
}
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUI.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUI.properties 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUI.properties 2008-05-21
09:01:58 UTC (rev 8250)
@@ -1,41 +0,0 @@
-LABEL_BROUSE=Browse...
-LABEL_WEB_SERVICE_CODEGEN=Web service code generation options
-LABEL_WEB_SERVICE_CLIENT_CODEGEN=Web service client code generation options
-LABEL_WEB_SERVICE_AAR=Web service archive options
-LABEL_DATABINDING=Default Databinding:
-LABEL_AAR_EXTENTION=AAR default extension:
-LABEL_JBOSSWS_RUNTIME_LOAD=JBossWS runtime loaded successfully
-LABEL_JBOSSWS_RUNTIME_LOAD_ERROR=Error occurred while loading JBossWS runtime. Select the
correct JBossWS runtime folder.
-LABEL_GENERATE_TESTCASE_CAPTION=Generate a JUnit test case to test the service
-LABEL_GENERATE_SERVERSIDE_INTERFACE=Generate an interface for the skeleton
-LABEL_GENERATE_ALL=Generate all types for all elements referred to by schemas
-LABEL_CLIENT_SIDE=Client mode
-LABEL_SYNC_AND_ASYNC=Generate a client which supports both synchronous and asynchronous
invocation
-LABEL_SYNC=Generate a synchronous client
-LABEL_ASYNC=Generate an asynchronous client
-
-JBOSSWS_LOCATION=JBossWS Runtime
-JBOSSWS_RUNTIME=JBossWS Runtime
-JBOSSWS_PREFERENCES=JBossWS Preferences
-JBOSSWS_RUNTIME_TOOLTIP=Select the JBossWS binary distribution folder
-JBOSSWS_PREFERENCES_TOOLTIP=Select the default preferences for JBossWS runtime
-JBOSSWS_RUNTIME_LOCATION=JBossWS runtime location:
-JBOSSWS_RUNTIME_PREFERENCES=JBossWS Runtime Preferences
-LABEL_JBOSSWS_RUNTIME_NOT_EXIT=Select the location of the JBossWS binary distribution or
the folder which contains the JBossWS war distribution.
-ERROR_INVALID_JBOSSWS_SERVER_LOCATION=Invalid JBossWS runtime location
-
-ERROR_INVALID_FILE_READ_WRITEL=Exception occurred while reading or writing file {0}
-ERROR_SERVER_IS_NOT_SET=The JBossWS facets cannot be installed since the JBossWS runtime
location has not been set. \nGo to the Web Services preference page and set the JBossWS
runtime location under JBossWS Preferences.
-
-PROGRESS_INSTALL_JBOSSWS_RUNTIME=Installing JBossWS Runtime
-PROGRESS_UNINSTALL_JBOSSWS_RUNTIME=Uninstalling the JBossWS Runtime
-
-DIR_DOT_METADATA=.metadata
-DIR_DOT_PLUGINS=.plugins
-TEMP_JBOSSWS_FACET_DIR=org.jboss.tools.ws.facet
-WEBAPP_EXPLODED_SERVER_LOCATION_FILE=server.properties
-SERVER_STATUS_LOCATION_FILE=status.properties
-WAR_STATUS_LOCATION_FILE=war.properties
-
-COMMOND=wsconsume.sh
-BIN=bin
\ No newline at end of file
Deleted:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIMessages.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIMessages.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @author Grid Qian
- */
-public final class JbossWSUIMessages extends NLS {
-
- private static final String BUNDLE_NAME =
- "org.jboss.tools.ws.ui.JbossWSUI"; //$NON-NLS-1$
-
- private JbossWSUIMessages() {
- // Do not instantiate
- }
-
- public static String LABEL_BROUSE;
- public static String LABEL_WEB_SERVICE_CODEGEN;
- public static String LABEL_WEB_SERVICE_CLIENT_CODEGEN;
- public static String LABEL_WEB_SERVICE_AAR;
- public static String LABEL_AAR_EXTENTION;
- public static String LABEL_DATABINDING;
- public static String LABEL_JBOSSWS_RUNTIME_LOAD;
- public static String LABEL_JBOSSWS_RUNTIME_LOAD_ERROR;
- public static String LABEL_JBOSSWS_RUNTIME_NOT_EXIT;
- public static String LABEL_GENERATE_TESTCASE_CAPTION;
- public static String LABEL_GENERATE_SERVERSIDE_INTERFACE;
- public static String LABEL_GENERATE_ALL;
- public static String LABEL_CLIENT_SIDE;
- public static String LABEL_SYNC_AND_ASYNC;
- public static String LABEL_SYNC;
- public static String LABEL_ASYNC;
-
- public static String JBOSSWS_LOCATION;
- public static String JBOSSWS_RUNTIME;
- public static String JBOSSWS_PREFERENCES;
- public static String JBOSSWS_RUNTIME_TOOLTIP;
- public static String JBOSSWS_PREFERENCES_TOOLTIP;
- public static String JBOSSWS_RUNTIME_LOCATION;
- public static String JBOSSWS_RUNTIME_PREFERENCES;
-
- public static String ERROR_INVALID_JBOSSWS_SERVER_LOCATION;
- public static String ERROR_INVALID_FILE_READ_WRITEL;
- public static String ERROR_SERVER_IS_NOT_SET;
-
- public static String PROGRESS_INSTALL_JBOSSWS_RUNTIME;
- public static String PROGRESS_UNINSTALL_JBOSSWS_RUNTIME;
-
- //generate for jbossws lib
- public static String DIR_DOT_METADATA;
- public static String DIR_DOT_PLUGINS;
- public static String TEMP_JBOSSWS_FACET_DIR;
- public static String WEBAPP_EXPLODED_SERVER_LOCATION_FILE;
- public static String SERVER_STATUS_LOCATION_FILE;
- public static String WAR_STATUS_LOCATION_FILE;
-
- public static String BIN;
- public static String COMMOND;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JbossWSUIMessages.class);
- }
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/UIUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/UIUtils.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/UIUtils.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -1,502 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-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.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Grid Qian
- */
-public class UIUtils {
- /**
- * A default padding value for horizontalResize().
- */
- public final static int DEFAULT_PADDING = 35;
-
- String infoPopid_;
-
- public UIUtils(String infoPopid) {
- infoPopid_ = infoPopid;
- }
-
- public Button createRadioButton(Composite parent, String labelName,
- String tooltip, String infopop) {
- return createButton(SWT.RADIO, parent, labelName, tooltip, infopop);
- }
-
- public Button createCheckbox(Composite parent, String labelName,
- String tooltip, String infopop) {
- return createButton(SWT.CHECK, parent, labelName, tooltip, infopop);
- }
-
- public Button createPushButton(Composite parent, String labelName,
- String tooltip, String infopop) {
- return createButton(SWT.NONE, parent, labelName, tooltip, infopop);
- }
-
- public Button createButton(int kind, Composite parent, String labelName,
- String tooltip, String infopop) {
- Button button = new Button(parent, kind);
-
- tooltip = tooltip == null ? labelName : tooltip;
- button.setText(labelName);
- button.setToolTipText(tooltip);
-
- if (infopop != null)
- PlatformUI.getWorkbench().getHelpSystem().setHelp(button,
- infoPopid_ + "." + infopop);
-
- return button;
- }
-
- public Combo createCombo(Composite parent, String labelName,
- String tooltip, String infopop, int style) {
- tooltip = tooltip == null ? labelName : tooltip;
-
- if (labelName != null) {
- Label label = new Label(parent, SWT.WRAP);
- label.setText(labelName);
- label.setToolTipText(tooltip);
- }
-
- Combo combo = new Combo(parent, style);
- GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL);
-
- combo.setLayoutData(griddata);
- combo.setToolTipText(tooltip);
-
- if (infopop != null)
- PlatformUI.getWorkbench().getHelpSystem().setHelp(combo,
- infoPopid_ + "." + infopop);
-
- return combo;
- }
-
- public Text createText(Composite parent, String labelName, String tooltip,
- String infopop, int style) {
- tooltip = tooltip == null ? labelName : tooltip;
-
- if (labelName != null) {
- Label label = new Label(parent, SWT.WRAP);
- label.setText(labelName);
- label.setToolTipText(tooltip);
- }
-
- Text text = new Text(parent, style);
- GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL);
-
- text.setLayoutData(griddata);
- text.setToolTipText(tooltip);
-
- if (infopop != null)
- PlatformUI.getWorkbench().getHelpSystem().setHelp(text,
- infoPopid_ + "." + infopop);
-
- return text;
- }
-
- public Composite createComposite(Composite parent, int columns) {
- return createComposite(parent, columns, -1, -1);
- }
-
- public Composite createComposite(Composite parent, int columns,
- int marginHeight, int marginWidth) {
- Composite composite = new Composite(parent, SWT.NONE);
-
- GridLayout gridlayout = new GridLayout();
- gridlayout.numColumns = columns;
-
- if (marginHeight >= 0)
- gridlayout.marginHeight = marginHeight;
- if (marginWidth >= 0)
- gridlayout.marginWidth = marginWidth;
-
- composite.setLayout(gridlayout);
- GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL);
- composite.setLayoutData(griddata);
-
- return composite;
-
- }
-
- public Group createGroup(Composite parent, String groupName,
- String tooltip, String infopop) {
- return createGroup(parent, groupName, tooltip, infopop, 1, -1, -1);
- }
-
- public Group createGroup(Composite parent, String groupName,
- String tooltip, String infopop, int columns, int marginHeight,
- int marginWidth) {
- Group newGroup = new Group(parent, SWT.NONE);
- GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL);
- GridLayout gridlayout = new GridLayout();
-
- gridlayout.numColumns = columns;
-
- if (marginHeight >= 0)
- gridlayout.marginHeight = marginHeight;
- if (marginWidth >= 0)
- gridlayout.marginWidth = marginWidth;
-
- tooltip = tooltip == null ? groupName : tooltip;
- newGroup.setLayout(gridlayout);
- newGroup.setText(groupName);
- newGroup.setLayoutData(griddata);
- newGroup.setToolTipText(tooltip);
-
- if (infopop != null)
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newGroup,
- infoPopid_ + "." + infopop);
-
- return newGroup;
- }
-
- public Tree createTree(Composite parent, String tooltip, String infopop,
- int style) {
-
- tooltip = tooltip == null ? "" : tooltip;
-
- Tree tree = new Tree(parent, style);
-
- tree.setLayoutData(createFillAll());
- tree.setToolTipText(tooltip);
-
- if (infopop != null)
- PlatformUI.getWorkbench().getHelpSystem().setHelp(tree,
- infoPopid_ + "." + infopop);
-
- return tree;
-
- }
-
- public Table createTable(Composite parent, String tooltip, String infopop,
- int style) {
-
- tooltip = tooltip == null ? "" : tooltip;
-
- Table table = new Table(parent, style);
-
- // table.setLayoutData( createFillAll() );
- table.setToolTipText(tooltip);
-
- if (infopop != null)
- PlatformUI.getWorkbench().getHelpSystem().setHelp(table,
- infoPopid_ + "." + infopop);
-
- return table;
-
- }
-
- public Label createHorizontalSeparator(Composite parent, int spacing) {
- Composite composite = createComposite(parent, 1, spacing, -1);
-
- Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
-
- GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL);
- separator.setLayoutData(griddata);
-
- return separator;
- }
-
- public GridData createFillAll() {
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL
- | GridData.GRAB_VERTICAL);
- return data;
- }
-
- public void createInfoPop(Control ctrl, String infopop) {
- if (infopop != null)
- PlatformUI.getWorkbench().getHelpSystem().setHelp(ctrl,
- infoPopid_ + "." + infopop);
- }
-
- /**
- * Resizes the width of the target composite so that it is as wide as the
- * reference composite plus a padding value.
- *
- * @param target
- * The composite to resize.
- * @param reference
- * The reference composite
- * @param padding
- * The padding value
- */
- public void horizontalResize(Composite target, Composite reference,
- int padding) {
-
- Point originalSize = target.getSize();
- Point referenceSize = reference.getSize();
-
- padding = padding >= 0 ? padding : DEFAULT_PADDING;
-
- if (referenceSize.x + padding > originalSize.x)
- target.setSize(referenceSize.x + padding, originalSize.y);
- }
-
- public static void writePropertyToFile(File file,String key, String value) throws
IOException {
- Writer out = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(file), "8859_1"));
- out.write(key+"="+value+"\n");
- out.close();
- }
-
- // file util
- public static void copyFile(String src, String dest) {
- InputStream is = null;
- FileOutputStream fos = null;
-
- try
- {
- is = new FileInputStream(src);
- fos = new FileOutputStream(dest);
- int c = 0;
- byte[] array = new byte[1024];
- while ((c = is.read(array)) >= 0){
- fos.write(array, 0, c);
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- finally {
- try {
- fos.close();
- is.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- public static File createFileAndParentDirectories(String fileName) throws Exception {
- File file = new File(fileName);
- File parent = file.getParentFile();
- if (!parent.exists()){
- parent.mkdirs();
- }
- file.createNewFile();
- return file;
- }
-
- public static boolean deleteDir(File dir) {
- if (dir.isDirectory()) {
- String[] children = dir.list();
- for (int i=0; i<children.length; i++) {
- boolean success = deleteDir(new File(dir, children[i]));
- if (!success) {
- return false;
- }
- }
- }
- return dir.delete();
- }
-
- public static void deleteDirectories(File dir) {
- File[] children = dir.listFiles();
- for (int i = 0; i < children.length; i++){
- if (children[i].list() != null && children[i].list().length > 0){
- deleteDirectories(children[i]);
- }
- else{
- children[i].delete();
- }
- }
- dir.delete();
- }
-
- public static void deleteDirectories(String dir) {
- File directory = new File(dir);
- deleteDirectories(directory);
- }
-
- public static void createTargetFile(String sourceFileName, String targetFileName)
- throws Exception {
- createTargetFile(sourceFileName, targetFileName, false);
- }
-
- public static void createTargetFile(String sourceFileName, String targetFileName,
- boolean overwrite) throws Exception{
- File idealResultFile = new File(targetFileName);
- if (overwrite || !idealResultFile.exists())
- {
- createFileAndParentDirectories(targetFileName);
- copyFile(sourceFileName, targetFileName);
- }
- }
-
- public static boolean createDirectory(String directory){
- // Create a directory; all ancestor directories must exist
- boolean success = (new File(directory)).mkdir();
- if (!success) {
- // Directory creation failed
- }
- return success;
- }
-
- public static boolean createDirectorys(String directory){
- // Create a directory; all ancestor directories must exist
- boolean success = (new File(directory)).mkdirs();
- if (!success) {
- // Directory creation failed
- }
- return success;
- }
-
- //Copies all files under srcDir to dstDir.
- // If dstDir does not exist, it will be created.
- public static void copyDirectory(File srcDir, File dstDir) throws IOException {
- if (srcDir.isDirectory()) {
- if (!dstDir.exists()) {
- dstDir.mkdir();
- }
-
- String[] children = srcDir.list();
- for (int i=0; i<children.length; i++) {
- copyDirectory(new File(srcDir, children[i]),
- new File(dstDir, children[i]));
- }
- } else {
- copy(srcDir, dstDir);
- }
- }
-
- //Copies src file to dst file.
- // If the dst file does not exist, it is created
- public static void copy(File src, File dst) throws IOException {
- InputStream in = new FileInputStream(src);
- OutputStream out = new FileOutputStream(dst);
-
- // Transfer bytes from in to out
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- in.close();
- out.close();
- }
-
- public static String addAnotherNodeToPath(String currentPath, String newNode) {
- return currentPath + File.separator + newNode;
- }
-
- public static String addNodesToPath(String currentPath, String[] newNode) {
- String returnPath=currentPath;
- for (int i = 0; i < newNode.length; i++) {
- returnPath = returnPath + File.separator + newNode[i];
- }
- return returnPath;
- }
-
- public static String addNodesToPath(StringBuffer currentPath, String[] pathNodes) {
- for (int i = 0; i < pathNodes.length; i++){
- currentPath.append(File.separator);
- currentPath.append(pathNodes[i]);
- }
- return currentPath.toString();
- }
-
- public static String addNodesToURL(String currentPath, String[] newNode) {
- String returnPath=currentPath;
- for (int i = 0; i < newNode.length; i++) {
- returnPath = returnPath + "/" + newNode[i];
- }
- return returnPath;
- }
-
- /**
- * Get the list of file with a prefix of <code>fileNamePrefix</code>
& an extension of
- * <code>extension</code>
- *
- * @param sourceDir The directory in which to search the files
- * @param fileNamePrefix The prefix to look for
- * @param extension The extension to look for
- * @return The list of file with a prefix of <code>fileNamePrefix</code>
& an extension of
- * <code>extension</code>
- */
- public static File[] getMatchingFiles(String sourceDir, String fileNamePrefix, String
extension) {
- List<File> fileList = new ArrayList<File>();
- File libDir = new File(sourceDir);
- String libDirPath = libDir.getAbsolutePath();
- String[] items = libDir.list();
- if (items != null) {
- for (int i = 0; i < items.length; i++) {
- String item = items[i];
- if (fileNamePrefix != null && extension != null) {
- if (item.startsWith(fileNamePrefix) &&
item.endsWith(extension)) {
- fileList.add(new File(libDirPath + File.separator + item));
- }
- } else if (fileNamePrefix == null && extension != null) {
- if (item.endsWith(extension)) {
- fileList.add(new File(libDirPath + File.separator + item));
- }
- } else if (fileNamePrefix != null && extension == null) {
- if (item.startsWith(fileNamePrefix)) {
- fileList.add(new File(libDirPath + File.separator + item));
- }
- } else {
- fileList.add(new File(libDirPath + File.separator + item));
- }
- }
- return (File[]) fileList.toArray(new File[fileList.size()]);
- }
- return new File[0];
- }
-
- /**
- * Filter out files inside a <code>sourceDir</code> with matching
<codefileNamePrefix></code>
- * and <code>extension</code>
- * @param sourceDir The directory to filter the files
- * @param fileNamePrefix The filtering filename prefix
- * @param extension The filtering file extension
- */
- public static void filterOutRestrictedFiles(String sourceDir, String fileNamePrefix,
String extension){
- File[] resultedMatchingFiles = getMatchingFiles(sourceDir, fileNamePrefix,
extension);
- for (int i = 0; i < resultedMatchingFiles.length; i++) {
- File matchingFilePath = new File(resultedMatchingFiles[i].getAbsolutePath());
- matchingFilePath.delete();
- }
- }
-
-}
\ No newline at end of file
Copied:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties
(from rev 8246,
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUI.properties)
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties 2008-05-21
09:01:58 UTC (rev 8250)
@@ -0,0 +1,41 @@
+LABEL_BROUSE=Browse...
+LABEL_WEB_SERVICE_CODEGEN=Web service code generation options
+LABEL_WEB_SERVICE_CLIENT_CODEGEN=Web service client code generation options
+LABEL_WEB_SERVICE_AAR=Web service archive options
+LABEL_DATABINDING=Default Databinding:
+LABEL_AAR_EXTENTION=AAR default extension:
+LABEL_JBOSSWS_RUNTIME_LOAD=JBossWS runtime loaded successfully
+LABEL_JBOSSWS_RUNTIME_LOAD_ERROR=Error occurred while loading JBossWS runtime. Select the
correct JBossWS runtime folder.
+LABEL_GENERATE_TESTCASE_CAPTION=Generate a JUnit test case to test the service
+LABEL_GENERATE_SERVERSIDE_INTERFACE=Generate an interface for the skeleton
+LABEL_GENERATE_ALL=Generate all types for all elements referred to by schemas
+LABEL_CLIENT_SIDE=Client mode
+LABEL_SYNC_AND_ASYNC=Generate a client which supports both synchronous and asynchronous
invocation
+LABEL_SYNC=Generate a synchronous client
+LABEL_ASYNC=Generate an asynchronous client
+
+JBOSSWS_LOCATION=JBossWS Runtime
+JBOSSWS_RUNTIME=JBossWS Runtime
+JBOSSWS_PREFERENCES=JBossWS Preferences
+JBOSSWS_RUNTIME_TOOLTIP=Select the JBossWS binary distribution folder
+JBOSSWS_PREFERENCES_TOOLTIP=Select the default preferences for JBossWS runtime
+JBOSSWS_RUNTIME_LOCATION=JBossWS runtime location:
+JBOSSWS_RUNTIME_PREFERENCES=JBossWS Runtime Preferences
+LABEL_JBOSSWS_RUNTIME_NOT_EXIT=Select the location of the JBossWS binary distribution or
the folder which contains the JBossWS war distribution.
+ERROR_INVALID_JBOSSWS_SERVER_LOCATION=Invalid JBossWS runtime location
+
+ERROR_INVALID_FILE_READ_WRITEL=Exception occurred while reading or writing file {0}
+ERROR_SERVER_IS_NOT_SET=The JBossWS facets cannot be installed since the JBossWS runtime
location has not been set. \nGo to the Web Services preference page and set the JBossWS
runtime location under JBossWS Preferences.
+
+PROGRESS_INSTALL_JBOSSWS_RUNTIME=Installing JBossWS Runtime
+PROGRESS_UNINSTALL_JBOSSWS_RUNTIME=Uninstalling the JBossWS Runtime
+
+DIR_DOT_METADATA=.metadata
+DIR_DOT_PLUGINS=.plugins
+TEMP_JBOSSWS_FACET_DIR=org.jboss.tools.ws.facet
+WEBAPP_EXPLODED_SERVER_LOCATION_FILE=server.properties
+SERVER_STATUS_LOCATION_FILE=status.properties
+WAR_STATUS_LOCATION_FILE=war.properties
+
+COMMOND=wsconsume.sh
+BIN=bin
\ No newline at end of file
Copied:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java
(from rev 8246,
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIMessages.java)
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public final class JbossWSUIMessages extends NLS {
+
+ private static final String BUNDLE_NAME =
+ "org.jboss.tools.ws.ui.JbossWSUI"; //$NON-NLS-1$
+
+ private JbossWSUIMessages() {
+ // Do not instantiate
+ }
+
+ public static String LABEL_BROUSE;
+ public static String LABEL_WEB_SERVICE_CODEGEN;
+ public static String LABEL_WEB_SERVICE_CLIENT_CODEGEN;
+ public static String LABEL_WEB_SERVICE_AAR;
+ public static String LABEL_AAR_EXTENTION;
+ public static String LABEL_DATABINDING;
+ public static String LABEL_JBOSSWS_RUNTIME_LOAD;
+ public static String LABEL_JBOSSWS_RUNTIME_LOAD_ERROR;
+ public static String LABEL_JBOSSWS_RUNTIME_NOT_EXIT;
+ public static String LABEL_GENERATE_TESTCASE_CAPTION;
+ public static String LABEL_GENERATE_SERVERSIDE_INTERFACE;
+ public static String LABEL_GENERATE_ALL;
+ public static String LABEL_CLIENT_SIDE;
+ public static String LABEL_SYNC_AND_ASYNC;
+ public static String LABEL_SYNC;
+ public static String LABEL_ASYNC;
+
+ public static String JBOSSWS_LOCATION;
+ public static String JBOSSWS_RUNTIME;
+ public static String JBOSSWS_PREFERENCES;
+ public static String JBOSSWS_RUNTIME_TOOLTIP;
+ public static String JBOSSWS_PREFERENCES_TOOLTIP;
+ public static String JBOSSWS_RUNTIME_LOCATION;
+ public static String JBOSSWS_RUNTIME_PREFERENCES;
+
+ public static String ERROR_INVALID_JBOSSWS_SERVER_LOCATION;
+ public static String ERROR_INVALID_FILE_READ_WRITEL;
+ public static String ERROR_SERVER_IS_NOT_SET;
+
+ public static String PROGRESS_INSTALL_JBOSSWS_RUNTIME;
+ public static String PROGRESS_UNINSTALL_JBOSSWS_RUNTIME;
+
+ //generate for jbossws lib
+ public static String DIR_DOT_METADATA;
+ public static String DIR_DOT_PLUGINS;
+ public static String TEMP_JBOSSWS_FACET_DIR;
+ public static String WEBAPP_EXPLODED_SERVER_LOCATION_FILE;
+ public static String SERVER_STATUS_LOCATION_FILE;
+ public static String WAR_STATUS_LOCATION_FILE;
+
+ public static String BIN;
+ public static String COMMOND;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JbossWSUIMessages.class);
+ }
+}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java 2008-05-21
08:55:11 UTC (rev 8249)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -32,11 +32,11 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.jboss.tools.ws.core.JbossWSCoreMessages;
import org.jboss.tools.ws.core.JbossWSCorePlugin;
-import org.jboss.tools.ws.ui.JbossWSUIMessages;
+import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
import org.jboss.tools.ws.ui.JbossWSUIPlugin;
-import org.jboss.tools.ws.ui.UIUtils;
+import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.utils.UIUtils;
/**
* @author Grid Qian
@@ -153,7 +153,6 @@
*/
private void storeValues() {
IPreferenceStore store = this.getPreferenceStore();
- System.out.println(jbosswsPath.getText());
store.setValue(JbossWSCoreMessages.WS_LOCATION, jbosswsPath.getText());
}
Copied:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/UIUtils.java (from
rev 8246, trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/UIUtils.java)
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/UIUtils.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/UIUtils.java 2008-05-21
09:01:58 UTC (rev 8250)
@@ -0,0 +1,502 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.utils;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+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.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Grid Qian
+ */
+public class UIUtils {
+ /**
+ * A default padding value for horizontalResize().
+ */
+ public final static int DEFAULT_PADDING = 35;
+
+ String infoPopid_;
+
+ public UIUtils(String infoPopid) {
+ infoPopid_ = infoPopid;
+ }
+
+ public Button createRadioButton(Composite parent, String labelName,
+ String tooltip, String infopop) {
+ return createButton(SWT.RADIO, parent, labelName, tooltip, infopop);
+ }
+
+ public Button createCheckbox(Composite parent, String labelName,
+ String tooltip, String infopop) {
+ return createButton(SWT.CHECK, parent, labelName, tooltip, infopop);
+ }
+
+ public Button createPushButton(Composite parent, String labelName,
+ String tooltip, String infopop) {
+ return createButton(SWT.NONE, parent, labelName, tooltip, infopop);
+ }
+
+ public Button createButton(int kind, Composite parent, String labelName,
+ String tooltip, String infopop) {
+ Button button = new Button(parent, kind);
+
+ tooltip = tooltip == null ? labelName : tooltip;
+ button.setText(labelName);
+ button.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(button,
+ infoPopid_ + "." + infopop);
+
+ return button;
+ }
+
+ public Combo createCombo(Composite parent, String labelName,
+ String tooltip, String infopop, int style) {
+ tooltip = tooltip == null ? labelName : tooltip;
+
+ if (labelName != null) {
+ Label label = new Label(parent, SWT.WRAP);
+ label.setText(labelName);
+ label.setToolTipText(tooltip);
+ }
+
+ Combo combo = new Combo(parent, style);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+
+ combo.setLayoutData(griddata);
+ combo.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(combo,
+ infoPopid_ + "." + infopop);
+
+ return combo;
+ }
+
+ public Text createText(Composite parent, String labelName, String tooltip,
+ String infopop, int style) {
+ tooltip = tooltip == null ? labelName : tooltip;
+
+ if (labelName != null) {
+ Label label = new Label(parent, SWT.WRAP);
+ label.setText(labelName);
+ label.setToolTipText(tooltip);
+ }
+
+ Text text = new Text(parent, style);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+
+ text.setLayoutData(griddata);
+ text.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(text,
+ infoPopid_ + "." + infopop);
+
+ return text;
+ }
+
+ public Composite createComposite(Composite parent, int columns) {
+ return createComposite(parent, columns, -1, -1);
+ }
+
+ public Composite createComposite(Composite parent, int columns,
+ int marginHeight, int marginWidth) {
+ Composite composite = new Composite(parent, SWT.NONE);
+
+ GridLayout gridlayout = new GridLayout();
+ gridlayout.numColumns = columns;
+
+ if (marginHeight >= 0)
+ gridlayout.marginHeight = marginHeight;
+ if (marginWidth >= 0)
+ gridlayout.marginWidth = marginWidth;
+
+ composite.setLayout(gridlayout);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+ composite.setLayoutData(griddata);
+
+ return composite;
+
+ }
+
+ public Group createGroup(Composite parent, String groupName,
+ String tooltip, String infopop) {
+ return createGroup(parent, groupName, tooltip, infopop, 1, -1, -1);
+ }
+
+ public Group createGroup(Composite parent, String groupName,
+ String tooltip, String infopop, int columns, int marginHeight,
+ int marginWidth) {
+ Group newGroup = new Group(parent, SWT.NONE);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+ GridLayout gridlayout = new GridLayout();
+
+ gridlayout.numColumns = columns;
+
+ if (marginHeight >= 0)
+ gridlayout.marginHeight = marginHeight;
+ if (marginWidth >= 0)
+ gridlayout.marginWidth = marginWidth;
+
+ tooltip = tooltip == null ? groupName : tooltip;
+ newGroup.setLayout(gridlayout);
+ newGroup.setText(groupName);
+ newGroup.setLayoutData(griddata);
+ newGroup.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newGroup,
+ infoPopid_ + "." + infopop);
+
+ return newGroup;
+ }
+
+ public Tree createTree(Composite parent, String tooltip, String infopop,
+ int style) {
+
+ tooltip = tooltip == null ? "" : tooltip;
+
+ Tree tree = new Tree(parent, style);
+
+ tree.setLayoutData(createFillAll());
+ tree.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(tree,
+ infoPopid_ + "." + infopop);
+
+ return tree;
+
+ }
+
+ public Table createTable(Composite parent, String tooltip, String infopop,
+ int style) {
+
+ tooltip = tooltip == null ? "" : tooltip;
+
+ Table table = new Table(parent, style);
+
+ // table.setLayoutData( createFillAll() );
+ table.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(table,
+ infoPopid_ + "." + infopop);
+
+ return table;
+
+ }
+
+ public Label createHorizontalSeparator(Composite parent, int spacing) {
+ Composite composite = createComposite(parent, 1, spacing, -1);
+
+ Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+ separator.setLayoutData(griddata);
+
+ return separator;
+ }
+
+ public GridData createFillAll() {
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL
+ | GridData.GRAB_VERTICAL);
+ return data;
+ }
+
+ public void createInfoPop(Control ctrl, String infopop) {
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(ctrl,
+ infoPopid_ + "." + infopop);
+ }
+
+ /**
+ * Resizes the width of the target composite so that it is as wide as the
+ * reference composite plus a padding value.
+ *
+ * @param target
+ * The composite to resize.
+ * @param reference
+ * The reference composite
+ * @param padding
+ * The padding value
+ */
+ public void horizontalResize(Composite target, Composite reference,
+ int padding) {
+
+ Point originalSize = target.getSize();
+ Point referenceSize = reference.getSize();
+
+ padding = padding >= 0 ? padding : DEFAULT_PADDING;
+
+ if (referenceSize.x + padding > originalSize.x)
+ target.setSize(referenceSize.x + padding, originalSize.y);
+ }
+
+ public static void writePropertyToFile(File file,String key, String value) throws
IOException {
+ Writer out = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file), "8859_1"));
+ out.write(key+"="+value+"\n");
+ out.close();
+ }
+
+ // file util
+ public static void copyFile(String src, String dest) {
+ InputStream is = null;
+ FileOutputStream fos = null;
+
+ try
+ {
+ is = new FileInputStream(src);
+ fos = new FileOutputStream(dest);
+ int c = 0;
+ byte[] array = new byte[1024];
+ while ((c = is.read(array)) >= 0){
+ fos.write(array, 0, c);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ fos.close();
+ is.close();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static File createFileAndParentDirectories(String fileName) throws Exception {
+ File file = new File(fileName);
+ File parent = file.getParentFile();
+ if (!parent.exists()){
+ parent.mkdirs();
+ }
+ file.createNewFile();
+ return file;
+ }
+
+ public static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i=0; i<children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+ return dir.delete();
+ }
+
+ public static void deleteDirectories(File dir) {
+ File[] children = dir.listFiles();
+ for (int i = 0; i < children.length; i++){
+ if (children[i].list() != null && children[i].list().length > 0){
+ deleteDirectories(children[i]);
+ }
+ else{
+ children[i].delete();
+ }
+ }
+ dir.delete();
+ }
+
+ public static void deleteDirectories(String dir) {
+ File directory = new File(dir);
+ deleteDirectories(directory);
+ }
+
+ public static void createTargetFile(String sourceFileName, String targetFileName)
+ throws Exception {
+ createTargetFile(sourceFileName, targetFileName, false);
+ }
+
+ public static void createTargetFile(String sourceFileName, String targetFileName,
+ boolean overwrite) throws Exception{
+ File idealResultFile = new File(targetFileName);
+ if (overwrite || !idealResultFile.exists())
+ {
+ createFileAndParentDirectories(targetFileName);
+ copyFile(sourceFileName, targetFileName);
+ }
+ }
+
+ public static boolean createDirectory(String directory){
+ // Create a directory; all ancestor directories must exist
+ boolean success = (new File(directory)).mkdir();
+ if (!success) {
+ // Directory creation failed
+ }
+ return success;
+ }
+
+ public static boolean createDirectorys(String directory){
+ // Create a directory; all ancestor directories must exist
+ boolean success = (new File(directory)).mkdirs();
+ if (!success) {
+ // Directory creation failed
+ }
+ return success;
+ }
+
+ //Copies all files under srcDir to dstDir.
+ // If dstDir does not exist, it will be created.
+ public static void copyDirectory(File srcDir, File dstDir) throws IOException {
+ if (srcDir.isDirectory()) {
+ if (!dstDir.exists()) {
+ dstDir.mkdir();
+ }
+
+ String[] children = srcDir.list();
+ for (int i=0; i<children.length; i++) {
+ copyDirectory(new File(srcDir, children[i]),
+ new File(dstDir, children[i]));
+ }
+ } else {
+ copy(srcDir, dstDir);
+ }
+ }
+
+ //Copies src file to dst file.
+ // If the dst file does not exist, it is created
+ public static void copy(File src, File dst) throws IOException {
+ InputStream in = new FileInputStream(src);
+ OutputStream out = new FileOutputStream(dst);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+
+ public static String addAnotherNodeToPath(String currentPath, String newNode) {
+ return currentPath + File.separator + newNode;
+ }
+
+ public static String addNodesToPath(String currentPath, String[] newNode) {
+ String returnPath=currentPath;
+ for (int i = 0; i < newNode.length; i++) {
+ returnPath = returnPath + File.separator + newNode[i];
+ }
+ return returnPath;
+ }
+
+ public static String addNodesToPath(StringBuffer currentPath, String[] pathNodes) {
+ for (int i = 0; i < pathNodes.length; i++){
+ currentPath.append(File.separator);
+ currentPath.append(pathNodes[i]);
+ }
+ return currentPath.toString();
+ }
+
+ public static String addNodesToURL(String currentPath, String[] newNode) {
+ String returnPath=currentPath;
+ for (int i = 0; i < newNode.length; i++) {
+ returnPath = returnPath + "/" + newNode[i];
+ }
+ return returnPath;
+ }
+
+ /**
+ * Get the list of file with a prefix of <code>fileNamePrefix</code>
& an extension of
+ * <code>extension</code>
+ *
+ * @param sourceDir The directory in which to search the files
+ * @param fileNamePrefix The prefix to look for
+ * @param extension The extension to look for
+ * @return The list of file with a prefix of <code>fileNamePrefix</code>
& an extension of
+ * <code>extension</code>
+ */
+ public static File[] getMatchingFiles(String sourceDir, String fileNamePrefix, String
extension) {
+ List<File> fileList = new ArrayList<File>();
+ File libDir = new File(sourceDir);
+ String libDirPath = libDir.getAbsolutePath();
+ String[] items = libDir.list();
+ if (items != null) {
+ for (int i = 0; i < items.length; i++) {
+ String item = items[i];
+ if (fileNamePrefix != null && extension != null) {
+ if (item.startsWith(fileNamePrefix) &&
item.endsWith(extension)) {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ } else if (fileNamePrefix == null && extension != null) {
+ if (item.endsWith(extension)) {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ } else if (fileNamePrefix != null && extension == null) {
+ if (item.startsWith(fileNamePrefix)) {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ } else {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ }
+ return (File[]) fileList.toArray(new File[fileList.size()]);
+ }
+ return new File[0];
+ }
+
+ /**
+ * Filter out files inside a <code>sourceDir</code> with matching
<codefileNamePrefix></code>
+ * and <code>extension</code>
+ * @param sourceDir The directory to filter the files
+ * @param fileNamePrefix The filtering filename prefix
+ * @param extension The filtering file extension
+ */
+ public static void filterOutRestrictedFiles(String sourceDir, String fileNamePrefix,
String extension){
+ File[] resultedMatchingFiles = getMatchingFiles(sourceDir, fileNamePrefix,
extension);
+ for (int i = 0; i < resultedMatchingFiles.length; i++) {
+ File matchingFilePath = new File(resultedMatchingFiles[i].getAbsolutePath());
+ matchingFilePath.delete();
+ }
+ }
+
+}
\ No newline at end of file