diff options
author | Christopher Gerking | 2018-08-22 10:44:34 +0000 |
---|---|---|
committer | Ed Willink | 2019-02-27 09:54:25 +0000 |
commit | a6dd5b0cd7cb4895922bd5d1251a9cf6b989c269 (patch) | |
tree | 760fa31e676216a1f38c5f59dffde11979edc22d /plugins/org.eclipse.m2m.qvt.oml.common/src | |
parent | f9beafc7daf83facad76f30c4b9f6069074b74a3 (diff) | |
download | org.eclipse.qvto-a6dd5b0cd7cb4895922bd5d1251a9cf6b989c269.tar.gz org.eclipse.qvto-a6dd5b0cd7cb4895922bd5d1251a9cf6b989c269.tar.xz org.eclipse.qvto-a6dd5b0cd7cb4895922bd5d1251a9cf6b989c269.zip |
[537609] Ensure proper IProcess termination, deprecating ShallowProcess
Diffstat (limited to 'plugins/org.eclipse.m2m.qvt.oml.common/src')
6 files changed, 167 insertions, 135 deletions
diff --git a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/Messages.java b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/Messages.java index 1b0c74e90..43ea58edb 100644 --- a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/Messages.java +++ b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/Messages.java @@ -1,38 +1,39 @@ /******************************************************************************* - * Copyright (c) 2007, 2018 Borland Software Corporation and others. - * + * Copyright (c) 2007, 2019 Borland Software Corporation and others. + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v20.html - * + * * Contributors: * Borland Software Corporation - initial API and implementation + * Christopher Gerking - bug 537609 *******************************************************************************/ package org.eclipse.m2m.internal.qvt.oml.common; import org.eclipse.osgi.util.NLS; public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.m2m.internal.qvt.oml.common.messages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.eclipse.m2m.internal.qvt.oml.common.messages"; //$NON-NLS-1$ - private Messages() { - } + private Messages() { + } - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - public static String FileUtil_CannotDelete; - public static String ShallowProcess_Label; - public static String ShallowProcess_LabelTransform; - public static String ShallowProcess_InvalidState; - - public static String TransformationRegistry_MissingMetamodelAttr; - public static String TransformationRegistry_MissingMetaclassAttr; - public static String TransformationRegistry_UnknownMetamodel; - public static String TransformationRegistry_NoElements; - - public static String InvalidFilePath; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + public static String FileUtil_CannotDelete; + public static String IProcess_Label; + public static String IProcess_LabelTransform; + public static String IProcess_InvalidState; + + public static String TransformationRegistry_MissingMetamodelAttr; + public static String TransformationRegistry_MissingMetaclassAttr; + public static String TransformationRegistry_UnknownMetamodel; + public static String TransformationRegistry_NoElements; + + public static String InvalidFilePath; } diff --git a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/BaseProcess.java b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/BaseProcess.java index 4085e3292..d69004265 100644 --- a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/BaseProcess.java +++ b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/BaseProcess.java @@ -1,13 +1,14 @@ /******************************************************************************* - * Copyright (c) 2007, 2018 Borland Software Corporation and others. - * + * Copyright (c) 2007, 2019 Borland Software Corporation and others. + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v20.html - * + * * Contributors: * Borland Software Corporation - initial API and implementation + * Christopher Gerking - bug 537609 *******************************************************************************/ package org.eclipse.m2m.internal.qvt.oml.common.launch; @@ -15,22 +16,23 @@ import org.eclipse.core.runtime.PlatformObject; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IStreamsProxy; +@Deprecated public abstract class BaseProcess extends PlatformObject implements IProcess { - + public static interface IRunnable { - - public void run() throws Exception; - - } - + + public void run() throws Exception; + + } + public void setStreamsProxy(IStreamsProxy streamsProxy) { myStreamsProxy = streamsProxy; } - - public IStreamsProxy getStreamsProxy() { - return myStreamsProxy; - } - - private IStreamsProxy myStreamsProxy; - + + public IStreamsProxy getStreamsProxy() { + return myStreamsProxy; + } + + private IStreamsProxy myStreamsProxy; + } diff --git a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/ProcessJob.java b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/ProcessJob.java index fcbc758a3..3ff71638f 100644 --- a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/ProcessJob.java +++ b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/ProcessJob.java @@ -1,10 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2007, 2019 Borland Software Corporation and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Borland Software Corporation - initial API and implementation + * Christopher Gerking - bug 537609 + *******************************************************************************/ package org.eclipse.m2m.internal.qvt.oml.common.launch; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.IProcess; @@ -23,6 +39,15 @@ public abstract class ProcessJob extends WorkspaceJob implements IProcess { this.launch = launch; this.proxy = proxy; + + addJobChangeListener(new JobChangeAdapter() { + @Override + public void done(IJobChangeEvent event) { + if (DebugPlugin.getDefault() != null) { + DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(ProcessJob.this, DebugEvent.TERMINATE)}); + } + } + }); } public boolean canTerminate() { @@ -33,7 +58,7 @@ public abstract class ProcessJob extends WorkspaceJob implements IProcess { return getResult() != null; } - public void terminate() throws DebugException { + public void terminate() { cancel(); } @@ -49,8 +74,8 @@ public abstract class ProcessJob extends WorkspaceJob implements IProcess { } return transformationURI != null - ? NLS.bind(Messages.ShallowProcess_LabelTransform, transformationURI) - : Messages.ShallowProcess_Label; + ? NLS.bind(Messages.IProcess_LabelTransform, transformationURI) + : Messages.IProcess_Label; } public ILaunch getLaunch() { @@ -69,7 +94,7 @@ public abstract class ProcessJob extends WorkspaceJob implements IProcess { public int getExitValue() throws DebugException { if(!isTerminated()) { - throw new DebugException(new Status(IStatus.ERROR, CommonPlugin.ID, 1, Messages.ShallowProcess_InvalidState, null)); + throw new DebugException(new Status(IStatus.ERROR, CommonPlugin.ID, 1, Messages.IProcess_InvalidState, null)); } return getResult().getSeverity(); diff --git a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/SafeRunner.java b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/SafeRunner.java index b6a7b3ddc..e5c764985 100644 --- a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/SafeRunner.java +++ b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/SafeRunner.java @@ -1,38 +1,39 @@ /******************************************************************************* - * Copyright (c) 2007, 2018 Borland Software Corporation and others. - * + * Copyright (c) 2007, 2019 Borland Software Corporation and others. + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v20.html - * + * * Contributors: * Borland Software Corporation - initial API and implementation + * Christopher Gerking - bug 537609 *******************************************************************************/ package org.eclipse.m2m.internal.qvt.oml.common.launch; import org.eclipse.m2m.internal.qvt.oml.common.launch.BaseProcess.IRunnable; - +@Deprecated public class SafeRunner { - public static interface IRunner { - public void run(BaseProcess.IRunnable r) throws Exception; - } - - public static BaseProcess.IRunnable getSafeRunnable(final BaseProcess.IRunnable r) { - final IRunner runner = SameThreadRunner.INSTANCE; - return new BaseProcess.IRunnable() { - public void run() throws Exception { - runner.run(r); - } - }; - } + public static interface IRunner { + public void run(BaseProcess.IRunnable r) throws Exception; + } + + public static BaseProcess.IRunnable getSafeRunnable(final BaseProcess.IRunnable r) { + final IRunner runner = SameThreadRunner.INSTANCE; + return new BaseProcess.IRunnable() { + public void run() throws Exception { + runner.run(r); + } + }; + } + + static class SameThreadRunner implements IRunner { + public void run(IRunnable r) throws Exception { + r.run(); + } - static class SameThreadRunner implements IRunner { - public void run(IRunnable r) throws Exception { - r.run(); - } - - static IRunner INSTANCE = new SameThreadRunner(); - } + static IRunner INSTANCE = new SameThreadRunner(); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/ShallowProcess.java b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/ShallowProcess.java index d2dd865f6..3555cb14d 100644 --- a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/ShallowProcess.java +++ b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/launch/ShallowProcess.java @@ -1,13 +1,14 @@ /******************************************************************************* - * Copyright (c) 2007, 2018 Borland Software Corporation and others. - * + * Copyright (c) 2007, 2019 Borland Software Corporation and others. + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v20.html - * + * * Contributors: * Borland Software Corporation - initial API and implementation + * Christopher Gerking - bug 537609 *******************************************************************************/ package org.eclipse.m2m.internal.qvt.oml.common.launch; @@ -25,34 +26,35 @@ import org.eclipse.m2m.internal.qvt.oml.common.Messages; import org.eclipse.osgi.util.NLS; +@Deprecated public class ShallowProcess extends BaseProcess { public ShallowProcess(ILaunch launch, IRunnable r) { - myLaunch = launch; - myRunnable = r; - } - - public void run() throws Exception { - run(null); - } - - public void run(IDebugTarget debugTarget) throws Exception { - myLaunch.addProcess(this); - try { - if(debugTarget != null) { - myLaunch.addDebugTarget(debugTarget); - } - myRunnable.run(); - } - finally { - myRunnable = null; - if (DebugPlugin.getDefault() != null) { - DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)}); - } - } - } - - public String getLabel() { + myLaunch = launch; + myRunnable = r; + } + + public void run() throws Exception { + run(null); + } + + public void run(IDebugTarget debugTarget) throws Exception { + myLaunch.addProcess(this); + try { + if(debugTarget != null) { + myLaunch.addDebugTarget(debugTarget); + } + myRunnable.run(); + } + finally { + myRunnable = null; + if (DebugPlugin.getDefault() != null) { + DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)}); + } + } + } + + public String getLabel() { String transformationURI = null; ILaunchConfiguration configuration = myLaunch.getLaunchConfiguration(); if(configuration != null) { @@ -62,42 +64,42 @@ public class ShallowProcess extends BaseProcess { CommonPlugin.log(e.getStatus()); } } - - return transformationURI != null - ? NLS.bind(Messages.ShallowProcess_LabelTransform, transformationURI) - : Messages.ShallowProcess_Label; - } - - public ILaunch getLaunch() { - return myLaunch; - } - - public void setAttribute(String key, String value) { - } - - public String getAttribute(String key) { - return null; - } - - public int getExitValue() throws DebugException { - if(!isTerminated()) { - throw new DebugException(new Status(IStatus.ERROR, CommonPlugin.ID, 1, Messages.ShallowProcess_InvalidState, null)); - } - - return 0; - } - - public boolean canTerminate() { - return !isTerminated(); - } - - public boolean isTerminated() { - return myRunnable == null; - } - - public void terminate() throws DebugException { - } - - private final ILaunch myLaunch; - private IRunnable myRunnable; + + return transformationURI != null + ? NLS.bind(Messages.IProcess_LabelTransform, transformationURI) + : Messages.IProcess_Label; + } + + public ILaunch getLaunch() { + return myLaunch; + } + + public void setAttribute(String key, String value) { + } + + public String getAttribute(String key) { + return null; + } + + public int getExitValue() throws DebugException { + if(!isTerminated()) { + throw new DebugException(new Status(IStatus.ERROR, CommonPlugin.ID, 1, Messages.IProcess_InvalidState, null)); + } + + return 0; + } + + public boolean canTerminate() { + return !isTerminated(); + } + + public boolean isTerminated() { + return myRunnable == null; + } + + public void terminate() throws DebugException { + } + + private final ILaunch myLaunch; + private IRunnable myRunnable; } diff --git a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/messages.properties b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/messages.properties index ce9c9e2b6..a33e19fa8 100644 --- a/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/messages.properties +++ b/plugins/org.eclipse.m2m.qvt.oml.common/src/org/eclipse/m2m/internal/qvt/oml/common/messages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2007, 2014 Borland Software Corporation and others. +# Copyright (c) 2007, 2019 Borland Software Corporation and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v2.0 @@ -8,12 +8,13 @@ # # Contributors: # Borland Software Corporation - initial API and implementation +# Christopher Gerking - bug 537609 ############################################################################### FileUtil_CannotDelete=Cannot delete ''{0}'' -ShallowProcess_Label=QVTO Process -ShallowProcess_LabelTransform=execute ''{0}'' -ShallowProcess_InvalidState=Invalid state +IProcess_Label=QVTO Process +IProcess_LabelTransform=execute ''{0}'' +IProcess_InvalidState=Invalid state TransformationRegistry_MissingMetamodelAttr=Missing metamodel attribute: {0} TransformationRegistry_MissingMetaclassAttr=Missing metaclass attribute: {0} |