KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > wizards > buildpaths > SourceAttachmentDialog


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.jdt.internal.ui.wizards.buildpaths;
12
13 import org.eclipse.core.runtime.IStatus;
14
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.Control;
19 import org.eclipse.swt.widgets.Shell;
20
21 import org.eclipse.jface.dialogs.StatusDialog;
22
23 import org.eclipse.ui.PlatformUI;
24
25 import org.eclipse.jdt.core.IClasspathEntry;
26
27 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
28 import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
29 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
30
31 /**
32  * A dialog to configure the source attachment of a library (class folder, archives
33  * and variable entries).
34  *
35  */

36 public class SourceAttachmentDialog extends StatusDialog {
37     
38     private SourceAttachmentBlock fSourceAttachmentBlock;
39
40     /**
41      * Creates an instance of the SourceAttachmentDialog. After
42      * <code>open</code>, the edited paths can be accessed from
43      * the classpath entry returned by <code>getResult</code>
44      * @param parent Parent shell for the dialog
45      * @param entry The entry to edit.
46      */

47     public SourceAttachmentDialog(Shell parent, IClasspathEntry entry) {
48         super(parent);
49         setShellStyle(getShellStyle() | SWT.RESIZE);
50
51         IStatusChangeListener listener= new IStatusChangeListener() {
52             public void statusChanged(IStatus status) {
53                 updateStatus(status);
54             }
55         };
56         fSourceAttachmentBlock= new SourceAttachmentBlock(listener, entry);
57     
58         setTitle(NewWizardMessages.SourceAttachmentDialog_title);
59     }
60     
61     /* (non-Javadoc)
62      * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
63      */

64     protected void configureShell(Shell newShell) {
65         super.configureShell(newShell);
66         PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.SOURCE_ATTACHMENT_DIALOG);
67     }
68             
69     /* (non-Javadoc)
70      * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
71      */

72     protected Control createDialogArea(Composite parent) {
73         Composite composite= (Composite) super.createDialogArea(parent);
74             
75         Control inner= createSourceAttachmentControls(composite);
76         inner.setLayoutData(new GridData(GridData.FILL_BOTH));
77         applyDialogFont(composite);
78         return composite;
79     }
80
81     /**
82      * Creates the controls for the source attachment configuration.
83      */

84     protected Control createSourceAttachmentControls(Composite composite) {
85         return fSourceAttachmentBlock.createControl(composite);
86     }
87     
88     /**
89      * Returns the configured class path entry
90      */

91     public IClasspathEntry getResult() {
92         return fSourceAttachmentBlock.getNewEntry();
93     }
94 }
95
Popular Tags