Hi Michel That code comes way before my time and I have no idea why (a) the Figs don't just contain their own listeners or (b) why there is a limit (there does appear to be).
Feel free to fix in GEF if needed. Bob. On 31/07/07, Michiel van der Wulp <[EMAIL PROTECTED]> wrote: > Hi Bob, et al., > > In my last commit, I added a property change listener to a Fig - see below. > > In the code of GEF, I found some warnings that the property change listeners > are limited in number: > > In the Fig class: > * Since most Fig's will never have any listeners, and I want Figs > * to be fairly light-weight objects, listeners are kept in a > * global Hashtable, keyed by Fig. > > And in the Globals class: > * A global dictionary of PropertyChangeListeners for Figs. Most > * Figs will not have any listeners at any given moment, so I did > * not want to allocate an instance variable to hold > * listeners. Instead I use this global Hashtable with Figs ans > * keys and arrays of up to 4 listeners as values. > > Now my question: > Is it true that we are limited to 4 listeners? Are we near this limit > already? > Why this limit - I do not understand the reasoning. > Would it not be better to remove this limit? > > Regards, > Michiel > > > ----- Original Message ----- > From: <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, July 31, 2007 11:00 PM > Subject: svn commit: r13195 - > trunk/src_new/org/argouml/ui/StylePanelFigNodeModelElement.java > > > > Author: mvw > > Date: 2007-07-31 14:00:01-0700 > > New Revision: 13195 > > > > Modified: > > trunk/src_new/org/argouml/ui/StylePanelFigNodeModelElement.java > > > > Log: > > Make the path-visibility checkbox on the Presentation panel update when > > the value is changed by the pop-up menu. > > > > Modified: trunk/src_new/org/argouml/ui/StylePanelFigNodeModelElement.java > > Url: > > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/StylePanelFigNodeModelElement.java?view=diff&rev=13195&p1=trunk/src_new/org/argouml/ui/StylePanelFigNodeModelElement.java&p2=trunk/src_new/org/argouml/ui/StylePanelFigNodeModelElement.java&r1=13194&r2=13195 > > ============================================================================== > > --- trunk/src_new/org/argouml/ui/StylePanelFigNodeModelElement.java > > (original) > > +++ trunk/src_new/org/argouml/ui/StylePanelFigNodeModelElement.java > > 2007-07-31 14:00:01-0700 > > @@ -29,6 +29,8 @@ > > import java.awt.event.ItemEvent; > > import java.awt.event.ItemListener; > > import java.awt.event.KeyListener; > > +import java.beans.PropertyChangeEvent; > > +import java.beans.PropertyChangeListener; > > > > import javax.swing.JCheckBox; > > import javax.swing.JLabel; > > @@ -36,16 +38,18 @@ > > > > import org.argouml.i18n.Translator; > > import org.argouml.uml.diagram.PathContainer; > > +import org.tigris.gef.presentation.Fig; > > import org.tigris.gef.ui.ColorRenderer; > > > > /** > > * Stylepanel which provides base style information for modelelements, > > e.g. > > - * shadow width. > > + * shadow width, the path checkbox. > > * > > */ > > public class StylePanelFigNodeModelElement > > extends StylePanelFig > > - implements ItemListener, FocusListener, KeyListener { > > + implements ItemListener, FocusListener, KeyListener, > > + PropertyChangeListener { > > > > /** > > * Flag to indicate that a refresh is going on. > > @@ -94,6 +98,19 @@ > > displayPane.add(cb); > > } > > > > + @Override > > + public void setTarget(Object t) { > > + Fig oldTarget = getPanelTarget(); > > + if (oldTarget != null) { > > + oldTarget.removePropertyChangeListener(this); > > + } > > + super.setTarget(t); > > + Fig newTarget = getPanelTarget(); > > + if (newTarget != null) { > > + newTarget.addPropertyChangeListener(this); > > + } > > + } > > + > > /* > > * @see org.argouml.ui.TabTarget#refresh() > > */ > > @@ -128,4 +145,28 @@ > > } > > } > > > > + /** > > + * This function is called when the Fig property is changed from > > + * outside this Panel, e.g. when the Fig is relocated or when one of > > + * its properties change. <p> > > + * > > + * We currently only need to react on the property > > + * that indicates that the "pathVisible" is changed. See > > + * the FigNodeModelElement for when this event is triggered. <p> > > + * > > + * When the user toggles the visibility of the path in > > + * the Fig's pop-up menu, then this function > > + * updates the Presentation panel checkbox. > > + * > > + * @param evt the event > > + * @see > > java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) > > + */ > > + public void propertyChange(PropertyChangeEvent evt) { > > + if ("pathVisible".equals(evt.getPropertyName())) { > > + refreshTransaction = true; > > + pathCheckBox.setSelected((Boolean) evt.getNewValue()); > > + refreshTransaction = false; > > + } > > + } > > + > > } /* end class StylePanelFigNodeModelElement */ > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > > No virus found in this incoming message. > > Checked by AVG Free Edition. > > Version: 7.5.476 / Virus Database: 269.11.0/927 - Release Date: 30/07/2007 > > 17:02 > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
