/* * Copyright (c) 2007,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.client; import org.eclipse.swt.graphics.Image; import com.foundation.tcv.swt.*; import com.foundation.tcv.view.*; public class Group extends Container implements IGroup, Component.IComponentListener { /** * Group constructor. */ public Group() { super(); }//Group()// /** * Gets the SWT Group that represents this group. * @return The SWT Group providing visualization for this group. */ public org.eclipse.swt.widgets.Group getSwtGroup() { return (org.eclipse.swt.widgets.Group) getSwtWidget(); }//getSwtGroup()// /* (non-Javadoc) * @see com.foundation.tcv.swt.client.AbstractComponent#internalViewInitialize() */ protected void internalViewInitialize() { //Register for image and title changes. Note: it is not necessary to initialize the title & image since they will be updated on the container's refresh and an event will fire if they are anything other than null.// registerListener(this); if(getContainerTitle() != null) { getSwtGroup().setText(getContainerTitle()); }//if// super.internalViewInitialize(); }//internalViewInitialize()// /* (non-Javadoc) * @see com.foundation.tcv.swt.client.AbstractComponent#internalViewRelease() */ protected void internalViewRelease() { super.internalViewRelease(); unregisterListener(this); }//internalViewRelease()// /* (non-Javadoc) * @see com.foundation.tcv.swt.client.AbstractComponent#internalViewSynchronize() */ protected void internalViewSynchronize() { super.internalViewSynchronize(); }//internalViewSynchronize()// /* (non-Javadoc) * @see com.foundation.tcv.swt.client.AbstractComponent#internalProcessMessage(com.foundation.tcv.model.ViewMessage) */ public Object internalProcessMessage(ViewMessage viewMessage) { Object result = null; switch(viewMessage.getMessageNumber()) { case MESSAGE_INITIALIZE: { if(getSwtControl() == null) { int[] data = (int[]) viewMessage.getMessageData(); int style = data[1]; //Link to the parent container.// setContainer((Container) getComponent(data[0])); getContainer().addComponent(this); //Create the SWT widget.// setSwtWidget(new org.eclipse.swt.widgets.Group(getContainer().getSwtParent(), style)); getSwtWidget().setData(this); //If the container has already been initialized then force the parent to re-layout so that this component will appear.// if(getContainer().isInitialized()) { getContainer().getSwtComposite().layout(true, true); }//if// }//if// break; }//case// default: { result = super.internalProcessMessage(viewMessage); }//default// }//switch// return result; }//internalProcessMessage()// /* (non-Javadoc) * @see com.foundation.tcv.swt.client.Component.IComponentListener#imageChanged(com.foundation.tcv.swt.client.Component, org.eclipse.swt.graphics.Image) */ public void imageChanged(Component component, Image newImage) { //Images not currently supported by Group.// //getSwtGroup().setImage(newImage); }//imageChanged()// /* (non-Javadoc) * @see com.foundation.tcv.swt.client.Component.IComponentListener#titleChanged(com.foundation.tcv.swt.client.Component, java.lang.String) */ public void titleChanged(Component component, String newTitle) { getSwtGroup().setText(newTitle); }//titleChanged()// /* (non-Javadoc) * @see com.foundation.tcv.swt.client.Component.IComponentListener#toolTipTextChanged(com.foundation.tcv.swt.client.Component, java.lang.String) */ public void toolTipTextChanged(Component component, String newToolTipText) { getSwtGroup().setToolTipText(newToolTipText); }//toolTipTextChanged()// }//Group//