93 lines
3.2 KiB
Java
93 lines
3.2 KiB
Java
|
|
/*
|
||
|
|
* Copyright (c) 2004,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.tcv.swt.ICardLayout;
|
||
|
|
import com.foundation.view.ResourceAssociation;
|
||
|
|
import com.foundation.view.SingleAssociationContainer;
|
||
|
|
import com.foundation.view.SingleResourceAssociation;
|
||
|
|
|
||
|
|
public class CardLayout extends Layout implements ICardLayout {
|
||
|
|
/** The layout's top index resource. */
|
||
|
|
private SingleResourceAssociation topIndex = new SingleResourceAssociation(getContainer(), this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
|
||
|
|
/**
|
||
|
|
* CardLayout constructor.
|
||
|
|
* @param container The container that is using the layout.
|
||
|
|
*/
|
||
|
|
public CardLayout(AbstractComponent container) {
|
||
|
|
super(container);
|
||
|
|
//Initialize the client component.//
|
||
|
|
sendMessage(MESSAGE_INITIALIZE, getContainer().getNumber());
|
||
|
|
}//CardLayout()//
|
||
|
|
/**
|
||
|
|
* Sets the layout margin width.
|
||
|
|
* @param marginWidth The layout margin width.
|
||
|
|
*/
|
||
|
|
public void setMarginWidth(int marginWidth) {
|
||
|
|
sendMessage(MESSAGE_SET_MARGIN_WIDTH, marginWidth);
|
||
|
|
}//setMarginWidth()//
|
||
|
|
/**
|
||
|
|
* Sets the layout margin height.
|
||
|
|
* @param marginHeight The layout margin height.
|
||
|
|
*/
|
||
|
|
public void setMarginHeight(int marginHeight) {
|
||
|
|
sendMessage(MESSAGE_SET_MARGIN_HEIGHT, marginHeight);
|
||
|
|
}//setMarginHeight()//
|
||
|
|
/**
|
||
|
|
* Sets an association container used to access the text.
|
||
|
|
* @param container The text association metadata.
|
||
|
|
*/
|
||
|
|
public void setTopIndexAssociation(SingleAssociationContainer container) {
|
||
|
|
this.topIndex.setAssociations(container);
|
||
|
|
}//setTextAssociation()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.tcv.swt.server.Layout#getClientClassName()
|
||
|
|
*/
|
||
|
|
protected String getClientClassName() {
|
||
|
|
return "com.foundation.tcv.swt.client.CardLayout";
|
||
|
|
}//getClientClassName()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.tcv.swt.server.Layout#initialize()
|
||
|
|
*/
|
||
|
|
public void initialize() {
|
||
|
|
topIndex.initialize();
|
||
|
|
}//initialize()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.tcv.swt.server.Layout#refresh()
|
||
|
|
*/
|
||
|
|
public void refresh() {
|
||
|
|
refreshTopIndex();
|
||
|
|
}//refresh()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.tcv.swt.server.Layout#release()
|
||
|
|
*/
|
||
|
|
public void release() {
|
||
|
|
topIndex.release();
|
||
|
|
}//release()//
|
||
|
|
/**
|
||
|
|
* Refreshes the top index assocation.
|
||
|
|
*/
|
||
|
|
protected void refreshTopIndex() {
|
||
|
|
if(topIndex.refresh()) {
|
||
|
|
sendMessage(MESSAGE_SET_TOP_INDEX, null, null, topIndex.getValue() == null ? 0 : ((Integer) topIndex.getValue()).intValue(), -1);
|
||
|
|
}//if//
|
||
|
|
}//refreshTopIndex()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.Layout#onValueChanged(com.foundation.view.ResourceAssociation)
|
||
|
|
*/
|
||
|
|
public void onValueChanged(ResourceAssociation resourceAssociation, int flags) {
|
||
|
|
if(resourceAssociation == topIndex) {
|
||
|
|
if(topIndex.refresh()) {
|
||
|
|
sendMessage(MESSAGE_SET_TOP_INDEX, null, null, topIndex.getValue() == null ? 0 : ((Integer) topIndex.getValue()).intValue(), -1);
|
||
|
|
}//if//
|
||
|
|
}//if//
|
||
|
|
else {
|
||
|
|
super.onValueChanged(resourceAssociation, flags);
|
||
|
|
}//else//
|
||
|
|
}//onValueChanged()//
|
||
|
|
}//CardLayout//
|