mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +02:00
Added a delete IProblem Markers action to context menu to allow users to manually
remove problems reported by the parser during an index.
This commit is contained in:
parent
1854217589
commit
88f6cff423
4 changed files with 114 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
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.
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.java
|
||||||
|
* plugin.xml
|
||||||
|
* plugin.properties
|
||||||
|
|
||||||
2005-01-29 Alain Magloire
|
2005-01-29 Alain Magloire
|
||||||
Fix for 81403: Move the Code Assist preference page
|
Fix for 81403: Move the Code Assist preference page
|
||||||
out of the CEditor preference page. It clean the CEditorPreferencePage
|
out of the CEditor preference page. It clean the CEditorPreferencePage
|
||||||
|
|
|
@ -123,6 +123,7 @@ CFolderActionSet.description=C Folder Action Set
|
||||||
|
|
||||||
# Task Action
|
# Task Action
|
||||||
DeleteTaskAction.label=Delete C/C++ Markers
|
DeleteTaskAction.label=Delete C/C++ Markers
|
||||||
|
DeleteIProblemMarkerAction.label=Delete IProblem Markers
|
||||||
|
|
||||||
# C/C++ Search
|
# C/C++ Search
|
||||||
CSearchPage.label= C/C++ Search
|
CSearchPage.label= C/C++ Search
|
||||||
|
|
|
@ -673,6 +673,19 @@
|
||||||
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
|
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
|
||||||
</action>
|
</action>
|
||||||
</viewerContribution>
|
</viewerContribution>
|
||||||
|
<objectContribution
|
||||||
|
objectClass="org.eclipse.core.resources.IMarker"
|
||||||
|
id="org.eclipse.cdt.ui.action.DeleteIProblemMarkers">
|
||||||
|
<action
|
||||||
|
label="%DeleteIProblemMarkerAction.label"
|
||||||
|
icon="icons/full/ovr16/error_co.gif"
|
||||||
|
class="org.eclipse.cdt.internal.ui.util.DeleteIProblemMarkerAction"
|
||||||
|
menubarPath="additions"
|
||||||
|
id="org.eclipse.cdt.ui.action.DeleteIProblemMarkers"/>
|
||||||
|
<filter
|
||||||
|
value="org.eclipse.cdt.core.indexermarker"
|
||||||
|
name="type"/>
|
||||||
|
</objectContribution>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.compare.structureCreators">
|
point="org.eclipse.compare.structureCreators">
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 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 - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.ui.IObjectActionDelegate;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.eclipse.ui.actions.ActionDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bogdan Gheorghe
|
||||||
|
*/
|
||||||
|
public class DeleteIProblemMarkerAction extends ActionDelegate implements IObjectActionDelegate {
|
||||||
|
|
||||||
|
private IStructuredSelection selection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ActionDelegate#run(IAction)
|
||||||
|
*/
|
||||||
|
public void run(IAction action) {
|
||||||
|
|
||||||
|
if (selection != null) {
|
||||||
|
if (selection.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
List list = selection.toList();
|
||||||
|
List listMarkers = new ArrayList();
|
||||||
|
Iterator iterator = list.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
IMarker marker = (IMarker)iterator.next();
|
||||||
|
if (marker.isSubtypeOf(ICModelMarker.INDEXER_MARKER)) {
|
||||||
|
listMarkers.add(marker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Bail out early
|
||||||
|
if (listMarkers.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IMarker[] markers = new IMarker[listMarkers.size()];
|
||||||
|
listMarkers.toArray(markers);
|
||||||
|
// be sure to only invoke one workspace operation
|
||||||
|
ResourcesPlugin.getWorkspace().deleteMarkers(markers);
|
||||||
|
selection = null;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
|
||||||
|
*/
|
||||||
|
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectionChanged(IAction action, ISelection selection) {
|
||||||
|
boolean enable = false;
|
||||||
|
if (selection instanceof IStructuredSelection) {
|
||||||
|
Object object = ((IStructuredSelection) selection).getFirstElement();
|
||||||
|
if (object instanceof IMarker) {
|
||||||
|
try {
|
||||||
|
IMarker marker = (IMarker) object;
|
||||||
|
if (marker.isSubtypeOf(ICModelMarker.INDEXER_MARKER)) {
|
||||||
|
enable = true;
|
||||||
|
}
|
||||||
|
this.selection = (IStructuredSelection)selection;
|
||||||
|
action.setEnabled(enable);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue