[Pydev-cvs] org.python.pydev/src/org/python/pydev/editor/actions PyOpenAction.java,1.14,1.15
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2006-01-15 20:36:13
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14068/src/org/python/pydev/editor/actions Modified Files: PyOpenAction.java Log Message: Index: PyOpenAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyOpenAction.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyOpenAction.java 15 Jan 2006 00:25:11 -0000 1.14 --- PyOpenAction.java 15 Jan 2006 20:36:05 -0000 1.15 *************** *** 26,80 **** * Opens an editor and selects text in it. * ! * Inspired by org.eclipse.jdt.ui.actions.OpenAction, but simplifies ! * all handling in a single class. */ public class PyOpenAction extends Action { - - public IEditorPart editor; public PyOpenAction() { ! } ! ! private void showInEditor( ! ITextEditor textEdit, ! Location start, ! Location end) { ! try { ! IDocument doc = ! textEdit.getDocumentProvider().getDocument( ! textEdit.getEditorInput()); ! int s; ! s = start.toOffset(doc); ! int e = end == null ? s : end.toOffset(doc); ! TextSelection sel = new TextSelection(s, e - s); ! textEdit.getSelectionProvider().setSelection(sel); ! } catch (BadLocationException e1) { ! PydevPlugin.log(IStatus.ERROR, "Error setting selection", e1); ! } ! } ! ! public void run(ItemPointer p) { ! editor = null; ! Object file = p.file; ! ! ! if (file instanceof IFile){ ! IPath fullPath = ((IFile)file).getFullPath(); ! editor = PydevPlugin.doOpenEditor(fullPath, true); ! ! }else if (file instanceof IPath) { ! IPath path = (IPath)file; editor = PydevPlugin.doOpenEditor(path, true); ! ! } else if (file instanceof File) { ! Path path = new Path(REF.getFileAbsolutePath((File)file)); ! editor = PydevPlugin.doOpenEditor(path, true); ! } ! ! if (editor instanceof ITextEditor && p.start.line >= 0) { ! showInEditor((ITextEditor)editor, p.start, p.end); ! } ! } } --- 26,70 ---- * Opens an editor and selects text in it. * ! * Inspired by org.eclipse.jdt.ui.actions.OpenAction, but simplifies all handling in a single class. */ public class PyOpenAction extends Action { + public IEditorPart editor; public PyOpenAction() { ! } ! public void showInEditor(ITextEditor textEdit, Location start, Location end) { ! try { ! IDocument doc = textEdit.getDocumentProvider().getDocument(textEdit.getEditorInput()); ! int s = start.toOffset(doc); ! int e = end == null ? s : end.toOffset(doc); ! TextSelection sel = new TextSelection(s, e - s); ! textEdit.getSelectionProvider().setSelection(sel); ! } catch (BadLocationException e1) { ! PydevPlugin.log(IStatus.ERROR, "Error setting selection", e1); ! } ! } ! ! public void run(ItemPointer p) { ! editor = null; ! Object file = p.file; ! ! if (file instanceof IFile) { ! IPath fullPath = ((IFile) file).getFullPath(); ! editor = PydevPlugin.doOpenEditor(fullPath, true); ! ! } else if (file instanceof IPath) { ! IPath path = (IPath) file; editor = PydevPlugin.doOpenEditor(path, true); ! ! } else if (file instanceof File) { ! Path path = new Path(REF.getFileAbsolutePath((File) file)); ! editor = PydevPlugin.doOpenEditor(path, true); ! } ! ! if (editor instanceof ITextEditor && p.start.line >= 0) { ! showInEditor((ITextEditor) editor, p.start, p.end); ! } ! } } |