| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011, the Dart project authors. | 2 * Copyright (c) 2011, 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.handlers; | 14 package com.google.dart.tools.ui.internal.handlers; |
| 15 | 15 |
| 16 import com.google.dart.tools.core.DartCore; | 16 import com.google.dart.tools.core.DartCore; |
| 17 import com.google.dart.tools.core.internal.util.Extensions; | 17 import com.google.dart.tools.core.internal.util.Extensions; |
| 18 import com.google.dart.tools.core.internal.util.ResourceUtil; | 18 import com.google.dart.tools.core.internal.util.ResourceUtil; |
| 19 import com.google.dart.tools.core.model.DartLibrary; | 19 import com.google.dart.tools.core.model.DartLibrary; |
| 20 import com.google.dart.tools.core.model.DartModelException; | 20 import com.google.dart.tools.core.model.DartModelException; |
| 21 import com.google.dart.tools.ui.DartToolsPlugin; | 21 import com.google.dart.tools.ui.DartToolsPlugin; |
| 22 import com.google.dart.tools.ui.DartUI; | 22 import com.google.dart.tools.ui.DartUI; |
| 23 import com.google.dart.tools.ui.actions.ActionMessages; | 23 import com.google.dart.tools.ui.Messages; |
| 24 import com.google.dart.tools.ui.internal.actions.WorkbenchRunnableAdapter; | 24 import com.google.dart.tools.ui.internal.actions.WorkbenchRunnableAdapter; |
| 25 import com.google.dart.tools.ui.internal.text.editor.EditorUtility; | 25 import com.google.dart.tools.ui.internal.text.editor.EditorUtility; |
| 26 import com.google.dart.tools.ui.internal.util.ExceptionHandler; | 26 import com.google.dart.tools.ui.internal.util.ExceptionHandler; |
| 27 | 27 |
| 28 import org.eclipse.core.commands.AbstractHandler; | 28 import org.eclipse.core.commands.AbstractHandler; |
| 29 import org.eclipse.core.commands.ExecutionEvent; | 29 import org.eclipse.core.commands.ExecutionEvent; |
| 30 import org.eclipse.core.commands.ExecutionException; | 30 import org.eclipse.core.commands.ExecutionException; |
| 31 import org.eclipse.core.resources.IFile; | 31 import org.eclipse.core.resources.IFile; |
| 32 import org.eclipse.core.resources.IWorkspaceRunnable; | 32 import org.eclipse.core.resources.IWorkspaceRunnable; |
| 33 import org.eclipse.core.runtime.CoreException; | 33 import org.eclipse.core.runtime.CoreException; |
| 34 import org.eclipse.core.runtime.IPath; | 34 import org.eclipse.core.runtime.IPath; |
| 35 import org.eclipse.core.runtime.IProgressMonitor; | 35 import org.eclipse.core.runtime.IProgressMonitor; |
| 36 import org.eclipse.core.runtime.NullProgressMonitor; | 36 import org.eclipse.core.runtime.NullProgressMonitor; |
| 37 import org.eclipse.core.runtime.Path; | 37 import org.eclipse.core.runtime.Path; |
| 38 import org.eclipse.jface.dialogs.IDialogSettings; | 38 import org.eclipse.jface.dialogs.IDialogSettings; |
| 39 import org.eclipse.jface.dialogs.MessageDialog; |
| 39 import org.eclipse.swt.SWT; | 40 import org.eclipse.swt.SWT; |
| 40 import org.eclipse.swt.widgets.FileDialog; | 41 import org.eclipse.swt.widgets.FileDialog; |
| 41 import org.eclipse.swt.widgets.Shell; | 42 import org.eclipse.swt.widgets.Shell; |
| 42 import org.eclipse.ui.PartInitException; | 43 import org.eclipse.ui.PartInitException; |
| 43 import org.eclipse.ui.PlatformUI; | 44 import org.eclipse.ui.PlatformUI; |
| 44 import org.eclipse.ui.handlers.HandlerUtil; | 45 import org.eclipse.ui.handlers.HandlerUtil; |
| 45 | 46 |
| 46 import java.io.File; | 47 import java.io.File; |
| 47 import java.lang.reflect.InvocationTargetException; | 48 import java.lang.reflect.InvocationTargetException; |
| 48 | 49 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 if (file.getProject().equals(libFile[0].getDartProject().getPr
oject())) { | 93 if (file.getProject().equals(libFile[0].getDartProject().getPr
oject())) { |
| 93 files[0] = file; | 94 files[0] = file; |
| 94 } | 95 } |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 monitor.done(); | 98 monitor.done(); |
| 98 } | 99 } |
| 99 })); // workspace lock | 100 })); // workspace lock |
| 100 | 101 |
| 101 } catch (InvocationTargetException e) { | 102 } catch (InvocationTargetException e) { |
| 102 ExceptionHandler.handle(e, shell, ActionMessages.FormatAllAction_error_tit
le, | 103 ExceptionHandler.handle(e, shell, HandlerMessages.OpenFile_label, |
| 103 ActionMessages.FormatAllAction_error_message); | 104 HandlerMessages.OpenFile_errorMessage); |
| 104 } catch (InterruptedException e) { | 105 } catch (InterruptedException e) { |
| 105 // canceled by user | 106 // canceled by user |
| 106 } | 107 } |
| 107 | 108 |
| 108 try { | 109 try { |
| 109 if (files[0] != null) { | 110 if (files[0] != null) { |
| 110 EditorUtility.openInEditor(files[0], true); | 111 EditorUtility.openInEditor(files[0], true); |
| 112 } else if (libFile[0] == null) { |
| 113 MessageDialog.openError(shell, HandlerMessages.OpenFile_label, |
| 114 Messages.format(HandlerMessages.OpenFile_errorFileNotInLibrary, sele
ctedFile.getName())); |
| 111 } | 115 } |
| 112 } catch (PartInitException e) { | 116 } catch (PartInitException e) { |
| 113 throwFailedToOpen(selectedFile, e); | 117 throwFailedToOpen(selectedFile, e); |
| 114 } catch (DartModelException e) { | 118 } catch (DartModelException e) { |
| 115 throwFailedToOpen(selectedFile, e); | 119 throwFailedToOpen(selectedFile, e); |
| 116 } | 120 } |
| 117 return null; | 121 return null; |
| 118 } | 122 } |
| 119 | 123 |
| 120 /** | 124 /** |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 if (result != null) { | 170 if (result != null) { |
| 167 settings.put(FILTER_PATH_KEY, dialog.getFilterPath()); | 171 settings.put(FILTER_PATH_KEY, dialog.getFilterPath()); |
| 168 } | 172 } |
| 169 return result; | 173 return result; |
| 170 } | 174 } |
| 171 | 175 |
| 172 private void throwFailedToOpen(File file, Exception e) throws ExecutionExcepti
on { | 176 private void throwFailedToOpen(File file, Exception e) throws ExecutionExcepti
on { |
| 173 throw new ExecutionException("Failed to open " + file, e); | 177 throw new ExecutionException("Failed to open " + file, e); |
| 174 } | 178 } |
| 175 } | 179 } |
| OLD | NEW |