Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 86600 Details for
Bug 204524
[KeyBindings] Jump between bookmarks with key shortcuts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Jump to Bookmark v02
jumpToBookmark-v02.txt (text/plain), 8.01 KB, created by
Paul Webster
on 2008-01-10 15:25:28 EST
(
hide
)
Description:
Jump to Bookmark v02
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2008-01-10 15:25:28 EST
Size:
8.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/plugin.xml,v >retrieving revision 1.255 >diff -u -r1.255 plugin.xml >--- plugin.xml 9 Jan 2008 16:49:16 -0000 1.255 >+++ plugin.xml 10 Jan 2008 20:22:51 -0000 >@@ -836,6 +836,19 @@ > id="org.eclipse.ui.ide.configureFilters" > name="%command.configureFilters.name"> > </command> >+ <command >+ categoryId="org.eclipse.ui.category.navigate" >+ defaultHandler="org.eclipse.ui.internal.ide.handlers.OpenBookmarkCommand" >+ description="%command.jumpToBookmark.description" >+ id="org.eclipse.ui.navigate.jumpToBookmark" >+ name="%command.jumpToBookmark.name"> >+ <commandParameter >+ id="jumpToBookmark.num" >+ name="%commandParameter.jumpToBookmark.name" >+ optional="false" >+ values="org.eclipse.ui.internal.ide.handlers.OpenBookmarkValues"> >+ </commandParameter> >+ </command> > </extension> > > <extension >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/plugin.properties,v >retrieving revision 1.124 >diff -u -r1.124 plugin.properties >--- plugin.properties 2 Jan 2008 21:38:57 -0000 1.124 >+++ plugin.properties 10 Jan 2008 20:22:51 -0000 >@@ -262,3 +262,8 @@ > Menu.Sort.mnemonic = S > Menu.SortBy.label = By Column > Menu.SortBy.mnemonic = B >+ >+ >+command.jumpToBookmark.description = Jump to the nth bookmark in the active editor >+command.jumpToBookmark.name = Jump To Bookmark >+commandParameter.jumpToBookmark.name = Bookmark Number >Index: src/org/eclipse/ui/internal/ide/handlers/MarkerComparator.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/ide/handlers/MarkerComparator.java >diff -N src/org/eclipse/ui/internal/ide/handlers/MarkerComparator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/ide/handlers/MarkerComparator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,23 @@ >+package org.eclipse.ui.internal.ide.handlers; >+ >+import java.util.Comparator; >+ >+import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.runtime.CoreException; >+ >+class MarkerComparator implements Comparator { >+ >+ public int compare(Object o1, Object o2) { >+ try { >+ Integer l1 = (Integer) (((IMarker)o1).getAttribute("lineNumber")); //$NON-NLS-1$ >+ Integer l2 = (Integer) (((IMarker)o2).getAttribute("lineNumber")); //$NON-NLS-1$ >+ >+ return l1.intValue() - l2.intValue(); >+ >+ } catch (CoreException e) { >+ } >+ >+ return 0; >+ } >+ >+} >Index: src/org/eclipse/ui/internal/ide/handlers/OpenBookmarkCommand.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/ide/handlers/OpenBookmarkCommand.java >diff -N src/org/eclipse/ui/internal/ide/handlers/OpenBookmarkCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/ide/handlers/OpenBookmarkCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,118 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.ide.handlers; >+ >+import java.util.Arrays; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.TextSelection; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IFileEditorInput; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * @since 3.4 >+ * >+ */ >+public class OpenBookmarkCommand extends AbstractHandler { >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IWorkbenchWindow window = PlatformUI.getWorkbench() >+ .getActiveWorkbenchWindow(); >+ >+ int bookmarkNumber = ((Event) event.getTrigger()).character - '1'; >+ >+ if (window == null) { >+ return null; >+ } >+ >+ IWorkbenchPage page = window.getActivePage(); >+ >+ if (page == null) { >+ return null; >+ } >+ >+ IEditorPart editor = page.getActiveEditor(); >+ if (editor == null) { >+ return null; >+ } >+ >+ if (!(editor instanceof AbstractDecoAbstractratedTextEditor)) { >+ return null; >+ } >+ >+ IEditorInput input = editor.getEditorInput(); >+ if (!(input instanceof IFileEditorInput)) { >+ return null; >+ } >+ >+ IFile file = ((IFileEditorInput) input).getFile(); >+ >+ IMarker[] markers; >+ try { >+ markers = file.findMarkers(IMarker.BOOKMARK, false, >+ IResource.DEPTH_ZERO); >+ } catch (CoreException e) { >+ return null; >+ } >+ >+ if (markers.length <= bookmarkNumber) { >+ return null; >+ } >+ >+ Arrays.sort(markers, new MarkerComparator()); >+ >+ IMarker marker = markers[bookmarkNumber]; >+ >+ Integer line; >+ try { >+ line = (Integer) marker.getAttribute("lineNumber"); //$NON-NLS-1$ >+ } catch (CoreException e) { >+ return null; >+ } >+ >+ AbstractDecoratedTextEditor textEditor = (AbstractDecoratedTextEditor) editor; >+ IDocument document = textEditor.getDocumentProvider() >+ .getDocument(input); >+ int offset; >+ try { >+ offset = document.getLineOffset(line.intValue() - 1); // markers >+ // have line >+ // numbers + >+ // 1 >+ } catch (BadLocationException e) { >+ return null; >+ } >+ >+ textEditor.getSelectionProvider().setSelection( >+ new TextSelection(offset, 0)); >+ >+ return null; >+ } >+} >Index: src/org/eclipse/ui/internal/ide/handlers/OpenBookmarkValues.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/ide/handlers/OpenBookmarkValues.java >diff -N src/org/eclipse/ui/internal/ide/handlers/OpenBookmarkValues.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/ide/handlers/OpenBookmarkValues.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,43 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.ide.handlers; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.commands.IParameterValues; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class OpenBookmarkValues implements IParameterValues { >+ private static Map values = null; >+ >+ private static Map getValues() { >+ if (values==null) { >+ values = new HashMap(); >+ for (int i=1; i<10; i++) { >+ values.put(Integer.toString(i), Integer.toString(i)); >+ } >+ } >+ return values; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.IParameterValues#getParameterValues() >+ */ >+ public Map getParameterValues() { >+ return getValues(); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 204524
:
79116
|
79117
| 86600