plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/projectimport/WrtProjectLocationWizardPage.java
changeset 484 f5df819c1852
parent 483 109da596fa9d
equal deleted inserted replaced
483:109da596fa9d 484:f5df819c1852
    90 import org.symbian.tools.wrttools.util.CoreUtil;
    90 import org.symbian.tools.wrttools.util.CoreUtil;
    91 import org.symbian.tools.wrttools.util.ProjectUtils;
    91 import org.symbian.tools.wrttools.util.ProjectUtils;
    92 
    92 
    93 @SuppressWarnings({ "restriction", "unchecked", "rawtypes" })
    93 @SuppressWarnings({ "restriction", "unchecked", "rawtypes" })
    94 public class WrtProjectLocationWizardPage extends WizardPage implements IOverwriteQuery {
    94 public class WrtProjectLocationWizardPage extends WizardPage implements IOverwriteQuery {
    95 
       
    96     /**
       
    97      * @since 3.5
       
    98      * 
       
    99      */
       
   100     private final class ProjectLabelProvider extends LabelProvider implements IColorProvider {
    95     private final class ProjectLabelProvider extends LabelProvider implements IColorProvider {
   101 
       
   102         public Color getBackground(Object element) {
    96         public Color getBackground(Object element) {
   103             return null;
    97             return null;
   104         }
    98         }
   105 
    99 
   106         public Color getForeground(Object element) {
   100         public Color getForeground(Object element) {
   130 
   124 
   131     // Keep track of the directory that we browsed to last time
   125     // Keep track of the directory that we browsed to last time
   132     // the wizard was invoked.
   126     // the wizard was invoked.
   133     private static String previouslyBrowsedDirectory = ""; //$NON-NLS-1$
   127     private static String previouslyBrowsedDirectory = ""; //$NON-NLS-1$
   134 
   128 
   135     private final static String STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$
   129     private static final String STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$
   136 
   130 
   137     private Text archivePathField;
   131     private Text archivePathField;
   138 
       
   139     private Button browseArchivesButton;
   132     private Button browseArchivesButton;
   140 
       
   141     private Button browseDirectoriesButton;
   133     private Button browseDirectoriesButton;
   142 
   134     private List createdProjects;
   143     List createdProjects;
       
   144 
       
   145     private Text directoryPathField;
   135     private Text directoryPathField;
   146 
   136 
   147     // The last time that the file or folder at the selected path was modified
   137     // The last time that the file or folder at the selected path was modified
   148     // to mimize searches
   138     // to mimize searches
   149     private long lastModified;
   139     private long lastModified;
   158     private CheckboxTreeViewer projectsList;
   148     private CheckboxTreeViewer projectsList;
   159     private ProjectRecord[] selectedProjects = new ProjectRecord[0];
   149     private ProjectRecord[] selectedProjects = new ProjectRecord[0];
   160 
   150 
   161     /**
   151     /**
   162      * The import structure provider.
   152      * The import structure provider.
   163      * 
   153      *
   164      * @since 3.4
   154      * @since 3.4
   165      */
   155      */
   166     private ILeveledImportStructureProvider structureProvider;
   156     private ILeveledImportStructureProvider structureProvider;
   167 
   157 
   168     private IProject[] wsProjects;
   158     private IProject[] wsProjects;
   187         return createdProjects;
   177         return createdProjects;
   188     }
   178     }
   189 
   179 
   190     /**
   180     /**
   191      * Collect the list of .project files that are under directory into files.
   181      * Collect the list of .project files that are under directory into files.
   192      * 
   182      *
   193      * @param files
   183      * @param files
   194      * @param directory
   184      * @param directory
   195      * @param directoriesVisited
   185      * @param directoriesVisited
   196      *            Set of canonical paths of directories, used as recursion guard
   186      *            Set of canonical paths of directories, used as recursion guard
   197      * @param monitor
   187      * @param monitor
   251         return true;
   241         return true;
   252     }
   242     }
   253 
   243 
   254     /**
   244     /**
   255      * Collect the list of .project files that are under directory into files.
   245      * Collect the list of .project files that are under directory into files.
   256      * 
   246      *
   257      * @param files
   247      * @param files
   258      * @param monitor
   248      * @param monitor
   259      *            The monitor to report to
   249      *            The monitor to report to
   260      * @return boolean <code>true</code> if the operation was completed.
   250      * @return boolean <code>true</code> if the operation was completed.
   261      */
   251      */
   290             files.add(projectRecord);
   280             files.add(projectRecord);
   291         }
   281         }
   292         return true;
   282         return true;
   293     }
   283     }
   294 
   284 
   295     /*
       
   296      * (non-Javadoc)
       
   297      * 
       
   298      * @see
       
   299      * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
       
   300      * .Composite)
       
   301      */
       
   302     public void createControl(Composite parent) {
   285     public void createControl(Composite parent) {
   303 
   286 
   304         initializeDialogUnits(parent);
   287         initializeDialogUnits(parent);
   305 
   288 
   306         Composite workArea = new Composite(parent, SWT.NONE);
   289         Composite workArea = new Composite(parent, SWT.NONE);
   317         updateProjectsList(directoryPathField.getText().trim());
   300         updateProjectsList(directoryPathField.getText().trim());
   318     }
   301     }
   319 
   302 
   320     /**
   303     /**
   321      * Create the project described in record. If it is successful return true.
   304      * Create the project described in record. If it is successful return true.
   322      * 
   305      *
   323      * @param record
   306      * @param record
   324      * @return boolean <code>true</code> if successful
   307      * @return boolean <code>true</code> if successful
   325      * @throws InterruptedException
   308      * @throws InterruptedException
   326      */
   309      */
   327     private boolean createExistingProject(final ProjectRecord record, IProgressMonitor monitor)
   310     private boolean createExistingProject(final ProjectRecord record, IProgressMonitor monitor)
   346         }
   329         }
   347     }
   330     }
   348 
   331 
   349     /**
   332     /**
   350      * Create the selected projects
   333      * Create the selected projects
   351      * 
   334      *
   352      * @return boolean <code>true</code> if all project creations were
   335      * @return boolean <code>true</code> if all project creations were
   353      *         successful.
   336      *         successful.
   354      */
   337      */
   355     public boolean createProjects() {
   338     public boolean createProjects() {
   356         saveWidgetValues();
   339         saveWidgetValues();
   395         return true;
   378         return true;
   396     }
   379     }
   397 
   380 
   398     /**
   381     /**
   399      * Create the checkbox list for the found projects.
   382      * Create the checkbox list for the found projects.
   400      * 
   383      *
   401      * @param workArea
   384      * @param workArea
   402      */
   385      */
   403     private void createProjectsList(Composite workArea) {
   386     private void createProjectsList(Composite workArea) {
   404 
   387 
   405         Label title = new Label(workArea, SWT.NONE);
   388         Label title = new Label(workArea, SWT.NONE);
   419         GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
   402         GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
   420         gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
   403         gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
   421         gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
   404         gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
   422         projectsList.getControl().setLayoutData(gridData);
   405         projectsList.getControl().setLayoutData(gridData);
   423         projectsList.setContentProvider(new ITreeContentProvider() {
   406         projectsList.setContentProvider(new ITreeContentProvider() {
   424 
       
   425             /*
       
   426              * (non-Javadoc)
       
   427              * 
       
   428              * @see org.eclipse.jface.viewers.IContentProvider#dispose()
       
   429              */
       
   430             public void dispose() {
   407             public void dispose() {
   431 
   408             }
   432             }
       
   433 
       
   434             /*
       
   435              * (non-Javadoc)
       
   436              * 
       
   437              * @see
       
   438              * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java
       
   439              * .lang.Object)
       
   440              */
       
   441             public Object[] getChildren(Object parentElement) {
   409             public Object[] getChildren(Object parentElement) {
   442                 return null;
   410                 return null;
   443             }
   411             }
   444 
   412 
   445             /*
       
   446              * (non-Javadoc)
       
   447              * 
       
   448              * @see
       
   449              * org.eclipse.jface.viewers.IStructuredContentProvider#getElements
       
   450              * (java.lang.Object)
       
   451              */
       
   452             public Object[] getElements(Object inputElement) {
   413             public Object[] getElements(Object inputElement) {
   453                 return getProjectRecords();
   414                 return getProjectRecords();
   454             }
   415             }
   455 
   416 
   456             /*
       
   457              * (non-Javadoc)
       
   458              * 
       
   459              * @see
       
   460              * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java
       
   461              * .lang.Object)
       
   462              */
       
   463             public Object getParent(Object element) {
   417             public Object getParent(Object element) {
   464                 return null;
   418                 return null;
   465             }
   419             }
   466 
   420 
   467             /*
       
   468              * (non-Javadoc)
       
   469              * 
       
   470              * @see
       
   471              * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java
       
   472              * .lang.Object)
       
   473              */
       
   474             public boolean hasChildren(Object element) {
   421             public boolean hasChildren(Object element) {
   475                 return false;
   422                 return false;
   476             }
   423             }
   477 
   424 
   478             /*
       
   479              * (non-Javadoc)
       
   480              * 
       
   481              * @see
       
   482              * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
       
   483              * .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
       
   484              */
       
   485             public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
   425             public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
   486             }
   426             }
   487 
   427 
   488         });
   428         });
   489 
   429 
   490         projectsList.setLabelProvider(new ProjectLabelProvider());
   430         projectsList.setLabelProvider(new ProjectLabelProvider());
   491 
   431 
   492         projectsList.addCheckStateListener(new ICheckStateListener() {
   432         projectsList.addCheckStateListener(new ICheckStateListener() {
   493             /*
       
   494              * (non-Javadoc)
       
   495              * 
       
   496              * @see
       
   497              * org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
       
   498              * (org.eclipse.jface.viewers.CheckStateChangedEvent)
       
   499              */
       
   500             public void checkStateChanged(CheckStateChangedEvent event) {
   433             public void checkStateChanged(CheckStateChangedEvent event) {
   501                 ProjectRecord element = (ProjectRecord) event.getElement();
   434                 ProjectRecord element = (ProjectRecord) event.getElement();
   502                 if (element.hasConflicts()) {
   435                 if (element.hasConflicts()) {
   503                     projectsList.setChecked(element, false);
   436                     projectsList.setChecked(element, false);
   504                 }
   437                 }
   511         createSelectionButtons(listComposite);
   444         createSelectionButtons(listComposite);
   512     }
   445     }
   513 
   446 
   514     /**
   447     /**
   515      * Create the area where you select the root directory for the projects.
   448      * Create the area where you select the root directory for the projects.
   516      * 
   449      *
   517      * @param workArea
   450      * @param workArea
   518      *            Composite
   451      *            Composite
   519      */
   452      */
   520     private void createProjectsRoot(Composite workArea) {
   453     private void createProjectsRoot(Composite workArea) {
   521 
   454 
   563         projectFromDirectoryRadio.setSelection(true);
   496         projectFromDirectoryRadio.setSelection(true);
   564         archivePathField.setEnabled(false);
   497         archivePathField.setEnabled(false);
   565         browseArchivesButton.setEnabled(false);
   498         browseArchivesButton.setEnabled(false);
   566 
   499 
   567         browseDirectoriesButton.addSelectionListener(new SelectionAdapter() {
   500         browseDirectoriesButton.addSelectionListener(new SelectionAdapter() {
   568             /*
       
   569              * (non-Javadoc)
       
   570              * 
       
   571              * @see org.eclipse.swt.events.SelectionAdapter#widgetS
       
   572              * elected(org.eclipse.swt.events.SelectionEvent)
       
   573              */
       
   574             public void widgetSelected(SelectionEvent e) {
   501             public void widgetSelected(SelectionEvent e) {
   575                 handleLocationDirectoryButtonPressed();
   502                 handleLocationDirectoryButtonPressed();
   576             }
   503             }
   577 
   504 
   578         });
   505         });
   579 
   506 
   580         browseArchivesButton.addSelectionListener(new SelectionAdapter() {
   507         browseArchivesButton.addSelectionListener(new SelectionAdapter() {
   581             /*
       
   582              * (non-Javadoc)
       
   583              * 
       
   584              * @see
       
   585              * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
       
   586              * .swt.events.SelectionEvent)
       
   587              */
       
   588             public void widgetSelected(SelectionEvent e) {
   508             public void widgetSelected(SelectionEvent e) {
   589                 handleLocationArchiveButtonPressed();
   509                 handleLocationArchiveButtonPressed();
   590             }
   510             }
   591 
   511 
   592         });
   512         });
   593 
   513 
   594         directoryPathField.addTraverseListener(new TraverseListener() {
   514         directoryPathField.addTraverseListener(new TraverseListener() {
   595 
       
   596             /*
       
   597              * (non-Javadoc)
       
   598              * 
       
   599              * @see
       
   600              * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse
       
   601              * .swt.events.TraverseEvent)
       
   602              */
       
   603             public void keyTraversed(TraverseEvent e) {
   515             public void keyTraversed(TraverseEvent e) {
   604                 if (e.detail == SWT.TRAVERSE_RETURN) {
   516                 if (e.detail == SWT.TRAVERSE_RETURN) {
   605                     e.doit = false;
   517                     e.doit = false;
   606                     updateProjectsList(directoryPathField.getText().trim());
   518                     updateProjectsList(directoryPathField.getText().trim());
   607                 }
   519                 }
   608             }
   520             }
   609 
       
   610         });
   521         });
   611 
   522 
   612         directoryPathField.addFocusListener(new FocusAdapter() {
   523         directoryPathField.addFocusListener(new FocusAdapter() {
   613 
       
   614             /*
       
   615              * (non-Javadoc)
       
   616              * 
       
   617              * @see
       
   618              * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt
       
   619              * .events.FocusEvent)
       
   620              */
       
   621             public void focusLost(org.eclipse.swt.events.FocusEvent e) {
   524             public void focusLost(org.eclipse.swt.events.FocusEvent e) {
   622                 updateProjectsList(directoryPathField.getText().trim());
   525                 updateProjectsList(directoryPathField.getText().trim());
   623             }
   526             }
   624 
   527 
   625         });
   528         });
   626 
   529 
   627         archivePathField.addTraverseListener(new TraverseListener() {
   530         archivePathField.addTraverseListener(new TraverseListener() {
   628 
       
   629             /*
       
   630              * (non-Javadoc)
       
   631              * 
       
   632              * @see
       
   633              * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse
       
   634              * .swt.events.TraverseEvent)
       
   635              */
       
   636             public void keyTraversed(TraverseEvent e) {
   531             public void keyTraversed(TraverseEvent e) {
   637                 if (e.detail == SWT.TRAVERSE_RETURN) {
   532                 if (e.detail == SWT.TRAVERSE_RETURN) {
   638                     e.doit = false;
   533                     e.doit = false;
   639                     updateProjectsList(archivePathField.getText().trim());
   534                     updateProjectsList(archivePathField.getText().trim());
   640                 }
   535                 }
   641             }
   536             }
   642 
   537 
   643         });
   538         });
   644 
   539 
   645         archivePathField.addFocusListener(new FocusAdapter() {
   540         archivePathField.addFocusListener(new FocusAdapter() {
   646             /*
       
   647              * (non-Javadoc)
       
   648              * 
       
   649              * @see
       
   650              * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt
       
   651              * .events.FocusEvent)
       
   652              */
       
   653             public void focusLost(org.eclipse.swt.events.FocusEvent e) {
   541             public void focusLost(org.eclipse.swt.events.FocusEvent e) {
   654                 updateProjectsList(archivePathField.getText().trim());
   542                 updateProjectsList(archivePathField.getText().trim());
   655             }
   543             }
   656         });
   544         });
   657 
   545 
   658         projectFromDirectoryRadio.addSelectionListener(new SelectionAdapter() {
   546         projectFromDirectoryRadio.addSelectionListener(new SelectionAdapter() {
   659             /*
       
   660              * (non-Javadoc)
       
   661              * 
       
   662              * @see
       
   663              * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse
       
   664              * .swt.events.SelectionEvent)
       
   665              */
       
   666             public void widgetSelected(SelectionEvent e) {
   547             public void widgetSelected(SelectionEvent e) {
   667                 directoryRadioSelected();
   548                 directoryRadioSelected();
   668             }
   549             }
   669         });
   550         });
   670 
   551 
   671         projectFromArchiveRadio.addSelectionListener(new SelectionAdapter() {
   552         projectFromArchiveRadio.addSelectionListener(new SelectionAdapter() {
   672             /*
       
   673              * (non-Javadoc)
       
   674              * 
       
   675              * @see
       
   676              * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse
       
   677              * .swt.events.SelectionEvent)
       
   678              */
       
   679             public void widgetSelected(SelectionEvent e) {
   553             public void widgetSelected(SelectionEvent e) {
   680                 archiveRadioSelected();
   554                 archiveRadioSelected();
   681             }
   555             }
   682         });
   556         });
   683     }
   557     }
   684 
   558 
   685     /**
   559     /**
   686      * Create the selection buttons in the listComposite.
   560      * Create the selection buttons in the listComposite.
   687      * 
   561      *
   688      * @param listComposite
   562      * @param listComposite
   689      */
   563      */
   690     private void createSelectionButtons(Composite listComposite) {
   564     private void createSelectionButtons(Composite listComposite) {
   691         Composite buttonsComposite = new Composite(listComposite, SWT.NONE);
   565         Composite buttonsComposite = new Composite(listComposite, SWT.NONE);
   692         GridLayout layout = new GridLayout();
   566         GridLayout layout = new GridLayout();
   714         setButtonLayoutData(selectAll);
   588         setButtonLayoutData(selectAll);
   715 
   589 
   716         Button deselectAll = new Button(buttonsComposite, SWT.PUSH);
   590         Button deselectAll = new Button(buttonsComposite, SWT.PUSH);
   717         deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll);
   591         deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll);
   718         deselectAll.addSelectionListener(new SelectionAdapter() {
   592         deselectAll.addSelectionListener(new SelectionAdapter() {
   719             /*
       
   720              * (non-Javadoc)
       
   721              * 
       
   722              * @see
       
   723              * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
       
   724              * .swt.events.SelectionEvent)
       
   725              */
       
   726             public void widgetSelected(SelectionEvent e) {
   593             public void widgetSelected(SelectionEvent e) {
   727 
       
   728                 projectsList.setCheckedElements(new Object[0]);
   594                 projectsList.setCheckedElements(new Object[0]);
   729                 setPageComplete(false);
   595                 setPageComplete(false);
   730             }
   596             }
   731         });
   597         });
   732         Dialog.applyDialogFont(deselectAll);
   598         Dialog.applyDialogFont(deselectAll);
   733         setButtonLayoutData(deselectAll);
   599         setButtonLayoutData(deselectAll);
   734 
   600 
   735         Button refresh = new Button(buttonsComposite, SWT.PUSH);
   601         Button refresh = new Button(buttonsComposite, SWT.PUSH);
   736         refresh.setText(DataTransferMessages.DataTransfer_refresh);
   602         refresh.setText(DataTransferMessages.DataTransfer_refresh);
   737         refresh.addSelectionListener(new SelectionAdapter() {
   603         refresh.addSelectionListener(new SelectionAdapter() {
   738             /*
       
   739              * (non-Javadoc)
       
   740              * 
       
   741              * @see
       
   742              * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
       
   743              * .swt.events.SelectionEvent)
       
   744              */
       
   745             public void widgetSelected(SelectionEvent e) {
   604             public void widgetSelected(SelectionEvent e) {
   746                 if (projectFromDirectoryRadio.getSelection()) {
   605                 if (projectFromDirectoryRadio.getSelection()) {
   747                     updateProjectsList(directoryPathField.getText().trim());
   606                     updateProjectsList(directoryPathField.getText().trim());
   748                 } else {
   607                 } else {
   749                     updateProjectsList(archivePathField.getText().trim());
   608                     updateProjectsList(archivePathField.getText().trim());
   765         }
   624         }
   766     }
   625     }
   767 
   626 
   768     /**
   627     /**
   769      * Display an error dialog with the specified message.
   628      * Display an error dialog with the specified message.
   770      * 
   629      *
   771      * @param message
   630      * @param message
   772      *            the error message
   631      *            the error message
   773      */
   632      */
   774     protected void displayErrorDialog(String message) {
   633     protected void displayErrorDialog(String message) {
   775         MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), getErrorDialogTitle(), message, SWT.SHEET);
   634         MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), getErrorDialogTitle(), message, SWT.SHEET);
   782         return IDEWorkbenchMessages.WizardExportPage_internalErrorTitle;
   641         return IDEWorkbenchMessages.WizardExportPage_internalErrorTitle;
   783     }
   642     }
   784 
   643 
   785     /**
   644     /**
   786      * Method used for test suite.
   645      * Method used for test suite.
   787      * 
   646      *
   788      * @return Button the Import from Directory RadioButton
   647      * @return Button the Import from Directory RadioButton
   789      */
   648      */
   790     public Button getProjectFromDirectoryRadio() {
   649     public Button getProjectFromDirectoryRadio() {
   791         return projectFromDirectoryRadio;
   650         return projectFromDirectoryRadio;
   792     }
   651     }
   794     /**
   653     /**
   795      * Get the array of project records that can be imported from the source
   654      * Get the array of project records that can be imported from the source
   796      * workspace or archive, selected by the user. If a project with the same
   655      * workspace or archive, selected by the user. If a project with the same
   797      * name exists in both the source workspace and the current workspace, then
   656      * name exists in both the source workspace and the current workspace, then
   798      * the hasConflicts flag would be set on that project record.
   657      * the hasConflicts flag would be set on that project record.
   799      * 
   658      *
   800      * Method declared public for test suite.
   659      * Method declared public for test suite.
   801      * 
   660      *
   802      * @return ProjectRecord[] array of projects that can be imported into the
   661      * @return ProjectRecord[] array of projects that can be imported into the
   803      *         workspace
   662      *         workspace
   804      */
   663      */
   805     public ProjectRecord[] getProjectRecords() {
   664     public ProjectRecord[] getProjectRecords() {
   806         List projectRecords = new ArrayList();
   665         List projectRecords = new ArrayList();
   813         return (ProjectRecord[]) projectRecords.toArray(new ProjectRecord[projectRecords.size()]);
   672         return (ProjectRecord[]) projectRecords.toArray(new ProjectRecord[projectRecords.size()]);
   814     }
   673     }
   815 
   674 
   816     /**
   675     /**
   817      * Retrieve all the projects in the current workspace.
   676      * Retrieve all the projects in the current workspace.
   818      * 
   677      *
   819      * @return IProject[] array of IProject in the current workspace
   678      * @return IProject[] array of IProject in the current workspace
   820      */
   679      */
   821     private IProject[] getProjectsInWorkspace() {
   680     private IProject[] getProjectsInWorkspace() {
   822         if (wsProjects == null) {
   681         if (wsProjects == null) {
   823             wsProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
   682             wsProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
   825         return wsProjects;
   684         return wsProjects;
   826     }
   685     }
   827 
   686 
   828     /**
   687     /**
   829      * Method used for test suite.
   688      * Method used for test suite.
   830      * 
   689      *
   831      * @return CheckboxTreeViewer the viewer containing all the projects found
   690      * @return CheckboxTreeViewer the viewer containing all the projects found
   832      */
   691      */
   833     public CheckboxTreeViewer getProjectsList() {
   692     public CheckboxTreeViewer getProjectsList() {
   834         return projectsList;
   693         return projectsList;
   835     }
   694     }
   939 
   798 
   940     }
   799     }
   941 
   800 
   942     /**
   801     /**
   943      * Determine if the project with the given name is in the current workspace.
   802      * Determine if the project with the given name is in the current workspace.
   944      * 
   803      *
   945      * @param projectName
   804      * @param projectName
   946      *            String the project name to check
   805      *            String the project name to check
   947      * @return boolean true if the project with the given name is in this
   806      * @return boolean true if the project with the given name is in this
   948      *         workspace
   807      *         workspace
   949      */
   808      */
   969 
   828 
   970     /**
   829     /**
   971      * The <code>WizardDataTransfer</code> implementation of this
   830      * The <code>WizardDataTransfer</code> implementation of this
   972      * <code>IOverwriteQuery</code> method asks the user whether the existing
   831      * <code>IOverwriteQuery</code> method asks the user whether the existing
   973      * resource at the given path should be overwritten.
   832      * resource at the given path should be overwritten.
   974      * 
   833      *
   975      * @param pathString
   834      * @param pathString
   976      * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
   835      * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
   977      *         <code>"ALL"</code>, or <code>"CANCEL"</code>
   836      *         <code>"ALL"</code>, or <code>"CANCEL"</code>
   978      */
   837      */
   979     public String queryOverwrite(String pathString) {
   838     public String queryOverwrite(String pathString) {
  1015 
   874 
  1016     /**
   875     /**
  1017      * Use the dialog store to restore widget values to the values that they
   876      * Use the dialog store to restore widget values to the values that they
  1018      * held last time this wizard was used to completion, or alternatively, if
   877      * held last time this wizard was used to completion, or alternatively, if
  1019      * an initial path is specified, use it to select values.
   878      * an initial path is specified, use it to select values.
  1020      * 
   879      *
  1021      * Method declared public only for use of tests.
   880      * Method declared public only for use of tests.
  1022      */
   881      */
  1023     public void restoreWidgetValues() {
   882     public void restoreWidgetValues() {
  1024 
   883 
  1025         // First, check to see if we have resore settings, and
   884         // First, check to see if we have resore settings, and
  1044     }
   903     }
  1045 
   904 
  1046     /**
   905     /**
  1047      * Since Finish was pressed, write widget values to the dialog store so that
   906      * Since Finish was pressed, write widget values to the dialog store so that
  1048      * they will persist into the next invocation of this wizard page.
   907      * they will persist into the next invocation of this wizard page.
  1049      * 
   908      *
  1050      * Method declared public only for use of tests.
   909      * Method declared public only for use of tests.
  1051      */
   910      */
  1052     public void saveWidgetValues() {
   911     public void saveWidgetValues() {
  1053         IDialogSettings settings = getDialogSettings();
   912         IDialogSettings settings = getDialogSettings();
  1054         if (settings != null) {
   913         if (settings != null) {
  1071     }
   930     }
  1072 
   931 
  1073     /**
   932     /**
  1074      * Update the list of projects based on path. Method declared public only
   933      * Update the list of projects based on path. Method declared public only
  1075      * for test suite.
   934      * for test suite.
  1076      * 
   935      *
  1077      * @param path
   936      * @param path
  1078      */
   937      */
  1079     public void updateProjectsList(final String path) {
   938     public void updateProjectsList(final String path) {
  1080         // on an empty path empty selectedProjects
   939         // on an empty path empty selectedProjects
  1081         if (path == null || path.length() == 0) {
   940         if (path == null || path.length() == 0) {
  1102         // We can't access the radio button from the inner class so get the
   961         // We can't access the radio button from the inner class so get the
  1103         // status beforehand
   962         // status beforehand
  1104         final boolean dirSelected = this.projectFromDirectoryRadio.getSelection();
   963         final boolean dirSelected = this.projectFromDirectoryRadio.getSelection();
  1105         try {
   964         try {
  1106             getContainer().run(true, true, new IRunnableWithProgress() {
   965             getContainer().run(true, true, new IRunnableWithProgress() {
  1107 
       
  1108                 /*
       
  1109                  * (non-Javadoc)
       
  1110                  * 
       
  1111                  * @see
       
  1112                  * org.eclipse.jface.operation.IRunnableWithProgress#run(org
       
  1113                  * .eclipse.core.runtime.IProgressMonitor)
       
  1114                  */
       
  1115                 public void run(IProgressMonitor monitor) {
   966                 public void run(IProgressMonitor monitor) {
  1116 
   967 
  1117                     monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_SearchingMessage, 100);
   968                     monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_SearchingMessage, 100);
  1118                     selectedProjects = new ProjectRecord[0];
   969                     selectedProjects = new ProjectRecord[0];
  1119                     Collection files = new ArrayList();
   970                     Collection files = new ArrayList();
  1155                         monitor.worked(50);
  1006                         monitor.worked(50);
  1156                         monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage);
  1007                         monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage);
  1157                         while (filesIterator.hasNext()) {
  1008                         while (filesIterator.hasNext()) {
  1158                             selectedProjects[index++] = (ProjectRecord) filesIterator.next();
  1009                             selectedProjects[index++] = (ProjectRecord) filesIterator.next();
  1159                         }
  1010                         }
  1160                     }
  1011                     } else if (dirSelected && directory.isDirectory()) {
  1161 
       
  1162                     else if (dirSelected && directory.isDirectory()) {
       
  1163 
       
  1164                         if (!collectProjectFilesFromDirectory(files, directory, null, monitor)) {
  1012                         if (!collectProjectFilesFromDirectory(files, directory, null, monitor)) {
  1165                             return;
  1013                             return;
  1166                         }
  1014                         }
  1167                         Iterator filesIterator = files.iterator();
  1015                         Iterator filesIterator = files.iterator();
  1168                         selectedProjects = new ProjectRecord[files.size()];
  1016                         selectedProjects = new ProjectRecord[files.size()];