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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/wizard/AbstractDartWizardPage.java

Issue 8332012: fix for new file adds file in wrong location (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 2 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/wizard/AbstractDartWizardPage.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/wizard/AbstractDartWizardPage.java (revision 632)
+++ editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/wizard/AbstractDartWizardPage.java (working copy)
@@ -21,6 +21,7 @@
import com.google.dart.tools.core.model.DartModelException;
import com.google.dart.tools.core.model.HTMLFile;
import com.google.dart.tools.ui.internal.dialogs.ResourceSelectionDialog;
+import com.google.dart.tools.ui.internal.text.editor.EditorUtility;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
@@ -169,24 +170,29 @@
protected DartLibrary getSelectedLibrary() {
ISelection selectedFolder = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
DartLibrary foundLibrary = null;
+ Object element = null;
if (selectedFolder instanceof TreeSelection) {
- Object firstElement = ((TreeSelection) selectedFolder).getFirstElement();
- if (firstElement != null) {
- if (firstElement instanceof DartElement) {
- foundLibrary = getParentDartLibrary((DartElement) firstElement);
- if (foundLibrary == null && firstElement instanceof HTMLFile) {
- HTMLFile htmlFile = (HTMLFile) firstElement;
- try {
- DartLibrary[] libraries = htmlFile.getReferencedLibraries();
- if (libraries.length > 0) {
- foundLibrary = libraries[0];
- }
- } catch (DartModelException e) {
+ element = ((TreeSelection) selectedFolder).getFirstElement();
+ }
+ if (element == null) {
+ element = EditorUtility.getActiveEditorJavaInput();
+ }
+ if (element != null) {
+ if (element instanceof DartElement) {
+ foundLibrary = getParentDartLibrary((DartElement) element);
+ if (foundLibrary == null && element instanceof HTMLFile) {
+ HTMLFile htmlFile = (HTMLFile) element;
+ try {
+ DartLibrary[] libraries = htmlFile.getReferencedLibraries();
+ if (libraries.length > 0) {
+ foundLibrary = libraries[0];
}
+ } catch (DartModelException e) {
}
}
}
}
+
if (foundLibrary != null) {
return foundLibrary;
} else {
« 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