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 java.net.URL;
13:
14: import org.eclipse.core.runtime.IStatus;
15:
16: import org.eclipse.swt.SWT;
17: import org.eclipse.swt.layout.GridData;
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.jface.dialogs.StatusDialog;
23:
24: import org.eclipse.ui.PlatformUI;
25:
26: import org.eclipse.jdt.internal.corext.util.Messages;
27:
28: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
29: import org.eclipse.jdt.internal.ui.preferences.JavadocConfigurationBlock;
30: import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
31: import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
32:
33: /**
34: * Dialog to configure a Javadoc location
35: */
36: public class JavadocLocationDialog extends StatusDialog {
37:
38: private JavadocConfigurationBlock fJavadocConfigurationBlock;
39:
40: /**
41: * Shows the UI for configuring a javadoc location.
42: * Use {@link org.eclipse.jdt.ui.JavaUI} to access and configure Javadoc locations.
43: *
44: * @param parent The parent shell for the dialog.
45: * @param libraryName Name of of the library to which configured javadoc location belongs.
46: * @param initialURL The initial URL or <code>null</code>.
47: */
48: public JavadocLocationDialog(Shell parent, String libraryName,
49: URL initialURL) {
50: super (parent);
51: setShellStyle(getShellStyle() | SWT.RESIZE);
52:
53: IStatusChangeListener listener = new IStatusChangeListener() {
54: public void statusChanged(IStatus status) {
55: updateStatus(status);
56: }
57: };
58:
59: setTitle(Messages
60: .format(
61: NewWizardMessages.LibrariesWorkbookPage_JavadocPropertyDialog_title,
62: libraryName));
63: fJavadocConfigurationBlock = new JavadocConfigurationBlock(
64: parent, listener, initialURL, false);
65: }
66:
67: /* (non-Javadoc)
68: * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
69: */
70: protected Control createDialogArea(Composite parent) {
71: Composite composite = (Composite) super
72: .createDialogArea(parent);
73: Control inner = fJavadocConfigurationBlock
74: .createContents(composite);
75: inner.setLayoutData(new GridData(GridData.FILL_BOTH));
76: applyDialogFont(composite);
77: return composite;
78: }
79:
80: /**
81: * Returns the configured Javadoc location. The result is only valid after the dialog
82: * has been opened and has not been cancelled by the user.
83: * @return The configured javadoc location
84: */
85: public URL getResult() {
86: return fJavadocConfigurationBlock.getJavadocLocation();
87: }
88:
89: /*
90: * @see org.eclipse.jface.window.Window#configureShell(Shell)
91: */
92: protected void configureShell(Shell newShell) {
93: super.configureShell(newShell);
94: PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell,
95: IJavaHelpContextIds.JAVADOC_PROPERTY_DIALOG);
96: }
97: }
|