Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 144610 - [Import/Export] Import existing projects does not search…
… subdirectories of found projects
  • Loading branch information
mhurne authored and Matt Hurne committed May 25, 2012
1 parent 523f636 commit b63a12f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2010 IBM Corporation and others.
* Copyright (c) 2005, 2010, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -97,6 +97,7 @@ public class DataTransferMessages extends NLS {
public static String WizardProjectsImportPage_ArchiveSelectTitle;
public static String WizardProjectsImportPage_SelectArchiveDialogTitle;
public static String WizardProjectsImportPage_CreateProjectsTask;
public static String WizardProjectsImportPage_SearchForNestedProjects;
public static String WizardProjectsImportPage_CopyProjectsIntoWorkspace;
public static String WizardProjectsImportPage_projectsInWorkspace;
public static String WizardProjectsImportPage_noProjectsToImport;
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2009, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -14,6 +14,8 @@
* - Bug 187318[Wizards] "Import Existing Project" loops forever with cyclic symbolic links
* Remy Chi Jian Suen (remy.suen@gmail.com)
* - Bug 210568 [Import/Export] [Import/Export] - Refresh button does not update list of projects
* Matt Hurne (matt@thehurnes.com)
* - Bug 144610 [Import/Export] Import existing projects does not search subdirectories of found projects
*******************************************************************************/

package org.eclipse.ui.internal.wizards.datatransfer;
Expand Down Expand Up @@ -285,6 +287,8 @@ public boolean hasConflicts() {
}

// dialog store id constants
private final static String STORE_NESTED_PROJECTS = "WizardProjectsImportPage.STORE_NESTED_PROJECTS"; //$NON-NLS-1$

private final static String STORE_COPY_PROJECT_ID = "WizardProjectsImportPage.STORE_COPY_PROJECT_ID"; //$NON-NLS-1$

private final static String STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$
Expand All @@ -293,6 +297,12 @@ public boolean hasConflicts() {

private CheckboxTreeViewer projectsList;

private Button nestedProjectsCheckbox;

private boolean nestedProjects = false;

private boolean lastNestedProjects = false;

private Button copyCheckbox;

private boolean copyFiles = false;
Expand Down Expand Up @@ -419,6 +429,21 @@ private void createOptionsArea(Composite workArea) {
optionsGroup.setLayout(new GridLayout());
optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

nestedProjectsCheckbox = new Button(optionsGroup, SWT.CHECK);
nestedProjectsCheckbox
.setText(DataTransferMessages.WizardProjectsImportPage_SearchForNestedProjects);
nestedProjectsCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
nestedProjectsCheckbox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
nestedProjects = nestedProjectsCheckbox.getSelection();
if (projectFromDirectoryRadio.getSelection()) {
updateProjectsList(directoryPathField.getText().trim());
} else {
updateProjectsList(archivePathField.getText().trim());
}
}
});

copyCheckbox = new Button(optionsGroup, SWT.CHECK);
copyCheckbox
.setText(DataTransferMessages.WizardProjectsImportPage_CopyProjectsIntoWorkspace);
Expand Down Expand Up @@ -800,6 +825,8 @@ private void archiveRadioSelected() {
browseArchivesButton.setEnabled(true);
updateProjectsList(archivePathField.getText());
archivePathField.setFocus();
nestedProjectsCheckbox.setSelection(true);
nestedProjectsCheckbox.setEnabled(false);
copyCheckbox.setSelection(true);
copyCheckbox.setEnabled(false);
}
Expand All @@ -813,6 +840,8 @@ private void directoryRadioSelected() {
browseArchivesButton.setEnabled(false);
updateProjectsList(directoryPathField.getText());
directoryPathField.setFocus();
nestedProjectsCheckbox.setEnabled(true);
nestedProjectsCheckbox.setSelection(nestedProjects);
copyCheckbox.setEnabled(true);
copyCheckbox.setSelection(copyFiles);
}
Expand Down Expand Up @@ -852,14 +881,19 @@ public void updateProjectsList(final String path) {

final File directory = new File(path);
long modified = directory.lastModified();
if (path.equals(lastPath) && lastModified == modified && lastCopyFiles == copyFiles) {
if (path.equals(lastPath)
&& lastModified == modified
&& lastNestedProjects == nestedProjects
&& lastCopyFiles == copyFiles)
{
// since the file/folder was not modified and the path did not
// change, no refreshing is required
return;
}

lastPath = path;
lastModified = modified;
lastNestedProjects = nestedProjects;
lastCopyFiles = copyFiles;

// We can't access the radio button from the inner class so get the
Expand Down Expand Up @@ -1095,12 +1129,15 @@ private boolean collectProjectFilesFromDirectory(Collection files,
File file = contents[i];
if (file.isFile() && file.getName().equals(dotProject)) {
files.add(file);
// don't search sub-directories since we can't have nested
// projects
return true;
if (!nestedProjects) {
// don't search sub-directories since we can't have nested
// projects
return true;
}
}
}
// no project description found, so recurse into sub-directories
// no project description found or search for nested projects enabled,
// so recurse into sub-directories
for (int i = 0; i < contents.length; i++) {
if (contents[i].isDirectory()) {
if (!contents[i].getName().equals(METADATA_FOLDER)) {
Expand Down Expand Up @@ -1563,6 +1600,11 @@ public void restoreWidgetValues() {
// take care of the checkbox
IDialogSettings settings = getDialogSettings();
if (settings != null) {
// checkbox
nestedProjects = settings.getBoolean(STORE_NESTED_PROJECTS);
nestedProjectsCheckbox.setSelection(nestedProjects);
lastNestedProjects = nestedProjects;

// checkbox
copyFiles = settings.getBoolean(STORE_COPY_PROJECT_ID);
copyCheckbox.setSelection(copyFiles);
Expand Down Expand Up @@ -1617,6 +1659,8 @@ else if (initialPath != null) {
public void saveWidgetValues() {
IDialogSettings settings = getDialogSettings();
if (settings != null) {
settings.put(STORE_NESTED_PROJECTS, nestedProjectsCheckbox.getSelection());

settings.put(STORE_COPY_PROJECT_ID, copyCheckbox.getSelection());

settings.put(STORE_ARCHIVE_SELECTED, projectFromArchiveRadio
Expand Down
Expand Up @@ -99,6 +99,7 @@ WizardProjectsImportPage_noProjectsToImport=No projects are found to import
WizardProjectsImportPage_CreateProjectsTask=Creating Projects
WizardProjectsImportPage_ImportProjectsDescription=Select a directory to search for existing Eclipse projects.
WizardProjectsImportPage_CheckingMessage= Checking: {0}
WizardProjectsImportPage_SearchForNestedProjects=Search for nested projects
WizardProjectsImportPage_CopyProjectsIntoWorkspace=&Copy projects into workspace
# The first parameter is the project folder name and the second is the name from the project description
WizardProjectsImportPage_projectLabel={0} ({1})
Expand Down

0 comments on commit b63a12f

Please sign in to comment.