KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > wizards > datatransfer > WizardProjectsImportPage


1 /*******************************************************************************
2  * Copyright (c) 2004, 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  * Red Hat, Inc - extensive changes to allow importing of Archive Files
11  * Philippe Ombredanne (pombredanne@nexb.com)
12  * - Bug 101180 [Import/Export] Import Existing Project into Workspace default widget is back button , should be text field
13  * Martin Oberhuber (martin.oberhuber@windriver.com)
14  * - Bug 187318[Wizards] "Import Existing Project" loops forever with cyclic symbolic links
15  *******************************************************************************/

16 package org.eclipse.ui.internal.wizards.datatransfer;
17
18 import java.io.File JavaDoc;
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
21 import java.lang.reflect.InvocationTargetException JavaDoc;
22 import java.net.URI JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collection JavaDoc;
25 import java.util.HashSet JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Set JavaDoc;
29 import java.util.zip.ZipException JavaDoc;
30 import java.util.zip.ZipFile JavaDoc;
31
32 import org.eclipse.core.resources.IProject;
33 import org.eclipse.core.resources.IProjectDescription;
34 import org.eclipse.core.resources.IResource;
35 import org.eclipse.core.resources.IWorkspace;
36 import org.eclipse.core.resources.ResourcesPlugin;
37 import org.eclipse.core.runtime.CoreException;
38 import org.eclipse.core.runtime.IPath;
39 import org.eclipse.core.runtime.IProgressMonitor;
40 import org.eclipse.core.runtime.IStatus;
41 import org.eclipse.core.runtime.OperationCanceledException;
42 import org.eclipse.core.runtime.Path;
43 import org.eclipse.core.runtime.Platform;
44 import org.eclipse.core.runtime.Status;
45 import org.eclipse.core.runtime.SubProgressMonitor;
46 import org.eclipse.jface.dialogs.Dialog;
47 import org.eclipse.jface.dialogs.ErrorDialog;
48 import org.eclipse.jface.dialogs.IDialogConstants;
49 import org.eclipse.jface.dialogs.IDialogSettings;
50 import org.eclipse.jface.dialogs.MessageDialog;
51 import org.eclipse.jface.operation.IRunnableWithProgress;
52 import org.eclipse.jface.viewers.CheckStateChangedEvent;
53 import org.eclipse.jface.viewers.CheckboxTreeViewer;
54 import org.eclipse.jface.viewers.ICheckStateListener;
55 import org.eclipse.jface.viewers.ITreeContentProvider;
56 import org.eclipse.jface.viewers.LabelProvider;
57 import org.eclipse.jface.viewers.Viewer;
58 import org.eclipse.jface.viewers.ViewerComparator;
59 import org.eclipse.jface.wizard.WizardPage;
60 import org.eclipse.osgi.util.NLS;
61 import org.eclipse.swt.SWT;
62 import org.eclipse.swt.events.FocusAdapter;
63 import org.eclipse.swt.events.SelectionAdapter;
64 import org.eclipse.swt.events.SelectionEvent;
65 import org.eclipse.swt.events.TraverseEvent;
66 import org.eclipse.swt.events.TraverseListener;
67 import org.eclipse.swt.layout.GridData;
68 import org.eclipse.swt.layout.GridLayout;
69 import org.eclipse.swt.widgets.Button;
70 import org.eclipse.swt.widgets.Composite;
71 import org.eclipse.swt.widgets.DirectoryDialog;
72 import org.eclipse.swt.widgets.FileDialog;
73 import org.eclipse.swt.widgets.Label;
74 import org.eclipse.swt.widgets.Text;
75 import org.eclipse.ui.actions.WorkspaceModifyOperation;
76 import org.eclipse.ui.dialogs.IOverwriteQuery;
77 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
78 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
79 import org.eclipse.ui.internal.ide.StatusUtil;
80 import org.eclipse.ui.statushandlers.StatusManager;
81 import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
82 import org.eclipse.ui.wizards.datatransfer.ImportOperation;
83
84 /**
85  * The WizardProjectsImportPage is the page that allows the user to import
86  * projects from a particular location.
87  */

88 public class WizardProjectsImportPage extends WizardPage implements
89         IOverwriteQuery {
90
91     /**
92      * The name of the folder containing metadata information for the workspace.
93      */

94     public static final String JavaDoc METADATA_FOLDER = ".metadata"; //$NON-NLS-1$
95

96     /**
97      * Class declared public only for test suite.
98      *
99      */

100     public class ProjectRecord {
101         File JavaDoc projectSystemFile;
102
103         Object JavaDoc projectArchiveFile;
104
105         String JavaDoc projectName;
106
107         Object JavaDoc parent;
108
109         int level;
110
111         IProjectDescription description;
112
113         ILeveledImportStructureProvider provider;
114
115         /**
116          * Create a record for a project based on the info in the file.
117          *
118          * @param file
119          */

120         ProjectRecord(File JavaDoc file) {
121             projectSystemFile = file;
122             setProjectName();
123         }
124
125         /**
126          * @param file
127          * The Object representing the .project file
128          * @param parent
129          * The parent folder of the .project file
130          * @param level
131          * The number of levels deep in the provider the file is
132          * @param entryProvider
133          * The provider for the archive file that contains it
134          */

135         ProjectRecord(Object JavaDoc file, Object JavaDoc parent, int level,
136                 ILeveledImportStructureProvider entryProvider) {
137             this.projectArchiveFile = file;
138             this.parent = parent;
139             this.level = level;
140             this.provider = entryProvider;
141             setProjectName();
142         }
143
144         /**
145          * Set the name of the project based on the projectFile.
146          */

147         private void setProjectName() {
148             IProjectDescription newDescription = null;
149             try {
150                 if (projectArchiveFile != null) {
151                     InputStream JavaDoc stream = provider
152                             .getContents(projectArchiveFile);
153                     if (stream != null) {
154                         newDescription = IDEWorkbenchPlugin
155                                 .getPluginWorkspace().loadProjectDescription(
156                                         stream);
157                         stream.close();
158                     }
159                 } else {
160                     IPath path = new Path(projectSystemFile.getPath());
161                     // if the file is in the default location, use the directory
162
// name as the project name
163
if (isDefaultLocation(path)) {
164                         projectName = path.segment(path.segmentCount() - 2);
165                         newDescription = IDEWorkbenchPlugin
166                                 .getPluginWorkspace().newProjectDescription(
167                                         projectName);
168                     } else {
169                         newDescription = IDEWorkbenchPlugin
170                                 .getPluginWorkspace().loadProjectDescription(
171                                         path);
172                     }
173                 }
174             } catch (CoreException e) {
175                 // no good couldn't get the name
176
} catch (IOException JavaDoc e) {
177                 // no good couldn't get the name
178
}
179
180             if (newDescription == null) {
181                 this.description = null;
182                 projectName = ""; //$NON-NLS-1$
183
} else {
184                 this.description = newDescription;
185                 projectName = this.description.getName();
186             }
187         }
188
189         /**
190          * Returns whether the given project description file path is in the
191          * default location for a project
192          *
193          * @param path
194          * The path to examine
195          * @return Whether the given path is the default location for a project
196          */

197         private boolean isDefaultLocation(IPath path) {
198             // The project description file must at least be within the project,
199
// which is within the workspace location
200
if (path.segmentCount() < 2)
201                 return false;
202             return path.removeLastSegments(2).toFile().equals(
203                     Platform.getLocation().toFile());
204         }
205
206         /**
207          * Get the name of the project
208          *
209          * @return String
210          */

211         public String JavaDoc getProjectName() {
212             return projectName;
213         }
214     }
215
216     // dialog store id constants
217
private final static String JavaDoc STORE_COPY_PROJECT_ID = "WizardProjectsImportPage.STORE_COPY_PROJECT_ID"; //$NON-NLS-1$
218

219     private final static String JavaDoc STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$
220

221     private Text directoryPathField;
222
223     private CheckboxTreeViewer projectsList;
224
225     private Button copyCheckbox;
226
227     private boolean copyFiles = false;
228
229     private ProjectRecord[] selectedProjects = new ProjectRecord[0];
230
231     // Keep track of the directory that we browsed to last time
232
// the wizard was invoked.
233
private static String JavaDoc previouslyBrowsedDirectory = ""; //$NON-NLS-1$
234

235     // Keep track of the archive that we browsed to last time
236
// the wizard was invoked.
237
private static String JavaDoc previouslyBrowsedArchive = ""; //$NON-NLS-1$
238

239     private Button projectFromDirectoryRadio;
240
241     private Button projectFromArchiveRadio;
242
243     private Text archivePathField;
244
245     private Button browseDirectoriesButton;
246
247     private Button browseArchivesButton;
248
249     private IProject[] wsProjects;
250
251     // constant from WizardArchiveFileResourceImportPage1
252
private static final String JavaDoc[] FILE_IMPORT_MASK = {
253             "*.jar;*.zip;*.tar;*.tar.gz;*.tgz", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
254

255     // The last selected path to mimize searches
256
private String JavaDoc lastPath;
257
258     /**
259      * Creates a new project creation wizard page.
260      *
261      */

262     public WizardProjectsImportPage() {
263         this("wizardExternalProjectsPage"); //$NON-NLS-1$
264
}
265
266     /**
267      * Create a new instance of the receiver.
268      *
269      * @param pageName
270      */

271     public WizardProjectsImportPage(String JavaDoc pageName) {
272         super(pageName);
273         setPageComplete(false);
274         setTitle(DataTransferMessages.WizardProjectsImportPage_ImportProjectsTitle);
275         setDescription(DataTransferMessages.WizardProjectsImportPage_ImportProjectsDescription);
276     }
277
278     /*
279      * (non-Javadoc)
280      *
281      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
282      */

283     public void createControl(Composite parent) {
284
285         initializeDialogUnits(parent);
286
287         Composite workArea = new Composite(parent, SWT.NONE);
288         setControl(workArea);
289
290         workArea.setLayout(new GridLayout());
291         workArea.setLayoutData(new GridData(GridData.FILL_BOTH
292                 | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
293
294         createProjectsRoot(workArea);
295         createProjectsList(workArea);
296         createOptionsArea(workArea);
297         restoreWidgetValues();
298         Dialog.applyDialogFont(workArea);
299
300     }
301
302     /**
303      * Create the area with the extra options.
304      *
305      * @param workArea
306      */

307     private void createOptionsArea(Composite workArea) {
308         Composite optionsGroup = new Composite(workArea, SWT.NONE);
309         optionsGroup.setLayout(new GridLayout());
310         optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
311
312         copyCheckbox = new Button(optionsGroup, SWT.CHECK);
313         copyCheckbox
314                 .setText(DataTransferMessages.WizardProjectsImportPage_CopyProjectsIntoWorkspace);
315         copyCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
316         copyCheckbox.addSelectionListener(new SelectionAdapter() {
317             public void widgetSelected(SelectionEvent e) {
318                 copyFiles = copyCheckbox.getSelection();
319             }
320         });
321     }
322
323     /**
324      * Create the checkbox list for the found projects.
325      *
326      * @param workArea
327      */

328     private void createProjectsList(Composite workArea) {
329
330         Label title = new Label(workArea, SWT.NONE);
331         title
332                 .setText(DataTransferMessages.WizardProjectsImportPage_ProjectsListTitle);
333
334         Composite listComposite = new Composite(workArea, SWT.NONE);
335         GridLayout layout = new GridLayout();
336         layout.numColumns = 2;
337         layout.marginWidth = 0;
338         layout.makeColumnsEqualWidth = false;
339         listComposite.setLayout(layout);
340
341         listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
342                 | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
343
344         projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER);
345         GridData listData = new GridData(GridData.GRAB_HORIZONTAL
346                 | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
347         projectsList.getControl().setLayoutData(listData);
348
349         projectsList.setContentProvider(new ITreeContentProvider() {
350
351             /*
352              * (non-Javadoc)
353              *
354              * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
355              */

356             public Object JavaDoc[] getChildren(Object JavaDoc parentElement) {
357                 return null;
358             }
359
360             /*
361              * (non-Javadoc)
362              *
363              * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
364              */

365             public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
366                 return getValidProjects();
367             }
368
369             /*
370              * (non-Javadoc)
371              *
372              * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
373              */

374             public boolean hasChildren(Object JavaDoc element) {
375                 return false;
376             }
377
378             /*
379              * (non-Javadoc)
380              *
381              * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
382              */

383             public Object JavaDoc getParent(Object JavaDoc element) {
384                 return null;
385             }
386
387             /*
388              * (non-Javadoc)
389              *
390              * @see org.eclipse.jface.viewers.IContentProvider#dispose()
391              */

392             public void dispose() {
393
394             }
395
396             /*
397              * (non-Javadoc)
398              *
399              * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
400              * java.lang.Object, java.lang.Object)
401              */

402             public void inputChanged(Viewer viewer, Object JavaDoc oldInput,
403                     Object JavaDoc newInput) {
404             }
405
406         });
407
408         projectsList.setLabelProvider(new LabelProvider() {
409             /*
410              * (non-Javadoc)
411              *
412              * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
413              */

414             public String JavaDoc getText(Object JavaDoc element) {
415                 return ((ProjectRecord) element).getProjectName();
416             }
417         });
418
419         projectsList.addCheckStateListener(new ICheckStateListener() {
420             /*
421              * (non-Javadoc)
422              *
423              * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
424              */

425             public void checkStateChanged(CheckStateChangedEvent event) {
426                 setPageComplete(projectsList.getCheckedElements().length > 0);
427             }
428         });
429
430         projectsList.setInput(this);
431         projectsList.setComparator(new ViewerComparator());
432         createSelectionButtons(listComposite);
433     }
434
435     /**
436      * Create the selection buttons in the listComposite.
437      *
438      * @param listComposite
439      */

440     private void createSelectionButtons(Composite listComposite) {
441         Composite buttonsComposite = new Composite(listComposite, SWT.NONE);
442         GridLayout layout = new GridLayout();
443         layout.marginWidth = 0;
444         layout.marginHeight = 0;
445         buttonsComposite.setLayout(layout);
446
447         buttonsComposite.setLayoutData(new GridData(
448                 GridData.VERTICAL_ALIGN_BEGINNING));
449
450         Button selectAll = new Button(buttonsComposite, SWT.PUSH);
451         selectAll.setText(DataTransferMessages.DataTransfer_selectAll);
452         selectAll.addSelectionListener(new SelectionAdapter() {
453             public void widgetSelected(SelectionEvent e) {
454                 projectsList.setCheckedElements(selectedProjects);
455                 setPageComplete(projectsList.getCheckedElements().length > 0);
456             }
457         });
458         Dialog.applyDialogFont(selectAll);
459         setButtonLayoutData(selectAll);
460
461         Button deselectAll = new Button(buttonsComposite, SWT.PUSH);
462         deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll);
463         deselectAll.addSelectionListener(new SelectionAdapter() {
464             /*
465              * (non-Javadoc)
466              *
467              * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
468              */

469             public void widgetSelected(SelectionEvent e) {
470
471                 projectsList.setCheckedElements(new Object JavaDoc[0]);
472                 setPageComplete(false);
473             }
474         });
475         Dialog.applyDialogFont(deselectAll);
476         setButtonLayoutData(deselectAll);
477
478         Button refresh = new Button(buttonsComposite, SWT.PUSH);
479         refresh.setText(DataTransferMessages.DataTransfer_refresh);
480         refresh.addSelectionListener(new SelectionAdapter() {
481             /*
482              * (non-Javadoc)
483              *
484              * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
485              */

486             public void widgetSelected(SelectionEvent e) {
487                 if (projectFromDirectoryRadio.getSelection()) {
488                     updateProjectsList(directoryPathField.getText().trim());
489                 } else {
490                     updateProjectsList(archivePathField.getText().trim());
491                 }
492             }
493         });
494         Dialog.applyDialogFont(refresh);
495         setButtonLayoutData(refresh);
496     }
497
498     /**
499      * Create the area where you select the root directory for the projects.
500      *
501      * @param workArea
502      * Composite
503      */

504     private void createProjectsRoot(Composite workArea) {
505
506         // project specification group
507
Composite projectGroup = new Composite(workArea, SWT.NONE);
508         GridLayout layout = new GridLayout();
509         layout.numColumns = 3;
510         layout.makeColumnsEqualWidth = false;
511         layout.marginWidth = 0;
512         projectGroup.setLayout(layout);
513         projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
514
515         // new project from directory radio button
516
projectFromDirectoryRadio = new Button(projectGroup, SWT.RADIO);
517         projectFromDirectoryRadio
518                 .setText(DataTransferMessages.WizardProjectsImportPage_RootSelectTitle);
519
520         // project location entry field
521
this.directoryPathField = new Text(projectGroup, SWT.BORDER);
522
523         this.directoryPathField.setLayoutData(new GridData(
524                 GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
525
526         // browse button
527
browseDirectoriesButton = new Button(projectGroup, SWT.PUSH);
528         browseDirectoriesButton
529                 .setText(DataTransferMessages.DataTransfer_browse);
530         setButtonLayoutData(browseDirectoriesButton);
531
532         // new project from archive radio button
533
projectFromArchiveRadio = new Button(projectGroup, SWT.RADIO);
534         projectFromArchiveRadio
535                 .setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle);
536
537         // project location entry field
538
archivePathField = new Text(projectGroup, SWT.BORDER);
539
540         archivePathField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
541                 | GridData.GRAB_HORIZONTAL));
542         // browse button
543
browseArchivesButton = new Button(projectGroup, SWT.PUSH);
544         browseArchivesButton.setText(DataTransferMessages.DataTransfer_browse);
545         setButtonLayoutData(browseArchivesButton);
546
547         projectFromDirectoryRadio.setSelection(true);
548         archivePathField.setEnabled(false);
549         browseArchivesButton.setEnabled(false);
550
551         browseDirectoriesButton.addSelectionListener(new SelectionAdapter() {
552             /*
553              * (non-Javadoc)
554              *
555              * @see org.eclipse.swt.events.SelectionAdapter#widgetS
556              * elected(org.eclipse.swt.events.SelectionEvent)
557              */

558             public void widgetSelected(SelectionEvent e) {
559                 handleLocationDirectoryButtonPressed();
560             }
561
562         });
563
564         browseArchivesButton.addSelectionListener(new SelectionAdapter() {
565             /*
566              * (non-Javadoc)
567              *
568              * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
569              */

570             public void widgetSelected(SelectionEvent e) {
571                 handleLocationArchiveButtonPressed();
572             }
573
574         });
575
576         directoryPathField.addTraverseListener(new TraverseListener() {
577
578             /*
579              * (non-Javadoc)
580              *
581              * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
582              */

583             public void keyTraversed(TraverseEvent e) {
584                 if (e.detail == SWT.TRAVERSE_RETURN) {
585                     e.doit = false;
586                     updateProjectsList(directoryPathField.getText().trim());
587                 }
588             }
589
590         });
591
592         directoryPathField.addFocusListener(new FocusAdapter() {
593
594             /*
595              * (non-Javadoc)
596              *
597              * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
598              */

599             public void focusLost(org.eclipse.swt.events.FocusEvent e) {
600                 updateProjectsList(directoryPathField.getText().trim());
601             }
602
603         });
604
605         archivePathField.addTraverseListener(new TraverseListener() {
606
607             /*
608              * (non-Javadoc)
609              *
610              * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
611              */

612             public void keyTraversed(TraverseEvent e) {
613                 if (e.detail == SWT.TRAVERSE_RETURN) {
614                     e.doit = false;
615                     updateProjectsList(archivePathField.getText().trim());
616                 }
617             }
618
619         });
620
621         archivePathField.addFocusListener(new FocusAdapter() {
622             /*
623              * (non-Javadoc)
624              *
625              * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
626              */

627             public void focusLost(org.eclipse.swt.events.FocusEvent e) {
628                 updateProjectsList(archivePathField.getText().trim());
629             }
630         });
631
632         projectFromDirectoryRadio.addSelectionListener(new SelectionAdapter() {
633             /*
634              * (non-Javadoc)
635              *
636              * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
637              */

638             public void widgetSelected(SelectionEvent e) {
639                 directoryRadioSelected();
640             }
641         });
642
643         projectFromArchiveRadio.addSelectionListener(new SelectionAdapter() {
644             /*
645              * (non-Javadoc)
646              *
647              * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
648              */

649             public void widgetSelected(SelectionEvent e) {
650                 archiveRadioSelected();
651             }
652         });
653     }
654
655     private void archiveRadioSelected() {
656         if (projectFromArchiveRadio.getSelection()) {
657             directoryPathField.setEnabled(false);
658             browseDirectoriesButton.setEnabled(false);
659             archivePathField.setEnabled(true);
660             browseArchivesButton.setEnabled(true);
661             updateProjectsList(archivePathField.getText());
662             archivePathField.setFocus();
663             copyCheckbox.setSelection(true);
664             copyCheckbox.setEnabled(false);
665         }
666     }
667
668     private void directoryRadioSelected() {
669         if (projectFromDirectoryRadio.getSelection()) {
670             directoryPathField.setEnabled(true);
671             browseDirectoriesButton.setEnabled(true);
672             archivePathField.setEnabled(false);
673             browseArchivesButton.setEnabled(false);
674             updateProjectsList(directoryPathField.getText());
675             directoryPathField.setFocus();
676             copyCheckbox.setEnabled(true);
677             copyCheckbox.setSelection(copyFiles);
678         }
679     }
680
681     /*
682      * (non-Javadoc) Method declared on IDialogPage. Set the focus on path
683      * fields when page becomes visible.
684      */

685     public void setVisible(boolean visible) {
686         super.setVisible(visible);
687         if (visible && this.projectFromDirectoryRadio.getSelection()) {
688             this.directoryPathField.setFocus();
689         }
690         if (visible && this.projectFromArchiveRadio.getSelection()) {
691             this.archivePathField.setFocus();
692         }
693     }
694
695     /**
696      * Update the list of projects based on path. Method declared public only
697      * for test suite.
698      *
699      * @param path
700      */

701     public void updateProjectsList(final String JavaDoc path) {
702
703         if (path.equals(lastPath)) {
704             return;
705         }
706
707         lastPath = path;
708
709         // on an empty path empty selectedProjects
710
if (path == null || path.length() == 0) {
711             selectedProjects = new ProjectRecord[0];
712             projectsList.refresh(true);
713             projectsList.setCheckedElements(selectedProjects);
714             setPageComplete(projectsList.getCheckedElements().length > 0);
715             return;
716         }
717         // We can't access the radio button from the inner class so get the
718
// status beforehand
719
final boolean dirSelected = this.projectFromDirectoryRadio
720                 .getSelection();
721         try {
722             getContainer().run(true, true, new IRunnableWithProgress() {
723
724                 /*
725                  * (non-Javadoc)
726                  *
727                  * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
728                  */

729                 public void run(IProgressMonitor monitor) {
730
731                     monitor
732                             .beginTask(
733                                     DataTransferMessages.WizardProjectsImportPage_SearchingMessage,
734                                     100);
735                     File JavaDoc directory = new File JavaDoc(path);
736                     selectedProjects = new ProjectRecord[0];
737                     Collection JavaDoc files = new ArrayList JavaDoc();
738                     monitor.worked(10);
739                     if (!dirSelected
740                             && ArchiveFileManipulations.isTarFile(path)) {
741                         TarFile sourceTarFile = getSpecifiedTarSourceFile(path);
742                         if (sourceTarFile == null) {
743                             return;
744                         }
745
746                         TarLeveledStructureProvider provider = ArchiveFileManipulations
747                                 .getTarStructureProvider(sourceTarFile,
748                                         getContainer().getShell());
749                         Object JavaDoc child = provider.getRoot();
750
751                         if (!collectProjectFilesFromProvider(files, provider,
752                                 child, 0, monitor)) {
753                             return;
754                         }
755                         Iterator JavaDoc filesIterator = files.iterator();
756                         selectedProjects = new ProjectRecord[files.size()];
757                         int index = 0;
758                         monitor.worked(50);
759                         monitor
760                                 .subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage);
761                         while (filesIterator.hasNext()) {
762                             selectedProjects[index++] = (ProjectRecord) filesIterator
763                                     .next();
764                         }
765                     } else if (!dirSelected
766                             && ArchiveFileManipulations.isZipFile(path)) {
767                         ZipFile JavaDoc sourceFile = getSpecifiedZipSourceFile(path);
768                         if (sourceFile == null) {
769                             return;
770                         }
771                         ZipLeveledStructureProvider provider = ArchiveFileManipulations
772                                 .getZipStructureProvider(sourceFile,
773                                         getContainer().getShell());
774                         Object JavaDoc child = provider.getRoot();
775
776                         if (!collectProjectFilesFromProvider(files, provider,
777                                 child, 0, monitor)) {
778                             return;
779                         }
780                         Iterator JavaDoc filesIterator = files.iterator();
781                         selectedProjects = new ProjectRecord[files.size()];
782                         int index = 0;
783                         monitor.worked(50);
784                         monitor
785                                 .subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage);
786                         while (filesIterator.hasNext()) {
787                             selectedProjects[index++] = (ProjectRecord) filesIterator
788                                     .next();
789                         }
790                     }
791
792                     else if (dirSelected && directory.isDirectory()) {
793
794                         if (!collectProjectFilesFromDirectory(files, directory,
795                                 null, monitor)) {
796                             return;
797                         }
798                         Iterator JavaDoc filesIterator = files.iterator();
799                         selectedProjects = new ProjectRecord[files.size()];
800                         int index = 0;
801                         monitor.worked(50);
802                         monitor
803                                 .subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage);
804                         while (filesIterator.hasNext()) {
805                             File JavaDoc file = (File JavaDoc) filesIterator.next();
806                             selectedProjects[index] = new ProjectRecord(file);
807                             index++;
808                         }
809                     } else {
810                         monitor.worked(60);
811                     }
812                     monitor.done();
813                 }
814
815             });
816         } catch (InvocationTargetException JavaDoc e) {
817             IDEWorkbenchPlugin.log(e.getMessage(), e);
818         } catch (InterruptedException JavaDoc e) {
819             // Nothing to do if the user interrupts.
820
}
821
822         projectsList.refresh(true);
823         projectsList.setCheckedElements(getValidProjects());
824         setPageComplete(projectsList.getCheckedElements().length > 0);
825     }
826
827     /**
828      * Answer a handle to the zip file currently specified as being the source.
829      * Return null if this file does not exist or is not of valid format.
830      */

831     private ZipFile JavaDoc getSpecifiedZipSourceFile(String JavaDoc fileName) {
832         if (fileName.length() == 0) {
833             return null;
834         }
835
836         try {
837             return new ZipFile JavaDoc(fileName);
838         } catch (ZipException JavaDoc e) {
839             displayErrorDialog(DataTransferMessages.ZipImport_badFormat);
840         } catch (IOException JavaDoc e) {
841             displayErrorDialog(DataTransferMessages.ZipImport_couldNotRead);
842         }
843
844         archivePathField.setFocus();
845         return null;
846     }
847
848     /**
849      * Answer a handle to the zip file currently specified as being the source.
850      * Return null if this file does not exist or is not of valid format.
851      */

852     private TarFile getSpecifiedTarSourceFile(String JavaDoc fileName) {
853         if (fileName.length() == 0) {
854             return null;
855         }
856
857         try {
858             return new TarFile(fileName);
859         } catch (TarException e) {
860             displayErrorDialog(DataTransferMessages.TarImport_badFormat);
861         } catch (IOException JavaDoc e) {
862             displayErrorDialog(DataTransferMessages.ZipImport_couldNotRead);
863         }
864
865         archivePathField.setFocus();
866         return null;
867     }
868
869     /**
870      * Display an error dialog with the specified message.
871      *
872      * @param message
873      * the error message
874      */

875     protected void displayErrorDialog(String JavaDoc message) {
876         MessageDialog.openError(getContainer().getShell(),
877                 getErrorDialogTitle(), message);
878     }
879
880     /**
881      * Get the title for an error dialog. Subclasses should override.
882      */

883     protected String JavaDoc getErrorDialogTitle() {
884         return IDEWorkbenchMessages.WizardExportPage_internalErrorTitle;
885     }
886
887     /**
888      * Collect the list of .project files that are under directory into files.
889      *
890      * @param files
891      * @param directory
892      * @param directoriesVisited
893      * Set of canonical paths of directories, used as recursion guard
894      * @param monitor
895      * The monitor to report to
896      * @return boolean <code>true</code> if the operation was completed.
897      */

898     private boolean collectProjectFilesFromDirectory(Collection JavaDoc files,
899             File JavaDoc directory, Set JavaDoc directoriesVisited, IProgressMonitor monitor) {
900
901         if (monitor.isCanceled()) {
902             return false;
903         }
904         monitor.subTask(NLS.bind(
905                 DataTransferMessages.WizardProjectsImportPage_CheckingMessage,
906                 directory.getPath()));
907         File JavaDoc[] contents = directory.listFiles();
908         if (contents == null)
909             return false;
910
911         // Initialize recursion guard for recursive symbolic links
912
if (directoriesVisited == null) {
913             directoriesVisited = new HashSet JavaDoc();
914             try {
915                 directoriesVisited.add(directory.getCanonicalPath());
916             } catch (IOException JavaDoc exception) {
917                 StatusManager.getManager().handle(
918                         StatusUtil.newStatus(IStatus.ERROR, exception
919                                 .getLocalizedMessage(), exception));
920             }
921         }
922
923         // first look for project description files
924
final String JavaDoc dotProject = IProjectDescription.DESCRIPTION_FILE_NAME;
925         for (int i = 0; i < contents.length; i++) {
926             File JavaDoc file = contents[i];
927             if (file.isFile() && file.getName().equals(dotProject)) {
928                 files.add(file);
929                 // don't search sub-directories since we can't have nested
930
// projects
931
return true;
932             }
933         }
934         // no project description found, so recurse into sub-directories
935
for (int i = 0; i < contents.length; i++) {
936             if (contents[i].isDirectory()) {
937                 if (!contents[i].getName().equals(METADATA_FOLDER)) {
938                     try {
939                         String JavaDoc canonicalPath = contents[i].getCanonicalPath();
940                         if (!directoriesVisited.add(canonicalPath)) {
941                             // already been here --> do not recurse
942
continue;
943                         }
944                     } catch (IOException JavaDoc exception) {
945                         StatusManager.getManager().handle(
946                                 StatusUtil.newStatus(IStatus.ERROR, exception
947                                         .getLocalizedMessage(), exception));
948
949                     }
950                     collectProjectFilesFromDirectory(files, contents[i],
951                             directoriesVisited, monitor);
952                 }
953             }
954         }
955         return true;
956     }
957
958     /**
959      * Collect the list of .project files that are under directory into files.
960      *
961      * @param files
962      * @param monitor
963      * The monitor to report to
964      * @return boolean <code>true</code> if the operation was completed.
965      */

966     private boolean collectProjectFilesFromProvider(Collection JavaDoc files,
967             ILeveledImportStructureProvider provider, Object JavaDoc entry, int level,
968             IProgressMonitor monitor) {
969
970         if (monitor.isCanceled()) {
971             return false;
972         }
973         monitor.subTask(NLS.bind(
974                 DataTransferMessages.WizardProjectsImportPage_CheckingMessage,
975                 provider.getLabel(entry)));
976         List JavaDoc children = provider.getChildren(entry);
977         if (children == null) {
978             children = new ArrayList JavaDoc(1);
979         }
980         Iterator JavaDoc childrenEnum = children.iterator();
981         while (childrenEnum.hasNext()) {
982             Object JavaDoc child = childrenEnum.next();
983             if (provider.isFolder(child)) {
984                 collectProjectFilesFromProvider(files, provider, child,
985                         level + 1, monitor);
986             }
987             String JavaDoc elementLabel = provider.getLabel(child);
988             if (elementLabel.equals(IProjectDescription.DESCRIPTION_FILE_NAME)) {
989                 files.add(new ProjectRecord(child, entry, level, provider));
990             }
991         }
992         return true;
993     }
994
995     /**
996      * The browse button has been selected. Select the location.
997      */

998     protected void handleLocationDirectoryButtonPressed() {
999
1000        DirectoryDialog dialog = new DirectoryDialog(directoryPathField
1001                .getShell());
1002        dialog
1003                .setMessage(DataTransferMessages.WizardProjectsImportPage_SelectDialogTitle);
1004
1005        String JavaDoc dirName = directoryPathField.getText().trim();
1006        if (dirName.length() == 0) {
1007            dirName = previouslyBrowsedDirectory;
1008        }
1009
1010        if (dirName.length() == 0) {
1011            dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace()
1012                    .getRoot().getLocation().toOSString());
1013        } else {
1014            File JavaDoc path = new File JavaDoc(dirName);
1015            if (path.exists()) {
1016                dialog.setFilterPath(new Path(dirName).toOSString());
1017            }
1018        }
1019
1020        String JavaDoc selectedDirectory = dialog.open();
1021        if (selectedDirectory != null) {
1022            previouslyBrowsedDirectory = selectedDirectory;
1023            directoryPathField.setText(previouslyBrowsedDirectory);
1024            updateProjectsList(selectedDirectory);
1025        }
1026
1027    }
1028
1029    /**
1030     * The browse button has been selected. Select the location.
1031     */

1032    protected void handleLocationArchiveButtonPressed() {
1033
1034        FileDialog dialog = new FileDialog(archivePathField.getShell());
1035        dialog.setFilterExtensions(FILE_IMPORT_MASK);
1036        dialog
1037                .setText(DataTransferMessages.WizardProjectsImportPage_SelectArchiveDialogTitle);
1038
1039        String JavaDoc fileName = archivePathField.getText().trim();
1040        if (fileName.length() == 0) {
1041            fileName = previouslyBrowsedArchive;
1042        }
1043
1044        if (fileName.length() == 0) {
1045            dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace()
1046                    .getRoot().getLocation().toOSString());
1047        } else {
1048            File JavaDoc path = new File JavaDoc(fileName);
1049            if (path.exists()) {
1050                dialog.setFilterPath(new Path(fileName).toOSString());
1051            }
1052        }
1053
1054        String JavaDoc selectedArchive = dialog.open();
1055        if (selectedArchive != null) {
1056            previouslyBrowsedArchive = selectedArchive;
1057            archivePathField.setText(previouslyBrowsedArchive);
1058            updateProjectsList(selectedArchive);
1059        }
1060
1061    }
1062
1063    /**
1064     * Create the selected projects
1065     *
1066     * @return boolean <code>true</code> if all project creations were
1067     * successful.
1068     */

1069    public boolean createProjects() {
1070        saveWidgetValues();
1071        final Object JavaDoc[] selected = projectsList.getCheckedElements();
1072        WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
1073            protected void execute(IProgressMonitor monitor)
1074                    throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
1075                try {
1076                    monitor.beginTask("", selected.length); //$NON-NLS-1$
1077
if (monitor.isCanceled()) {
1078                        throw new OperationCanceledException();
1079                    }
1080                    for (int i = 0; i < selected.length; i++) {
1081                        createExistingProject((ProjectRecord) selected[i],
1082                                new SubProgressMonitor(monitor, 1));
1083                    }
1084                } finally {
1085                    monitor.done();
1086                }
1087            }
1088        };
1089        // run the new project creation operation
1090
try {
1091            getContainer().run(true, true, op);
1092        } catch (InterruptedException JavaDoc e) {
1093            return false;
1094        } catch (InvocationTargetException JavaDoc e) {
1095            // one of the steps resulted in a core exception
1096
Throwable JavaDoc t = e.getTargetException();
1097            String JavaDoc message = DataTransferMessages.WizardExternalProjectImportPage_errorMessage;
1098            IStatus status;
1099            if (t instanceof CoreException) {
1100                status = ((CoreException) t).getStatus();
1101            } else {
1102                status = new Status(IStatus.ERROR,
1103                        IDEWorkbenchPlugin.IDE_WORKBENCH, 1, message, t);
1104            }
1105            ErrorDialog.openError(getShell(), message, null, status);
1106            return false;
1107        }
1108        return true;
1109    }
1110
1111    /**
1112     * Performs clean-up if the user cancels the wizard without doing anything
1113     */

1114    public void performCancel() {
1115        ArchiveFileManipulations.clearProviderCache(getContainer().getShell());
1116    }
1117
1118    /**
1119     * Create the project described in record. If it is successful return true.
1120     *
1121     * @param record
1122     * @return boolean <code>true</code> if successful
1123     * @throws InterruptedException
1124     */

1125    private boolean createExistingProject(final ProjectRecord record,
1126            IProgressMonitor monitor) throws InvocationTargetException JavaDoc,
1127            InterruptedException JavaDoc {
1128        String JavaDoc projectName = record.getProjectName();
1129        final IWorkspace workspace = ResourcesPlugin.getWorkspace();
1130        final IProject project = workspace.getRoot().getProject(projectName);
1131        if (record.description == null) {
1132            // error case
1133
record.description = workspace.newProjectDescription(projectName);
1134            IPath locationPath = new Path(record.projectSystemFile
1135                    .getAbsolutePath());
1136
1137            // If it is under the root use the default location
1138
if (Platform.getLocation().isPrefixOf(locationPath)) {
1139                record.description.setLocation(null);
1140            } else {
1141                record.description.setLocation(locationPath);
1142            }
1143        } else {
1144            record.description.setName(projectName);
1145        }
1146        if (record.projectArchiveFile != null) {
1147            // import from archive
1148
List JavaDoc fileSystemObjects = record.provider.getChildren(record.parent);
1149            record.provider.setStrip(record.level);
1150            ImportOperation operation = new ImportOperation(project
1151                    .getFullPath(), record.provider.getRoot(), record.provider,
1152                    this, fileSystemObjects);
1153            operation.setContext(getShell());
1154            operation.run(monitor);
1155            return true;
1156        }
1157        // import from file system
1158
File JavaDoc importSource = null;
1159        if (copyFiles) {
1160            // import project from location copying files - use default project
1161
// location for this workspace
1162
URI JavaDoc locationURI = record.description.getLocationURI();
1163            // if location is null, project already exists in this location or
1164
// some error condition occured.
1165
if (locationURI != null) {
1166                importSource = new File JavaDoc(locationURI);
1167                IProjectDescription desc = workspace
1168                        .newProjectDescription(projectName);
1169                desc.setBuildSpec(record.description.getBuildSpec());
1170                desc.setComment(record.description.getComment());
1171                desc.setDynamicReferences(record.description
1172                        .getDynamicReferences());
1173                desc.setNatureIds(record.description.getNatureIds());
1174                desc.setReferencedProjects(record.description
1175                        .getReferencedProjects());
1176                record.description = desc;
1177            }
1178        }
1179
1180        try {
1181            monitor
1182                    .beginTask(
1183                            DataTransferMessages.WizardProjectsImportPage_CreateProjectsTask,
1184                            100);
1185            project.create(record.description, new SubProgressMonitor(monitor,
1186                    30));
1187            project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(
1188                    monitor, 70));
1189        } catch (CoreException e) {
1190            throw new InvocationTargetException JavaDoc(e);
1191        } finally {
1192            monitor.done();
1193        }
1194
1195        // import operation to import project files if copy checkbox is selected
1196
if (copyFiles && importSource != null) {
1197            List JavaDoc filesToImport = FileSystemStructureProvider.INSTANCE
1198                    .getChildren(importSource);
1199            ImportOperation operation = new ImportOperation(project
1200                    .getFullPath(), importSource,
1201                    FileSystemStructureProvider.INSTANCE, this, filesToImport);
1202            operation.setContext(getShell());
1203            operation.setOverwriteResources(true); // need to overwrite
1204
// .project, .classpath
1205
// files
1206
operation.setCreateContainerStructure(false);
1207            operation.run(monitor);
1208        }
1209
1210        return true;
1211    }
1212
1213    /**
1214     * The <code>WizardDataTransfer</code> implementation of this
1215     * <code>IOverwriteQuery</code> method asks the user whether the existing
1216     * resource at the given path should be overwritten.
1217     *
1218     * @param pathString
1219     * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
1220     * <code>"ALL"</code>, or <code>"CANCEL"</code>
1221     */

1222    public String JavaDoc queryOverwrite(String JavaDoc pathString) {
1223
1224        Path path = new Path(pathString);
1225
1226        String JavaDoc messageString;
1227        // Break the message up if there is a file name and a directory
1228
// and there are at least 2 segments.
1229
if (path.getFileExtension() == null || path.segmentCount() < 2) {
1230            messageString = NLS.bind(
1231                    IDEWorkbenchMessages.WizardDataTransfer_existsQuestion,
1232                    pathString);
1233        } else {
1234            messageString = NLS
1235                    .bind(
1236                            IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
1237                            path.lastSegment(), path.removeLastSegments(1)
1238                                    .toOSString());
1239        }
1240
1241        final MessageDialog dialog = new MessageDialog(getContainer()
1242                .getShell(), IDEWorkbenchMessages.Question, null,
1243                messageString, MessageDialog.QUESTION, new String JavaDoc[] {
1244                        IDialogConstants.YES_LABEL,
1245                        IDialogConstants.YES_TO_ALL_LABEL,
1246                        IDialogConstants.NO_LABEL,
1247                        IDialogConstants.NO_TO_ALL_LABEL,
1248                        IDialogConstants.CANCEL_LABEL }, 0);
1249        String JavaDoc[] response = new String JavaDoc[] { YES, ALL, NO, NO_ALL, CANCEL };
1250        // run in syncExec because callback is from an operation,
1251
// which is probably not running in the UI thread.
1252
getControl().getDisplay().syncExec(new Runnable JavaDoc() {
1253            public void run() {
1254                dialog.open();
1255            }
1256        });
1257        return dialog.getReturnCode() < 0 ? CANCEL : response[dialog
1258                .getReturnCode()];
1259    }
1260
1261    /**
1262     * Method used for test suite.
1263     *
1264     * @return Button the Import from Directory RadioButton
1265     */

1266    public Button getProjectFromDirectoryRadio() {
1267        return projectFromDirectoryRadio;
1268    }
1269
1270    /**
1271     * Method used for test suite.
1272     *
1273     * @return CheckboxTreeViewer the viewer containing all the projects found
1274     */

1275    public CheckboxTreeViewer getProjectsList() {
1276        return projectsList;
1277    }
1278
1279    /**
1280     * Retrieve all the projects in the current workspace.
1281     *
1282     * @return IProject[] array of IProject in the current workspace
1283     */

1284    private IProject[] getProjectsInWorkspace() {
1285        if (wsProjects == null) {
1286            wsProjects = IDEWorkbenchPlugin.getPluginWorkspace().getRoot()
1287                    .getProjects();
1288        }
1289        return wsProjects;
1290    }
1291
1292    /**
1293     * Get the array of valid project records that can be imported from the
1294     * source workspace or archive, selected by the user. If a project with the
1295     * same name exists in both the source workspace and the current workspace,
1296     * it will not appear in the list of projects to import and thus cannot be
1297     * selected for import.
1298     *
1299     * Method declared public for test suite.
1300     *
1301     * @return ProjectRecord[] array of projects that can be imported into the
1302     * workspace
1303     */

1304    public ProjectRecord[] getValidProjects() {
1305        List JavaDoc validProjects = new ArrayList JavaDoc();
1306        for (int i = 0; i < selectedProjects.length; i++) {
1307            if (!isProjectInWorkspace(selectedProjects[i].getProjectName())) {
1308                validProjects.add(selectedProjects[i]);
1309            }
1310        }
1311        return (ProjectRecord[]) validProjects
1312                .toArray(new ProjectRecord[validProjects.size()]);
1313    }
1314
1315    /**
1316     * Determine if the project with the given name is in the current workspace.
1317     *
1318     * @param projectName
1319     * String the project name to check
1320     * @return boolean true if the project with the given name is in this
1321     * workspace
1322     */

1323    private boolean isProjectInWorkspace(String JavaDoc projectName) {
1324        if (projectName == null) {
1325            return false;
1326        }
1327        IProject[] workspaceProjects = getProjectsInWorkspace();
1328        for (int i = 0; i < workspaceProjects.length; i++) {
1329            if (projectName.equals(workspaceProjects[i].getName())) {
1330                return true;
1331            }
1332        }
1333        return false;
1334    }
1335
1336    /**
1337     * Use the dialog store to restore widget values to the values that they
1338     * held last time this wizard was used to completion.
1339     *
1340     * Method declared public only for use of tests.
1341     */

1342    public void restoreWidgetValues() {
1343        IDialogSettings settings = getDialogSettings();
1344        if (settings != null) {
1345            // checkbox
1346
copyFiles = settings.getBoolean(STORE_COPY_PROJECT_ID);
1347            copyCheckbox.setSelection(copyFiles);
1348
1349            // radio selection
1350
boolean archiveSelected = settings
1351                    .getBoolean(STORE_ARCHIVE_SELECTED);
1352            projectFromDirectoryRadio.setSelection(!archiveSelected);
1353            projectFromArchiveRadio.setSelection(archiveSelected);
1354            if (archiveSelected) {
1355                archiveRadioSelected();
1356            } else {
1357                directoryRadioSelected();
1358            }
1359        }
1360    }
1361
1362    /**
1363     * Since Finish was pressed, write widget values to the dialog store so that
1364     * they will persist into the next invocation of this wizard page.
1365     *
1366     * Method declared public only for use of tests.
1367     */

1368    public void saveWidgetValues() {
1369        IDialogSettings settings = getDialogSettings();
1370        if (settings != null) {
1371            settings.put(STORE_COPY_PROJECT_ID, copyCheckbox.getSelection());
1372
1373            settings.put(STORE_ARCHIVE_SELECTED, projectFromArchiveRadio
1374                    .getSelection());
1375        }
1376    }
1377
1378    /**
1379     * Method used for test suite.
1380     *
1381     * @return Button copy checkbox
1382     */

1383    public Button getCopyCheckbox() {
1384        return copyCheckbox;
1385    }
1386}
1387
Popular Tags