001: /*******************************************************************************
002: * Copyright (c) 2005, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.ui.launcher;
011:
012: import org.eclipse.core.runtime.CoreException;
013: import org.eclipse.debug.core.ILaunchConfiguration;
014: import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
015: import org.eclipse.jface.dialogs.Dialog;
016: import org.eclipse.pde.internal.ui.IHelpContextIds;
017: import org.eclipse.pde.internal.ui.PDEPluginImages;
018: import org.eclipse.pde.internal.ui.PDEUIMessages;
019: import org.eclipse.pde.internal.ui.launcher.ConfigurationAreaBlock;
020: import org.eclipse.pde.internal.ui.launcher.ConfigurationTemplateBlock;
021: import org.eclipse.swt.SWT;
022: import org.eclipse.swt.graphics.Image;
023: import org.eclipse.swt.layout.GridData;
024: import org.eclipse.swt.layout.GridLayout;
025: import org.eclipse.swt.widgets.Composite;
026: import org.eclipse.ui.PlatformUI;
027:
028: /**
029: * A launch configuration tab that displays and edits the configuration area
030: * location and template for a PDE launch configuration.
031: * <p>
032: * This class may be instantiated, but it is not intended to be subclassed by clients.
033: * </p>
034: * @since 3.2
035: */
036: public class ConfigurationTab extends AbstractLauncherTab implements
037: IPDELauncherConstants {
038:
039: private ConfigurationAreaBlock fConfigurationArea;
040: private ConfigurationTemplateBlock fTemplateArea;
041: private Image fImage;
042: private boolean fJUnitConfig;
043:
044: /**
045: * Constructor. Equivalent to ConfigurationTab(false).
046: *
047: * @see #ConfigurationTab(boolean)
048: */
049: public ConfigurationTab() {
050: this (false);
051: }
052:
053: /**
054: * Constructor
055: *
056: * @param isJUnitConfig a flag to indicate if the tab is to be used with a Plug-in JUnit launch configuration.
057: */
058: public ConfigurationTab(boolean isJUnitConfig) {
059: fImage = PDEPluginImages.DESC_SETTINGS_OBJ.createImage();
060: fConfigurationArea = new ConfigurationAreaBlock(this );
061: fTemplateArea = new ConfigurationTemplateBlock(this );
062: fJUnitConfig = isJUnitConfig;
063: }
064:
065: /*
066: /* (non-Javadoc)
067: * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
068: */
069: public void createControl(Composite parent) {
070: Composite container = new Composite(parent, SWT.NONE);
071: container.setLayout(new GridLayout());
072: container.setLayoutData(new GridData(GridData.FILL_BOTH));
073:
074: fConfigurationArea.createControl(container);
075: fTemplateArea.createControl(container);
076:
077: Dialog.applyDialogFont(container);
078: setControl(container);
079: PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
080: IHelpContextIds.LAUNCHER_CONFIGURATION);
081: }
082:
083: /*
084: * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
085: */
086: public void setDefaults(
087: ILaunchConfigurationWorkingCopy configuration) {
088: fConfigurationArea.setDefaults(configuration, fJUnitConfig);
089: fTemplateArea.setDefaults(configuration);
090: }
091:
092: /* (non-Javadoc)
093: * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
094: */
095: public void initializeFrom(ILaunchConfiguration configuration) {
096: try {
097: fConfigurationArea.initializeFrom(configuration);
098: fTemplateArea.initializeFrom(configuration);
099: } catch (CoreException e) {
100: }
101: }
102:
103: /*
104: /* (non-Javadoc)
105: * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
106: */
107: public void performApply(
108: ILaunchConfigurationWorkingCopy configuration) {
109: fConfigurationArea.performApply(configuration);
110: fTemplateArea.performApply(configuration);
111: }
112:
113: /*
114: /* (non-Javadoc)
115: * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
116: */
117: public String getName() {
118: return PDEUIMessages.ConfigurationTab_name;
119: }
120:
121: /*
122: /* (non-Javadoc)
123: * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getImage()
124: */
125: public Image getImage() {
126: return fImage;
127: }
128:
129: /*
130: /* (non-Javadoc)
131: * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#dispose()
132: */
133: public void dispose() {
134: if (fImage != null)
135: fImage.dispose();
136: }
137:
138: /**
139: * Validates the page and flags an error if the configuration area
140: * location or the configuration template location does not exist.
141: *
142: * @see org.eclipse.pde.ui.launcher.AbstractLauncherTab#validateTab()
143: */
144: public void validateTab() {
145: String error = fConfigurationArea.validate();
146: if (error == null)
147: error = fTemplateArea.validate();
148: setErrorMessage(error);
149: }
150: }
|