/* (non-Javadoc) * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) */ public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { if (provider.isDisposed()) { set.removeSyncSetChangedListener(this); } else { reset(); } }
/* (non-Javadoc) * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) */ public void resourceChanged(final IResourceChangeEvent event) { String[] markerTypes = getMarkerTypes(); Set handledResources = new HashSet(); Set changes = new HashSet(); // Accumulate all distinct resources that have had problem marker // changes for (int idx = 0; idx < markerTypes.length; idx++) { IMarkerDelta[] markerDeltas = event.findMarkerDeltas(markerTypes[idx], true); for (int i = 0; i < markerDeltas.length; i++) { IMarkerDelta delta = markerDeltas[i]; IResource resource = delta.getResource(); if (!handledResources.contains(resource)) { handledResources.add(resource); ISynchronizeModelElement[] elements = provider.getClosestExistingParents(delta.getResource()); if (elements != null && elements.length > 0) { for (int j = 0; j < elements.length; j++) { ISynchronizeModelElement element = elements[j]; changes.add(element); } } } } } if (!changes.isEmpty()) { updateMarkersFor( (ISynchronizeModelElement[]) changes.toArray(new ISynchronizeModelElement[changes.size()])); } }
/** Create the marker update handler. */ public SynchronizeModelUpdateHandler(AbstractSynchronizeModelProvider provider) { super( TeamUIMessages.SynchronizeModelProvider_0, TeamUIMessages.SynchronizeModelUpdateHandler_0); // this.provider = provider; ResourcesPlugin.getWorkspace().addResourceChangeListener(this); provider.getSyncInfoSet().addSyncSetChangedListener(this); }
/* * Method that can be called from the UI thread to update the view model. */ private void internalRunViewUpdate(final Runnable runnable, boolean preserveExpansion) { StructuredViewer viewer = getViewer(); IResource[] expanded = null; IResource[] selected = null; try { if (Utils.canUpdateViewer(viewer)) { viewer.getControl().setRedraw(false); if (preserveExpansion) { expanded = provider.getExpandedResources(); selected = provider.getSelectedResources(); } if (viewer instanceof AbstractTreeViewer && additionsMap == null) additionsMap = new HashMap(); } runnable.run(); } finally { if (Utils.canUpdateViewer(viewer)) { try { if (additionsMap != null && !additionsMap.isEmpty() && Utils.canUpdateViewer(viewer)) { for (Iterator iter = additionsMap.keySet().iterator(); iter.hasNext(); ) { ISynchronizeModelElement parent = (ISynchronizeModelElement) iter.next(); if (Policy.DEBUG_SYNC_MODELS) { System.out.println("Adding child view items of " + parent.getName()); // $NON-NLS-1$ } Set toAdd = (Set) additionsMap.get(parent); ((AbstractTreeViewer) viewer).add(parent, toAdd.toArray(new Object[toAdd.size()])); } additionsMap = null; } if (expanded != null) { provider.expandResources(expanded); } if (selected != null) { provider.selectResources(selected); } } finally { viewer.getControl().setRedraw(true); } } } ISynchronizeModelElement root = provider.getModelRoot(); if (root instanceof SynchronizeModelElement) ((SynchronizeModelElement) root).fireChanges(); }
/** * Calculate and propagate problem markers in the element model * * @param element the ssynchronize element */ private void propagateProblemMarkers(ISynchronizeModelElement element) { IResource resource = element.getResource(); if (resource != null) { String property = provider.calculateProblemMarker(element); // If it doesn't have a direct change, a parent might boolean recalculateParentDecorations = hadProblemProperty(element, property); if (recalculateParentDecorations) { ISynchronizeModelElement parent = (ISynchronizeModelElement) element.getParent(); if (parent != null) { propagateProblemMarkers(parent); } } } }
/* (non-Javadoc) * @see org.eclipse.team.internal.core.BackgroundEventHandler#processEvent(org.eclipse.team.internal.core.BackgroundEventHandler.Event, org.eclipse.core.runtime.IProgressMonitor) */ protected void processEvent(Event event, IProgressMonitor monitor) throws CoreException { switch (event.getType()) { case BackgroundEventHandler.RUNNABLE_EVENT: executeRunnable(event, monitor); break; case MARKERS_CHANGED: // Changes contains all elements that need their labels updated long start = System.currentTimeMillis(); ISynchronizeModelElement[] elements = getChangedElements(event); for (int i = 0; i < elements.length; i++) { ISynchronizeModelElement element = elements[i]; propagateProblemMarkers(element); updateParentLabels(element); } if (Policy.DEBUG_SYNC_MODELS) { long time = System.currentTimeMillis() - start; DateFormat TIME_FORMAT = new SimpleDateFormat("m:ss.SSS"); // $NON-NLS-1$ String took = TIME_FORMAT.format(new Date(time)); System.out.println( took + " for " + elements.length + " files"); // $NON-NLS-1$//$NON-NLS-2$ } break; case BUSY_STATE_CHANGED: BusyStateChangeEvent e = (BusyStateChangeEvent) event; queueForLabelUpdate(e.getElement()); if (e.isBusy()) { // indicate that we want an early dispatch to show busy elements dispatchEarly = true; } break; case RESET: // Perform the reset immediately pendingLabelUpdates.clear(); provider.reset(); break; case SYNC_INFO_SET_CHANGED: // Handle the sync change immediately handleChanges(((SyncInfoSetChangeEvent) event).getEvent(), monitor); default: break; } }
private String getDebugDisplayLabel(AbstractSynchronizeModelProvider provider2) { return provider2.toString(); }
public void dispose() { shutdown(); ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); provider.getSyncInfoSet().removeSyncSetChangedListener(this); }
/** * Return the <code>AbstractTreeViewer</code> associated with this provider or <code>null</code> * if the viewer is not of the proper type. * * @return the structured viewer that is displaying the model managed by this provider */ public StructuredViewer getViewer() { return provider.getViewer(); }