FileDocCategorySizeDatePackage
UISWTStatusEntryImpl.javaAPI DocAzureus 3.0.3.43275Sun Feb 04 03:29:22 GMT 2007org.gudy.azureus2.ui.swt.pluginsimpl

UISWTStatusEntryImpl

public class UISWTStatusEntryImpl extends Object implements org.gudy.azureus2.ui.swt.plugins.UISWTStatusEntry, MainStatusBar.CLabelUpdater
author
Allan Crooks

Fields Summary
private org.gudy.azureus2.core3.util.AEMonitor
this_mon
private org.gudy.azureus2.ui.swt.plugins.UISWTStatusEntryListener
listener
private boolean
needs_update
private String
text
private String
tooltip
private boolean
image_enabled
private org.eclipse.swt.graphics.Image
image
private boolean
is_visible
private boolean
needs_disposing
private boolean
is_destroyed
Constructors Summary
Methods Summary
private voidcheckDestroyed()

	
	   
		if (is_destroyed) {throw new RuntimeException("object is destroyed, cannot be reused");}
	
public voiddestroy()

		try {
			this_mon.enter();
			this.is_visible = false;
			this.listener = null;
			this.image = null;
			this.needs_disposing = true;
			this.is_destroyed = true;
		}
		finally {
			this_mon.exit();
		}
	
voidonClick()

		UISWTStatusEntryListener listener0 = listener; // Avoid race conditions.
		if (listener0 != null) {listener.entryClicked(this);}
	
public voidsetImage(int image_id)

		String img_name;
		switch (image_id) {
			case IMAGE_LED_GREEN:
				img_name = "greenled";
				break;
			case IMAGE_LED_RED:
				img_name = "redled";
				break;
			case IMAGE_LED_YELLOW:
				img_name = "yellowled";
				break;
			default:
				img_name = "grayled";
				break;
		}
		this.setImage(ImageRepository.getImage(img_name));
	
public voidsetImage(org.eclipse.swt.graphics.Image image)

		checkDestroyed();
		this_mon.enter();
		this.image = image;
		this.needs_update = true;
		this_mon.exit();
	
public voidsetImageEnabled(boolean enabled)

		checkDestroyed();
		this_mon.enter();
		this.image_enabled = enabled;
		this.needs_update = true;
		this_mon.exit();
	
public voidsetListener(org.gudy.azureus2.ui.swt.plugins.UISWTStatusEntryListener listener)

		checkDestroyed();
		this.listener = listener;
	
public voidsetText(java.lang.String text)

		checkDestroyed();
		this_mon.enter();
		this.text = text;
		this.needs_update = true;
		this_mon.exit();
	
public voidsetTooltipText(java.lang.String text)

		checkDestroyed();
		this_mon.enter();
		this.tooltip = text;
		this.needs_update = true;
		this_mon.exit();
	
public voidsetVisible(boolean visible)

		checkDestroyed();
		this_mon.enter();
		this.is_visible = visible;
		this.needs_update = true;
		this_mon.exit();
	
public voidupdate(org.eclipse.swt.custom.CLabel label)

		if (needs_disposing && !label.isDisposed()) {label.dispose(); return;}
		if (!needs_update) {return;}
		
		// This is where we do a big update.
		try {
			this_mon.enter();
			update0(label);
		}
		finally {
			this_mon.exit();
		}
	
private voidupdate0(org.eclipse.swt.custom.CLabel label)

		label.setText(text);
		label.setToolTipText(tooltip);
		label.setImage(image_enabled ? image : null);
		label.setVisible(this.is_visible);