KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > ui > sourcelookup > SourceLookupTab


1 /*******************************************************************************
2  * Copyright (c) 2003, 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.debug.ui.sourcelookup;
12
13 import org.eclipse.debug.core.ILaunchConfiguration;
14 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
15 import org.eclipse.debug.internal.ui.DebugPluginImages;
16 import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
17 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
18 import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupPanel;
19 import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages;
20 import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
21 import org.eclipse.jface.dialogs.Dialog;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.graphics.Image;
24 import org.eclipse.swt.layout.GridData;
25 import org.eclipse.swt.layout.GridLayout;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.ui.PlatformUI;
28
29 /**
30  * A launch configuration tab that displays and edits the source
31  * lookup path for a launch configuration. This tab works with the
32  * debug platform source lookup facilities - a source lookup director
33  * with associated participants and source containers.
34  * <p>
35  * This tab may be instantiated. This class is not intended to be subclassed.
36  * </p>
37  * @since 3.0
38  */

39
40 public class SourceLookupTab extends AbstractLaunchConfigurationTab {
41     //the panel displaying the containers
42
private SourceLookupPanel fSourceLookupPanel;
43         
44     /* (non-Javadoc)
45      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
46      */

47     public void createControl(Composite parent) {
48         Composite comp = new Composite(parent, SWT.NONE);
49         setControl(comp);
50         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.SOURCELOOKUP_TAB);
51         GridLayout topLayout = new GridLayout();
52         topLayout.marginWidth = 0;
53         topLayout.marginHeight = 0;
54         topLayout.numColumns = 1;
55         comp.setLayout(topLayout);
56         comp.setFont(parent.getFont());
57         
58         fSourceLookupPanel = new SourceLookupPanel();
59         fSourceLookupPanel.setLaunchConfigurationDialog(
60                 getLaunchConfigurationDialog());
61         fSourceLookupPanel.createControl(comp);
62         GridData gd = (GridData) fSourceLookupPanel.getControl().getLayoutData();
63         gd.heightHint = 200;
64         gd.widthHint = 250;
65         Dialog.applyDialogFont(comp);
66     }
67     
68     /* (non-Javadoc)
69      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
70      */

71     public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
72         
73     }
74     
75     /* (non-Javadoc)
76      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
77      */

78     public void initializeFrom(ILaunchConfiguration configuration) {
79         fSourceLookupPanel.initializeFrom(configuration);
80     }
81     
82     /* (non-Javadoc)
83      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
84      */

85     public void performApply(ILaunchConfigurationWorkingCopy configuration) {
86         fSourceLookupPanel.performApply(configuration);
87     }
88     
89     /* (non-Javadoc)
90      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
91      */

92     public String JavaDoc getName() {
93         return SourceLookupUIMessages.sourceTab_tabTitle;
94     }
95     
96     /* (non-Javadoc)
97      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
98      */

99     public Image getImage() {
100         return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_SRC_LOOKUP_TAB);
101     }
102     
103     /* (non-Javadoc)
104      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
105      */

106     public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
107         fSourceLookupPanel.activated(workingCopy);
108     }
109     
110     /* (non-Javadoc)
111      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose()
112      */

113     public void dispose() {
114         if (fSourceLookupPanel != null) {
115             if (fSourceLookupPanel.getDirector() != null) {
116                 fSourceLookupPanel.getDirector().dispose();
117             }
118             fSourceLookupPanel.dispose();
119         }
120         fSourceLookupPanel = null;
121         super.dispose();
122     }
123     
124     /* (non-Javadoc)
125      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getErrorMessage()
126      */

127     public String JavaDoc getErrorMessage() {
128         if (fSourceLookupPanel != null) {
129             return fSourceLookupPanel.getErrorMessage();
130         }
131         return super.getErrorMessage();
132     }
133     /* (non-Javadoc)
134      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getMessage()
135      */

136     public String JavaDoc getMessage() {
137         if (fSourceLookupPanel != null) {
138             return fSourceLookupPanel.getMessage();
139         }
140         return super.getMessage();
141     }
142 }
143
Popular Tags