Java Code Examples for org.eclipse.core.resources.IMarkerDelta#getKind()

The following examples show how to use org.eclipse.core.resources.IMarkerDelta#getKind() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProblemManager.java    From typescript.java with MIT License 6 votes vote down vote up
private boolean isProblemDelta(IResourceDelta delta) {
	if ((delta.getFlags() & IResourceDelta.MARKERS) == 0) {
		return false;
	}
	for (IMarkerDelta markerDelta : delta.getMarkerDeltas()) {
		if (markerDelta.isSubtypeOf(IMarker.PROBLEM)) {

			// Detect added/removed problem markers
			int kind = markerDelta.getKind();
			if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED) {
				return true;
			}

			// Detect changes in problem marker severity
			int oldSeverity = markerDelta.getAttribute(IMarker.SEVERITY, -1);
			int newSeverity = markerDelta.getMarker().getAttribute(IMarker.SEVERITY, -1);
			if (newSeverity != oldSeverity) {
				return true;
			}
		}
	}
	return false;
}
 
Example 2
Source File: DefaultResourceChangeToIssueProcessor.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void dispatchMarkerDelta(final IMarkerDelta iMarkerDelta, final String elementID) {
	switch (iMarkerDelta.getKind()) {
		case IResourceDelta.ADDED :
			addSCTIssue(iMarkerDelta, elementID);
			break;
		case IResourceDelta.REMOVED :
			removeSCTIssue(iMarkerDelta, elementID);
			break;
		case IResourceDelta.CHANGED :
			removeSCTIssue(iMarkerDelta, elementID);
			addSCTIssue(iMarkerDelta, elementID);
			break;
		default :
			break;
	}
}
 
Example 3
Source File: ProblemMarkerManager.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private boolean isErrorDelta(IResourceDelta delta) {
    if ((delta.getFlags() & IResourceDelta.MARKERS) != 0) {
        IMarkerDelta[] markerDeltas = delta.getMarkerDeltas();
        for (int i = 0; i < markerDeltas.length; i++) {
            IMarkerDelta iMarkerDelta = markerDeltas[i];
            if (iMarkerDelta.isSubtypeOf(IMarker.PROBLEM)) {
                int kind = iMarkerDelta.getKind();
                if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED) {
                    return true;
                }
                int severity = iMarkerDelta.getAttribute(IMarker.SEVERITY, -1);
                int newSeverity = iMarkerDelta.getMarker().getAttribute(IMarker.SEVERITY, -1);
                if (newSeverity != severity) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 4
Source File: ResourceChangeListener.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {

    boolean postBuild = event.getType() == IResourceChangeEvent.POST_BUILD;
    boolean accepted = false;

    /*
     * gather all marker changes from the delta. be sure to do this in the
     * calling thread, as the delta is destroyed when this method returns
     */
    IMarkerDelta[] markerDeltas = event.findMarkerDeltas(FindBugsMarker.NAME, true);
    for (IMarkerDelta mdelta : markerDeltas) {
        IMarker marker = mdelta.getMarker();
        if (marker == null) {
            continue;
        }
        DeltaInfo deltaInfo = new DeltaInfo(marker, mdelta.getKind());
        if (BugContentProvider.DEBUG) {
            System.out.println("resource change for: " + deltaInfo);
        }

        accepted |= refreshJob.addToQueue(deltaInfo);
    }

    if (!accepted) {
        return;
    }

    if (postBuild) {
        scheduleRefreshJob(SHORT_DELAY);
    } else {
        // After some time do updates anyways
        scheduleRefreshJob(LONG_DELAY);
    }
}
 
Example 5
Source File: TimeChartView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
    for (IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) {
        for (TimeChartDecorationProvider provider : fDecorationProviders.values()) {
            if (delta.getResource().equals(provider.getBookmarksFile())) {
                if (delta.getKind() == IResourceDelta.REMOVED ||
                        delta.getMarker().getAttribute(IMarker.LOCATION, -1) != -1 ||
                        delta.getMarker().getAttribute(ITmfMarker.MARKER_RANK, (String) null) != null) {
                    provider.refreshBookmarks();
                }
            }
        }
    }
    redecorate();
}
 
Example 6
Source File: TmfEventsEditor.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void resourceChanged(final IResourceChangeEvent event) {
    final Set<@NonNull IMarker> added = new HashSet<>();
    final Set<@NonNull IMarker> removed = new HashSet<>();
    boolean deltaFound = false;
    for (final IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) {
        if (delta.getResource().equals(fFile)) {
            if (delta.getKind() == IResourceDelta.REMOVED) {
                removed.add(delta.getMarker());
            } else if (delta.getKind() == IResourceDelta.ADDED) {
                added.add(delta.getMarker());
            }
            /* this also covers IResourceDelta.CHANGED */
            deltaFound = true;
        }
    }
    if (!deltaFound) {
        return;
    }
    Display.getDefault().asyncExec(() -> {
        if (removed.isEmpty() && added.isEmpty()) {
            fEventsTable.getTable().refresh();
        } else {
            if (!removed.isEmpty()) {
                fEventsTable.removeBookmark(Iterables.toArray(removed, IMarker.class));
            }
            if (!added.isEmpty()) {
                fEventsTable.addBookmark(Iterables.toArray(added, IMarker.class));
            }
        }
    });
}
 
Example 7
Source File: ExternalFileAnnotationModel.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Updates this model to the given marker deltas.
 * 
 * @param markerDeltas
 *            the array of marker deltas
 */
protected void update(IMarkerDelta[] markerDeltas)
{
	if (markerDeltas.length == 0)
	{
		return;
	}

	for (IMarkerDelta delta : markerDeltas)
	{
		switch (delta.getKind())
		{
			case IResourceDelta.ADDED:
				addMarkerAnnotation(delta.getMarker());
				break;
			case IResourceDelta.REMOVED:
				removeMarkerAnnotation(delta.getMarker());
				break;
			case IResourceDelta.CHANGED:
				modifyMarkerAnnotation(delta.getMarker());
				break;
			default:
				break;
		}
	}
	fireModelChanged();
}
 
Example 8
Source File: ExternalBreakpointWatcher.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	IResourceDelta delta = event.getDelta();
	if(delta == null) {
		return;
	}
	
	IResource res = delta.getResource();
	if(res instanceof IWorkspaceRoot && (delta.getFlags() & IResourceDelta.MARKERS) != 0) {
		
		IMarkerDelta[] markerDeltas = delta.getMarkerDeltas();
		for (IMarkerDelta markerDelta : markerDeltas) {
			int kind = markerDelta.getKind();
			
			if(markerDelta.isSubtypeOf(CBREAKPOINT_MARKER_TYPE)) {
				
				if (kind == IResourceDelta.ADDED) {
					addMarkerAnnotation(markerDelta.getMarker());
				}
				
				if (kind == IResourceDelta.REMOVED) {
					removeMarkerAnnotation(markerDelta.getMarker());
				}
				
				if (kind == IResourceDelta.CHANGED) {
					updateMarkerAnnotation(markerDelta.getMarker());
				}
				
			}
		}
	}
}