KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.debug.ui.AbstractLaunchConfigurationTabGroup;
17 import org.eclipse.debug.ui.CommonTab;
18 import org.eclipse.debug.ui.EnvironmentTab;
19 import org.eclipse.debug.ui.ILaunchConfigurationDialog;
20 import org.eclipse.debug.ui.ILaunchConfigurationTab;
21 import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
22 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
23 import org.eclipse.pde.internal.core.PDECore;
24 import org.eclipse.swt.custom.BusyIndicator;
25 import org.eclipse.swt.widgets.Display;
26
27 public class WorkbenchLauncherTabGroup extends AbstractLaunchConfigurationTabGroup {
28
29     /**
30      * @see ILaunchConfigurationTabGroup#createTabs(ILaunchConfigurationDialog,
31      * String)
32      */

33 public void createTabs(ILaunchConfigurationDialog dialog, String JavaDoc mode) {
34         ILaunchConfigurationTab[] tabs = null;
35         if (PDECore.getDefault().getModelManager().isOSGiRuntime()) {
36             tabs = new ILaunchConfigurationTab[]{new BasicLauncherTab(),
37                     new AdvancedLauncherTab(), new ConfigurationTab(),
38                     new TracingLauncherTab(), new EnvironmentTab(),
39                     new SourceLookupTab(), new CommonTab()};
40         } else {
41             tabs = new ILaunchConfigurationTab[]{new BasicLauncherTab(),
42                     new AdvancedLauncherTab(), new TracingLauncherTab(),
43                     new EnvironmentTab(), new SourceLookupTab(),
44                     new CommonTab()};
45         }
46         setTabs(tabs);
47     }
48     /**
49      * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup#initializeFrom(ILaunchConfiguration)
50      */

51     public void initializeFrom(ILaunchConfiguration configuration) {
52         final ILaunchConfiguration config = configuration;
53         final ILaunchConfigurationTab[] tabs = getTabs();
54         BusyIndicator.showWhile(Display.getCurrent(), new Runnable JavaDoc() {
55             public void run() {
56                 try {
57                     String JavaDoc id =
58                         config.getAttribute(
59                             IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER,
60                             (String JavaDoc) null);
61                     if (id == null
62                         && config instanceof ILaunchConfigurationWorkingCopy) {
63                         ILaunchConfigurationWorkingCopy wc =
64                             (ILaunchConfigurationWorkingCopy) config;
65                         wc.setAttribute(
66                             IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER,
67                             "org.eclipse.pde.ui.workbenchClasspathProvider"); //$NON-NLS-1$
68
}
69                 } catch (CoreException e) {
70                 }
71                 for (int i = 0; i < tabs.length; i++) {
72                     tabs[i].initializeFrom(config);
73                 }
74             }
75         });
76     }
77
78     /**
79      * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
80      */

81     public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
82         super.setDefaults(configuration);
83         configuration.setAttribute(
84             IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER,
85             "org.eclipse.pde.ui.workbenchClasspathProvider"); //$NON-NLS-1$
86
}
87
88 }
89
Popular Tags