Merge "Issue #2079 add dispose method to ModeListener" into development
Former-commit-id:34b6d1be04
[formerly1482e7f6dd
] [formerly956a26aedc
] [formerlyaf0a542f2f
[formerly956a26aedc
[formerly f3619f573f102fcffd0503e0c0359e941568550f]]] Former-commit-id:af0a542f2f
Former-commit-id: 22991bb048f167bc529d180a7206cda6e4be1dbc [formerly257de35a28
] Former-commit-id:430c19d19b
This commit is contained in:
commit
d6c1b38c30
1 changed files with 20 additions and 0 deletions
|
@ -20,6 +20,8 @@
|
|||
|
||||
package com.raytheon.viz.ui.dialogs;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
|
@ -49,6 +51,7 @@ import com.raytheon.viz.core.mode.CAVEMode;
|
|||
* Date Ticket# Engineer Description
|
||||
* ---------- ---------- ----------- --------------------------
|
||||
* 12/20/07 561 Dan Fitch Initial Creation.
|
||||
* 6/7/2013 mnash Implementation for Chris Golden to allow instances to be garbage collected.
|
||||
* </pre>
|
||||
*
|
||||
* @author Dan Fitch
|
||||
|
@ -65,10 +68,27 @@ public class ModeListener implements PaintListener {
|
|||
DEFAULT_SWT_FORE = disp.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
|
||||
}
|
||||
|
||||
private WeakReference<Composite> comp;
|
||||
|
||||
public ModeListener(Composite comp) {
|
||||
this.comp = new WeakReference<Composite>(comp);
|
||||
comp.addPaintListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose of this mode listener.
|
||||
*/
|
||||
public void dispose() {
|
||||
// If the composite is still reachable and it has not
|
||||
// been disposed, remove this listener; then delete
|
||||
// the reference.
|
||||
Composite comp = this.comp.get();
|
||||
if ((comp != null) && (comp.isDisposed() == false)) {
|
||||
comp.removePaintListener(this);
|
||||
}
|
||||
this.comp = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintControl(PaintEvent paintevent) {
|
||||
Color bgColor = CAVEMode.getBackgroundColor();
|
||||
|
|
Loading…
Add table
Reference in a new issue