1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-07 16:26:11 +02:00

CommonNavigator: Performance tuning for problem decoration

This commit is contained in:
Anton Leherbauer 2007-04-10 14:04:21 +00:00
parent b0e68cbd53
commit 29aec8d2ad
3 changed files with 55 additions and 11 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -10,23 +10,23 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.navigator;
import org.eclipse.core.resources.IResource;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;
import org.eclipse.ui.navigator.ICommonLabelProvider;
import org.eclipse.cdt.core.model.IArchiveContainer;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.IBinaryContainer;
import org.eclipse.cdt.core.model.IBinaryModule;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.ui.cview.CViewLabelProvider;
import org.eclipse.cdt.internal.ui.cview.CViewMessages;
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
import org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator;
import org.eclipse.core.resources.IResource;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;
import org.eclipse.ui.navigator.ICommonLabelProvider;
/**
* A label provider suitable for the Common Navigator providing also
@ -44,7 +44,7 @@ public class CNavigatorLabelProvider extends CViewLabelProvider implements IComm
super(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
| CElementImageProvider.SMALL_ICONS);
addLabelDecorator(new ProblemsLabelDecorator(null));
addLabelDecorator(new CNavigatorProblemsLabelDecorator());
}
/*

View file

@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.navigator;
import org.eclipse.core.resources.IResource;
import org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator;
/**
* A {@link ProblemsLabelDecorator} optimized for use with the Common Navigator.
*
* @since 4.0
*/
public class CNavigatorProblemsLabelDecorator extends ProblemsLabelDecorator {
/**
* Create a problems label decorator for the Common Navigator.
*/
public CNavigatorProblemsLabelDecorator() {
super(null);
}
/*
* @see org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator#fireProblemsChanged(org.eclipse.core.resources.IResource[], boolean)
*/
protected void fireProblemsChanged(IResource[] changedResources,
boolean isMarkerChange) {
// performance: if the number of changed resources is large, it is faster
// to trigger a viewer refresh by setting changedResources to null
if (changedResources != null && changedResources.length > 500) {
changedResources= null;
}
super.fireProblemsChanged(changedResources, isMarkerChange);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* Copyright (c) 2000, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -344,7 +344,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
}
}
void fireProblemsChanged(IResource[] changedResources, boolean isMarkerChange) {
protected void fireProblemsChanged(IResource[] changedResources, boolean isMarkerChange) {
if (fListeners != null && !fListeners.isEmpty()) {
LabelProviderChangedEvent event= new ProblemsLabelChangedEvent(this, changedResources, isMarkerChange);
Object[] listeners= fListeners.getListeners();