| Index: editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/launch/RunInBrowserAction.java
|
| ===================================================================
|
| --- editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/launch/RunInBrowserAction.java (revision 2081)
|
| +++ editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/launch/RunInBrowserAction.java (working copy)
|
| @@ -11,20 +11,18 @@
|
| * or implied. See the License for the specific language governing permissions and limitations under
|
| * the License.
|
| */
|
| -package com.google.dart.tools.ui.actions;
|
| +package com.google.dart.tools.debug.ui.launch;
|
|
|
| import com.google.dart.compiler.backend.js.JavascriptBackend;
|
| import com.google.dart.tools.core.DartCore;
|
| -import com.google.dart.tools.core.DartCoreDebug;
|
| import com.google.dart.tools.core.internal.model.DartLibraryImpl;
|
| import com.google.dart.tools.core.model.DartElement;
|
| import com.google.dart.tools.core.model.DartLibrary;
|
| import com.google.dart.tools.core.model.DartModelException;
|
| import com.google.dart.tools.core.model.HTMLFile;
|
| -import com.google.dart.tools.ui.DartPluginImages;
|
| +import com.google.dart.tools.debug.core.DartDebugCorePlugin;
|
| import com.google.dart.tools.ui.DartToolsPlugin;
|
| import com.google.dart.tools.ui.ImportedDartLibraryContainer;
|
| -import com.google.dart.tools.ui.internal.util.ExceptionHandler;
|
|
|
| import org.eclipse.core.resources.IFile;
|
| import org.eclipse.core.resources.IResource;
|
| @@ -33,6 +31,8 @@
|
| import org.eclipse.core.runtime.IProgressMonitor;
|
| import org.eclipse.core.runtime.IStatus;
|
| import org.eclipse.core.runtime.Status;
|
| +import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
| +import org.eclipse.core.runtime.preferences.InstanceScope;
|
| import org.eclipse.jface.action.Action;
|
| import org.eclipse.jface.dialogs.MessageDialog;
|
| import org.eclipse.jface.viewers.ArrayContentProvider;
|
| @@ -42,6 +42,7 @@
|
| import org.eclipse.jface.viewers.SelectionChangedEvent;
|
| import org.eclipse.jface.viewers.StructuredSelection;
|
| import org.eclipse.osgi.util.NLS;
|
| +import org.eclipse.swt.program.Program;
|
| import org.eclipse.ui.IEditorPart;
|
| import org.eclipse.ui.IEditorReference;
|
| import org.eclipse.ui.IEditorRegistry;
|
| @@ -121,11 +122,8 @@
|
| setId(ACTION_ID);
|
| setDescription(ActionMessages.OpenInBrowserAction_description);
|
| setToolTipText(ActionMessages.OpenInBrowserAction_toolTip);
|
| - if (DartCoreDebug.BLEEDING_EDGE) {
|
| - setImageDescriptor(DartToolsPlugin.getImageDescriptor("icons/full/dart16/run_client.png"));
|
| - } else {
|
| - setImageDescriptor(DartPluginImages.DESC_TOOL_RUN);
|
| - }
|
| + setImageDescriptor(DartToolsPlugin.getImageDescriptor("icons/full/dart16/run_client.png"));
|
| +
|
| setEnabled(false);
|
|
|
| window.getPartService().addPartListener(this);
|
| @@ -195,15 +193,35 @@
|
| if (htmlFile.getReferencedLibraries().length > 0) {
|
| DartLibrary library = htmlFile.getReferencedLibraries()[0];
|
| File jsOutFile = getJsAppArtifactFile(library.getCorrespondingResource().getLocation());
|
| -
|
| + boolean useDefaultBrowser;
|
| if (jsOutFile.exists()) {
|
| try {
|
| + if (InstanceScope.INSTANCE.getNode(DartDebugCorePlugin.PLUGIN_ID) != null) {
|
| + IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(DartDebugCorePlugin.PLUGIN_ID);
|
| + useDefaultBrowser = prefs.getBoolean(DartDebugCorePlugin.PREFS_DEFAULT_BROWSER,
|
| + true);
|
| + if (!useDefaultBrowser) {
|
| + String browserName = prefs.get(DartDebugCorePlugin.PREFS_BROWSER_NAME, "");
|
| + if (!browserName.isEmpty()) {
|
| + Program program = findProgram(browserName);
|
| + if (program != null) {
|
| + program.execute(file.getLocation().toOSString());
|
| +
|
| + } else {
|
| + MessageDialog.openError(window.getShell(),
|
| + ActionMessages.OpenInBrowserAction_unableToLaunch,
|
| + ActionMessages.OpenInBrowserAction_couldNotOpenFile);
|
| + }
|
| + return;
|
| + }
|
| + }
|
| + }
|
| String editorId = IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID;
|
| page.openEditor(new FileEditorInput(file), editorId, true, MATCH_BOTH);
|
| } catch (PartInitException e) {
|
| - ExceptionHandler.handle(e, window.getShell(),
|
| - ActionMessages.OpenInBrowserAction_title,
|
| + MessageDialog.openError(window.getShell(), ActionMessages.OpenInBrowserAction_title,
|
| ActionMessages.OpenInBrowserAction_couldNotOpenFile);
|
| + DartDebugCorePlugin.logError(e);
|
| }
|
| } else {
|
| MessageDialog.openError(
|
| @@ -214,8 +232,9 @@
|
| }
|
| }
|
| } catch (DartModelException ex) {
|
| - ExceptionHandler.handle(ex, window.getShell(), ActionMessages.OpenInBrowserAction_title,
|
| + MessageDialog.openError(window.getShell(), ActionMessages.OpenInBrowserAction_title,
|
| ActionMessages.OpenInBrowserAction_couldNotOpenFile);
|
| + DartDebugCorePlugin.logError(ex);
|
| }
|
| }
|
| }
|
| @@ -252,8 +271,9 @@
|
| job.schedule(isSaveNeeded ? 100 : 0);
|
| }
|
| } catch (DartModelException e) {
|
| - ExceptionHandler.handle(e, window.getShell(), ActionMessages.OpenInBrowserAction_title,
|
| + MessageDialog.openError(window.getShell(), ActionMessages.OpenInBrowserAction_title,
|
| ActionMessages.OpenInBrowserAction_couldNotOpenFile);
|
| + DartDebugCorePlugin.logError(e);
|
| }
|
| }
|
|
|
| @@ -277,6 +297,18 @@
|
| return (IFile) result[0];
|
| }
|
|
|
| + private Program findProgram(String name) {
|
| +
|
| + Program[] programs = Program.getPrograms();
|
| + for (Program program : programs) {
|
| + if (program.getName().equals(name)) {
|
| + return program;
|
| + }
|
| + }
|
| +
|
| + return null;
|
| + }
|
| +
|
| private List<IFile> getFileResourcesForSelection() throws DartModelException {
|
| IResource resource = null;
|
| DartElement element = null;
|
|
|