/* * Copyright (c) 2006,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.tcv.model.LinkInfo; import com.foundation.tcv.swt.*; import com.foundation.tcv.view.*; public class FontNameComboBox extends Component implements IFontNameComboBox { /** The selection resource. */ private SingleResourceAssociation selection = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, true, null); /** Whether the button's selection state (for check boxes and the like) should be synchronized by the client when changed. */ private boolean autoSynchronizeSelection = false; /** * FontNameComboBox 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. */ public FontNameComboBox(Container parent, String name, int style) { super(parent, name, style); //Initialize the client component.// sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style}); }//FontNameComboBox()// /** * Sets the association container used to access the selection. * @param container The selection association metadata. */ public void setSelectionAssociation(SingleAssociationContainer container) { verifyThread(); this.selection.setAssociations(container); }//setSelectionAssociation()// /** * Adds a link for the selection. * @param link The local linkage for the selection. */ public void addSelectionLink(LinkData link) { sendMessage(MESSAGE_ADD_SELECTION_LINK, new LinkInfo(((AbstractComponent) link.getComponent()).getNumber(), link.getTarget(), link.getData(), link.isBoolean(), link.invertLogic(), link.nullValue())); }//addSelectionLink()// /** * Gets the component selection state. * @return The selection. */ public String getSelection() { verifyThread(); return (String) selection.getValue(); }//getSelection()// /** * Sets the component default selection. * @param selection The component's selection. */ public void setSelection(String selection) { verifyThread(); this.selection.setDefaultValue(selection); }//setSelection()// /** * Sets whether the control auto synchronizes the selected state of the button. * @param autoSynchronizeSelection Whether the button state is automatically synchronized. */ public void setAutoSynchronizeSelection(boolean autoSynchronizeSelection) { verifyThread(); if(autoSynchronizeSelection != this.autoSynchronizeSelection) { this.autoSynchronizeSelection = autoSynchronizeSelection; //Notify the client as to whether it should auto synchronize the selection.// sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION, autoSynchronizeSelection ? Boolean.TRUE : Boolean.FALSE); }//if// }//setAutoSynchronizeSelection()// /* (non-Javadoc) * @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize() */ protected void internalViewInitialize() { super.internalViewInitialize(); selection.initialize(); }//internalViewInitialize()// /* (non-Javadoc) * @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease() */ protected void internalViewRelease() { super.internalViewRelease(); selection.release(); }//internalViewRelease()// /* (non-Javadoc) * @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh() */ protected void internalViewRefresh() { super.internalViewRefresh(); internalViewRefreshSelection(); }//internalViewRefresh()// /** * Refreshes the selection. */ protected void internalViewRefreshSelection() { if(selection.refresh()) { sendMessage(MESSAGE_SET_SELECTION, selection.getValue()); }//if// }//internalViewRefreshSelection()// /* (non-Javadoc) * @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation) */ protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) { if(resourceAssociation == selection) { internalViewRefreshSelection(); }//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()) { case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: { String selection = (String) viewMessage.getMessageData(); this.selection.setValue(selection); break; }//case// 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.FontNameComboBox"; }//getClientClassName()// }//FontNameComboBox//