001: /*
002: * Copyright (c) 2004-2006, Jean-François Brazeau. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * 1. Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * 2. Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: *
014: * 3. The name of the author may not be used to endorse or promote products
015: * derived from this software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
018: * IMPLIEDWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
019: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
020: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
021: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
022: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
023: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
024: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
025: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
026: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: */
028: package jfb.tools.activitymgr.ui.util;
029:
030: import java.util.ArrayList;
031: import java.util.Iterator;
032:
033: import org.apache.log4j.Logger;
034: import org.eclipse.jface.viewers.ILabelProviderListener;
035: import org.eclipse.jface.viewers.IStructuredContentProvider;
036: import org.eclipse.jface.viewers.ITableLabelProvider;
037: import org.eclipse.jface.viewers.LabelProviderChangedEvent;
038: import org.eclipse.jface.viewers.Viewer;
039: import org.eclipse.swt.graphics.Image;
040:
041: /**
042: * Classe de base implémentant une partie des méthodes qui doivent être
043: * implémentées pour gérer des tableaux.
044: */
045: public abstract class AbstractTableMgr implements ITableLabelProvider,
046: IStructuredContentProvider {
047:
048: /** Logger */
049: private static Logger log = Logger
050: .getLogger(AbstractTableMgr.class);
051:
052: /** Noeud racine */
053: protected static Object ROOT_NODE = "ROOT_NODE";
054:
055: /** Liste des ILabelProviderListener */
056: private ArrayList labelProviderListeners = new ArrayList();
057:
058: /* (non-Javadoc)
059: * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
060: */
061: public void inputChanged(Viewer viewer, Object oldInput,
062: Object newInput) {
063: log.debug("ITreeContentProvider.inputChanged(" + viewer + ", "
064: + oldInput + ", " + newInput + ")");
065: }
066:
067: /* (non-Javadoc)
068: * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
069: */
070: public Image getColumnImage(Object element, int columnIndex) {
071: return null;
072: }
073:
074: /* (non-Javadoc)
075: * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
076: */
077: public void addListener(ILabelProviderListener listener) {
078: log.debug("ContentProvider.addListener(" + listener + ")");
079: if (!labelProviderListeners.contains(listener))
080: labelProviderListeners.add(listener);
081: }
082:
083: /* (non-Javadoc)
084: * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
085: */
086: public void dispose() {
087: }
088:
089: /* (non-Javadoc)
090: * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
091: */
092: public boolean isLabelProperty(Object element, String property) {
093: return false;
094: }
095:
096: /* (non-Javadoc)
097: * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
098: */
099: public void removeListener(ILabelProviderListener listener) {
100: log.debug("ContentProvider.addListener(" + listener + ")");
101: labelProviderListeners.remove(listener);
102: }
103:
104: /**
105: * Notifie les listeners du changement de valeur d'un label.
106: * @param e l'évènement.
107: */
108: protected void notifyLabelProviderListener(
109: LabelProviderChangedEvent e) {
110: Iterator it = labelProviderListeners.iterator();
111: while (it.hasNext()) {
112: ILabelProviderListener listener = (ILabelProviderListener) it
113: .next();
114: log.debug("notifying listener(" + listener + ")");
115: listener.labelProviderChanged(e);
116: }
117: }
118:
119: }
|