Initial commit from SVN.
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2003,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.tcv.swt.server;
|
||||
|
||||
import com.foundation.view.*;
|
||||
import com.foundation.view.resource.ResourceReference;
|
||||
import com.foundation.tcv.swt.*;
|
||||
import com.foundation.tcv.view.*;
|
||||
|
||||
public class Label extends Component implements ILabel {
|
||||
/** The label text. */
|
||||
private SingleResourceAssociation text = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, "");
|
||||
/** The label image. */
|
||||
private SingleResourceAssociation image = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGE, false, null);
|
||||
/**
|
||||
* Label constructor.
|
||||
* @param parent A composite control which will be the parent of the new instance (cannot be null).
|
||||
* @param name The unique component name.
|
||||
* @param style The style of control to construct
|
||||
* @see #SEPARATOR
|
||||
* @see #HORIZONTAL
|
||||
* @see #VERTICAL
|
||||
* @see #SHADOW_IN
|
||||
* @see #SHADOW_OUT
|
||||
* @see #SHADOW_NONE
|
||||
* @see #LEFT
|
||||
* @see #RIGHT
|
||||
* @see #CENTER
|
||||
* @see #WRAP
|
||||
*/
|
||||
public Label(Container parent, String name, int style) {
|
||||
super(parent, name, style);
|
||||
|
||||
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
|
||||
}//Label()//
|
||||
/**
|
||||
* Sets the label's text. This will be the default text if there is a text attribute associated with this component.
|
||||
* @param text The text that will appear in the label.
|
||||
*/
|
||||
public void setText(String text) {
|
||||
verifyThread();
|
||||
this.text.setDefaultValue(text);
|
||||
}//setText()//
|
||||
/**
|
||||
* Sets the component's default text resource.
|
||||
* @param text The text to be displayed by this component.
|
||||
*/
|
||||
public void setText(ResourceReference text) {
|
||||
verifyThread();
|
||||
this.text.setDefaultValue(text);
|
||||
}//setText()//
|
||||
/**
|
||||
* Sets the association container used to access the text.
|
||||
* @param container The text association metadata.
|
||||
*/
|
||||
public void setTextAssociation(SingleAssociationContainer container) {
|
||||
verifyThread();
|
||||
this.text.setAssociations(container);
|
||||
}//setTextAssociation()//
|
||||
/**
|
||||
* Sets the association container used to access the image.
|
||||
* @param container The image association metadata.
|
||||
*/
|
||||
public void setImageAssociation(SingleAssociationContainer container) {
|
||||
verifyThread();
|
||||
this.image.setAssociations(container);
|
||||
}//setImageAssociation()//
|
||||
/**
|
||||
* Sets the label's image. This will be the default image if there is a image attribute associated with this component.
|
||||
* @param image The image to be displayed by the label.
|
||||
*/
|
||||
public void setImage(JefImage image) {
|
||||
verifyThread();
|
||||
this.image.setDefaultValue(image);
|
||||
}//setImage()//
|
||||
/**
|
||||
* Sets the component's default image resource.
|
||||
* @param image The image to be displayed by this component.
|
||||
*/
|
||||
public void setImage(ResourceReference image) {
|
||||
verifyThread();
|
||||
this.image.setDefaultValue(image);
|
||||
}//setImage()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
|
||||
*/
|
||||
protected void internalViewInitialize() {
|
||||
super.internalViewInitialize();
|
||||
text.initialize(true);
|
||||
image.initialize(true);
|
||||
}//internalViewInitialize()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
|
||||
*/
|
||||
protected void internalViewRelease() {
|
||||
super.internalViewRelease();
|
||||
text.release();
|
||||
image.release();
|
||||
}//internalViewRelease()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
|
||||
*/
|
||||
protected void internalViewRefresh() {
|
||||
super.internalViewRefresh();
|
||||
|
||||
internalViewRefreshText();
|
||||
internalViewRefreshImage();
|
||||
}//viewRefresh()//
|
||||
/**
|
||||
* Refreshes the component's text.
|
||||
*/
|
||||
protected void internalViewRefreshText() {
|
||||
if(text.refresh()) {
|
||||
sendMessage(MESSAGE_SET_TEXT, text.getValue());
|
||||
}//if//
|
||||
}//internalViewRefreshText()//
|
||||
/**
|
||||
* Refreshes the component's image.
|
||||
*/
|
||||
protected void internalViewRefreshImage() {
|
||||
if(image.refresh()) {
|
||||
sendMessage(MESSAGE_SET_IMAGE, image.getValue());
|
||||
}//if//
|
||||
}//internalViewRefreshImage()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
|
||||
*/
|
||||
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
|
||||
if(resourceAssociation == text) {
|
||||
internalViewRefreshText();
|
||||
}//if//
|
||||
else if(resourceAssociation == image) {
|
||||
internalViewRefreshImage();
|
||||
}//else if//
|
||||
else {
|
||||
super.internalOnValueChanged(resourceAssociation, flags);
|
||||
}//else//
|
||||
}//internalOnValueChanged()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.tcv.view.IViewComponent#processMessage(com.foundation.tcv.model.ViewMessage)
|
||||
*/
|
||||
public Object processMessage(ViewMessage viewMessage) {
|
||||
Object retVal = null;
|
||||
|
||||
switch(viewMessage.getMessageNumber()) {
|
||||
default: {
|
||||
retVal = super.processMessage(viewMessage);
|
||||
}//default//
|
||||
}//switch//
|
||||
|
||||
return retVal;
|
||||
}//processMessage()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
|
||||
*/
|
||||
protected String getClientClassName() {
|
||||
return "com.foundation.tcv.swt.client.Label";
|
||||
}//getClientClassName()//
|
||||
}//Label//
|
||||
Reference in New Issue
Block a user