| 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);
|
| }
|
| }
|
|
|