/* * 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.server; import com.common.debug.Debug; import com.foundation.controller.DecorationManager; import com.foundation.tcv.server.controller.SessionViewController; import com.foundation.tcv.swt.ILayout; import com.foundation.tcv.view.ViewMessage; import com.foundation.view.AbstractDecoration; import com.foundation.view.IVariableResourceAssociationChangeListener; import com.foundation.view.IViewContext; import com.foundation.view.ResourceAssociation; import com.foundation.view.resource.AbstractResourceService; public abstract class Layout implements ILayout, IVariableResourceAssociationChangeListener { /** The container that uses this layout. */ private AbstractComponent container = null; /** The controller for this view session. */ private SessionViewController sessionViewController = null; /** The component number assigned to this instance. */ private int number = -1; /** * Layout constructor. * @param container The container that is using the layout. */ public Layout(AbstractComponent container) { this.container = container; sessionViewController = container.getSessionViewController(); number = sessionViewController.registerComponent(this); sessionViewController.sendMessage(new ViewMessage(0, MESSAGE_CREATE_COMPONENT, getClientClassName(), null, number, 0, true), false); }//Layout()// /** * Gets the view context for the layout. * @return The layout's view context. */ protected IViewContext getViewContext() { return container.getViewContext(); }//getViewContext()// /** * Gets the container using this layout. * @return The container that this layout supports. */ protected AbstractComponent getContainer() { return container; }//getContainer()// /** * Gets the controller for this view session. * @return The controller that provides access to session mechanics. */ public SessionViewController getSessionViewController() { return sessionViewController; }//getSessionViewController()// /** * Initializes the layout. */ public abstract void initialize(); /** * Refreshes the layout by transfering data from the model to the view. */ public abstract void refresh(); /** * Releases the layout. */ public abstract void release(); /** * Gets the qualified class name for the client side class that mirrors the server side component. * @return The client side class name for this component. */ protected abstract String getClientClassName(); /** * Gets the unique number assigned to this view part. * @return The number identifying this view part on both the client and server. */ public int getNumber() { return number; }//getNumber()// /* (non-Javadoc) * @see com.foundation.tcv.view.IAbstractRemoteViewComponent#processRequest(int, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object) */ public final Object processRequest(int eventNumber, Object value1, Object value2, Object value3, Object value4) { return null; }//processRequest()// /* (non-Javadoc) * @see com.foundation.tcv.view.IAbstractRemoteViewComponent#processMessage(com.foundation.tcv.view.ViewMessage) */ public Object processMessage(ViewMessage viewMessage) { Object result = null; switch(viewMessage.getMessageNumber()) { default: { Debug.log("Error: processMessage(ViewMessage) is not implemented."); break; }//default// }//switch// return result; }//processMessage()// /** * Sends a one way message to the server and does not wait for a result. * @param messageNumber The component specific number indicating the message type. * @param messageData The data specific to the message type. */ public void sendMessage(int messageNumber, Object messageData) { sendMessage(messageNumber, messageData, null, 0, 0); }//sendMessage()// /** * Sends a one way message to the server and does not wait for a result. * @param messageNumber The component specific number indicating the message type. * @param messageData The data specific to the message type. */ public void sendMessage(int messageNumber, int messageInteger) { sendMessage(messageNumber, null, null, messageInteger, 0); }//sendMessage()// /** * Sends a one way message to the server and does not wait for a result. * @param messageNumber The component specific number indicating the message type. * @param messageData The data specific to the message type. * @param secondaryMessageData The optional secondary message data reference. * @param messageInteger The numeric data associated with the message. * @param secondaryMessageInteger The secondary numeric data associated with the message. */ public void sendMessage(int messageNumber, Object messageData, Object secondaryMessageData, int messageInteger, int secondaryMessageInteger) { getSessionViewController().sendMessage(new ViewMessage(number, messageNumber, messageData, secondaryMessageData, messageInteger, secondaryMessageInteger, false), false); }//sendMessage()// /* (non-Javadoc) * @see com.foundation.view.ISingleResourceAssociationChangeListener#addDecoration(com.foundation.view.AbstractDecoration) */ public void addDecoration(AbstractDecoration decoration) { }//addDecoration()// /* (non-Javadoc) * @see com.foundation.view.IMultiResourceAssociationChangeListener#addDecoration(com.foundation.view.ResourceAssociation, java.lang.Object, java.lang.Object, com.foundation.view.AbstractDecoration) */ public void addDecoration(ResourceAssociation association, Object row, Object data, AbstractDecoration decoration) { }//addDecoration()// /* (non-Javadoc) * @see com.foundation.view.ISingleResourceAssociationChangeListener#addMessageHold() */ public void addMessageHold() { }//addMessageHold()// /* (non-Javadoc) * @see com.foundation.view.ISingleResourceAssociationChangeListener#getDecorationManager() */ public DecorationManager getDecorationManager() { return container.getDecorationManager(); }//getDecorationManager()// /* (non-Javadoc) * @see com.foundation.view.ISingleResourceAssociationChangeListener#getResourceService() */ public AbstractResourceService getResourceService() { return container.getResourceService(); }//getResourceService()// /* (non-Javadoc) * @see com.foundation.view.ISingleResourceAssociationChangeListener#onValueChanged(com.foundation.view.ResourceAssociation) */ public void onValueChanged(ResourceAssociation resourceAssociation, int flags) { Debug.log(new RuntimeException("Error: Unexpected (unhandled by Layout) resource association found. Resource URL: " + resourceAssociation.toString())); }//onValueChanged()// /* (non-Javadoc) * @see com.foundation.view.IMultiResourceAssociationChangeListener#onValueChanged(com.foundation.view.ResourceAssociation, java.lang.Object, java.lang.Object, boolean) */ public void onValueChanged(ResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) { Debug.log(new RuntimeException("Error: Unexpected (unhandled by Layout) resource association found. Resource URL: " + resourceAssociation.toString())); }//onValueChanged()// /* (non-Javadoc) * @see com.foundation.view.IMultiResourceAssociationChangeListener#onModelExternallyChanged(com.foundation.view.ResourceAssociation, java.lang.Object, java.lang.Object, boolean, java.lang.Object) */ public void onModelExternallyChanged(ResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isCleared, Object originalValue) { }//onModelExternallyChanged()// /* (non-Javadoc) * @see com.foundation.view.ISingleResourceAssociationChangeListener#onModelExternallyChanged(com.foundation.view.ResourceAssociation, boolean, java.lang.Object) */ public void onModelExternallyChanged(ResourceAssociation resourceAssociation, boolean isCleared, Object originalValue) { }//onModelExternallyChanged()// /* (non-Javadoc) * @see com.foundation.view.ISingleResourceAssociationChangeListener#removeDecoration(com.foundation.view.AbstractDecoration) */ public void removeDecoration(AbstractDecoration decoration) { }//removeDecoration()// /* (non-Javadoc) * @see com.foundation.view.ISingleResourceAssociationChangeListener#removeMessageHold() */ public void removeMessageHold() { }//removeMessageHold()// /* (non-Javadoc) * @see com.foundation.view.IMultiResourceAssociationChangeListener#removeDecoration(com.foundation.view.ResourceAssociation, java.lang.Object, java.lang.Object, com.foundation.view.AbstractDecoration) */ public void removeDecoration(ResourceAssociation association, Object row, Object data, AbstractDecoration decoration) { }//removeDecoration()// }//Layout//