KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > dialogs > WizardNewFileCreationPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.ui.dialogs;
12
13 import java.io.ByteArrayInputStream JavaDoc;
14 import java.io.InputStream JavaDoc;
15 import java.lang.reflect.InvocationTargetException JavaDoc;
16 import java.net.URI JavaDoc;
17 import java.util.Iterator JavaDoc;
18 import org.eclipse.core.commands.ExecutionException;
19 import org.eclipse.core.resources.IFile;
20 import org.eclipse.core.resources.IFolder;
21 import org.eclipse.core.resources.IResource;
22 import org.eclipse.core.resources.IResourceStatus;
23 import org.eclipse.core.resources.IWorkspace;
24 import org.eclipse.core.resources.IWorkspaceRoot;
25 import org.eclipse.core.resources.ResourcesPlugin;
26 import org.eclipse.core.runtime.CoreException;
27 import org.eclipse.core.runtime.IAdaptable;
28 import org.eclipse.core.runtime.IPath;
29 import org.eclipse.core.runtime.IProgressMonitor;
30 import org.eclipse.core.runtime.IStatus;
31 import org.eclipse.core.runtime.OperationCanceledException;
32 import org.eclipse.core.runtime.Preferences;
33 import org.eclipse.core.runtime.jobs.ISchedulingRule;
34 import org.eclipse.jface.dialogs.ErrorDialog;
35 import org.eclipse.jface.dialogs.MessageDialog;
36 import org.eclipse.jface.operation.IRunnableWithProgress;
37 import org.eclipse.jface.viewers.IStructuredSelection;
38 import org.eclipse.jface.wizard.WizardPage;
39 import org.eclipse.osgi.util.NLS;
40 import org.eclipse.swt.SWT;
41 import org.eclipse.swt.events.SelectionAdapter;
42 import org.eclipse.swt.events.SelectionEvent;
43 import org.eclipse.swt.graphics.Point;
44 import org.eclipse.swt.layout.GridData;
45 import org.eclipse.swt.layout.GridLayout;
46 import org.eclipse.swt.widgets.Button;
47 import org.eclipse.swt.widgets.Composite;
48 import org.eclipse.swt.widgets.Event;
49 import org.eclipse.swt.widgets.Listener;
50 import org.eclipse.swt.widgets.Shell;
51 import org.eclipse.ui.PlatformUI;
52 import org.eclipse.ui.ide.undo.CreateFileOperation;
53 import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
54 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
55 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
56 import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
57 import org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup;
58 import org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup;
59
60 /**
61  * Standard main page for a wizard that creates a file resource.
62  * <p>
63  * This page may be used by clients as-is; it may be also be subclassed to suit.
64  * </p>
65  * <p>
66  * Subclasses may override
67  * <ul>
68  * <li><code>getInitialContents</code></li>
69  * <li><code>getNewFileLabel</code></li>
70  * </ul>
71  * </p>
72  * <p>
73  * Subclasses may extend
74  * <ul>
75  * <li><code>handleEvent</code></li>
76  * </ul>
77  * </p>
78  */

79 public class WizardNewFileCreationPage extends WizardPage implements Listener {
80     private static final int SIZING_CONTAINER_GROUP_HEIGHT = 250;
81
82     // the current resource selection
83
private IStructuredSelection currentSelection;
84
85     // cache of newly-created file
86
private IFile newFile;
87
88     private URI JavaDoc linkTargetPath;
89
90     // widgets
91
private ResourceAndContainerGroup resourceGroup;
92
93     private Button advancedButton;
94
95     private CreateLinkedResourceGroup linkedResourceGroup;
96
97     private Composite linkedResourceParent;
98
99     private Composite linkedResourceComposite;
100
101     // initial value stores
102
private String JavaDoc initialFileName;
103     
104     /**
105      * The file extension to use for this page's file name field when
106      * it does not exist yet.
107      * @see WizardNewFileCreationPage#setFileExtension(String)
108      * @since 3.3
109      */

110     private String JavaDoc initialFileExtension;
111
112     private IPath initialContainerFullPath;
113
114     /**
115      * Height of the "advanced" linked resource group. Set when the advanced
116      * group is first made visible.
117      */

118     private int linkedResourceGroupHeight = -1;
119
120     /**
121      * First time the advanced group is validated.
122      */

123     private boolean firstLinkCheck = true;
124
125     /**
126      * Creates a new file creation wizard page. If the initial resource
127      * selection contains exactly one container resource then it will be used as
128      * the default container resource.
129      *
130      * @param pageName
131      * the name of the page
132      * @param selection
133      * the current resource selection
134      */

135     public WizardNewFileCreationPage(String JavaDoc pageName,
136             IStructuredSelection selection) {
137         super(pageName);
138         setPageComplete(false);
139         this.currentSelection = selection;
140     }
141
142     /**
143      * Creates the widget for advanced options.
144      *
145      * @param parent
146      * the parent composite
147      */

148     protected void createAdvancedControls(Composite parent) {
149         Preferences preferences = ResourcesPlugin.getPlugin()
150                 .getPluginPreferences();
151
152         if (preferences.getBoolean(ResourcesPlugin.PREF_DISABLE_LINKING) == false) {
153             linkedResourceParent = new Composite(parent, SWT.NONE);
154             linkedResourceParent.setFont(parent.getFont());
155             linkedResourceParent.setLayoutData(new GridData(
156                     GridData.FILL_HORIZONTAL));
157             GridLayout layout = new GridLayout();
158             layout.marginHeight = 0;
159             layout.marginWidth = 0;
160             linkedResourceParent.setLayout(layout);
161
162             advancedButton = new Button(linkedResourceParent, SWT.PUSH);
163             advancedButton.setFont(linkedResourceParent.getFont());
164             advancedButton.setText(IDEWorkbenchMessages.showAdvanced);
165             GridData data = setButtonLayoutData(advancedButton);
166             data.horizontalAlignment = GridData.BEGINNING;
167             advancedButton.setLayoutData(data);
168             advancedButton.addSelectionListener(new SelectionAdapter() {
169                 public void widgetSelected(SelectionEvent e) {
170                     handleAdvancedButtonSelect();
171                 }
172             });
173         }
174         linkedResourceGroup = new CreateLinkedResourceGroup(IResource.FILE,
175                 new Listener() {
176                     public void handleEvent(Event e) {
177                         setPageComplete(validatePage());
178                         firstLinkCheck = false;
179                     }
180                 }, new CreateLinkedResourceGroup.IStringValue() {
181                     public void setValue(String JavaDoc string) {
182                         resourceGroup.setResource(string);
183                     }
184
185                     public String JavaDoc getValue() {
186                         return resourceGroup.getResource();
187                     }
188                 });
189     }
190
191     /**
192      * (non-Javadoc) Method declared on IDialogPage.
193      */

194     public void createControl(Composite parent) {
195         initializeDialogUnits(parent);
196         // top level group
197
Composite topLevel = new Composite(parent, SWT.NONE);
198         topLevel.setLayout(new GridLayout());
199         topLevel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
200                 | GridData.HORIZONTAL_ALIGN_FILL));
201         topLevel.setFont(parent.getFont());
202         PlatformUI.getWorkbench().getHelpSystem().setHelp(topLevel,
203                 IIDEHelpContextIds.NEW_FILE_WIZARD_PAGE);
204
205         // resource and container group
206
resourceGroup = new ResourceAndContainerGroup(topLevel, this,
207                 getNewFileLabel(),
208                 IDEWorkbenchMessages.WizardNewFileCreationPage_file, false,
209                 SIZING_CONTAINER_GROUP_HEIGHT);
210         resourceGroup.setAllowExistingResources(false);
211         initialPopulateContainerNameField();
212         createAdvancedControls(topLevel);
213         if (initialFileName != null) {
214             resourceGroup.setResource(initialFileName);
215         }
216         if (initialFileExtension != null) {
217             resourceGroup.setResourceExtension(initialFileExtension);
218         }
219         validatePage();
220         // Show description on opening
221
setErrorMessage(null);
222         setMessage(null);
223         setControl(topLevel);
224     }
225
226     /**
227      * Creates a file resource given the file handle and contents.
228      *
229      * @param fileHandle
230      * the file handle to create a file resource with
231      * @param contents
232      * the initial contents of the new file resource, or
233      * <code>null</code> if none (equivalent to an empty stream)
234      * @param monitor
235      * the progress monitor to show visual progress with
236      * @exception CoreException
237      * if the operation fails
238      * @exception OperationCanceledException
239      * if the operation is canceled
240      *
241      * @deprecated As of 3.3, use or override {@link #createNewFile()} which
242      * uses the undoable operation support. To supply customized
243      * file content for a subclass, use
244      * {@link #getInitialContents()}.
245      */

246     protected void createFile(IFile fileHandle, InputStream JavaDoc contents,
247             IProgressMonitor monitor) throws CoreException {
248         if (contents == null) {
249             contents = new ByteArrayInputStream JavaDoc(new byte[0]);
250         }
251
252         try {
253             // Create a new file resource in the workspace
254
if (linkTargetPath != null) {
255                 fileHandle.createLink(linkTargetPath,
256                         IResource.ALLOW_MISSING_LOCAL, monitor);
257             } else {
258                 IPath path = fileHandle.getFullPath();
259                 IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
260                 int numSegments = path.segmentCount();
261                 if (numSegments > 2
262                         && !root.getFolder(path.removeLastSegments(1)).exists()) {
263                     // If the direct parent of the path doesn't exist, try to
264
// create the
265
// necessary directories.
266
for (int i = numSegments - 2; i > 0; i--) {
267                         IFolder folder = root.getFolder(path
268                                 .removeLastSegments(i));
269                         if (!folder.exists()) {
270                             folder.create(false, true, monitor);
271                         }
272                     }
273                 }
274                 fileHandle.create(contents, false, monitor);
275             }
276         } catch (CoreException e) {
277             // If the file already existed locally, just refresh to get contents
278
if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED) {
279                 fileHandle.refreshLocal(IResource.DEPTH_ZERO, null);
280             } else {
281                 throw e;
282             }
283         }
284
285         if (monitor.isCanceled()) {
286             throw new OperationCanceledException();
287         }
288     }
289
290     /**
291      * Creates a file resource handle for the file with the given workspace
292      * path. This method does not create the file resource; this is the
293      * responsibility of <code>createFile</code>.
294      *
295      * @param filePath
296      * the path of the file resource to create a handle for
297      * @return the new file resource handle
298      * @see #createFile
299      */

300     protected IFile createFileHandle(IPath filePath) {
301         return IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getFile(
302                 filePath);
303     }
304
305     /**
306      * Creates the link target path if a link target has been specified.
307      */

308     protected void createLinkTarget() {
309         linkTargetPath = linkedResourceGroup.getLinkTargetURI();
310     }
311
312     /**
313      * Creates a new file resource in the selected container and with the
314      * selected name. Creates any missing resource containers along the path;
315      * does nothing if the container resources already exist.
316      * <p>
317      * In normal usage, this method is invoked after the user has pressed Finish
318      * on the wizard; the enablement of the Finish button implies that all
319      * controls on on this page currently contain valid values.
320      * </p>
321      * <p>
322      * Note that this page caches the new file once it has been successfully
323      * created; subsequent invocations of this method will answer the same file
324      * resource without attempting to create it again.
325      * </p>
326      * <p>
327      * This method should be called within a workspace modify operation since it
328      * creates resources.
329      * </p>
330      *
331      * @return the created file resource, or <code>null</code> if the file was
332      * not created
333      */

334     public IFile createNewFile() {
335         if (newFile != null) {
336             return newFile;
337         }
338
339         // create the new file and cache it if successful
340

341         final IPath containerPath = resourceGroup.getContainerFullPath();
342         IPath newFilePath = containerPath.append(resourceGroup.getResource());
343         final IFile newFileHandle = createFileHandle(newFilePath);
344         final InputStream JavaDoc initialContents = getInitialContents();
345
346         createLinkTarget();
347         IRunnableWithProgress op = new IRunnableWithProgress() {
348             public void run(IProgressMonitor monitor) {
349                 CreateFileOperation op = new CreateFileOperation(newFileHandle,
350                         linkTargetPath, initialContents,
351                         IDEWorkbenchMessages.WizardNewFileCreationPage_title);
352                 try {
353                     PlatformUI.getWorkbench().getOperationSupport()
354                             .getOperationHistory().execute(
355                                     op,
356                                     monitor,
357                                     WorkspaceUndoUtil
358                                             .getUIInfoAdapter(getShell()));
359                 } catch (final ExecutionException e) {
360                     getContainer().getShell().getDisplay().syncExec(
361                             new Runnable JavaDoc() {
362                                 public void run() {
363                                     if (e.getCause() instanceof CoreException) {
364                                         ErrorDialog
365                                                 .openError(
366                                                         getContainer()
367                                                                 .getShell(), // Was
368
// Utilities.getFocusShell()
369
IDEWorkbenchMessages.WizardNewFileCreationPage_errorTitle,
370                                                         null, // no special
371
// message
372
((CoreException) e
373                                                                 .getCause())
374                                                                 .getStatus());
375                                     } else {
376                                         IDEWorkbenchPlugin
377                                                 .log(
378                                                         getClass(),
379                                                         "createNewFile()", e.getCause()); //$NON-NLS-1$
380
MessageDialog
381                                                 .openError(
382                                                         getContainer()
383                                                                 .getShell(),
384                                                         IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
385                                                         NLS
386                                                                 .bind(
387                                                                         IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
388                                                                         e
389                                                                                 .getCause()
390                                                                                 .getMessage()));
391                                     }
392                                 }
393                             });
394                 }
395             }
396         };
397         try {
398             getContainer().run(true, true, op);
399         } catch (InterruptedException JavaDoc e) {
400             return null;
401         } catch (InvocationTargetException JavaDoc e) {
402             // Execution Exceptions are handled above but we may still get
403
// unexpected runtime errors.
404
IDEWorkbenchPlugin.log(getClass(),
405                     "createNewFile()", e.getTargetException()); //$NON-NLS-1$
406
MessageDialog
407                     .openError(
408                             getContainer().getShell(),
409                             IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
410                             NLS
411                                     .bind(
412                                             IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
413                                             e.getTargetException().getMessage()));
414
415             return null;
416         }
417
418         newFile = newFileHandle;
419
420         return newFile;
421     }
422
423     /**
424      * Returns the scheduling rule to use when creating the resource at the
425      * given container path. The rule should be the creation rule for the
426      * top-most non-existing parent.
427      *
428      * @param resource
429      * The resource being created
430      * @return The scheduling rule for creating the given resource
431      * @since 3.1
432      * @deprecated As of 3.3, scheduling rules are provided by the undoable
433      * operation that this page creates and executes.
434      */

435     protected ISchedulingRule createRule(IResource resource) {
436         IResource parent = resource.getParent();
437         while (parent != null) {
438             if (parent.exists()) {
439                 return resource.getWorkspace().getRuleFactory().createRule(
440                         resource);
441             }
442             resource = parent;
443             parent = parent.getParent();
444         }
445         return resource.getWorkspace().getRoot();
446     }
447
448     /**
449      * Returns the current full path of the containing resource as entered or
450      * selected by the user, or its anticipated initial value.
451      *
452      * @return the container's full path, anticipated initial value, or
453      * <code>null</code> if no path is known
454      */

455     public IPath getContainerFullPath() {
456         return resourceGroup.getContainerFullPath();
457     }
458
459     /**
460      * Returns the current file name as entered by the user, or its anticipated
461      * initial value.
462      * <br><br>
463      * The current file name will include the file extension if
464      * the preconditions are met.
465      * @see WizardNewFileCreationPage#setFileExtension(String)
466      *
467      * @return the file name, its anticipated initial value, or
468      * <code>null</code> if no file name is known
469      */

470     public String JavaDoc getFileName() {
471         if (resourceGroup == null) {
472             return initialFileName;
473         }
474
475         return resourceGroup.getResource();
476     }
477     
478     /**
479      * Returns the file extension to use when creating the new file.
480      *
481      * @return the file extension or <code>null</code>.
482      * @see WizardNewFileCreationPage#setFileExtension(String)
483      * @since 3.3
484      */

485     public String JavaDoc getFileExtension() {
486         if (resourceGroup == null) {
487             return initialFileExtension;
488         }
489         return resourceGroup.getResourceExtension();
490     }
491
492     /**
493      * Returns a stream containing the initial contents to be given to new file
494      * resource instances. <b>Subclasses</b> may wish to override. This default
495      * implementation provides no initial contents.
496      *
497      * @return initial contents to be given to new file resource instances
498      */

499     protected InputStream JavaDoc getInitialContents() {
500         return null;
501     }
502
503     /**
504      * Returns the label to display in the file name specification visual
505      * component group.
506      * <p>
507      * Subclasses may reimplement.
508      * </p>
509      *
510      * @return the label to display in the file name specification visual
511      * component group
512      */

513     protected String JavaDoc getNewFileLabel() {
514         return IDEWorkbenchMessages.WizardNewFileCreationPage_fileLabel;
515     }
516
517     /**
518      * Shows/hides the advanced option widgets.
519      */

520     protected void handleAdvancedButtonSelect() {
521         Shell shell = getShell();
522         Point shellSize = shell.getSize();
523         Composite composite = (Composite) getControl();
524
525         if (linkedResourceComposite != null) {
526             linkedResourceComposite.dispose();
527             linkedResourceComposite = null;
528             composite.layout();
529             shell.setSize(shellSize.x, shellSize.y - linkedResourceGroupHeight);
530             advancedButton.setText(IDEWorkbenchMessages.showAdvanced);
531         } else {
532             linkedResourceComposite = linkedResourceGroup
533                     .createContents(linkedResourceParent);
534             if (linkedResourceGroupHeight == -1) {
535                 Point groupSize = linkedResourceComposite.computeSize(
536                         SWT.DEFAULT, SWT.DEFAULT, true);
537                 linkedResourceGroupHeight = groupSize.y;
538             }
539             shell.setSize(shellSize.x, shellSize.y + linkedResourceGroupHeight);
540             composite.layout();
541             advancedButton.setText(IDEWorkbenchMessages.hideAdvanced);
542         }
543     }
544
545     /**
546      * The <code>WizardNewFileCreationPage</code> implementation of this
547      * <code>Listener</code> method handles all events and enablements for
548      * controls on this page. Subclasses may extend.
549      */

550     public void handleEvent(Event event) {
551         setPageComplete(validatePage());
552     }
553
554     /**
555      * Sets the initial contents of the container name entry field, based upon
556      * either a previously-specified initial value or the ability to determine
557      * such a value.
558      */

559     protected void initialPopulateContainerNameField() {
560         if (initialContainerFullPath != null) {
561             resourceGroup.setContainerFullPath(initialContainerFullPath);
562         } else {
563             Iterator JavaDoc it = currentSelection.iterator();
564             if (it.hasNext()) {
565                 Object JavaDoc object = it.next();
566                 IResource selectedResource = null;
567                 if (object instanceof IResource) {
568                     selectedResource = (IResource) object;
569                 } else if (object instanceof IAdaptable) {
570                     selectedResource = (IResource) ((IAdaptable) object)
571                             .getAdapter(IResource.class);
572                 }
573                 if (selectedResource != null) {
574                     if (selectedResource.getType() == IResource.FILE) {
575                         selectedResource = selectedResource.getParent();
576                     }
577                     if (selectedResource.isAccessible()) {
578                         resourceGroup.setContainerFullPath(selectedResource
579                                 .getFullPath());
580                     }
581                 }
582             }
583         }
584     }
585
586     /**
587      * Sets the value of this page's container name field, or stores it for
588      * future use if this page's controls do not exist yet.
589      *
590      * @param path
591      * the full path to the container
592      */

593     public void setContainerFullPath(IPath path) {
594         if (resourceGroup == null) {
595             initialContainerFullPath = path;
596         } else {
597             resourceGroup.setContainerFullPath(path);
598         }
599     }
600
601     /**
602      * Sets the value of this page's file name field, or stores it for future
603      * use if this page's controls do not exist yet.
604      *
605      * @param value
606      * new file name
607      */

608     public void setFileName(String JavaDoc value) {
609         if (resourceGroup == null) {
610             initialFileName = value;
611         } else {
612             resourceGroup.setResource(value);
613         }
614     }
615
616     /**
617      * Set the only file extension allowed for this page's file name field.
618      * If this page's controls do not exist yet, store it for future use.
619      * <br><br>
620      * If a file extension is specified, then it will always be
621      * appended with a '.' to the text from the file name field for
622      * validation when the following conditions are met:
623      * <br><br>
624      * (1) File extension length is greater than 0
625      * <br>
626      * (2) File name field text length is greater than 0
627      * <br>
628      * (3) File name field text does not already end with a '.' and the file
629      * extension specified (case sensitive)
630      * <br><br>
631      * The file extension will not be reflected in the actual file
632      * name field until the file name field loses focus.
633      *
634      * @param value
635      * The file extension without the '.' prefix
636      * (e.g. 'java', 'xml')
637      * @since 3.3
638      */

639     public void setFileExtension(String JavaDoc value) {
640         if (resourceGroup == null) {
641             initialFileExtension = value;
642         } else {
643             resourceGroup.setResourceExtension(value);
644         }
645     }
646     
647     /**
648      * Checks whether the linked resource target is valid. Sets the error
649      * message accordingly and returns the status.
650      *
651      * @return IStatus validation result from the CreateLinkedResourceGroup
652      */

653     protected IStatus validateLinkedResource() {
654         IPath containerPath = resourceGroup.getContainerFullPath();
655         IPath newFilePath = containerPath.append(resourceGroup.getResource());
656         IFile newFileHandle = createFileHandle(newFilePath);
657         IStatus status = linkedResourceGroup
658                 .validateLinkLocation(newFileHandle);
659
660         if (status.getSeverity() == IStatus.ERROR) {
661             if (firstLinkCheck) {
662                 setMessage(status.getMessage());
663             } else {
664                 setErrorMessage(status.getMessage());
665             }
666         } else if (status.getSeverity() == IStatus.WARNING) {
667             setMessage(status.getMessage(), WARNING);
668             setErrorMessage(null);
669         }
670         return status;
671     }
672
673     /**
674      * Returns whether this page's controls currently all contain valid values.
675      *
676      * @return <code>true</code> if all controls are valid, and
677      * <code>false</code> if at least one is invalid
678      */

679     protected boolean validatePage() {
680         boolean valid = true;
681
682         if (!resourceGroup.areAllValuesValid()) {
683             // if blank name then fail silently
684
if (resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_RESOURCE_EMPTY
685                     || resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_CONTAINER_EMPTY) {
686                 setMessage(resourceGroup.getProblemMessage());
687                 setErrorMessage(null);
688             } else {
689                 setErrorMessage(resourceGroup.getProblemMessage());
690             }
691             valid = false;
692         }
693
694         String JavaDoc resourceName = resourceGroup.getResource();
695         IWorkspace workspace = ResourcesPlugin.getWorkspace();
696         IStatus result = workspace.validateName(resourceName, IResource.FILE);
697         if (!result.isOK()) {
698             setErrorMessage(result.getMessage());
699             return false;
700         }
701
702         IStatus linkedResourceStatus = null;
703         if (valid) {
704             linkedResourceStatus = validateLinkedResource();
705             if (linkedResourceStatus.getSeverity() == IStatus.ERROR) {
706                 valid = false;
707             }
708         }
709         // validateLinkedResource sets messages itself
710
if (valid
711                 && (linkedResourceStatus == null || linkedResourceStatus.isOK())) {
712             setMessage(null);
713             setErrorMessage(null);
714         }
715         return valid;
716     }
717
718     /*
719      * @see DialogPage.setVisible(boolean)
720      */

721     public void setVisible(boolean visible) {
722         super.setVisible(visible);
723         if (visible) {
724             resourceGroup.setFocus();
725         }
726     }
727 }
728
Popular Tags