KickJava   Java API By Example, From Geeks To Geeks.

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


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.ILaunchConfigurationWorkingCopy;
16 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
17 import org.eclipse.pde.internal.ui.IPDEUIConstants;
18
19 public class OSGiMigrationDelegate extends PDEMigrationDelegate {
20
21     public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException {
22         return super.isCandidate(candidate)
23                  || !candidate.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "").equals("3.3"); //$NON-NLS-1$ //$NON-NLS-2$
24
}
25
26     public void migrate (ILaunchConfigurationWorkingCopy wc) throws CoreException {
27         if (!wc.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "").equals("3.3")) { //$NON-NLS-1$ //$NON-NLS-2$
28
wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
29
StringBuffer JavaDoc vmArgs = new StringBuffer JavaDoc(wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "")); //$NON-NLS-1$
30
if (vmArgs.indexOf("-Declipse.ignoreApp") == -1) { //$NON-NLS-1$
31
if (vmArgs.length() > 0)
32                     vmArgs.append(" "); //$NON-NLS-1$
33
vmArgs.append("-Declipse.ignoreApp=true"); //$NON-NLS-1$
34
}
35             if (vmArgs.indexOf("-Dosgi.noShutdown") == -1) { //$NON-NLS-1$
36
vmArgs.append(" -Dosgi.noShutdown=true"); //$NON-NLS-1$
37
}
38             wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
39         }
40         super.migrate(wc);
41     }
42
43 }
44
Popular Tags