KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > javadocexport > JavadocStandardWizardPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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
12 package org.eclipse.jdt.internal.ui.javadocexport;
13
14 import java.io.File JavaDoc;
15 import java.lang.reflect.InvocationTargetException JavaDoc;
16 import java.net.URL JavaDoc;
17 import java.util.ArrayList JavaDoc;
18 import java.util.Arrays JavaDoc;
19 import java.util.HashSet JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22
23 import org.eclipse.core.runtime.CoreException;
24 import org.eclipse.core.runtime.IPath;
25 import org.eclipse.core.runtime.IProgressMonitor;
26 import org.eclipse.core.runtime.IStatus;
27
28 import org.eclipse.core.resources.IProject;
29 import org.eclipse.core.resources.IWorkspaceRunnable;
30
31 import org.eclipse.swt.SWT;
32 import org.eclipse.swt.events.ModifyEvent;
33 import org.eclipse.swt.events.ModifyListener;
34 import org.eclipse.swt.events.SelectionAdapter;
35 import org.eclipse.swt.events.SelectionEvent;
36 import org.eclipse.swt.layout.GridData;
37 import org.eclipse.swt.layout.GridLayout;
38 import org.eclipse.swt.widgets.Button;
39 import org.eclipse.swt.widgets.Composite;
40 import org.eclipse.swt.widgets.Control;
41 import org.eclipse.swt.widgets.Group;
42 import org.eclipse.swt.widgets.Shell;
43 import org.eclipse.swt.widgets.Text;
44
45 import org.eclipse.jface.dialogs.Dialog;
46 import org.eclipse.jface.dialogs.StatusDialog;
47 import org.eclipse.jface.viewers.ViewerComparator;
48 import org.eclipse.jface.window.Window;
49
50 import org.eclipse.ui.PlatformUI;
51
52 import org.eclipse.jdt.core.IClasspathEntry;
53 import org.eclipse.jdt.core.IJavaProject;
54 import org.eclipse.jdt.core.JavaCore;
55
56 import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
57 import org.eclipse.jdt.launching.JavaRuntime;
58
59 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
60 import org.eclipse.jdt.internal.ui.JavaPlugin;
61 import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter;
62 import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
63 import org.eclipse.jdt.internal.ui.dialogs.StatusUtil;
64 import org.eclipse.jdt.internal.ui.preferences.JavadocConfigurationBlock;
65 import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
66 import org.eclipse.jdt.internal.ui.util.SWTUtil;
67 import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
68 import org.eclipse.jdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
69 import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
70 import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
71 import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
72 import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
73 import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
74
75 public class JavadocStandardWizardPage extends JavadocWizardPage {
76     
77     
78     private final int STYLESHEETSTATUS= 1;
79     private final int LINK_REFERENCES= 2;
80     
81     private JavadocOptionsManager fStore;
82     private Composite fUpperComposite;
83
84     private Group fBasicOptionsGroup;
85     private Group fTagsGroup;
86
87     private Button fTitleButton;
88     private Text fTitleText;
89     private Text fStyleSheetText;
90     private FlaggedButton fDeprecatedList;
91     private FlaggedButton fDeprecatedCheck;
92     private FlaggedButton fIndexCheck;
93     private FlaggedButton fSeperatedIndexCheck;
94     private Button fStyleSheetBrowseButton;
95     private Button fStyleSheetButton;
96
97     private CheckedListDialogField fListDialogField;
98
99     private StatusInfo fStyleSheetStatus;
100     private StatusInfo fLinkRefStatus;
101     
102     private ArrayList JavaDoc fButtonsList;
103     private JavadocTreeWizardPage fFirstPage;
104
105
106     public JavadocStandardWizardPage(String JavaDoc pageName, JavadocTreeWizardPage firstPage, JavadocOptionsManager store) {
107         super(pageName);
108         fFirstPage= firstPage;
109         setDescription(JavadocExportMessages.JavadocStandardWizardPage_description);
110
111         fStore= store;
112         fButtonsList= new ArrayList JavaDoc();
113         fStyleSheetStatus= new StatusInfo();
114         fLinkRefStatus= new StatusInfo();
115     }
116     /*
117      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
118      */

119     public void createControl(Composite parent) {
120
121         initializeDialogUnits(parent);
122
123         fUpperComposite= new Composite(parent, SWT.NONE);
124         fUpperComposite.setFont(parent.getFont());
125         fUpperComposite.setLayoutData(createGridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL, 1, 0));
126
127         GridLayout layout= createGridLayout(4);
128         layout.marginHeight= 0;
129         fUpperComposite.setLayout(layout);
130
131         createBasicOptionsGroup(fUpperComposite);
132         createTagOptionsGroup(fUpperComposite);
133         createListDialogField(fUpperComposite);
134         createStyleSheetGroup(fUpperComposite);
135
136         setControl(fUpperComposite);
137         Dialog.applyDialogFont(fUpperComposite);
138         PlatformUI.getWorkbench().getHelpSystem().setHelp(fUpperComposite, IJavaHelpContextIds.JAVADOC_STANDARD_PAGE);
139     }
140     private void createBasicOptionsGroup(Composite composite) {
141
142         fTitleButton= createButton(composite, SWT.CHECK, JavadocExportMessages.JavadocStandardWizardPage_titlebutton_label, createGridData(1));
143         fTitleText= createText(composite, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, 3, 0));
144         String JavaDoc text= fStore.getTitle();
145         if (!text.equals("")) { //$NON-NLS-1$
146
fTitleText.setText(text);
147             fTitleButton.setSelection(true);
148         } else
149             fTitleText.setEnabled(false);
150
151         fBasicOptionsGroup= new Group(composite, SWT.SHADOW_ETCHED_IN);
152         fBasicOptionsGroup.setLayout(createGridLayout(1));
153         fBasicOptionsGroup.setLayoutData(createGridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, 2, 0));
154         fBasicOptionsGroup.setText(JavadocExportMessages.JavadocStandardWizardPage_basicgroup_label);
155
156         new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_usebutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.USE, true);
157         new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_hierarchybutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.NOTREE, false);
158         new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_navigartorbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.NONAVBAR, false);
159
160         fIndexCheck= new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_indexbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.NOINDEX, false);
161
162         fSeperatedIndexCheck= new FlaggedButton(fBasicOptionsGroup, JavadocExportMessages.JavadocStandardWizardPage_seperateindexbutton_label, createGridData(GridData.GRAB_HORIZONTAL, 1, convertWidthInCharsToPixels(3)), fStore.SPLITINDEX, true);
163         fSeperatedIndexCheck.getButton().setEnabled(fIndexCheck.getButton().getSelection());
164
165         fIndexCheck.getButton().addSelectionListener(new ToggleSelectionAdapter(new Control[] { fSeperatedIndexCheck.getButton()}));
166         fTitleButton.addSelectionListener(new ToggleSelectionAdapter(new Control[] { fTitleText }));
167
168     }
169
170     private void createTagOptionsGroup(Composite composite) {
171         fTagsGroup= new Group(composite, SWT.SHADOW_ETCHED_IN);
172         fTagsGroup.setLayout(createGridLayout(1));
173         fTagsGroup.setLayoutData(createGridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, 2, 0));
174         fTagsGroup.setText(JavadocExportMessages.JavadocStandardWizardPage_tagsgroup_label);
175
176         new FlaggedButton(fTagsGroup, JavadocExportMessages.JavadocStandardWizardPage_authorbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.AUTHOR, true);
177         new FlaggedButton(fTagsGroup, JavadocExportMessages.JavadocStandardWizardPage_versionbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.VERSION, true);
178         fDeprecatedCheck= new FlaggedButton(fTagsGroup, JavadocExportMessages.JavadocStandardWizardPage_deprecatedbutton_label, new GridData(GridData.FILL_HORIZONTAL), fStore.NODEPRECATED, false);
179         fDeprecatedList= new FlaggedButton(fTagsGroup, JavadocExportMessages.JavadocStandardWizardPage_deprecatedlistbutton_label, createGridData(GridData.FILL_HORIZONTAL, 1, convertWidthInCharsToPixels(3)), fStore.NODEPRECATEDLIST, false);
180         fDeprecatedList.getButton().setEnabled(fDeprecatedCheck.getButton().getSelection());
181
182         fDeprecatedCheck.getButton().addSelectionListener(new ToggleSelectionAdapter(new Control[] { fDeprecatedList.getButton()}));
183     } //end createTagOptionsGroup
184

185     private void createStyleSheetGroup(Composite composite) {
186         Composite c= new Composite(composite, SWT.NONE);
187         c.setLayout(createGridLayout(3));
188         c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 4, 0));
189         ((GridLayout) c.getLayout()).marginWidth= 0;
190
191         fStyleSheetButton= createButton(c, SWT.CHECK, JavadocExportMessages.JavadocStandardWizardPage_stylesheettext_label, createGridData(1));
192         fStyleSheetText= createText(c, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, 1, 0));
193         //there really aught to be a way to specify this
194
((GridData) fStyleSheetText.getLayoutData()).widthHint= 200;
195         fStyleSheetBrowseButton= createButton(c, SWT.PUSH, JavadocExportMessages.JavadocStandardWizardPage_stylesheetbrowsebutton_label, createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 0));
196         SWTUtil.setButtonDimensionHint(fStyleSheetBrowseButton);
197
198         String JavaDoc str= fStore.getStyleSheet();
199         if (str.equals("")) { //$NON-NLS-1$
200
//default
201
fStyleSheetText.setEnabled(false);
202             fStyleSheetBrowseButton.setEnabled(false);
203         } else {
204             fStyleSheetButton.setSelection(true);
205             fStyleSheetText.setText(str);
206         }
207
208         //Listeners
209
fStyleSheetButton.addSelectionListener(new ToggleSelectionAdapter(new Control[] { fStyleSheetText, fStyleSheetBrowseButton }) {
210             public void validate() {
211                 doValidation(STYLESHEETSTATUS);
212             }
213         });
214
215         fStyleSheetText.addModifyListener(new ModifyListener() {
216             public void modifyText(ModifyEvent e) {
217                 doValidation(STYLESHEETSTATUS);
218             }
219         });
220
221         fStyleSheetBrowseButton.addSelectionListener(new SelectionAdapter() {
222             public void widgetSelected(SelectionEvent event) {
223                 handleFileBrowseButtonPressed(fStyleSheetText, new String JavaDoc[] { "*.css" }, JavadocExportMessages.JavadocSpecificsWizardPage_stylesheetbrowsedialog_title); //$NON-NLS-1$
224
}
225         });
226
227     }
228
229     private void createListDialogField(Composite composite) {
230         Composite c= new Composite(composite, SWT.NONE);
231         c.setFont(composite.getFont());
232         c.setLayout(createGridLayout(3));
233         c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, 4, 0));
234         ((GridLayout) c.getLayout()).marginWidth= 0;
235
236         String JavaDoc[] buttonlabels= new String JavaDoc[] { JavadocExportMessages.JavadocStandardWizardPage_selectallbutton_label, JavadocExportMessages.JavadocStandardWizardPage_clearallbutton_label, JavadocExportMessages.JavadocStandardWizardPage_configurebutton_label};
237
238         JavadocLinkDialogLabelProvider labelProvider= new JavadocLinkDialogLabelProvider();
239         
240         ListAdapter adapter= new ListAdapter();
241         
242         fListDialogField= new CheckedListDialogField(adapter, buttonlabels, labelProvider);
243         fListDialogField.setDialogFieldListener(adapter);
244         fListDialogField.setCheckAllButtonIndex(0);
245         fListDialogField.setUncheckAllButtonIndex(1);
246         fListDialogField.setViewerComparator(new ViewerComparator());
247
248         createLabel(c, SWT.NONE, JavadocExportMessages.JavadocStandardWizardPage_referencedclasses_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 4, 0));
249         fListDialogField.doFillIntoGrid(c, 3);
250
251         LayoutUtil.setHorizontalGrabbing(fListDialogField.getListControl(null));
252
253         fListDialogField.enableButton(2, false);
254     }
255
256     private List JavaDoc getCheckedReferences(JavadocLinkRef[] referencesClasses) {
257         List JavaDoc checkedElements= new ArrayList JavaDoc();
258         
259         String JavaDoc hrefs[]= fStore.getHRefs();
260         if (hrefs.length > 0) {
261             HashSet JavaDoc set= new HashSet JavaDoc();
262             for (int i= 0; i < hrefs.length; i++) {
263                 set.add(hrefs[i]);
264             }
265             for (int i = 0; i < referencesClasses.length; i++) {
266                 JavadocLinkRef curr= referencesClasses[i];
267                 URL JavaDoc url= curr.getURL();
268                 if (url != null && set.contains(url.toExternalForm())) {
269                     checkedElements.add(curr);
270                 }
271             }
272         }
273         return checkedElements;
274     }
275     
276
277     
278     /**
279      * Returns IJavaProjects and IPaths that will be on the classpath
280      */

281     private JavadocLinkRef[] getReferencedElements(IJavaProject[] checkedProjects) {
282         HashSet JavaDoc result= new HashSet JavaDoc();
283         for (int i= 0; i < checkedProjects.length; i++) {
284             IJavaProject project= checkedProjects[i];
285             try {
286                 collectReferencedElements(project, result);
287             } catch (CoreException e) {
288                 JavaPlugin.log(e);
289                 // ignore
290
}
291         }
292         return (JavadocLinkRef[]) result.toArray(new JavadocLinkRef[result.size()]);
293     }
294     
295     private void collectReferencedElements(IJavaProject project, HashSet JavaDoc result) throws CoreException {
296         IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
297         for (int i= 0; i < unresolved.length; i++) {
298             IRuntimeClasspathEntry curr= unresolved[i];
299             if (curr.getType() == IRuntimeClasspathEntry.PROJECT) {
300                 result.add(new JavadocLinkRef(JavaCore.create((IProject) curr.getResource())));
301             } else {
302                 IRuntimeClasspathEntry[] entries= JavaRuntime.resolveRuntimeClasspathEntry(curr, project);
303                 for (int k = 0; k < entries.length; k++) {
304                     IRuntimeClasspathEntry entry= entries[k];
305                     if (entry.getType() == IRuntimeClasspathEntry.PROJECT) {
306                         result.add(new JavadocLinkRef(JavaCore.create((IProject) entry.getResource())));
307                     } else if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE) {
308                         IClasspathEntry classpathEntry= entry.getClasspathEntry();
309                         if (classpathEntry != null) {
310                             IPath containerPath= null;
311                             if (curr.getType() == IRuntimeClasspathEntry.CONTAINER) {
312                                 containerPath= curr.getPath();
313                             }
314                             result.add(new JavadocLinkRef(containerPath, classpathEntry, project));
315                         }
316                     }
317                 }
318             }
319         }
320     }
321     
322     final void doValidation(int VALIDATE) {
323         switch (VALIDATE) {
324             case STYLESHEETSTATUS :
325                 fStyleSheetStatus= new StatusInfo();
326                 if (fStyleSheetButton.getSelection()) {
327                     String JavaDoc filename= fStyleSheetText.getText();
328                     if (filename.length() == 0) {
329                         fStyleSheetStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewnotfound_error);
330                     } else {
331                         File JavaDoc file= new File JavaDoc(filename);
332                         String JavaDoc ext= filename.substring(filename.lastIndexOf('.') + 1);
333                         if (!file.isFile()) {
334                             fStyleSheetStatus.setError(JavadocExportMessages.JavadocStandardWizardPage_stylesheetnopath_error);
335                         } else if (!ext.equalsIgnoreCase("css")) { //$NON-NLS-1$
336
fStyleSheetStatus.setError(JavadocExportMessages.JavadocStandardWizardPage_stylesheetnotcss_error);
337                         }
338                     }
339                 }
340                 break;
341             case LINK_REFERENCES:
342                 fLinkRefStatus= new StatusInfo();
343                 List JavaDoc list= fListDialogField.getCheckedElements();
344                 for (int i= 0; i < list.size(); i++) {
345                     JavadocLinkRef curr= (JavadocLinkRef) list.get(i);
346                     URL JavaDoc url= curr.getURL();
347                     if (url == null) {
348                         fLinkRefStatus.setWarning(JavadocExportMessages.JavadocStandardWizardPage_nolinkref_error);
349                         break;
350                     } else if ("jar".equals(url.getProtocol())) { //$NON-NLS-1$
351
fLinkRefStatus.setWarning(JavadocExportMessages.JavadocStandardWizardPage_nojarlinkref_error);
352                         break;
353                     }
354                 }
355                 break;
356         }
357
358         updateStatus(findMostSevereStatus());
359
360     }
361
362     private IStatus findMostSevereStatus() {
363         return StatusUtil.getMostSevere(new IStatus[] { fStyleSheetStatus, fLinkRefStatus });
364     }
365
366     public void updateStore() {
367
368         if (fTitleButton.getSelection())
369             fStore.setTitle(fTitleText.getText());
370         else
371             fStore.setTitle(""); //$NON-NLS-1$
372

373         //don't store the buttons if they are not enabled
374
//this will change when there is a single page aimed at the standard doclet
375
if (true) {
376             Object JavaDoc[] buttons= fButtonsList.toArray();
377             for (int i= 0; i < buttons.length; i++) {
378                 FlaggedButton button= (FlaggedButton) buttons[i];
379                 if (button.getButton().getEnabled())
380                     fStore.setBoolean(button.getFlag(), !(button.getButton().getSelection() ^ button.show()));
381                 else
382                     fStore.setBoolean(button.getFlag(), false == button.show());
383             }
384         }
385
386         if (fStyleSheetText.getEnabled())
387             fStore.setStyleSheet(fStyleSheetText.getText());
388         else
389             fStore.setStyleSheet(""); //$NON-NLS-1$
390

391         fStore.setHRefs(getHRefs());
392     }
393
394     private String JavaDoc[] getHRefs() {
395         HashSet JavaDoc res= new HashSet JavaDoc();
396         List JavaDoc checked= fListDialogField.getCheckedElements();
397         for (Iterator JavaDoc iterator= checked.iterator(); iterator.hasNext();) {
398             JavadocLinkRef element= (JavadocLinkRef) iterator.next();
399             URL JavaDoc url= element.getURL();
400             if (url != null) {
401                 res.add(url.toExternalForm());
402             }
403         }
404         return (String JavaDoc[]) res.toArray(new String JavaDoc[res.size()]);
405     }
406
407     //get the links
408

409     public void setVisible(boolean visible) {
410         super.setVisible(visible);
411         if (visible) {
412             doValidation(STYLESHEETSTATUS);
413             updateHRefList(fFirstPage.getCheckedProjects());
414         } else {
415             fStore.setHRefs(getHRefs());
416         }
417     }
418
419     /**
420      * Method will refresh the list of referenced libraries and projects
421      * depended on the projects or elements of projects selected in the
422      * TreeViewer on the JavadocTreeWizardPage.
423      */

424     private void updateHRefList(IJavaProject[] checkedProjects) {
425         JavadocLinkRef[] res= getReferencedElements(checkedProjects);
426         fListDialogField.setElements(Arrays.asList(res));
427             
428         List JavaDoc checked= getCheckedReferences(res);
429         fListDialogField.setCheckedElements(checked);
430     }
431
432     public void init() {
433         updateStatus(new StatusInfo());
434     }
435
436     protected class FlaggedButton {
437
438         private Button fButton;
439         private String JavaDoc fFlag;
440         private boolean fShowFlag;
441
442         public FlaggedButton(Composite composite, String JavaDoc message, GridData gridData, String JavaDoc flag, boolean show) {
443             fFlag= flag;
444             fShowFlag= show;
445             fButton= createButton(composite, SWT.CHECK, message, gridData);
446             fButtonsList.add(this);
447             setButtonSettings();
448         }
449
450         public Button getButton() {
451             return fButton;
452         }
453
454         public String JavaDoc getFlag() {
455             return fFlag;
456         }
457         public boolean show() {
458             return fShowFlag;
459         }
460
461         private void setButtonSettings() {
462
463             fButton.setSelection(!(fStore.getBoolean(fFlag) ^ fShowFlag));
464         }
465
466     } //end class FlaggesButton
467

468     private class ListAdapter implements IListAdapter, IDialogFieldListener {
469
470         /**
471          * @see IListAdapter#customButtonPressed(ListDialogField, int)
472          */

473         public void customButtonPressed(ListDialogField field, int index) {
474             if (index == 2)
475                 doEditButtonPressed();
476         }
477
478         /**
479          * @see IListAdapter#selectionChanged(ListDialogField)
480          */

481         public void selectionChanged(ListDialogField field) {
482             List JavaDoc selection= fListDialogField.getSelectedElements();
483             if (selection.size() != 1) {
484                 fListDialogField.enableButton(2, false);
485             } else {
486                 fListDialogField.enableButton(2, true);
487             }
488         }
489         
490         public void doubleClicked(ListDialogField field) {
491             doEditButtonPressed();
492         }
493         
494         public void dialogFieldChanged(DialogField field) {
495             doValidation(LINK_REFERENCES);
496         }
497
498     }
499
500     /**
501      * Method doEditButtonPressed.
502      */

503     private void doEditButtonPressed() {
504
505         List JavaDoc selected= fListDialogField.getSelectedElements();
506         if (selected.isEmpty()) {
507             return;
508         }
509         JavadocLinkRef obj= (JavadocLinkRef) selected.get(0);
510         if (obj != null) {
511             JavadocPropertyDialog jdialog= new JavadocPropertyDialog(getShell(), obj);
512             if (jdialog.open() == Window.OK) {
513                 fListDialogField.refresh();
514             }
515         }
516
517     }
518
519     private class JavadocPropertyDialog extends StatusDialog implements IStatusChangeListener {
520
521         private JavadocConfigurationBlock fJavadocConfigurationBlock;
522         private JavadocLinkRef fElement;
523
524         public JavadocPropertyDialog(Shell parent, JavadocLinkRef selection) {
525             super(parent);
526             setTitle(JavadocExportMessages.JavadocStandardWizardPage_javadocpropertydialog_title);
527
528             fElement= selection;
529             URL JavaDoc initialLocation= selection.getURL();
530             fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, this, initialLocation, selection.isProjectRef());
531         }
532
533         protected Control createDialogArea(Composite parent) {
534             Composite composite= (Composite) super.createDialogArea(parent);
535             Control inner= fJavadocConfigurationBlock.createContents(composite);
536             inner.setLayoutData(new GridData(GridData.FILL_BOTH));
537             applyDialogFont(composite);
538             return composite;
539         }
540
541         public void statusChanged(IStatus status) {
542             updateStatus(status);
543
544         }
545
546         /**
547          * @see Dialog#okPressed()
548          */

549         protected void okPressed() {
550             try {
551                 IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
552                     public void run(IProgressMonitor monitor) throws CoreException {
553                         URL JavaDoc javadocLocation= fJavadocConfigurationBlock.getJavadocLocation();
554                         fElement.setURL(javadocLocation, monitor);
555                     }
556                 };
557                 PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable));
558
559             } catch (InvocationTargetException JavaDoc e) {
560                 String JavaDoc title= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_title;
561                 String JavaDoc message= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_message;
562                 ExceptionHandler.handle(e, getShell(), title, message);
563             } catch (InterruptedException JavaDoc e) {
564                 // user cancelled
565
}
566             
567             fListDialogField.refresh();
568             doValidation(LINK_REFERENCES);
569             super.okPressed();
570         }
571
572         /*
573          * @see org.eclipse.jface.window.Window#configureShell(Shell)
574          */

575         protected void configureShell(Shell newShell) {
576             super.configureShell(newShell);
577             PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.JAVADOC_PROPERTY_DIALOG);
578         }
579     }
580 }
581
Popular Tags