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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. 2 * Copyright (c) 2012, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
11 * or implied. See the License for the specific language governing permissions a nd limitations under 11 * or implied. See the License for the specific language governing permissions a nd limitations under
12 * the License. 12 * the License.
13 */ 13 */
14 package com.google.dart.tools.ui.internal.projects; 14 package com.google.dart.tools.ui.internal.projects;
15 15
16 import com.google.dart.tools.core.DartCore;
17 import com.google.dart.tools.core.pub.RunPubJob;
18
19 import org.eclipse.core.resources.IContainer;
16 import org.eclipse.core.resources.IFolder; 20 import org.eclipse.core.resources.IFolder;
17 import org.eclipse.core.runtime.IStatus; 21 import org.eclipse.core.runtime.IStatus;
18 import org.eclipse.core.runtime.Status; 22 import org.eclipse.core.runtime.Status;
19 import org.eclipse.jface.viewers.IStructuredSelection; 23 import org.eclipse.jface.viewers.IStructuredSelection;
20 import org.eclipse.swt.widgets.Composite; 24 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.ui.IWorkbench; 25 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.dialogs.WizardNewFolderMainPage; 26 import org.eclipse.ui.dialogs.WizardNewFolderMainPage;
23 import org.eclipse.ui.internal.wizards.newresource.ResourceMessages; 27 import org.eclipse.ui.internal.wizards.newresource.ResourceMessages;
24 import org.eclipse.ui.wizards.newresource.BasicNewFolderResourceWizard; 28 import org.eclipse.ui.wizards.newresource.BasicNewFolderResourceWizard;
25 29
30 import java.util.Arrays;
31 import java.util.List;
32
26 /** 33 /**
27 * Create a new folder wizard 34 * Create a new folder wizard
28 */ 35 */
29 @SuppressWarnings("restriction") 36 @SuppressWarnings("restriction")
30 public class CreateFolderWizard extends BasicNewFolderResourceWizard { 37 public class CreateFolderWizard extends BasicNewFolderResourceWizard {
31 38
32 private class CreateFolderWizardPage extends WizardNewFolderMainPage { 39 private class CreateFolderWizardPage extends WizardNewFolderMainPage {
33 40
34 public CreateFolderWizardPage(String pageName, IStructuredSelection selectio n) { 41 public CreateFolderWizardPage(String pageName, IStructuredSelection selectio n) {
35 super(pageName, selection); 42 super(pageName, selection);
(...skipping 15 matching lines...) Expand all
51 return Status.OK_STATUS; 58 return Status.OK_STATUS;
52 } 59 }
53 60
54 } 61 }
55 62
56 /** 63 /**
57 * The wizard id for creating new folders in the workspace. 64 * The wizard id for creating new folders in the workspace.
58 */ 65 */
59 public static final String WIZARD_ID = "com.google.dart.tools.ui.new.folder"; //$NON-NLS-1$ 66 public static final String WIZARD_ID = "com.google.dart.tools.ui.new.folder"; //$NON-NLS-1$
60 67
68 /**
69 * The directories in the pub white list, ones which have symlinks to the packa ges directory
70 */
71 public static final List<String> pubDirectories = Arrays.asList("web", "exampl e", "test", "bin");
danrubel 2013/02/25 21:44:17 How can we keep this in sync with pub? Does pub ha
72
61 private WizardNewFolderMainPage mainPage; 73 private WizardNewFolderMainPage mainPage;
62 74
63 @Override 75 @Override
64 public void addPages() { 76 public void addPages() {
65 77
66 mainPage = new CreateFolderWizardPage("newFolderPage1", getSelection()); 78 mainPage = new CreateFolderWizardPage("newFolderPage1", getSelection());
67 mainPage.setTitle(ResourceMessages.NewFolder_title); 79 mainPage.setTitle(ResourceMessages.NewFolder_title);
68 mainPage.setDescription("Create a new folder resource"); 80 mainPage.setDescription("Create a new folder resource");
69 addPage(mainPage); 81 addPage(mainPage);
70 } 82 }
71 83
72 @Override 84 @Override
73 public void init(IWorkbench workbench, IStructuredSelection currentSelection) { 85 public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
74 super.init(workbench, currentSelection); 86 super.init(workbench, currentSelection);
75 setWindowTitle(ResourceMessages.FileResource_shellTitle); 87 setWindowTitle(ResourceMessages.FileResource_shellTitle);
76 setNeedsProgressMonitor(true); 88 setNeedsProgressMonitor(true);
77 } 89 }
78 90
79 @Override 91 @Override
80 public boolean performFinish() { 92 public boolean performFinish() {
81 IFolder folder = mainPage.createNewFolder(); 93 IFolder folder = mainPage.createNewFolder();
82 if (folder == null) { 94 if (folder == null) {
83 return false; 95 return false;
84 } 96 }
97 // if new folder is pub white listed directory/sub-directory, run pub instal l
98 // to create the link to packages
99 if (pubDirectories.contains(folder.getName()) || isPubDirectoryParent(folder )) {
100 IContainer pubspecDir = getPubWorkingDir(folder);
101 if (pubspecDir != null) {
102 RunPubJob job = new RunPubJob(pubspecDir, RunPubJob.INSTALL_COMMAND);
103 job.schedule();
104 }
105 }
85 selectAndReveal(folder); 106 selectAndReveal(folder);
107
86 return true; 108 return true;
87 } 109 }
88 110
111 private IContainer getPubWorkingDir(IFolder folder) {
112 IContainer container = folder;
113 while (container != null) {
114 if (container.findMember(DartCore.PUBSPEC_FILE_NAME) != null) {
115 return container;
116 }
117 container = container.getParent();
118 }
119 return null;
120 }
121
122 private boolean isPubDirectoryParent(IFolder folder) {
123 IContainer parent = folder.getParent();
124 while (parent != null) {
125 if (pubDirectories.contains(parent.getName())) {
126 return true;
127 }
128 parent = parent.getParent();
129 }
130 return false;
131 }
132
89 } 133 }
OLDNEW
« 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