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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/actions/RunInBrowserAction.java

Issue 8469003: Change the launch browser action to be disabled if there are no candidate html files to run. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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/actions/RunInBrowserAction.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/actions/RunInBrowserAction.java (revision 1415)
+++ editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/actions/RunInBrowserAction.java (working copy)
@@ -16,7 +16,6 @@
import com.google.dart.compiler.backend.js.JavascriptBackend;
import com.google.dart.tools.core.DartCore;
import com.google.dart.tools.core.internal.model.DartLibraryImpl;
-import com.google.dart.tools.core.internal.model.DartModelManager;
import com.google.dart.tools.core.model.DartElement;
import com.google.dart.tools.core.model.DartLibrary;
import com.google.dart.tools.core.model.DartModelException;
@@ -218,7 +217,7 @@
void openInBrowser(IWorkbenchPage page) {
try {
- List<IFile> files = getFileResources();
+ List<IFile> files = getFileResourcesForSelection();
IFile file = null;
@@ -273,20 +272,14 @@
return (IFile) result[0];
}
- private List<IFile> getAllAvailableHtmlFiles() throws DartModelException {
- Set<IFile> files = new HashSet<IFile>();
-
- for (DartLibrary library : DartModelManager.getInstance().getDartModel().getDartLibraries()) {
- files.addAll(getHtmlFilesFor(library));
- }
-
- return new ArrayList<IFile>(files);
- }
-
- private List<IFile> getFileResources() throws DartModelException {
+ private List<IFile> getFileResourcesForSelection() throws DartModelException {
IResource resource = null;
DartElement element = null;
+ if (selectedObject == null) {
+ return Collections.emptyList();
+ }
+
if (selectedObject instanceof IResource) {
resource = (IResource) selectedObject;
}
@@ -317,7 +310,7 @@
}
if (element == null) {
- return getAllAvailableHtmlFiles();
+ return Collections.emptyList();
} else {
// DartElement in a library
DartLibrary library = element.getAncestor(DartLibrary.class);
@@ -330,7 +323,7 @@
}
}
- return getAllAvailableHtmlFiles();
+ return Collections.emptyList();
}
}
@@ -355,11 +348,13 @@
private void handleSelectionChanged(IStructuredSelection selection) {
if (selection != null && !selection.isEmpty()) {
selectedObject = selection.getFirstElement();
-
- setEnabled(true);
} else {
selectedObject = null;
+ }
+ try {
+ setEnabled(getFileResourcesForSelection().size() > 0);
+ } catch (DartModelException e) {
setEnabled(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