Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/projects/CreateFolderWizard.java

Issue 12335069: create package symlinks in new folders dartbug.com/6688 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
+
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698