]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceAttachmentDialog.java
1e7c759a052f6e3da711318359370f39da89ca92
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / wizards / buildpaths / SourceAttachmentDialog.java
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
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.swt.layout.GridData;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.swt.widgets.Shell;
17
18 import org.eclipse.core.runtime.IStatus;
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                 this(parent, entry, false);
48         }
49
50         /**
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
57          */
58         public SourceAttachmentDialog(Shell parent, IClasspathEntry entry, boolean canEditEncoding) {
59                 super(parent);
60
61                 IStatusChangeListener listener= new IStatusChangeListener() {
62                         public void statusChanged(IStatus status) {
63                                 updateStatus(status);
64                         }
65                 };
66                 fSourceAttachmentBlock= new SourceAttachmentBlock(listener, entry, canEditEncoding);
67
68                 setTitle(NewWizardMessages.SourceAttachmentDialog_title);
69         }
70         
71         /*
72          * @see org.eclipse.jface.dialogs.Dialog#isResizable()
73          * @since 3.4
74          */
75         @Override
76         protected boolean isResizable() {
77                 return true;
78         }
79
80         /* (non-Javadoc)
81          * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
82          */
83         @Override
84         protected void configureShell(Shell newShell) {
85                 super.configureShell(newShell);
86                 PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.SOURCE_ATTACHMENT_DIALOG);
87         }
88
89         /* (non-Javadoc)
90          * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
91          */
92         @Override
93         protected Control createDialogArea(Composite parent) {
94                 Composite composite= (Composite) super.createDialogArea(parent);
95
96                 Control inner= createSourceAttachmentControls(composite);
97                 inner.setLayoutData(new GridData(GridData.FILL_BOTH));
98                 applyDialogFont(composite);
99                 return composite;
100         }
101
102         /**
103          * Creates the controls for the source attachment configuration.
104          *
105          * @param composite the parent composite
106          * @return the control
107          */
108         protected Control createSourceAttachmentControls(Composite composite) {
109                 return fSourceAttachmentBlock.createControl(composite);
110         }
111
112         /**
113          * Returns the configured class path entry.
114          *
115          * @return the configured class path entry
116          */
117         public IClasspathEntry getResult() {
118                 return fSourceAttachmentBlock.getNewEntry();
119         }
120 }