diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index e5034f2a314..e037b1365fe 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,3 +1,16 @@
+2005-02-016 Alain Magloire
+ PR 84423, Patch from : Tomaszewski Przemek
+ Added keybinding next/previous(CTRL-SHIFT-UP/DOWN) to from
+ member to member in the CEditor(PR 84423).
+
+ * NEWS
+ * plugin.properties
+ * plugin.xml
+ * src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+ * src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
+ * src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
+ * src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
+
2005-02-02 Bogdan Gheorghe
Added a delete IProblem Markers action to context menu to allow users to manually
remove problems reported by the parser during an index.
diff --git a/core/org.eclipse.cdt.ui/NEWS b/core/org.eclipse.cdt.ui/NEWS
index 2779570a8b9..a5597e9a0a0 100644
--- a/core/org.eclipse.cdt.ui/NEWS
+++ b/core/org.eclipse.cdt.ui/NEWS
@@ -1,5 +1,8 @@
Release CDT-3.0
+ * Added keybinding next/previous(CTRL-SHIFT-UP/DOWN) to move from
+ member to member in the CEditor(PR 84423).
+
* Drag && Drop support
for ICElement classes , in the C/C++ project view and C Outliner.
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index 160bdfde5e7..e2907033d94 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -170,6 +170,11 @@ CEditorFontDefinition.description = The C/C++ editor text font is used by C/C++
BuildConsoleFontDefinition.description= The C-Build console font is used by the C-Build console
BuildConsoleFontDefinition.label= C-Build Console Text Font
+ActionDefinition.GotoNextMember.name = Go to next C/C++ member
+ActionDefinition.GotoNextMember.description = Goes to the next C/C++ member
+ActionDefinition.GotoPrevMember.name = Go to previous C/C++ member
+ActionDefinition.GotoPrevMember.description = Goes to the previous C/C++ member
+
##########################################################################
# Filter Support
##########################################################################
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index c84b65bde54..b3d59c8510f 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -969,6 +969,30 @@
command="org.eclipse.cdt.ui.edit.open.outline"
configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+
+
+
+
+
+
+
+
offsets[i].intValue())
+ && (actualOffset < offsets[i + 1].intValue())) {
+ return offsets[i + 1].intValue();
+ }
+ }
+ return actualOffset;
+ }
+
+ /**
+ * Searches for previous offset within array of offsets.
+ * @param offsets Offsets to search.
+ * @param actualOffset Actual offset.
+ * @return Found offset or actual.
+ */
+ private static int getPreviousOffset(Integer[] offsets, int actualOffset) {
+ if (actualOffset > offsets[offsets.length - 1].intValue())
+ {
+ return offsets[offsets.length - 1].intValue();
+ }
+ for (int i = 1; i < offsets.length; i++) {
+ if (offsets[i].intValue() == actualOffset) {
+ return offsets[i - 1].intValue();
+ } else if ((actualOffset > offsets[i - 1].intValue())
+ && (actualOffset < offsets[i].intValue())) {
+ return offsets[i - 1].intValue();
+ }
+ }
+ return actualOffset;
+ }
+
+ /**
+ * Creates array in indexes from ICElements.
+ * @param elements Elements to retrieve needed data.
+ * @return indexes.
+ * @throws CModelException Thrown if source range not found.
+ */
+ private static Integer[] createSourceIndexes(ICElement[] elements) throws CModelException
+ {
+ final List indexesList = new LinkedList();
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i] instanceof ISourceReference) {
+ indexesList.add(new Integer(((ISourceReference) elements[i]).getSourceRange().getStartPos()));
+ }
+ }
+ //System.out.println("Indexes list:" + indexesList); //$NON-NLS-1$
+ final Integer[] indexes = new Integer[indexesList.size()];
+ indexesList.toArray(indexes);
+ return indexes;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
index 32cc3bb0b71..1eb113df067 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
@@ -1,9 +1,9 @@
-package org.eclipse.cdt.internal.ui.editor;
-
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
+package org.eclipse.cdt.internal.ui.editor;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -22,6 +22,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction;
import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup;
+import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
import org.eclipse.cdt.internal.ui.browser.typehierarchy.OpenTypeHierarchyAction;
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
@@ -119,7 +120,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
*/
private class EditorSelectionChangedListener extends AbstractSelectionChangedListener {
- /*
+ /**
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
public void selectionChanged(SelectionChangedEvent event) {
@@ -141,7 +142,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
/** Search actions **/
private ActionGroup fSelectionSearchGroup;
+ /** Groups refactoring actions. */
private ActionGroup fRefactoringActionGroup;
+ /** Action which shows selected element in CView. */
private ShowInCViewAction fShowInCViewAction;
/** Activity Listeners **/
@@ -153,9 +156,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
/** The mouse listener */
private MouseClickListener fMouseListener;
- protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
+ /** Pairs of brackets, used to match. */
+ protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
- protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
+ /** Matches the brackets. */
+ protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
/** The editor's tab converter */
private TabConverter fTabConverter;
@@ -163,9 +168,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
/** Listener to annotation model changes that updates the error tick in the tab image */
private CEditorErrorTickUpdater fCEditorErrorTickUpdater;
- /* Preference key for matching brackets */
+ /** Preference key for matching brackets */
public final static String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
- /* Preference key for matching brackets color */
+ /** Preference key for matching brackets color */
public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
/** Preference key for inserting spaces rather than tabs */
public final static String SPACES_FOR_TABS = "spacesForTabs"; //$NON-NLS-1$
@@ -204,13 +209,19 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
*/
private IMarker fLastMarkerTarget= null;
+ /**
+ * Handles property changes.
+ */
private class PropertyChangeListener implements org.eclipse.core.runtime.Preferences.IPropertyChangeListener, org.eclipse.jface.util.IPropertyChangeListener {
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ /**
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
handlePreferencePropertyChanged(event);
}
+ /**
+ * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
+ */
public void propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
handlePreferencePropertyChanged(new org.eclipse.jface.util.PropertyChangeEvent(event.getSource(), event.getProperty(), event.getOldValue(), event.getNewValue()));
}
@@ -223,7 +234,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
super();
}
- /* (non-Javadoc)
+ /**
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor()
*/
protected void initializeEditor() {
@@ -244,7 +255,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);
}
- /* (non-Javadoc)
+ /**
* @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
*/
protected void doSetInput(IEditorInput input) throws CoreException {
@@ -257,7 +268,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
}
/**
- * Update the title image
+ * Update the title image.
+ * @param image Title image.
*/
public void updatedTitleImage(Image image) {
setTitleImage(image);
@@ -265,6 +277,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
/**
* Gets the current input
+ * @return IFile Input file.
*/
public IFile getInputFile() {
IEditorInput editorInput = getEditorInput();
@@ -276,11 +289,15 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
return null;
}
- public boolean isSaveAsAllowed() {
+ /**
+ * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
+ */
+ public boolean isSaveAsAllowed() {
return true;
}
/**
- * Gets the outline page of the c-editor
+ * Gets the outline page of the c-editor.
+ * @return Outline page.
*/
public CContentOutlinePage getOutlinePage() {
if (fOutlinePage == null) {
@@ -291,7 +308,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
return fOutlinePage;
}
- /* (non-Javadoc)
+ /**
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class required) {
@@ -402,7 +419,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
updateStatusLine();
}
- /* (non-Javadoc)
+ /**
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
public void selectionChanged(SelectionChangedEvent event) {
@@ -417,12 +434,17 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
setSelection(range, !isActivePart());
}
} catch (CModelException e) {
+ // Selection change not applied.
}
}
}
}
- public void setSelection(ICElement element) {
+ /**
+ * Sets selection for C element.
+ * @param element Element to select.
+ */
+ public void setSelection(ICElement element) {
if (element == null || element instanceof ITranslationUnit) {
/*
@@ -445,7 +467,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
}
}
- public void setSelection(ISourceReference element, boolean moveCursor) {
+ /**
+ * Sets selection for source reference.
+ * @param element Source reference to set.
+ * @param moveCursor Should cursor be moved.
+ */
+ public void setSelection(ISourceReference element, boolean moveCursor) {
if (element != null) {
StyledText textWidget= null;
@@ -459,6 +486,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
try {
setSelection(element.getSourceRange(), moveCursor);
} catch (CModelException e) {
+ // Selection not applied.
}
}
}
@@ -524,20 +552,29 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
}
return;
} catch (IllegalArgumentException x) {
+ // No information to the user
} catch (BadLocationException e) {
+ // No information to the user
}
if (moveCursor)
resetHighlightRange();
}
- private boolean isActivePart() {
+ /**
+ * Checks is the editor active part.
+ * @return true
if editor is the active part of the workbench.
+ */
+ private boolean isActivePart() {
IWorkbenchWindow window = getSite().getWorkbenchWindow();
IPartService service = window.getPartService();
return (this == service.getActivePart());
}
- public void dispose() {
+ /**
+ * @see org.eclipse.ui.IWorkbenchPart#dispose()
+ */
+ public void dispose() {
if (fProjectionModelUpdater != null) {
fProjectionModelUpdater.uninstall();
@@ -610,7 +647,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
super.dispose();
}
- /* (non-Javadoc)
+ /**
* @see org.eclipse.ui.texteditor.AbstractTextEditor#canHandleMove(org.eclipse.ui.IEditorInput, org.eclipse.ui.IEditorInput)
*/
protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
@@ -640,6 +677,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
return oldLanguage.equals(newLanguage);
}
+ /**
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions()
+ */
protected void createActions() {
super.createActions();
@@ -706,7 +746,15 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_OUTLINE);
setAction("OpenOutline", action); //$NON-NLS-1$*/
- //Assorted action groupings
+ action = new GoToNextPreviousMemberAction(CEditorMessages.getResourceBundle(), "GotoNextMemeber.", this, true);
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
+ setAction("GotoNextMember", action); //$NON-NLS-1$*/
+
+ action = new GoToNextPreviousMemberAction(CEditorMessages.getResourceBundle(), "GotoPrevMemeber.", this, false);
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
+ setAction("GotoPrevMember", action); //$NON-NLS-1$*/
+
+ //Assorted action groupings
fSelectionSearchGroup = new SelectionSearchGroup(this);
fRefactoringActionGroup = new RefactoringActionGroup(this, null);
@@ -716,6 +764,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
}
+ /**
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
+ */
public void editorContextMenuAboutToShow(IMenuManager menu) {
super.editorContextMenuAboutToShow(menu);
@@ -732,6 +783,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenDeclarations"); //$NON-NLS-1$
addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenTypeHierarchy"); //$NON-NLS-1$
+ addAction(menu, ITextEditorActionConstants.GROUP_FIND, "GotoNextMember"); //$NON-NLS-1$
+ addAction(menu, ITextEditorActionConstants.GROUP_FIND, "GotoPrevMember"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ContentAssistProposal"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "AddIncludeOnSelection"); //$NON-NLS-1$
@@ -744,13 +797,22 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
}
- public void setOutlinePageInput(CContentOutlinePage page, IEditorInput input) {
+ /**
+ * Sets an input for the outline page.
+ * @param page Page to set the input.
+ * @param input Input to set.
+ */
+ public static void setOutlinePageInput(CContentOutlinePage page, IEditorInput input) {
if (page != null) {
IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
page.setInput(manager.getWorkingCopy(input));
}
}
+ /**
+ * Determines is folding enabled.
+ * @return true
if folding is enabled, false
otherwise.
+ */
boolean isFoldingEnabled() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
}
@@ -764,6 +826,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
* We attach our own mouseDown listener on the menu bar,
* and our own listener for cursor/key/selection events to update cursor position in
* status bar.
+
+ * @param parent Parent composite of the control.
*/
public void createPartControl(Composite parent) {
super.createPartControl(parent);
@@ -804,6 +868,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
preferences.addPropertyChangeListener(fPropertyChangeListener);
}
+ /**
+ * Returns a next error in the editor.
+ * @param offset Offset to start check.
+ * @param forward Do check forward.
+ * @return Found error marker or null
.
+ */
private IMarker getNextError(int offset, boolean forward) {
IMarker nextError = null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
index 3dc337baa4a..0ccb361cf61 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
@@ -170,3 +170,10 @@ CEditor.menu.search=Search
EditorUtility.concatModifierStrings= {0} + {1}
OpenOnSelection.label=Open On Selection
+
+GotoNextMemeber.description=Goes to next member
+GotoNextMemeber.label=Go to &next member
+GotoNextMemeber.tooltip=Goes to next member
+GotoPrevMemeber.description=Goes to previous member
+GotoPrevMemeber.label=Go to &previous member
+GotoPrevMemeber.tooltip=Goes to previous member.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
index f8376c99385..4c6d5f79ea5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
@@ -101,7 +101,6 @@ public class CSourceViewer extends ProjectionViewer implements ITextViewerExtens
}
case SHOW_OUTLINE:
{
- System.out.println("Show outline operation called.");
fOutlinePresenter.showInformation();
return;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
index 66970f55567..2fbbdedbae1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
@@ -114,8 +114,20 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
public static final String OPEN_EDITOR= "org.eclipse.cdt.ui.edit.text.c.open.editor"; //$NON-NLS-1$
/**
- * Action definition ID of the open outline dialog.
+ * Action definition ID of the open quick outline.
* (value "org.eclipse.cdt.ui.edit.open.outline"
).
*/
public static final String OPEN_OUTLINE= "org.eclipse.cdt.ui.edit.open.outline"; //$NON-NLS-1$
+
+ /**
+ * Action definition ID for go to next c member.
+ * (value "org.eclipse.cdt.ui.edit.text.c.goto.next.memeber"
)
+ */
+ public static final String GOTO_NEXT_MEMBER = "org.eclipse.cdt.ui.edit.text.c.goto.next.member"; //$NON-NLS-1$
+
+ /**
+ * Action definition ID for go to previous c member.
+ * (value "org.eclipse.cdt.ui.edit.text.c.goto.prev.memeber"
)
+ */
+ public static final String GOTO_PREVIOUS_MEMBER = "org.eclipse.cdt.ui.edit.text.c.goto.prev.member"; //$NON-NLS-1$
}