Bug #270133: CXF web service scenarios using ANT
diff --git a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/LaunchUtils.java b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/LaunchUtils.java
index 3d8ce3a..dd0e3b7 100644
--- a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/LaunchUtils.java
+++ b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/LaunchUtils.java
@@ -42,7 +42,7 @@
import org.eclipse.ui.console.MessageConsole;
public final class LaunchUtils {
-
+
private LaunchUtils() {
}
@@ -79,7 +79,7 @@
}
public static void launch(IJavaProject javaProject, String className, String[] programArgs)
- throws CoreException {
+ throws CoreException {
IVMInstall vmInstall = JavaRuntime.getVMInstall(javaProject);
if (vmInstall == null) {
vmInstall = JavaRuntime.getDefaultVMInstall();
@@ -116,11 +116,14 @@
logStream(outputStream);
String errorStream = processes[0].getStreamsProxy().getErrorStreamMonitor().getContents();
logStream(errorStream);
-
+
logErrorStreamContents(errorStream, className);
}
private static void logStream(String outputStream) {
+ if (!PlatformUI.isWorkbenchRunning()) {
+ return;
+ }
try {
MessageConsole cxfConsole = getCXFConsole();
IWorkbench workbench = PlatformUI.getWorkbench();
@@ -147,26 +150,26 @@
IConsole[] existingConsoles = consoleManager.getConsoles();
CXFContext context = CXFCorePlugin.getDefault().getJava2WSContext();
for (int i = 0; i < existingConsoles.length; i++) {
- if (existingConsoles[i].getName().equals(context.getCxfRuntimeEdition() + " "
- + context.getCxfRuntimeVersion())) {
- return (MessageConsole) existingConsoles[i];
- }
+ if (existingConsoles[i].getName().equals(context.getCxfRuntimeEdition() + " "
+ + context.getCxfRuntimeVersion())) {
+ return (MessageConsole) existingConsoles[i];
+ }
}
- MessageConsole cxfConsole = new MessageConsole(context.getCxfRuntimeEdition() + " "
+ MessageConsole cxfConsole = new MessageConsole(context.getCxfRuntimeEdition() + " "
+ context.getCxfRuntimeVersion(),
- CXFCorePlugin.imageDescriptorFromPlugin(CXFCorePlugin.PLUGIN_ID,
- "icons/view16/console_view.gif")); //$NON-NLS-1$
+ CXFCorePlugin.imageDescriptorFromPlugin(CXFCorePlugin.PLUGIN_ID,
+ "icons/view16/console_view.gif")); //$NON-NLS-1$
consoleManager.addConsoles(new IConsole[]{cxfConsole});
return cxfConsole;
- }
+ }
private static void logErrorStreamContents(String message, String className) {
- String toolName = className.substring(className.lastIndexOf(".") + 1, //$NON-NLS-1$
+ String toolName = className.substring(className.lastIndexOf(".") + 1, //$NON-NLS-1$
className.length());
if (message != null && message.indexOf(toolName + " Error") != -1) { //$NON-NLS-1$
- Status toolStatus = new Status(IStatus.ERROR, CXFCorePlugin.PLUGIN_ID, message);
- CXFCorePlugin.log(toolStatus);
+ Status toolStatus = new Status(IStatus.ERROR, CXFCorePlugin.PLUGIN_ID, message);
+ CXFCorePlugin.log(toolStatus);
}
}
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/JAXWSAnnotateJavaCommand.java b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/JAXWSAnnotateJavaCommand.java
index 0a7948a..3ee05ce 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/JAXWSAnnotateJavaCommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/JAXWSAnnotateJavaCommand.java
@@ -21,7 +21,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
@@ -36,7 +35,6 @@
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.TextFileChange;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.wst.command.internal.env.ant.AntEnvironment;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
@@ -55,6 +53,9 @@
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IStatus status = Status.OK_STATUS;
+ if (getEnvironment() instanceof AntEnvironment) {
+ return status;
+ }
try {
if (model.isUseServiceEndpointInterface()) {
annotateInterface(monitor);
@@ -193,44 +194,26 @@
return;
}
- if (getEnvironment() instanceof AntEnvironment) {
- Display.getDefault().asyncExec(new Runnable() {
-
- public void run() {
- try {
- change.initializeValidationData(monitor);
- RefactoringStatus valid= change.isValid(new SubProgressMonitor(monitor, 1));
- if (valid.hasFatalError()) {
- return;
- }
- Change undo= change.perform(new SubProgressMonitor(monitor, 1));
- } catch (CoreException ce) {
- CXFCreationCorePlugin.log(ce.getStatus());
- }
- }
- });
- } else {
- IUndoManager manager = RefactoringCore.getUndoManager();
- boolean successful = false;
- Change undoChange = null;
- try {
- change.initializeValidationData(monitor);
- RefactoringStatus valid = change.isValid(monitor);
- if (valid.isOK()) {
- manager.aboutToPerformChange(change);
- undoChange = change.perform(monitor);
- successful = true;
- numberOfChanges++;
- }
- } catch (CoreException ce) {
- CXFCreationCorePlugin.log(ce.getStatus());
- } finally {
- manager.changePerformed(change, successful);
+ IUndoManager manager = RefactoringCore.getUndoManager();
+ boolean successful = false;
+ Change undoChange = null;
+ try {
+ change.initializeValidationData(monitor);
+ RefactoringStatus valid = change.isValid(monitor);
+ if (valid.isOK()) {
+ manager.aboutToPerformChange(change);
+ undoChange = change.perform(monitor);
+ successful = true;
+ numberOfChanges++;
}
- if (undoChange != null) {
- undoChange.initializeValidationData(monitor);
- manager.addUndo(undoChange.getName(), undoChange);
- }
+ } catch (CoreException ce) {
+ CXFCreationCorePlugin.log(ce.getStatus());
+ } finally {
+ manager.changePerformed(change, successful);
+ }
+ if (undoChange != null) {
+ undoChange.initializeValidationData(monitor);
+ manager.addUndo(undoChange.getName(), undoChange);
}
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSSelectSEICommand.java b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSSelectSEICommand.java
index 8a55198..cbe094d 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSSelectSEICommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSSelectSEICommand.java
@@ -40,6 +40,7 @@
import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.ant.AntEnvironment;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
@SuppressWarnings("restriction")
@@ -47,7 +48,7 @@
private Change undoExtractInterfaceChange;
private Java2WSDataModel model;
-
+
private IType startingPointType;
public Java2WSSelectSEICommand(Java2WSDataModel model) {
@@ -63,7 +64,7 @@
IJavaProject javaProject = JDTUtils.getJavaProject(projectName);
startingPointType = JDTUtils.getType(javaProject, javaStartingPoint);
-
+
if (startingPointType.isInterface()) {
model.setFullyQualifiedJavaInterfaceName(startingPointType.getFullyQualifiedName());
} else if (startingPointType.isClass()) {
@@ -81,6 +82,9 @@
}
private void extractInterface(IType type, IProgressMonitor monitor) {
+ if (getEnvironment() instanceof AntEnvironment) {
+ return;
+ }
try {
final ExtractInterfaceProcessor extractInterfaceProcessor = new ExtractInterfaceProcessor(type,
JavaPreferencesSettings.getCodeGenerationSettings(type.getJavaProject()));
@@ -97,7 +101,7 @@
}
extractInterfaceProcessor.setTypeName(typeName);
extractInterfaceProcessor.setReplace(false);
-
+
Set<IMethod> methods = model.getMethodMap().keySet();
extractInterfaceProcessor.setExtractedMembers(methods.toArray(new IMember[methods.size()]));
extractInterfaceProcessor.setAbstract(false);
@@ -109,12 +113,12 @@
new CheckConditionsOperation(extractInterfaceRefactoring,
CheckConditionsOperation.FINAL_CONDITIONS), RefactoringCore
.getConditionCheckingFailedSeverity());
-
+
PerformChangeOperation performChangeOperation = new PerformChangeOperation(createChangeOperation);
-
+
WorkbenchRunnableAdapter adapter = new WorkbenchRunnableAdapter(performChangeOperation);
PlatformUI.getWorkbench().getProgressService().runInUI(
- new BusyIndicatorRunnableContext(), adapter, adapter.getSchedulingRule());
+ new BusyIndicatorRunnableContext(), adapter, adapter.getSchedulingRule());
if (performChangeOperation.changeExecuted()) {
String packageName = type.getPackageFragment().getElementName();
@@ -123,9 +127,9 @@
}
String fullyQualifiedJavaInterfaceName = packageName + extractInterfaceProcessor.getTypeName();
model.setFullyQualifiedJavaInterfaceName(fullyQualifiedJavaInterfaceName);
- model.setMethodMap(CXFModelUtils.getMethodMap(JDTUtils.getType(model.getProjectName(),
+ model.setMethodMap(CXFModelUtils.getMethodMap(JDTUtils.getType(model.getProjectName(),
fullyQualifiedJavaInterfaceName), model));
-
+
undoExtractInterfaceChange = performChangeOperation.getUndoChange();
}
} catch (JavaModelException jme) {
@@ -134,7 +138,7 @@
CXFCreationCorePlugin.log(ite);
} catch (InterruptedException ie) {
CXFCreationCorePlugin.log(ie);
- }
+ }
}
@Override
@@ -142,12 +146,12 @@
IStatus status = Status.OK_STATUS;
if (undoExtractInterfaceChange != null) {
try {
- PerformChangeOperation changeOperation = new PerformChangeOperation(undoExtractInterfaceChange);
-
+ PerformChangeOperation changeOperation = new PerformChangeOperation(undoExtractInterfaceChange);
+
WorkbenchRunnableAdapter adapter= new WorkbenchRunnableAdapter(changeOperation);
PlatformUI.getWorkbench().getProgressService().runInUI(
new BusyIndicatorRunnableContext(), adapter, adapter.getSchedulingRule());
-
+
if (!startingPointType.getCompilationUnit().isConsistent()) {
startingPointType.getCompilationUnit().makeConsistent(monitor);
}