org.eclipse.core.resources.IMarkerDelta Java Examples

The following examples show how to use org.eclipse.core.resources.IMarkerDelta. 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: JavaReconciler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void resourceChanged(IResourceChangeEvent e) {
	if (isRunningInReconcilerThread())
		return;

	IResourceDelta delta= e.getDelta();
	IResource resource= getResource();
	if (delta != null && resource != null) {
		IResourceDelta child= delta.findMember(resource.getFullPath());
		if (child != null) {
			IMarkerDelta[] deltas= child.getMarkerDeltas();
			int i= deltas.length;
			while (--i >= 0) {
				if (deltas[i].isSubtypeOf(IMarker.PROBLEM)) {
					forceReconciling();
					return;
				}
			}
		}
	}
}
 
Example #2
Source File: UniformResourceChangeEvent.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see com.aptana.ide.core.resources.IUniformResourceChangeEvent#findMarkerDeltas(java.lang.String, boolean)
 */
public IMarkerDelta[] findMarkerDeltas(String type, boolean includeSubtypes) {
	ArrayList<IMarkerDelta> matching = new ArrayList<IMarkerDelta>();
	IMarkerDelta[] deltas = getMarkerDeltas();
	for( int i = 0; i < deltas.length; ++i ) {
		IMarkerDelta markerDelta = deltas[i];
		if (type == null || (includeSubtypes ? markerDelta.isSubtypeOf(type) : markerDelta.getType().equals(type)))
		{
			matching.add(markerDelta);
		}
	}
	if ( matching.size() == 0 )
	{
		return NO_MARKER_DELTAS;
	}
	return matching.toArray(new IMarkerDelta[matching.size()]);
}
 
Example #3
Source File: ProblemMarkerManager.java    From APICloud-Studio with GNU General Public License v3.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++)
		{
			if (markerDeltas[i].isSubtypeOf(IMarker.PROBLEM))
			{
				int kind = markerDeltas[i].getKind();
				if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED)
				{
					return true;
				}
				int severity = markerDeltas[i].getAttribute(IMarker.SEVERITY, -1);
				int newSeverity = markerDeltas[i].getMarker().getAttribute(IMarker.SEVERITY, -1);
				if (newSeverity != severity)
				{
					return true;
				}
			}
		}
	}
	return false;
}
 
Example #4
Source File: BibtexEntryView.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Update the BibtextEntryView when markers change.
 */
public boolean visit(IResourceDelta delta) throws CoreException {
	if (delta == null) {
		return false;
	}

	IMarkerDelta[] markerDeltas = delta.getMarkerDeltas();

	if (markerDeltas.length > 0) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				refreshAction.run();
			}
		});
	}
	return true;
}
 
Example #5
Source File: ClassFileMarkerAnnotationModel.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void checkDeltas(IMarkerDelta[] markerDeltas) throws CoreException {
	for (int i= 0; i < markerDeltas.length; i++) {
		if (isAffected(markerDeltas[i])) {
			IMarker marker= markerDeltas[i].getMarker();
			switch (markerDeltas[i].getKind()) {
				case IResourceDelta.ADDED :
					addMarkerAnnotation(marker);
					fChangesApplied= true;
					break;
				case IResourceDelta.REMOVED :
					removeMarkerAnnotation(marker);
					fChangesApplied= true;
					break;
				case IResourceDelta.CHANGED:
					modifyMarkerAnnotation(marker);
					fChangesApplied= true;
					break;
			}
		}
	}
}
 
Example #6
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 #7
Source File: ProblemMarkerManager.java    From Eclipse-Postfix-Code-Completion 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++) {
			if (markerDeltas[i].isSubtypeOf(IMarker.PROBLEM)) {
				int kind= markerDeltas[i].getKind();
				if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED)
					return true;
				int severity= markerDeltas[i].getAttribute(IMarker.SEVERITY, -1);
				int newSeverity= markerDeltas[i].getMarker().getAttribute(IMarker.SEVERITY, -1);
				if (newSeverity != severity)
					return true;
			}
		}
	}
	return false;
}
 
Example #8
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void breakpointChanged( IBreakpoint breakpoint, IMarkerDelta delta )
{
	if ( !supportsBreakpoint( breakpoint ) )
	{
		return;
	}
	try
	{
		if ( breakpoint.isEnabled( ) )
		{
			breakpointAdded( breakpoint );
		}
		else
		{
			breakpointRemoved( breakpoint, null );
		}
	}
	catch ( CoreException e )
	{

	}
}
 
Example #9
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void breakpointRemoved( IBreakpoint breakpoint, IMarkerDelta delta )
{
	if ( !supportsBreakpoint( breakpoint ) )
	{
		return;
	}

	JsLineBreakPoint point = new JsLineBreakPoint( ( (ScriptLineBreakpoint) breakpoint ).getSubName( ),
			( (ScriptLineBreakpoint) breakpoint ).getScriptLineNumber( ) );
	if ( breakPoints.contains( point ) )
	{
		breakPoints.remove( point );
		try
		{
			reportVM.removeBreakPoint( point );
		}
		catch ( VMException e )
		{
			logger.warning( e.getMessage( ) );
		}
	}
}
 
Example #10
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 #11
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 #12
Source File: ProblemMarkerManager.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
protected boolean isErrorDelta(IResourceDelta delta) {
	if ((delta.getFlags() & IResourceDelta.MARKERS) != 0) {
		IMarkerDelta[] markerDeltas= delta.getMarkerDeltas();
		for (int i= 0; i < markerDeltas.length; i++) {
			if (markerDeltas[i].isSubtypeOf(IMarker.PROBLEM)) {
				int kind= markerDeltas[i].getKind();
				if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED)
					return true;
				int severity= markerDeltas[i].getAttribute(IMarker.SEVERITY, -1);
				int newSeverity= markerDeltas[i].getMarker().getAttribute(IMarker.SEVERITY, -1);
				if (newSeverity != severity)
					return true;
			}
		}
	}
	return false;
}
 
Example #13
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());
				}
				
			}
		}
	}
}
 
Example #14
Source File: ClassFileMarkerAnnotationModel.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see IResourceChangeListener#resourceChanged
 */
public void resourceChanged(IResourceChangeEvent e) {
	try {
		IMarkerDelta[] deltas= e.findMarkerDeltas(null, true);
		if (deltas != null) {
			fChangesApplied= false;
			checkDeltas(deltas);
			if (fChangesApplied)
				fireModelChanged();
		}
	} catch (CoreException x) {
		handleCoreException(x, JavaEditorMessages.ClassFileMarkerAnnotationModel_error_resourceChanged);
	}
}
 
Example #15
Source File: AbstractDebugTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Removes an existing breakpoint from the debug target.
 */
@Override
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (breakpoint instanceof PyBreakpoint) {
        PyBreakpoint b = (PyBreakpoint) breakpoint;
        if (currentBreakpointsAdded.contains(b.breakpointId)) {
            currentBreakpointsAdded.remove(b.breakpointId);
            RemoveBreakpointCommand cmd = new RemoveBreakpointCommand(this, b.breakpointId, b.getFile(),
                    b.getType());
            this.postCommand(cmd);
        }
    }
}
 
Example #16
Source File: ClassFileMarkerAnnotationModel.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean isAffected(IMarkerDelta markerDelta) {
	try {
		return JavaCore.isReferencedBy(fClassFile, markerDelta);
	} catch (CoreException x) {
		handleCoreException(x, JavaEditorMessages.ClassFileMarkerAnnotationModel_error_isAffected);
		return false;
	}
}
 
Example #17
Source File: AbstractDebugTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Called when a breakpoint is changed.
 * E.g.:
 *  - When line numbers change in the file
 *  - When the manager decides to enable/disable all existing markers
 *  - When the breakpoint properties (hit condition) are edited
 */
@Override
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (breakpoint instanceof PyBreakpoint) {
        breakpointRemoved(breakpoint, null);
        breakpointAdded(breakpoint);
    }
}
 
Example #18
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 #19
Source File: MarkerManager.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void handleResourceChanged()
{
	if (currentDeltas == null)
	{
		return;
	}
	MarkerSet[] markers;
	synchronized (lock)
	{
		markers = (MarkerSet[]) currentDeltas.values().toArray(new MarkerSet[currentDeltas.size()]);
		currentDeltas = null;
	}
	Object[] list = listeners.getListeners();
	for (int j = 0; j < markers.length; ++j)
	{
		IMarkerDelta[] deltas = new IMarkerDelta[markers[j].size()];
		markers[j].copyInto(deltas);
		IUniformResource resource = null;
		if (deltas.length > 0 && deltas[0] instanceof MarkerDelta)
		{
			resource = ((MarkerDelta) deltas[0]).getUniformResource();
		}
		UniformResourceChangeEvent event = new UniformResourceChangeEvent(this, resource, deltas);
		for (int i = 0; i < list.length; ++i)
		{
			try
			{
				((IUniformResourceChangeListener) list[i]).resourceChanged(event);
			}
			catch (Exception e)
			{
				IdeLog.logError(CorePlugin.getDefault(), e);
			}
		}
	}
}
 
Example #20
Source File: AbstractStatsView.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createPartControl(Composite parent) {

  mMainComposite = parent;

  // create and register the workspace focus listener
  mFocusListener = new ISelectionListener() {
    @Override
    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
      AbstractStatsView.this.focusSelectionChanged(part, selection);
    }
  };

  getSite().getPage().addSelectionListener(mFocusListener);
  focusSelectionChanged(getSite().getPage().getActivePart(), getSite().getPage().getSelection());

  // create and register the listener for resource changes
  mResourceListener = new IResourceChangeListener() {
    @Override
    public void resourceChanged(IResourceChangeEvent event) {

      IMarkerDelta[] markerDeltas = event.findMarkerDeltas(CheckstyleMarker.MARKER_ID, true);

      if (markerDeltas.length > 0) {
        refresh();
      }
    }
  };

  ResourcesPlugin.getWorkspace().addResourceChangeListener(mResourceListener);

  makeActions();
  initActionBars(getViewSite().getActionBars());
}
 
Example #21
Source File: UniformResourceChangeEvent.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see com.aptana.ide.core.resources.IUniformResourceChangeEvent#getMarkerDeltas()
 */
public IMarkerDelta[] getMarkerDeltas() {
	if ( deltas == null )
	{
		return NO_MARKER_DELTAS;
	}
	return deltas;
}
 
Example #22
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 #23
Source File: DefaultResourceChangeToIssueProcessor.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void removeSCTIssue(final IMarkerDelta iMarkerDelta, final String elementID) {
	final String message = (String) iMarkerDelta.getAttributes().get(IMarker.MESSAGE);
	final Iterator<SCTIssue> iterator = currentIssues.get(elementID).iterator();
	while (iterator.hasNext()) {
		final SCTIssue sctIssue = iterator.next();
		if (sctIssue.getMessage().equals(message)) {
			iterator.remove();
		}
	}
	changedIssuesElementIDs.add(elementID);
}
 
Example #24
Source File: ProblemViewResourceListener.java    From tlaplus with MIT License 5 votes vote down vote up
private boolean hasMarkerDelta(IResourceChangeEvent event) {
	IMarkerDelta[] deltas = event.findMarkerDeltas(TLAMarkerHelper.TOOLBOX_MARKERS_ALL_MARKER_ID, true);
	if (deltas.length > 0) {
		return true;
	}
	return false;
}
 
Example #25
Source File: DefaultResourceChangeToIssueProcessor.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private IMarkerDelta[] getSortedMarkerDelta(final IResourceDelta delta) {
	IMarkerDelta[] markerDeltas = delta.getMarkerDeltas();
	//sort IResourceDelta.CHANGED > IResourceDelta.REMOVED > IResourceDelta.ADDED 
	Arrays.sort(markerDeltas, new Comparator<IMarkerDelta>(){
		@Override
		public int compare(IMarkerDelta o1, IMarkerDelta o2) {
			return -((Integer)o1.getKind()).compareTo(o2.getKind());
		}
	});

	return markerDeltas;
}
 
Example #26
Source File: DefaultResourceChangeToIssueProcessor.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void processMarkerDelta(final IResourceDelta delta) {
	final IMarkerDelta[] markerDeltas = getSortedMarkerDelta(delta);
	
	for (final IMarkerDelta markerDelta : markerDeltas) {
		final Object elementID = markerDelta
				.getAttribute(SCTMarkerType.SEMANTIC_ELEMENT_ID);
		if (elementID == null) {
			continue;
		}
		dispatchMarkerDelta(markerDelta, elementID.toString());
	}
}
 
Example #27
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 #28
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 #29
Source File: AbstractTimeGraphView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.0
 */
@Override
public void resourceChanged(final IResourceChangeEvent event) {
    for (final IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) {
        if (delta.getResource().equals(fEditorFile)) {
            fTimeGraphViewer.setBookmarks(refreshBookmarks(fEditorFile));
            redraw();
            return;
        }
    }
}
 
Example #30
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {}