Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline import of Dart projects #116

Merged
merged 1 commit into from Aug 1, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Streamline import of Dart projects

Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
  • Loading branch information...
jonas-jonas committed Jul 31, 2019
commit d10359c35834cda633f71ab80e48e7988a532ece
@@ -248,4 +248,25 @@
class="org.eclipse.dartboard.ListenerService">
</startup>
</extension>
<extension
point="org.eclipse.ui.importWizards">
<wizard
category="org.eclipse.dartboard.import.category"
class="org.eclipse.ui.internal.wizards.datatransfer.SmartImportWizard"
icon="icons/dart.png"
id="org.eclipse.dartboard.import.wizard"
name="Dart Project">
</wizard>
<category
id="org.eclipse.dartboard.import.category"
name="Dart">
</category>
</extension>
<extension
point="org.eclipse.ui.ide.projectConfigurators">
<projectConfigurator
class="org.eclipse.dartboard.project.DartProjectConfigurator"
label="Dart Project">
</projectConfigurator>
</extension>
</plugin>
@@ -0,0 +1,69 @@
package org.eclipse.dartboard.project;

import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.HashSet;
import java.util.Set;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.dartboard.Constants;
import org.eclipse.ui.wizards.datatransfer.ProjectConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DartProjectConfigurator implements ProjectConfigurator {

private static final Logger LOG = LoggerFactory.getLogger(DartProjectConfigurator.class);

@Override
public Set<File> findConfigurableLocations(File root, IProgressMonitor monitor) {
Set<File> files = new HashSet<>();

try {
Files.walkFileTree(root.toPath(), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (file.endsWith(Constants.PUBSPEC)) {
files.add(file.toFile().getParentFile());
}
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
LOG.error("Couldn't walk children directories", e); //$NON-NLS-1$
}
return files;
}

@Override
public boolean shouldBeAnEclipseProject(IContainer container, IProgressMonitor monitor) {
return true;
}

@Override
public Set<IFolder> getFoldersToIgnore(IProject project, IProgressMonitor monitor) {
// Currently there are no to ignore in Dart projects
return null;
}

@Override
public boolean canConfigure(IProject project, Set<IPath> ignoredPaths, IProgressMonitor monitor) {
// Do nothing, as everything is handled in ListenerService
return false;
}

@Override
public void configure(IProject project, Set<IPath> ignoredPaths, IProgressMonitor monitor) {
// Do nothing, as everything is handled in ListenerService
}

}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.