01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.wizards.buildpaths;
11:
12: import org.eclipse.core.runtime.IStatus;
13:
14: import org.eclipse.swt.SWT;
15: import org.eclipse.swt.layout.GridData;
16: import org.eclipse.swt.widgets.Composite;
17: import org.eclipse.swt.widgets.Control;
18: import org.eclipse.swt.widgets.Shell;
19:
20: import org.eclipse.jface.dialogs.StatusDialog;
21:
22: import org.eclipse.ui.PlatformUI;
23:
24: import org.eclipse.jdt.core.IClasspathEntry;
25:
26: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
27: import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
28: import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
29:
30: /**
31: * A dialog to configure the source attachment of a library (class folder, archives
32: * and variable entries).
33: *
34: */
35: public class SourceAttachmentDialog extends StatusDialog {
36:
37: private SourceAttachmentBlock fSourceAttachmentBlock;
38:
39: /**
40: * Creates an instance of the SourceAttachmentDialog. After
41: * <code>open</code>, the edited paths can be accessed from
42: * the classpath entry returned by <code>getResult</code>
43: * @param parent Parent shell for the dialog
44: * @param entry The entry to edit.
45: */
46: public SourceAttachmentDialog(Shell parent, IClasspathEntry entry) {
47: super (parent);
48: setShellStyle(getShellStyle() | SWT.RESIZE);
49:
50: IStatusChangeListener listener = new IStatusChangeListener() {
51: public void statusChanged(IStatus status) {
52: updateStatus(status);
53: }
54: };
55: fSourceAttachmentBlock = new SourceAttachmentBlock(listener,
56: 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,
67: IJavaHelpContextIds.SOURCE_ATTACHMENT_DIALOG);
68: }
69:
70: /* (non-Javadoc)
71: * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
72: */
73: protected Control createDialogArea(Composite parent) {
74: Composite composite = (Composite) super
75: .createDialogArea(parent);
76:
77: Control inner = createSourceAttachmentControls(composite);
78: inner.setLayoutData(new GridData(GridData.FILL_BOTH));
79: applyDialogFont(composite);
80: return composite;
81: }
82:
83: /**
84: * Creates the controls for the source attachment configuration.
85: */
86: protected Control createSourceAttachmentControls(Composite composite) {
87: return fSourceAttachmentBlock.createControl(composite);
88: }
89:
90: /**
91: * Returns the configured class path entry
92: */
93: public IClasspathEntry getResult() {
94: return fSourceAttachmentBlock.getNewEntry();
95: }
96: }
|