1 /*******************************************************************************
2 * Copyright (c) 2000, 2012 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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.wizards.buildpaths;
13 import org.eclipse.swt.layout.GridData;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.swt.widgets.Shell;
18 import org.eclipse.core.runtime.IStatus;
20 import org.eclipse.jface.dialogs.StatusDialog;
22 import org.eclipse.ui.PlatformUI;
24 import org.eclipse.jdt.core.IClasspathEntry;
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;
31 * A dialog to configure the source attachment of a library (class folder, archives
32 * and variable entries).
35 public class SourceAttachmentDialog extends StatusDialog {
37 private SourceAttachmentBlock fSourceAttachmentBlock;
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.
46 public SourceAttachmentDialog(Shell parent, IClasspathEntry entry) {
47 this(parent, entry, false);
51 * Creates an instance of the SourceAttachmentDialog. After
52 * <code>open</code>, the edited paths can be accessed from
53 * the classpath entry returned by <code>getResult</code>
54 * @param parent Parent shell for the dialog
55 * @param entry The entry to edit.
56 * @param canEditEncoding whether the source attachment encoding can be edited
58 public SourceAttachmentDialog(Shell parent, IClasspathEntry entry, boolean canEditEncoding) {
61 IStatusChangeListener listener= new IStatusChangeListener() {
62 public void statusChanged(IStatus status) {
66 fSourceAttachmentBlock= new SourceAttachmentBlock(listener, entry, canEditEncoding);
68 setTitle(NewWizardMessages.SourceAttachmentDialog_title);
72 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
76 protected boolean isResizable() {
81 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
84 protected void configureShell(Shell newShell) {
85 super.configureShell(newShell);
86 PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.SOURCE_ATTACHMENT_DIALOG);
90 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
93 protected Control createDialogArea(Composite parent) {
94 Composite composite= (Composite) super.createDialogArea(parent);
96 Control inner= createSourceAttachmentControls(composite);
97 inner.setLayoutData(new GridData(GridData.FILL_BOTH));
98 applyDialogFont(composite);
103 * Creates the controls for the source attachment configuration.
105 * @param composite the parent composite
106 * @return the control
108 protected Control createSourceAttachmentControls(Composite composite) {
109 return fSourceAttachmentBlock.createControl(composite);
113 * Returns the configured class path entry.
115 * @return the configured class path entry
117 public IClasspathEntry getResult() {
118 return fSourceAttachmentBlock.getNewEntry();