Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 185170
Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java (-39 / +16 lines)
Lines 141-198 Link Here
141
	// -------- Initialization ---------
141
	// -------- Initialization ---------
142
		
142
		
143
	public void init(IStructuredSelection selection) {
143
	public void init(IStructuredSelection selection) {
144
		if (selection == null || selection.isEmpty()) {
144
		String projPath= getProjectPath(selection);		
145
			setDefaultAttributes();
145
		if (projPath != null) {
146
			return;
146
			fProjectField.setText(projPath);
147
		}
147
		}
148
		
148
		fRootDialogField.setText(""); //$NON-NLS-1$
149
		Object selectedElement= selection.getFirstElement();
149
	}
150
		if (selectedElement == null) {
150
151
	private String getProjectPath(IStructuredSelection selection) {
152
		Object selectedElement= null;
153
		if (selection == null || selection.isEmpty()) {
151
			selectedElement= EditorUtility.getActiveEditorJavaInput();
154
			selectedElement= EditorUtility.getActiveEditorJavaInput();
152
		}				
155
		} else if (selection.size() == 1) {
153
		
156
			selectedElement= selection.getFirstElement();
154
		String projPath= null;
157
		}
155
		
158
		
156
		if (selectedElement instanceof IResource) {
159
		if (selectedElement instanceof IResource) {
157
			IProject proj= ((IResource)selectedElement).getProject();
160
			IProject proj= ((IResource)selectedElement).getProject();
158
			if (proj != null) {
161
			if (proj != null) {
159
				projPath= proj.getFullPath().makeRelative().toString();
162
				return proj.getFullPath().makeRelative().toString();
160
			}	
163
			}	
161
		} else if (selectedElement instanceof IJavaElement) {
164
		} else if (selectedElement instanceof IJavaElement) {
162
			IJavaProject jproject= ((IJavaElement)selectedElement).getJavaProject();
165
			IJavaProject jproject= ((IJavaElement)selectedElement).getJavaProject();
163
			if (jproject != null) {
166
			if (jproject != null) {
164
				projPath= jproject.getProject().getFullPath().makeRelative().toString();
167
				return jproject.getProject().getFullPath().makeRelative().toString();
165
			}
168
			}
166
		}	
169
		}	
167
		
170
168
		if (projPath != null) {
171
		return null;
169
			fProjectField.setText(projPath);
170
			fRootDialogField.setText(""); //$NON-NLS-1$
171
		} else {
172
			setDefaultAttributes();
173
		}
174
	}
175
	
176
	private void setDefaultAttributes() {
177
		String projPath= ""; //$NON-NLS-1$
178
		
179
		try {
180
			// find the first java project
181
			IProject[] projects= fWorkspaceRoot.getProjects();
182
			for (int i= 0; i < projects.length; i++) {
183
				IProject proj= projects[i];
184
				if (proj.hasNature(JavaCore.NATURE_ID)) {
185
					projPath= proj.getFullPath().makeRelative().toString();
186
					break;
187
				}
188
			}					
189
		} catch (CoreException e) {
190
			// ignore here
191
		}
192
		fProjectField.setText(projPath);
193
		fRootDialogField.setText("");		 //$NON-NLS-1$
194
	}
172
	}
195
	
196
173
197
	// -------- UI Creation ---------
174
	// -------- UI Creation ---------
198
175
(-)src/org/eclipse/jdt/junit/wizards/NewTestSuiteWizardPage.java (-1 / +1 lines)
Lines 213-219 Link Here
213
	 * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
213
	 * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
214
	 */
214
	 */
215
	public void setVisible(boolean visible) {
215
	public void setVisible(boolean visible) {
216
		super.setVisible(visible);
217
		if (visible) {
216
		if (visible) {
218
			setFocus();		
217
			setFocus();		
219
			updateClassesInSuiteTable();
218
			updateClassesInSuiteTable();
Lines 221-226 Link Here
221
		} else {
220
		} else {
222
			saveWidgetValues();
221
			saveWidgetValues();
223
		}
222
		}
223
		super.setVisible(visible);
224
	}
224
	}
225
225
226
	private void handleAllFieldsChanged() {
226
	private void handleAllFieldsChanged() {

Return to bug 185170