01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.launcher;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.debug.core.ILaunchConfiguration;
14: import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate;
15: import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16: import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
17: import org.eclipse.pde.internal.ui.IPDEUIConstants;
18:
19: public class PDEMigrationDelegate implements
20: ILaunchConfigurationMigrationDelegate {
21:
22: public boolean isCandidate(ILaunchConfiguration candidate)
23: throws CoreException {
24: return !candidate.getAttribute(
25: IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false);
26: }
27:
28: public void migrate(ILaunchConfiguration candidate)
29: throws CoreException {
30: ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy();
31: migrate(wc);
32: wc.doSave();
33: }
34:
35: public void migrate(ILaunchConfigurationWorkingCopy candidate)
36: throws CoreException {
37: if (!candidate.getAttribute(
38: IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false)) {
39: candidate.setAttribute(
40: IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
41: String args = candidate
42: .getAttribute(
43: IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
44: ""); //$NON-NLS-1$
45: StringBuffer buffer = new StringBuffer(
46: LaunchArgumentsHelper.getInitialProgramArguments());
47: if (args.length() > 0) {
48: buffer.append(" "); //$NON-NLS-1$
49: buffer.append(args);
50: }
51: candidate
52: .setAttribute(
53: IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
54: buffer.toString());
55: }
56: }
57:
58: }
|