KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2004, 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 implementation
10  *******************************************************************************/

11 package org.eclipse.ant.internal.ui.launchConfigurations;
12
13 import org.eclipse.ant.internal.ui.AntUtil;
14 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
15 import org.eclipse.debug.ui.EnvironmentTab;
16 import org.eclipse.jface.dialogs.Dialog;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.graphics.Color;
19 import org.eclipse.swt.layout.GridData;
20 import org.eclipse.swt.layout.GridLayout;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Display;
23 import org.eclipse.swt.widgets.Label;
24 import org.eclipse.swt.widgets.Table;
25
26 /**
27  * An environment tab for Ant launch configurations.
28  * Environment variables are only supported when Ant is
29  * run in a separate VM, so this tab adds a warning message
30  * at the top and disables the widgets if the config isn't
31  * set to run in a separate VM.
32  */

33 public class AntEnvironmentTab extends EnvironmentTab {
34     
35     protected Composite wrappingComposite;
36     protected Label warningLabel;
37     
38     public void createControl(Composite parent) {
39         wrappingComposite= new Composite(parent, SWT.NONE);
40         wrappingComposite.setLayout(new GridLayout());
41         wrappingComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
42         wrappingComposite.setFont(parent.getFont());
43         
44         warningLabel= new Label(wrappingComposite, SWT.NONE);
45         warningLabel.setText(AntLaunchConfigurationMessages.AntEnvironmentTab_0);
46         
47         super.createControl(wrappingComposite);
48         setControl(wrappingComposite); // Overwrite setting in super method
49
Dialog.applyDialogFont(parent);
50     }
51     
52     /* (non-Javadoc)
53      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
54      */

55     public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
56         updateWidgetsEnabled(workingCopy);
57     }
58     
59     protected void updateWidgetsEnabled(ILaunchConfigurationWorkingCopy workingCopy) {
60         if (wrappingComposite == null) {
61             return;
62         }
63         boolean isSeparateJREBuild= AntUtil.isSeparateJREAntBuild(workingCopy);
64         
65         Color tableColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
66         Color labelColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_RED);
67         Table table = environmentTable.getTable();
68         table.setEnabled(isSeparateJREBuild);
69         table.setBackground(tableColor);
70         warningLabel.setForeground(labelColor);
71         envAddButton.setEnabled(isSeparateJREBuild);
72         envSelectButton.setEnabled(isSeparateJREBuild);
73         updateAppendReplace();
74         //update the enabled state of the edit and remove buttons
75
environmentTable.setSelection(environmentTable.getSelection());
76     }
77 }
78
Popular Tags