]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2011 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 java.util.List; | |
14 | ||
15 | import org.eclipse.swt.SWT; | |
16 | import org.eclipse.swt.layout.GridData; | |
17 | import org.eclipse.swt.layout.GridLayout; | |
18 | import org.eclipse.swt.widgets.Composite; | |
19 | import org.eclipse.swt.widgets.Control; | |
20 | import org.eclipse.swt.widgets.Shell; | |
21 | ||
22 | import org.eclipse.core.resources.IContainer; | |
23 | import org.eclipse.core.resources.IProject; | |
24 | ||
25 | import org.eclipse.jface.dialogs.StatusDialog; | |
26 | ||
27 | import org.eclipse.ui.PlatformUI; | |
28 | ||
29 | import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; | |
30 | import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; | |
31 | import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; | |
32 | import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; | |
33 | import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; | |
34 | import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; | |
35 | import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField; | |
36 | ||
37 | public class NewSourceFolderDialog extends StatusDialog { | |
38 | ||
39 | private SelectionButtonDialogField fUseProjectButton; | |
40 | public SelectionButtonDialogField fUseFolderButton; | |
41 | ||
42 | public StringDialogField fContainerDialogField; | |
43 | public StatusInfo fContainerFieldStatus; | |
44 | ||
45 | public IContainer fFolder; | |
46 | public List<IContainer> fExistingFolders; | |
47 | public IProject fCurrProject; | |
48 | ||
49 | public NewSourceFolderDialog(Shell parent, String title, IProject project, List<IContainer> existingFolders, CPListElement entryToEdit) { | |
50 | super(parent); | |
51 | setTitle(title); | |
52 | ||
53 | fContainerFieldStatus= new StatusInfo(); | |
54 | ||
55 | SourceContainerAdapter adapter= new SourceContainerAdapter(); | |
56 | ||
57 | fUseProjectButton= new SelectionButtonDialogField(SWT.RADIO); | |
58 | fUseProjectButton.setLabelText(NewWizardMessages.NewSourceFolderDialog_useproject_button); | |
59 | fUseProjectButton.setDialogFieldListener(adapter); | |
60 | ||
61 | fUseFolderButton= new SelectionButtonDialogField(SWT.RADIO); | |
62 | fUseFolderButton.setLabelText(NewWizardMessages.NewSourceFolderDialog_usefolder_button); | |
63 | fUseFolderButton.setDialogFieldListener(adapter); | |
64 | ||
65 | fContainerDialogField= new StringDialogField(); | |
66 | boolean useFolders= fContainerDialogField.generated_708656993785352015(this, project, existingFolders, entryToEdit, adapter); | |
67 | fUseFolderButton.setSelection(useFolders); | |
68 | fUseProjectButton.setSelection(!useFolders); | |
69 | } | |
70 | ||
71 | public void setMessage(String message) { | |
72 | fContainerDialogField.setLabelText(message); | |
73 | } | |
74 | ||
75 | @Override | |
76 | protected Control createDialogArea(Composite parent) { | |
77 | Composite composite= (Composite)super.createDialogArea(parent); | |
78 | ||
79 | Composite inner= new Composite(composite, SWT.NONE); | |
80 | GridLayout layout= new GridLayout(); | |
81 | layout.marginHeight= 0; | |
82 | layout.marginWidth= 0; | |
83 | layout.numColumns= 1; | |
84 | inner.setLayout(layout); | |
85 | ||
86 | int widthHint= convertWidthInCharsToPixels(50); | |
87 | ||
88 | ||
89 | GridData data= new GridData(GridData.FILL_HORIZONTAL); | |
90 | data.widthHint= widthHint; | |
91 | ||
92 | if (fExistingFolders.contains(fCurrProject)) { | |
93 | fContainerDialogField.doFillIntoGrid(inner, 2); | |
94 | } else { | |
95 | fUseProjectButton.doFillIntoGrid(inner, 1); | |
96 | fUseFolderButton.doFillIntoGrid(inner, 1); | |
97 | fContainerDialogField.getTextControl(inner); | |
98 | ||
99 | int horizontalIndent= convertWidthInCharsToPixels(3); | |
100 | data.horizontalIndent= horizontalIndent; | |
101 | } | |
102 | return fContainerDialogField.generated_5589485323602657728(parent, composite, data); | |
103 | } | |
104 | ||
105 | ||
106 | ||
107 | ||
108 | // -------- SourceContainerAdapter -------- | |
109 | ||
110 | public class SourceContainerAdapter implements IDialogFieldListener { | |
111 | ||
112 | // -------- IDialogFieldListener | |
113 | ||
114 | public void dialogFieldChanged(DialogField field) { | |
115 | doStatusLineUpdate(); | |
116 | } | |
117 | } | |
118 | ||
119 | protected void doStatusLineUpdate() { | |
120 | checkIfPathValid(); | |
121 | updateStatus(fContainerFieldStatus); | |
122 | } | |
123 | ||
124 | protected void checkIfPathValid() { | |
125 | fContainerFieldStatus.generated_7340645186492419393(this); | |
126 | } | |
127 | ||
128 | public boolean isExisting(IContainer folder) { | |
129 | return fExistingFolders.contains(folder); | |
130 | } | |
131 | ||
132 | ||
133 | ||
134 | public IContainer getSourceFolder() { | |
135 | return fFolder; | |
136 | } | |
137 | ||
138 | /* | |
139 | * @see org.eclipse.jface.window.Window#configureShell(Shell) | |
140 | */ | |
141 | @Override | |
142 | protected void configureShell(Shell newShell) { | |
143 | super.configureShell(newShell); | |
144 | PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.NEW_CONTAINER_DIALOG); | |
145 | } | |
146 | ||
147 | ||
148 | } |