KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > launchConfigurations > AntTabGroup


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.ant.internal.ui.launchConfigurations;
12
13 import org.eclipse.core.resources.IFile;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.variables.VariablesPlugin;
17 import org.eclipse.debug.core.DebugPlugin;
18 import org.eclipse.debug.core.ILaunchConfiguration;
19 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
20 import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
21 import org.eclipse.debug.ui.CommonTab;
22 import org.eclipse.debug.ui.DebugUITools;
23 import org.eclipse.debug.ui.IDebugUIConstants;
24 import org.eclipse.debug.ui.ILaunchConfigurationDialog;
25 import org.eclipse.debug.ui.ILaunchConfigurationTab;
26 import org.eclipse.debug.ui.RefreshTab;
27 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
28 import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
29
30 public class AntTabGroup extends AbstractLaunchConfigurationTabGroup {
31
32     /* (non-Javadoc)
33      * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
34      */

35     public void initializeFrom(ILaunchConfiguration configuration) {
36         try {
37             boolean captureOutput = configuration.getAttribute(IExternalToolConstants.ATTR_CAPTURE_OUTPUT, true);
38             if (!captureOutput && configuration instanceof ILaunchConfigurationWorkingCopy) {
39                 ILaunchConfigurationWorkingCopy copy = (ILaunchConfigurationWorkingCopy) configuration;
40                 copy.setAttribute(IExternalToolConstants.ATTR_CAPTURE_OUTPUT, (String JavaDoc)null);
41                 copy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, false);
42                 copy.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, false);
43             }
44         } catch (CoreException e) {
45         }
46         super.initializeFrom(configuration);
47     }
48     
49     /* (non-Javadoc)
50      * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
51      */

52     public void createTabs(ILaunchConfigurationDialog dialog, String JavaDoc mode) {
53         ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
54             new AntMainTab(),
55             new RefreshTab(),
56             new AntBuildTab(),
57             new AntTargetsTab(),
58             new AntClasspathTab(),
59             new AntPropertiesTab(),
60             new AntJRETab(),
61             new AntEnvironmentTab(),
62             new CommonTab()
63         };
64         setTabs(tabs);
65     }
66     
67     /* (non-Javadoc)
68      * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
69      */

70     public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
71         //set default name for script
72
IResource resource = DebugUITools.getSelectedResource();
73         if (resource != null && resource instanceof IFile) {
74             IFile file = (IFile)resource;
75             String JavaDoc extension = file.getFileExtension();
76             if (extension != null && extension.equalsIgnoreCase("xml")) { //$NON-NLS-1$
77
String JavaDoc projectName= file.getProject().getName();
78                 StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(projectName);
79                 buffer.append(' ');
80                 buffer.append(file.getName());
81                 String JavaDoc name = buffer.toString().trim();
82                 name= DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name);
83                 configuration.rename(name);
84                 //set the project name so that the correct default VM install can be determined
85
configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
86                 configuration.setAttribute(IExternalToolConstants.ATTR_LOCATION,
87                         VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", file.getFullPath().toString())); //$NON-NLS-1$
88
}
89         }
90         configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$
91
super.setDefaults(configuration);
92     }
93 }
94
Popular Tags