Chromium Code Reviews| Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/projects/CreateFolderWizard.java |
| =================================================================== |
| --- editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/projects/CreateFolderWizard.java (revision 18975) |
| +++ editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/projects/CreateFolderWizard.java (working copy) |
| @@ -13,6 +13,10 @@ |
| */ |
| package com.google.dart.tools.ui.internal.projects; |
| +import com.google.dart.tools.core.DartCore; |
| +import com.google.dart.tools.core.pub.RunPubJob; |
| + |
| +import org.eclipse.core.resources.IContainer; |
| import org.eclipse.core.resources.IFolder; |
| import org.eclipse.core.runtime.IStatus; |
| import org.eclipse.core.runtime.Status; |
| @@ -23,6 +27,9 @@ |
| import org.eclipse.ui.internal.wizards.newresource.ResourceMessages; |
| import org.eclipse.ui.wizards.newresource.BasicNewFolderResourceWizard; |
| +import java.util.Arrays; |
| +import java.util.List; |
| + |
| /** |
| * Create a new folder wizard |
| */ |
| @@ -58,6 +65,11 @@ |
| */ |
| public static final String WIZARD_ID = "com.google.dart.tools.ui.new.folder"; //$NON-NLS-1$ |
| + /** |
| + * The directories in the pub white list, ones which have symlinks to the packages directory |
| + */ |
| + public static final List<String> pubDirectories = Arrays.asList("web", "example", "test", "bin"); |
|
danrubel
2013/02/25 21:44:17
How can we keep this in sync with pub?
Does pub ha
|
| + |
| private WizardNewFolderMainPage mainPage; |
| @Override |
| @@ -82,8 +94,40 @@ |
| if (folder == null) { |
| return false; |
| } |
| + // if new folder is pub white listed directory/sub-directory, run pub install |
| + // to create the link to packages |
| + if (pubDirectories.contains(folder.getName()) || isPubDirectoryParent(folder)) { |
| + IContainer pubspecDir = getPubWorkingDir(folder); |
| + if (pubspecDir != null) { |
| + RunPubJob job = new RunPubJob(pubspecDir, RunPubJob.INSTALL_COMMAND); |
| + job.schedule(); |
| + } |
| + } |
| selectAndReveal(folder); |
| + |
| return true; |
| } |
| + private IContainer getPubWorkingDir(IFolder folder) { |
| + IContainer container = folder; |
| + while (container != null) { |
| + if (container.findMember(DartCore.PUBSPEC_FILE_NAME) != null) { |
| + return container; |
| + } |
| + container = container.getParent(); |
| + } |
| + return null; |
| + } |
| + |
| + private boolean isPubDirectoryParent(IFolder folder) { |
| + IContainer parent = folder.getParent(); |
| + while (parent != null) { |
| + if (pubDirectories.contains(parent.getName())) { |
| + return true; |
| + } |
| + parent = parent.getParent(); |
| + } |
| + return false; |
| + } |
| + |
| } |