KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > launcher > PDEMigrationDelegate


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.launcher;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.ILaunchConfiguration;
15 import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate;
16 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
18 import org.eclipse.pde.internal.ui.IPDEUIConstants;
19
20 public class PDEMigrationDelegate implements ILaunchConfigurationMigrationDelegate {
21     
22     public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException {
23         return !candidate.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false);
24     }
25
26     public void migrate(ILaunchConfiguration candidate) throws CoreException {
27         ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy();
28         migrate(wc);
29         wc.doSave();
30     }
31
32     public void migrate(ILaunchConfigurationWorkingCopy candidate) throws CoreException {
33         if (!candidate.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false)) {
34             candidate.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
35             String JavaDoc args = candidate.getAttribute(
36                     IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
37                     ""); //$NON-NLS-1$
38
StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(LaunchArgumentsHelper.getInitialProgramArguments());
39             if (args.length() > 0) {
40                 buffer.append(" "); //$NON-NLS-1$
41
buffer.append(args);
42             }
43             candidate.setAttribute(
44                     IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
45                     buffer.toString());
46         }
47     }
48
49 }
50
Popular Tags