1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 11:25:35 +02:00

2005-01-28 David Inglis

Implement Eclipse 3.0 Next/Prev Annonation retargetable actions for  CEditor with Problems
	view highlighting.
This commit is contained in:
David Inglis 2005-01-28 20:40:32 +00:00
parent a7df99552f
commit 1321b32353
15 changed files with 431 additions and 122 deletions

View file

@ -1,3 +1,26 @@
2005-01-28 David Inglis
Implement Eclipse 3.0 Next/Prev Annonation retargetable actions for CEditor with Problems
view highlighting.
* plugin.xml
* src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
* src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
* src/org/eclipse/cdt/internal/ui/editor/CEditor.java
* src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
* src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
+ src/org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.java
- icons/full/ctool16/next_error_nav.gif
- icons/full/ctool16/prev_error_nav.gif
- icons/full/dtool16/next_error_nav.gif
- icons/full/dtool16/prev_error_nav.gif
- icons/full/etool16/next_error_nav.gif
- icons/full/etool16/prev_error_nav.gif
- src/org/eclipse/cdt/internal/ui/editor/GotoErrorAction.java
2005-01-26 Alain Magloire
Part of implementing PR 83112
* src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

View file

@ -1053,6 +1053,12 @@
id="org.eclipse.search.SearchResultView">
</part>
</actionSetPartAssociation>
<actionSetPartAssociation
targetID="org.eclipse.ui.edit.text.actionSet.annotationNavigation">
<part
id="org.eclipse.cdt.ui.editor.CEditor">
</part>
</actionSetPartAssociation>
</extension>
<extension
point="org.eclipse.cdt.ui.BinaryParserPage">
@ -1108,7 +1114,13 @@
textPreferenceValue="true"
textPreferenceKey="indexResultIndication"
verticalRulerPreferenceKey="indexResultIndicationInVerticalRuler"
overviewRulerPreferenceKey="indexResultIndicationInOverviewRuler">
overviewRulerPreferenceKey="indexResultIndicationInOverviewRuler"
showInNextPrevDropdownToolbarActionKey="isIndexResultInNextPrevDropdownToolbarAction"
showInNextPrevDropdownToolbarAction="true"
isGoToNextNavigationTargetKey="isIndexResultGoToNextNavigationTarget"
isGoToNextNavigationTarget="false"
isGoToPreviousNavigationTargetKey="isIndexResultGoToPreviousNavigationTarget"
isGoToPreviousNavigationTarget="false">
</specification>
</extension>
<extension

View file

@ -36,6 +36,8 @@ public interface ICHelpContextIds {
public static final String PREVIOUS_CHANGE_ACTION=PREFIX + "previous_change_action"; //$NON-NLS-1$
public static final String NEXT_PROBLEM_ACTION= PREFIX + "next_problem_action"; //$NON-NLS-1$
public static final String PREVIOUS_PROBLEM_ACTION= PREFIX + "previous_problem_action"; //$NON-NLS-1$
public static final String GOTO_NEXT_ERROR_ACTION= PREFIX + "goto_next_error_action"; //$NON-NLS-1$
public static final String GOTO_PREVIOUS_ERROR_ACTION= PREFIX + "goto_previous_error_action"; //$NON-NLS-1$
// Preference/property pages
public static final String C_PREF_PAGE = PREFIX + "c_pref"; //$NON-NLS-1$

View file

@ -403,6 +403,39 @@ public class CDocumentProvider extends TextFileDocumentProvider {
return super.createMarkerAnnotation(marker);
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#createPositionFromMarker(org.eclipse.core.resources.IMarker)
*/
protected Position createPositionFromMarker(IMarker marker) {
int start= MarkerUtilities.getCharStart(marker);
int end= MarkerUtilities.getCharEnd(marker);
if (start > end) {
end= start + end;
start= end - start;
end= end - start;
}
if (start == -1 && end == -1) {
// marker line number is 1-based
int line= MarkerUtilities.getLineNumber(marker);
if (line > 0 && fDocument != null) {
try {
start= fDocument.getLineOffset(line - 1);
String ld = fDocument.getLineDelimiter(line - 1);
int lineDelimiterLegnth = ld != null ? ld.length(): 0;
end= fDocument.getLineLength(line - 1) + start - lineDelimiterLegnth;
} catch (BadLocationException x) {
}
}
}
if (start > -1 && end > -1)
return new Position(start, end - start);
return null;
}
/*
* @see org.eclipse.jface.text.source.AnnotationModel#createAnnotationModelEvent()
*/

View file

@ -5,6 +5,8 @@ package org.eclipse.cdt.internal.ui.editor;
* All Rights Reserved.
*/
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Iterator;
import org.eclipse.cdt.core.CCorePlugin;
@ -75,7 +77,6 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
@ -88,11 +89,11 @@ import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.EditorActionBarContributor;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.IDocumentProvider;
@ -104,7 +105,6 @@ import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.ui.views.tasklist.TaskList;
/**
@ -112,6 +112,30 @@ import org.eclipse.ui.views.tasklist.TaskList;
*/
public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource , IReconcilingParticipant{
/**
* Updates the Java outline page selection and this editor's range indicator.
*
* @since 3.0
*/
private class EditorSelectionChangedListener extends AbstractSelectionChangedListener {
/*
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
public void selectionChanged(SelectionChangedEvent event) {
// XXX: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=56161
CEditor.this.selectionChanged();
}
}
/**
* The editor selection changed listener.
*
* @since 3.0
*/
private EditorSelectionChangedListener fEditorSelectionChangedListener;
/** The outline page */
protected CContentOutlinePage fOutlinePage;
@ -169,6 +193,16 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
*/
private FoldingActionGroup fFoldingGroup;
/**
* Indicates whether this editor is about to update any annotation views.
* @since 3.0
*/
private boolean fIsUpdatingAnnotationViews= false;
/**
* The marker that served as last target for a goto marker request.
* @since 3.0
*/
private IMarker fLastMarkerTarget= null;
private class PropertyChangeListener implements org.eclipse.core.runtime.Preferences.IPropertyChangeListener, org.eclipse.jface.util.IPropertyChangeListener {
/*
@ -353,6 +387,21 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
}
}
/**
* React to changed selection.
*
* @since 3.0
*/
protected void selectionChanged() {
if (getSelectionProvider() == null)
return;
// ISourceReference element= computeHighlightRangeSourceReference();
// if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
// synchronizeOutlinePage(element);
// setSelection(element, false);
updateStatusLine();
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
@ -550,6 +599,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
fSelectionSearchGroup = null;
}
if (fEditorSelectionChangedListener != null) {
fEditorSelectionChangedListener.uninstall(getSelectionProvider());
fEditorSelectionChangedListener= null;
}
stopTabConversion();
disableBrowserLikeLinks();
@ -735,22 +789,10 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
WorkbenchHelp.setHelp(parent, ICHelpContextIds.CEDITOR_VIEW);
fSelectionUpdateListener = new ISelectionChangedListener() {
private Runnable fRunnable = new Runnable() {
public void run() {
updateStatusField(CTextEditorActionConstants.STATUS_CURSOR_POS);
}
};
private Display fDisplay;
fEditorSelectionChangedListener= new EditorSelectionChangedListener();
fEditorSelectionChangedListener.install(getSelectionProvider());
public void selectionChanged(SelectionChangedEvent event) {
if (fDisplay == null)
fDisplay = getSite().getShell().getDisplay();
fDisplay.asyncExec(fRunnable);
}
};
getSelectionProvider().addSelectionChangedListener(fSelectionUpdateListener);
if (isTabConversionEnabled())
startTabConversion();
@ -807,44 +849,219 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
return nextError;
}
public void gotoError(boolean forward) {
ISelectionProvider provider = getSelectionProvider();
if (fStatusLineClearer != null) {
provider.removeSelectionChangedListener(fStatusLineClearer);
fStatusLineClearer = null;
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#gotoMarker(org.eclipse.core.resources.IMarker)
*/
public void gotoMarker(IMarker marker) {
fLastMarkerTarget= marker;
if (!fIsUpdatingAnnotationViews) {
super.gotoMarker(marker);
}
}
ITextSelection s = (ITextSelection) provider.getSelection();
IMarker nextError = getNextError(s.getOffset(), forward);
if (nextError != null) {
IDE.gotoMarker(this, nextError);
IWorkbenchPage page = getSite().getPage();
IViewPart view = view = page.findView("org.eclipse.ui.views.TaskList"); //$NON-NLS-1$
if (view instanceof TaskList) {
StructuredSelection ss = new StructuredSelection(nextError);
((TaskList) view).setSelection(ss, true);
/**
* Jumps to the next enabled annotation according to the given direction.
* An annotation type is enabled if it is configured to be in the
* Next/Previous tool bar drop down menu and if it is checked.
*
* @param forward <code>true</code> if search direction is forward, <code>false</code> if backward
*/
public void gotoAnnotation(boolean forward) {
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Position position= new Position(0, 0);
if (false /* delayed - see bug 18316 */) {
getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
selectAndReveal(position.getOffset(), position.getLength());
} else /* no delay - see bug 18316 */ {
Annotation annotation= getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
setStatusLineErrorMessage(null);
setStatusLineMessage(null);
if (annotation != null) {
updateAnnotationViews(annotation);
selectAndReveal(position.getOffset(), position.getLength());
setStatusLineMessage(annotation.getText());
}
}
}
getStatusLineManager().setErrorMessage(nextError.getAttribute(IMarker.MESSAGE, "")); //$NON-NLS-1$
fStatusLineClearer = new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
getSelectionProvider().removeSelectionChangedListener(fStatusLineClearer);
fStatusLineClearer = null;
getStatusLineManager().setErrorMessage(""); //$NON-NLS-1$
/**
* Returns whether the given annotation is configured as a target for the
* "Go to Next/Previous Annotation" actions
*
* @param annotation the annotation
* @return <code>true</code> if this is a target, <code>false</code>
* otherwise
* @since 3.0
*/
private boolean isNavigationTarget(Annotation annotation) {
Preferences preferences= EditorsUI.getPluginPreferences();
AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
// See bug 41689
// String key= forward ? preference.getIsGoToNextNavigationTargetKey() : preference.getIsGoToPreviousNavigationTargetKey();
String key= preference == null ? null : preference.getIsGoToNextNavigationTargetKey();
return (key != null && preferences.getBoolean(key));
}
/**
* Returns the annotation closest to the given range respecting the given
* direction. If an annotation is found, the annotations current position
* is copied into the provided annotation position.
*
* @param offset the region offset
* @param length the region length
* @param forward <code>true</code> for forwards, <code>false</code> for backward
* @param annotationPosition the position of the found annotation
* @return the found annotation
*/
private Annotation getNextAnnotation(final int offset, final int length, boolean forward, Position annotationPosition) {
Annotation nextAnnotation= null;
Position nextAnnotationPosition= null;
Annotation containingAnnotation= null;
Position containingAnnotationPosition= null;
boolean currentAnnotation= false;
IDocument document= getDocumentProvider().getDocument(getEditorInput());
int endOfDocument= document.getLength();
int distance= Integer.MAX_VALUE;
IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
Iterator e= new CAnnotationIterator(model, true, true);
while (e.hasNext()) {
Annotation a= (Annotation) e.next();
if ((a instanceof ICAnnotation) && ((ICAnnotation)a).hasOverlay() || !isNavigationTarget(a))
continue;
Position p= model.getPosition(a);
if (p == null)
continue;
if (forward && p.offset == offset || !forward && p.offset + p.getLength() == offset + length) {// || p.includes(offset)) {
if (containingAnnotation == null || (forward && p.length >= containingAnnotationPosition.length || !forward && p.length >= containingAnnotationPosition.length)) {
containingAnnotation= a;
containingAnnotationPosition= p;
currentAnnotation= (p.length == length) || (p.length - 1 == length);
}
};
provider.addSelectionChangedListener(fStatusLineClearer);
} else {
getStatusLineManager().setErrorMessage(""); //$NON-NLS-1$
int currentDistance= 0;
if (forward) {
currentDistance= p.getOffset() - offset;
if (currentDistance < 0)
currentDistance= endOfDocument + currentDistance;
if (currentDistance < distance || currentDistance == distance && p.length < nextAnnotationPosition.length) {
distance= currentDistance;
nextAnnotation= a;
nextAnnotationPosition= p;
}
} else {
currentDistance= offset + length - (p.getOffset() + p.length);
if (currentDistance < 0)
currentDistance= endOfDocument + currentDistance;
if (currentDistance < distance || currentDistance == distance && p.length < nextAnnotationPosition.length) {
distance= currentDistance;
nextAnnotation= a;
nextAnnotationPosition= p;
}
}
}
}
if (containingAnnotationPosition != null && (!currentAnnotation || nextAnnotation == null)) {
annotationPosition.setOffset(containingAnnotationPosition.getOffset());
annotationPosition.setLength(containingAnnotationPosition.getLength());
return containingAnnotation;
}
if (nextAnnotationPosition != null) {
annotationPosition.setOffset(nextAnnotationPosition.getOffset());
annotationPosition.setLength(nextAnnotationPosition.getLength());
}
return nextAnnotation;
}
protected void updateStatusLine() {
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Annotation annotation= getAnnotation(selection.getOffset(), selection.getLength());
setStatusLineErrorMessage(null);
setStatusLineMessage(null);
if (annotation != null) {
try {
fIsUpdatingAnnotationViews= true;
updateAnnotationViews(annotation);
} finally {
fIsUpdatingAnnotationViews= false;
}
if (annotation instanceof ICAnnotation && ((ICAnnotation) annotation).isProblem())
setStatusLineMessage(annotation.getText());
}
}
/**
* Updates the annotation views that show the given annotation.
*
* @param annotation the annotation
*/
private void updateAnnotationViews(Annotation annotation) {
IMarker marker= null;
if (annotation instanceof MarkerAnnotation)
marker= ((MarkerAnnotation) annotation).getMarker();
else if (annotation instanceof ICAnnotation) {
Iterator e= ((ICAnnotation) annotation).getOverlaidIterator();
if (e != null) {
while (e.hasNext()) {
Object o= e.next();
if (o instanceof MarkerAnnotation) {
marker= ((MarkerAnnotation) o).getMarker();
break;
}
}
}
}
if (marker != null && !marker.equals(fLastMarkerTarget)) {
try {
boolean isProblem= marker.isSubtypeOf(IMarker.PROBLEM);
IWorkbenchPage page= getSite().getPage();
IViewPart view= page.findView(isProblem ? IPageLayout.ID_PROBLEM_VIEW: IPageLayout.ID_TASK_LIST); //$NON-NLS-1$ //$NON-NLS-2$
if (view != null) {
Method method= view.getClass().getMethod("setSelection", new Class[] { IStructuredSelection.class, boolean.class}); //$NON-NLS-1$
method.invoke(view, new Object[] {new StructuredSelection(marker), Boolean.TRUE });
}
} catch (CoreException x) {
} catch (NoSuchMethodException x) {
} catch (IllegalAccessException x) {
} catch (InvocationTargetException x) {
}
// ignore exceptions, don't update any of the lists, just set status line
}
}
/**
* Returns the annotation overlapping with the given range or <code>null</code>.
*
* @param offset the region offset
* @param length the region length
* @return the found annotation or <code>null</code>
* @since 3.0
*/
private Annotation getAnnotation(int offset, int length) {
IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
Iterator e= new CAnnotationIterator(model, true, true);
while (e.hasNext()) {
Annotation a= (Annotation) e.next();
if (!isNavigationTarget(a))
continue;
Position p= model.getPosition(a);
if (p != null && p.overlapsWith(offset, length))
return a;
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.ui.part.IShowInSource#getShowInContext()
*
@ -1119,6 +1336,18 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
}
/**
* Sets the given message as message to this editor's status line.
*
* @param msg message to be set
* @since 3.0
*/
protected void setStatusLineMessage(String msg) {
IEditorStatusLine statusLine= (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
if (statusLine != null)
statusLine.setMessage(false, msg, null);
}
/**
* Enables browser like links, requires disable to clean up
*/

View file

@ -9,19 +9,22 @@ import java.util.ResourceBundle;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.editors.text.TextEditorActionContributor;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.RetargetTextEditorAction;
import org.eclipse.ui.texteditor.TextEditorAction;
@ -87,9 +90,8 @@ public class CEditorActionContributor extends TextEditorActionContributor {
protected SelectionAction fShiftLeft;
protected SelectionAction fShiftRight;
private TogglePresentationAction fTogglePresentation;
//private ToggleTextHoverAction fToggleTextHover;
private GotoErrorAction fPreviousError;
private GotoErrorAction fNextError;
private GotoAnnotationAction fPreviousAnnotation;
private GotoAnnotationAction fNextAnnotation;
public CEditorActionContributor() {
@ -122,13 +124,10 @@ public class CEditorActionContributor extends TextEditorActionContributor {
//fToggleTextHover= new ToggleTextHoverAction();
fPreviousError= new GotoErrorAction("PreviousError.", false); //$NON-NLS-1$
fPreviousError.setActionDefinitionId("org.eclipse.ui.navigate.previous"); //$NON-NLS-1$
CPluginImages.setImageDescriptors(fPreviousError, CPluginImages.T_TOOL, CPluginImages.IMG_TOOL_GOTO_PREV_ERROR);
fPreviousAnnotation= new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
fNextAnnotation= new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
fNextError= new GotoErrorAction("NextError.", true); //$NON-NLS-1$
fNextError.setActionDefinitionId("org.eclipse.ui.navigate.next"); //$NON-NLS-1$
CPluginImages.setImageDescriptors(fNextError, CPluginImages.T_TOOL, CPluginImages.IMG_TOOL_GOTO_NEXT_ERROR);
//fToggleTextHover= new ToggleTextHoverAction();
}
@ -149,9 +148,9 @@ public class CEditorActionContributor extends TextEditorActionContributor {
editMenu.add(fShiftRight);
editMenu.add(fShiftLeft);
editMenu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
editMenu.add(fNextError);
editMenu.add(fPreviousError);
// editMenu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
// editMenu.add(fNextError);
// editMenu.add(fPreviousError);
editMenu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fContentAssist);
@ -166,18 +165,15 @@ public class CEditorActionContributor extends TextEditorActionContributor {
*/
public void init(IActionBars bars) {
super.init(bars);
// register actions that have a dynamic editor.
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation);
bars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, fNextAnnotation);
bars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, fPreviousAnnotation);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
}
/**
* @see EditorActionBarContributor#contributeToToolBar(IToolBarManager)
*/
public void contributeToToolBar(IToolBarManager tbm) {
super.contributeToToolBar(tbm);
tbm.add(new Separator());
tbm.add(fNextError);
tbm.add(fPreviousError);
}
/**
* @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
@ -192,9 +188,9 @@ public class CEditorActionContributor extends TextEditorActionContributor {
fShiftRight.setEditor(textEditor);
fShiftLeft.setEditor(textEditor);
fNextError.setEditor(textEditor);
fPreviousError.setEditor(textEditor);
fTogglePresentation.setEditor(textEditor);
fPreviousAnnotation.setEditor(textEditor);
fNextAnnotation.setEditor(textEditor);
//caAction.setEditor(textEditor);
//caAction.update();

View file

@ -145,6 +145,14 @@ ShiftLeft.label=S&hift Left@Ctrl+Shift+I
ShiftLeft.tooltip=Shift Left
ShiftLeft.description=Shift the selected text to the left
NextAnnotation.label= Ne&xt Annotation
NextAnnotation.tooltip= Next Annotation
NextAnnotation.description= Next Annotation
PreviousAnnotation.label= Pre&vious Annotation
PreviousAnnotation.tooltip= Previous Annotation
PreviousAnnotation.description= Previous Annotation
CompilationUnitDocumentProvider.error.createElementInfo=CompilationUnitDocumentProvider.createElementInfo
CompilationUnitDocumentProvider.out_of_sync.message=Compilation unit buffer and document are out of sync

View file

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
public class GotoAnnotationAction extends TextEditorAction {
private boolean fForward;
public GotoAnnotationAction(String prefix, boolean forward) {
super(CEditorMessages.getResourceBundle(), prefix, null);
fForward= forward;
if (forward)
WorkbenchHelp.setHelp(this, ICHelpContextIds.GOTO_NEXT_ERROR_ACTION);
else
WorkbenchHelp.setHelp(this, ICHelpContextIds.GOTO_PREVIOUS_ERROR_ACTION);
}
public void run() {
CEditor e= (CEditor) getTextEditor();
e.gotoAnnotation(fForward);
}
public void setEditor(ITextEditor editor) {
if (editor instanceof CEditor)
super.setEditor(editor);
update();
}
public void update() {
setEnabled(getTextEditor() instanceof CEditor);
}
}

View file

@ -1,42 +0,0 @@
package org.eclipse.cdt.internal.ui.editor;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
public class GotoErrorAction extends TextEditorAction {
private boolean fForward;
public GotoErrorAction(String prefix, boolean forward) {
super(CEditorMessages.getResourceBundle(), prefix, null);
fForward= forward;
}
/**
* @see Action#run()
*/
public void run() {
CEditor e= (CEditor) getTextEditor();
e.gotoError(fForward);
}
/**
* @see TextEditorAction#setEditor(ITextEditor)
*/
public void setEditor(ITextEditor editor) {
if (editor instanceof CEditor)
super.setEditor(editor);
}
/**
* @see TextEditorAction#update()
*/
public void update() {
setEnabled(true);
}
}