Initial commit from SVN.

This commit is contained in:
wcrisman
2014-05-30 10:31:51 -07:00
commit b45e56b890
1968 changed files with 370949 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="/Common"/>
<classpathentry kind="src" path="/Foundation"/>
<classpathentry kind="src" path="/SWT"/>
<classpathentry kind="src" path="/Foundation TCV"/>
<classpathentry kind="src" path="/Foundation TCV Server"/>
<classpathentry kind="src" path="/Foundation TCV SWT"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Foundation TCV SWT Server</name>
<comment></comment>
<projects>
<project>Common</project>
<project>Foundation</project>
<project>Foundation TCV</project>
<project>Foundation TCV SWT</project>
<project>Foundation TCV Server</project>
<project>SWT</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,732 @@
/*
* 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 java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import com.common.debug.*;
import com.common.util.optimized.ObjectIntHashMap;
import com.foundation.view.*;
import com.foundation.view.resource.AbstractResourceService;
import com.foundation.controller.AbstractViewController;
import com.foundation.controller.DecorationManager;
import com.foundation.event.*;
import com.foundation.tcv.server.controller.*;
import com.foundation.tcv.view.*;
public abstract class AbstractComponent implements com.foundation.tcv.swt.IAbstractComponent, IAbstractComponent, IAbstractRemoteViewComponent, IEventHandler {
/** Identifies the controller for the client session that this component interacts over. */
private SessionViewController sessionViewController = null;
/** The component's number. This allows lookup of components in the view by the number. */
private int number = -1;
/** The handler for all requests. All requests should pass through this handler so they are handled on the proper thread in the proper order. */
private IViewRequestHandler requestHandler = null;
/** Flags the component to suppress all updates to the view. This is useful for hidden components that will be explicitly refreshed. */
private boolean suppressUpdates = false;
/** Whether the component has already been initialized. This is useful when setting attributes which require initialization after or durring the component's initialization. */
private boolean isInitialized = false;
/** The last used decoration identifier number. */
private int lastDecorationNumber = 0;
/** A mapping of decoration identifier numbers by the decoration. */
private ObjectIntHashMap decorationMap = new ObjectIntHashMap(5);
/**
* AbstractComponent default constructor.
*/
public AbstractComponent() {
}//AbstractComponent()//
/**
* AbstractComponent constructor.
* @param sessionViewController The view component's session controller.
*/
public AbstractComponent(SessionViewController sessionViewController) {
super();
String clientClassName = getClientClassName();
this.sessionViewController = sessionViewController;
requestHandler = sessionViewController.getViewRequestHandler();
//Notify the client to create the control if the control has a client side part.//
if((clientClassName != null) && (clientClassName.length() > 0)) {
number = sessionViewController.registerComponent(this);
sessionViewController.sendMessage(new ViewMessage(0, MESSAGE_CREATE_COMPONENT, getClientClassName(), null, number, 0, true), false);
}//if//
else if(clientClassName == null) {
Debug.log("Error: Must implement the getClientClassName() method and return a non-null value from the class: " + getClass().getName());
}//else if//
}//AbstractComponent()//
/**
* Suspends all layouts and packing while the view is getting setup.
*/
public void suspendLayouts() {
sendMessage(MESSAGE_SUSPEND_LAYOUTS, null, null, 1, -1);
}//suspendLayouts()//
/**
* Resumes processing of requests to layout or pack components.
*/
public void resumeLayouts() {
sendMessage(MESSAGE_SUSPEND_LAYOUTS, null);
}//resumeLayouts()//
/**
* Whether the component is suspending all layouts and packing while the view is getting setup.
* @return Whether the component should not layout or pack.
*/
public boolean isSuspendingLayouts() {
return false;
}//isSuspendingLayouts()//
/* (non-Javadoc)
* @see com.foundation.view.IView#getViewContext()
*/
public IViewContext getViewContext() {
return getSessionViewController().getSessionController();
}//getViewContext()//
/**
* Gets the session view controller for the component.
* @return The component's session view controller.
*/
public SessionViewController getSessionViewController() {
return sessionViewController;
}//getSessionViewController()//
/**
* Gets the event loop used to queue outside requests so that the internals are mostly single threaded.
* @return The request handler that single threads external requests (from the application). Internal requests from the remote process will be handled on a different thread.
*/
protected IViewRequestHandler getEventLoop() {
return requestHandler;
}//getEventLoop()//
/**
* Sets the menu for the component.
* @param menu The menu optionally used by the component.
*/
public void setMenu(Menu menu) {
//Does nothing.//
}//setMenu()//
/**
* Determines whether the calling thread is the view's event thread.
* @return Whether the view's event thread and the calling thread are one and the same.
* @link com.foundation.view.IView.isViewThread()
*/
public boolean isViewThread() {
return getEventLoop().isRequestThread();
}//isViewThread()//
/**
* Verifies that the calling thread is allowed access to the view components.
* <p>Note: This is really a debug only operation and should be turned off for production applications.</p>
*/
public void verifyThread() {
if(!isViewThread()) {
Debug.log(new RuntimeException("Error: Invalid thread."));
}//if//
}//verifyThread()//
/**
* Determines whether updates to the view should be suppressed.
* @return Whether update suppression is requested.
*/
public boolean suppressUpdates() {
return suppressUpdates;
}//suppressUpdates()//
/**
* Determines whether updates to the view should be suppressed.
* @param suppressUpdates Whether update suppression is requested.
*/
public void suppressUpdates(boolean suppressUpdates) {
this.suppressUpdates = suppressUpdates;
}//suppressUpdates()//
/**
* Determines whether the component has already been initialized. This is useful when setting attributes which require initialization after or during the component's initialization.
* @return Whether the component's internalViewInitalize method has been or is being run.
*/
protected boolean isInitialized() {
return isInitialized;
}//isInitialized()//
/**
* Determines whether the component has already been initialized.
* @param isInitialized Whether the component's internalViewInitalize method has been or is being run.
*/
protected void isInitialized(boolean isInitialized) {
this.isInitialized = isInitialized;
}//isInitialized()//
/**
* Gets the component's number which identifies this component in the view.
* @return The view unique number for this component.
*/
public int getNumber() {
return number;
}//getNumber()//
/**
* Gets the component's set of numbers that identifies it uniquely within the session.
* @return The identity of the component within the session.
*/
public long[] getIdentity() {
return new long[] {getSessionViewController().getNumber(), (long) number};
}//getIdentity()//
/**
* Increments the hold count on the message queue so that messages will be queued up until the count reaches zero.
*/
public void addMessageHold() {
//TODO: Remove this method.
suspendMessages();
}//addMessageHold()//
/**
* Decrements the hold count on the message queue so that messages will be queued up until the count reaches zero.
*/
public void removeMessageHold() {
//TODO: Remove this method.
resumeMessages();
}//removeMessageHold()//
/**
* Increments the hold count on the message queue so that messages will be queued up until the count reaches zero.
*/
public void suspendMessages() {
sessionViewController.incrementMessageHoldCount();
}//suspendMessages()//
/**
* Decrements the hold count on the message queue so that messages will be queued up until the count reaches zero.
*/
public void resumeMessages() {
sessionViewController.decrementMessageHoldCount();
}//resumeMessages()//
/**
* Suspends all drawing on the client.
*/
public void suspendRedraw() {
sendMessage(MESSAGE_SUSPEND_REDRAW, null);
}//suspendRedraw()//
/**
* Resumes all drawing on the client.
*/
public void resumeRedraw() {
sendMessage(MESSAGE_RESUME_REDRAW, null);
}//resumeRedraw()//
/**
* Tries to load an image from the file system.
* @param imageName The image name and path. If a path is not provided the application path will be used.
* @return The image bytes, or null if the image was not found.
*/
protected byte[] loadImage(String imageName) {
File file = new File(imageName);
byte[] result = null;
if((file.exists()) && (file.isFile())) {
FileInputStream in = null;
try {
in = new FileInputStream(file);
result = new byte[in.available()];
in.read(result);
}//try//
catch(FileNotFoundException e) {
Debug.log(e, "Unable to load the image: " + imageName);
result = null;
}//catch//
catch(IOException e) {
Debug.log(e, "Unable to load the image: " + imageName);
result = null;
}//catch//
finally {
try {
in.close();
}//try//
catch(Throwable e) {
Debug.handle(e);
}//catch//
}//finally//
}//if//
return result;
}//loadImage()//
/**
* Gets the container containing this component.
* @return The containing container, or null if this component is a root level window.
*/
public abstract IAbstractContainer getContainer();
/* (non-Javadoc)
* @see com.foundation.view.IMultiResourceAssociationChangeListener#getResourceService()
*/
public AbstractResourceService getResourceService() {
return getContainer().getResourceService();
}//getResourceService()//
/**
* Gets the component in the view given the component's view unique number.
* @return The view component assigned the component number.
*/
protected AbstractComponent getComponent(int componentNumber) {
return (AbstractComponent) getSessionViewController().getComponent(componentNumber);
}//getComponent()//
/**
* Creates a new view message with the given message number and message data.
* @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.
* @param isOneWay Whether the message doesn't require a return value.
* @return The view message object representing the message.
*/
private ViewMessage createViewMessage(int messageNumber, Object messageData, Object secondaryMessageData, int messageInteger, int secondaryMessageInteger, boolean isOneWay) {
ViewMessage result = null;
if(number != -1) {
result = new ViewMessage(number, messageNumber, messageData, secondaryMessageData, messageInteger, secondaryMessageInteger, !isOneWay);
}//if//
else {
Debug.log("Error: Cannot send a message to the client from a component that has an invalid number.");
}//else//
return result;
}//createViewMessage()//
/**
* Sends a message to the client component.
* @param messageNumber The message number which will be used by the client component to handle the message and interperate the parameters.
* @param messageData The data associated with the message.
*/
public void sendMessage(int messageNumber, Object messageData) {
sendMessage(messageNumber, messageData, null, 0, 0);
}//sendMessage()//
/**
* Sends a message to the client component.
* @param messageNumber The message number which will be used by the client component to handle the message and interperate the parameters.
* @param messageData The data associated with the message.
* @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) {
sessionViewController.sendMessage(createViewMessage(messageNumber, messageData, secondaryMessageData, messageInteger, secondaryMessageInteger, true), false);
}//sendMessage()//
/**
* Sends a round trip message to the client, waiting until the message result comes back.
* @param messageNumber The control's number for the message (as defined in the control's interface shared between the client and server).
* @param messageData The data specific to the message.
* @return The result of the message.
*/
public Object sendRoundTripMessage(int messageNumber, Object messageData) {
return sendRoundTripMessage(messageNumber, messageData, null, 0, 0);
}//sendRoundTripMessage()//
/**
* Sends a round trip message to the client, waiting until the message result comes back.
* @param messageNumber The control's number for the message (as defined in the control's interface shared between the client and server).
* @param messageData The data specific to the message.
* @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.
* @return The result of the message.
*/
public Object sendRoundTripMessage(int messageNumber, Object messageData, Object secondaryMessageData, int messageInteger, int secondaryMessageInteger) {
return sessionViewController.sendMessage(createViewMessage(messageNumber, messageData, secondaryMessageData, messageInteger, secondaryMessageInteger, false), true);
}//sendRoundTripMessage()//
/* (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()//
/* (non-Javadoc)
* @see com.foundation.event.IHandler#evaluate(int, java.lang.Object[], int)
*/
public final void evaluate(int eventNumber, Object[] arguments, int flags) {
Debug.log("Error: evaluate(int, Object[]) should never be called.");
}//evaluate()//
/* (non-Javadoc)
* @see com.foundation.event.IEventHandler#evaluate(com.foundation.event.IEventEmitter, int, java.lang.Object[], int)
*/
public final void evaluate(final IEventEmitter eventEmitter, final int eventNumber, final Object[] arguments, int flags) {
if(EventSupport.isStandardEvent(flags)) {
verifyThread();
internalEvaluate(eventEmitter, eventNumber, arguments);
}//if//
}//evaluate()//
/**
* A default handler for events received by the component.
* @param eventEmitter The object which fired the event.
* @param eventNumber The unique number for the event.
* @param arguments The event arguments which may be null if there are none.
*/
protected void internalEvaluate(IEventEmitter eventEmitter, int eventNumber, Object[] arguments) {
//Subclasses should override this and provide an implementation.//
//Subclasses would only need an implementation if they had IEventAssociation or IAttributeAssociation attributes.//
internalEvaluate(eventEmitter, EventSupport.getEventName(eventEmitter.getClass(), eventNumber), arguments);
}//internalEvaluate()//
/**
* A default handler for events received by the component.
* @param eventEmitter The object which fired the event.
* @param eventNumber The unique name for the event.
* @param arguments The event arguments which may be null if there are none.
*/
protected void internalEvaluate(IEventEmitter eventEmitter, String eventName, Object[] arguments) {
//Subclasses should override this and provide an implementation.//
//Subclasses would only need an implementation if they had IEventAssociation or IAttributeAssociation attributes.//
}//internalEvaluate()//
/* (non-Javadoc)
* @see com.foundation.view.IAttributeAssociationChangeListener#onValueChanged(com.foundation.view.IAttributeAssociation)
*/
public void onValueChanged(IAttributeAssociation attributeAssociation) {
verifyThread();
internalOnValueChanged(attributeAssociation);
}//onValueChanged()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#onValueChanged(com.foundation.view.ResourceAssociation, int)
*/
public final void onValueChanged(ResourceAssociation resourceAssociation, int flags) {
verifyThread();
if(isInitialized()) {
if(resourceAssociation instanceof SingleResourceAssociation) {
internalOnValueChanged((SingleResourceAssociation) resourceAssociation, flags);
}//if//
else if(resourceAssociation instanceof CollectingSingleResourceAssociation) {
internalOnValueChanged((CollectingSingleResourceAssociation) resourceAssociation);
}//else if//
}//if//
}//onValueChanged()//
/* (non-Javadoc)
* @see com.foundation.view.IMultiResourceAssociationChangeListener#onValueChanged(com.foundation.view.ResourceAssociation, java.lang.Object, java.lang.Object, boolean)
*/
public final void onValueChanged(ResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
verifyThread();
if(isInitialized()) {
if(resourceAssociation instanceof MultiResourceAssociation) {
internalOnValueChanged((MultiResourceAssociation) resourceAssociation, alteredItem, data, isUpdate);
}//else if//
else if(resourceAssociation instanceof CollectingMultiResourceAssociation) {
internalOnValueChanged((CollectingMultiResourceAssociation) resourceAssociation, alteredItem, data);
}//else if//
}//if//
}//onValueChanged()//
/* (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) {
verifyThread();
if(isInitialized()) {
internalOnModelExternallyChanged((SingleResourceAssociation) resourceAssociation, isCleared, originalValue);
}//if//
}//onModelExternallyChanged()//
/* (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) {
verifyThread();
if(isInitialized()) {
internalOnModelExternallyChanged((MultiResourceAssociation) resourceAssociation, alteredItem, data, isCleared, originalValue);
}//if//
}//onModelExternallyChanged()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#onEventFired(com.foundation.view.IEventAssociation, java.lang.Object[])
*/
public void onEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
verifyThread();
addMessageHold();
try {
internalOnEventFired(eventAssociation, eventArguments);
}//try//
finally {
removeMessageHold();
}//finally//
}//onEventFired()//
/**
* Called by the value holders when a registered attribute changes value or the value containing the attribute changes.
* @param attributeAssociation The attribute association used to register with the attribute.
*/
protected void internalOnValueChanged(IAttributeAssociation attributeAssociation) {
Debug.log(new RuntimeException("Error: Unexpected (unhandled by AbstractComponent) attribute association found. AttributeName: " + attributeAssociation.getAttributeName()));
}//internalOnValueChanged()//
/**
* Called by the resource association when a resource changes value.
* <p>The change in value will be because the resource context altered its set of current resources and the associated resources was in the set that was altered.</p>
* @param resourceAssociation The resource association used to register with the resource.
* @param isUpdate Whether the alteration was due to the object's reflected object updating it, in which case the user might want to be warned.
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
Debug.log(new RuntimeException("Error: Unexpected (unhandled by AbstractComponent) resource association found. Resource URL: " + resourceAssociation.toString()));
}//internalOnValueChanged()//
/**
* Called by the resource association when a resource changes value.
* <p>The change in value will be because the resource context altered its set of current resources and the associated resources was in the set that was altered.</p>
* @param resourceAssociation The resource association used to register with the resource.
* @param alteredItem The item whose value has been altered.
* @param data The data passed when the item was registered with the resource association.
* @param isUpdate Whether the alteration was due to the object's reflected object updating it, in which case the user might want to be warned.
*/
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
Debug.log(new RuntimeException("Error: Unexpected (unhandled by AbstractComponent) resource association found. Resource URL: " + resourceAssociation.toString()));
}//internalOnValueChanged()//
/**
* Called by the resource association when a resource changes value.
* <p>The change in value will be because the resource context altered its set of current resources and the associated resources was in the set that was altered.</p>
* @param resourceAssociation The resource association used to register with the resource.
* @param alteredItem The item whose value has been altered.
* @param data The data passed when the item was registered with the resource association.
*/
protected void internalOnValueChanged(CollectingMultiResourceAssociation resourceAssociation, Object alteredItem, Object data) {
Debug.log(new RuntimeException("Error: Unexpected (unhandled by AbstractComponent) resource association found. Resource URL: " + resourceAssociation.toString()));
}//internalOnValueChanged()//
/**
* Called by the resource association when a resource changes value.
* <p>The change in value will be because the resource context altered its set of current resources and the associated resources was in the set that was altered.</p>
* @param resourceAssociation The resource association used to register with the resource.
*/
protected void internalOnValueChanged(CollectingSingleResourceAssociation resourceAssociation) {
Debug.log(new RuntimeException("Error: Unexpected (unhandled by AbstractComponent) resource association found. Resource URL: " + resourceAssociation.toString()));
}//internalOnValueChanged()//
/**
* Called by the resource association when a resource changes value.
* <p>The change in value will be because the resource context altered its set of current resources and the associated resources was in the set that was altered.</p>
* @param resourceAssociation The resource association used to register with the resource.
* @param isCleared Whether the original value was cleared, in which case the original value parameter should be ignored.
* @param originalValue The model value unaltered by the view's user.
*/
protected void internalOnModelExternallyChanged(SingleResourceAssociation resourceAssociation, boolean isCleared, Object originalValue) {
//Debug.log(new RuntimeException("Error: Unexpected (unhandled by AbstractComponent) resource association found. Resource URL: " + resourceAssociation.toString()));
}//internalOnModelExternallyChanged()//
/**
* Called by the resource association when a resource changes value.
* <p>The change in value will be because the resource context altered its set of current resources and the associated resources was in the set that was altered.</p>
* @param resourceAssociation The resource association used to register with the resource.
* @param alteredItem The item whose value has been altered.
* @param data TODO
* @param isCleared Whether the original value was cleared, in which case the original value parameter should be ignored.
* @param originalValue The model value unaltered by the view's user.
*/
protected void internalOnModelExternallyChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isCleared, Object originalValue) {
//Debug.log(new RuntimeException("Error: Unexpected (unhandled by AbstractComponent) resource association found. Resource URL: " + resourceAssociation.toString()));
}//internalOnModelExternallyChanged()//
/**
* Called when any event association connected with this component is notified that the event has fired.
* @param eventAssociation The event association for the event that was fired.
* @param eventArguments The non-null event arguments as received by the event association.
*/
protected void internalOnEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
Debug.log(new RuntimeException("Error: Unexpected (unhandled by AbstractComponent) event association found. Event Number: " + eventAssociation.getEventNumber()));
}//internalOnEventFired()//
/* (non-Javadoc)
* @see com.foundation.view.IView#viewInitializeAll()
*/
public final void viewInitializeAll() {
verifyThread();
// suspendMessages();
// suspendRedraw();
try {
internalViewInitializeAll();
sendMessage(MESSAGE_VIEW_INITIALIZE_ALL, null);
internalViewRefreshAll();
sendMessage(MESSAGE_VIEW_INITIALIZATION_COMPLETE, null);
}//try//
finally {
// resumeRedraw();
// resumeMessages();
}//finally//
}//viewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.view.IView#viewReleaseAll()
*/
public final void viewReleaseAll() {
verifyThread();
suspendMessages();
//suspendRedraw();
try {
internalViewReleaseAll();
sendMessage(MESSAGE_VIEW_RELEASE_ALL, null);
}//try//
finally {
//resumeRedraw();
resumeMessages();
}//finally//
}//viewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.view.IView#viewRefreshAll()
*/
public final void viewRefreshAll() {
verifyThread();
addMessageHold();
try {
//Don't send any message to the client. Each control will send what ever refresh messages are necessary.//
internalViewRefreshAll();
}//try//
finally {
removeMessageHold();
}//finally//
}//viewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.view.IView#viewSynchronizeAll()
*/
public final void viewSynchronizeAll() {
verifyThread();
try {
internalViewSynchronizeAll();
}//try//
catch(Throwable e) {
Debug.handle(e);
}//catch//
}//viewSynchronizeAll()//
/* (non-Javadoc)
* @see com.foundation.view.IView#viewRefreshAll()
*/
public final void viewRefresh() {
verifyThread();
addMessageHold();
try {
//Don't send any message to the client. Each control will send what ever refresh messages are necessary.//
internalViewRefresh();
}//try//
finally {
removeMessageHold();
}//finally//
}//viewRefresh()//
/* (non-Javadoc)
* @see com.foundation.view.IView#viewSynchronize()
*/
public final void viewSynchronize() {
verifyThread();
try {
sendRoundTripMessage(MESSAGE_VIEW_SYNCHRONIZE, null);
}//try//
catch(Throwable e) {
Debug.handle(e);
}//catch//
}//viewSynchronize()//
/**
* Initializes this view and all its' contained components.
*/
protected void internalViewInitializeAll() {
try {
//Initialize this component.//
internalViewInitialize();
}//try//
catch(Throwable e) {
Debug.log(e);
Debug.halt();
}//catch//
}//internalViewInitializeAll()//
/**
* Releases this view and all its' contained components.
*/
protected void internalViewReleaseAll() {
try {
//Release this component.//
internalViewRelease();
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}//internalViewReleaseAll()//
/**
* Refreshes this view and all its' contained components.
*/
protected void internalViewRefreshAll() {
try {
//Refresh this component.//
internalViewRefresh();
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}//internalViewRefreshAll()//
/**
* Initializes this component only.
* @see #internalViewInitializeAll()
*/
protected void internalViewInitialize() {
this.isInitialized = true;
}//internalViewInitialize()//
/**
* Releases this component only.
* @see #internalViewReleaseAll()
*/
protected void internalViewRelease() {
}//internalViewRelease()//
/**
* Refreshes this component only.
* @see #internalViewRefreshAll()
*/
protected void internalViewRefresh() {
}//internalViewRefresh()//
/**
* Synchronize this component only.
* @see #internalViewSynchronizeAll()
*/
protected final void internalViewSynchronize() {
sendRoundTripMessage(MESSAGE_VIEW_SYNCHRONIZE, null);
}//internalViewSynchronize()//
/**
* Synchronizes this view and all its' contained components.
*/
protected void internalViewSynchronizeAll() {
sendRoundTripMessage(MESSAGE_VIEW_SYNCHRONIZE_ALL, null);
}//internalViewSynchronizeAll()//
/**
* 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 controller for the view component.
* @return The view's controller.
*/
public AbstractViewController getController() {
return getContainer().getController();
}//getController()//
/**
* Notifies the view controller that it should validate.
*/
protected void postSynchronizeValidate() {
getController().validate();
}//postSynchronizeValidate()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#getDecorationManager()
*/
public DecorationManager getDecorationManager() {
return getController().getDecorationManager();
}//getDecorationManager()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#addDecoration(com.foundation.view.AbstractDecoration)
*/
public void addDecoration(AbstractDecoration decoration) {
decorationMap.put(decoration, ++lastDecorationNumber);
sendMessage(MESSAGE_ADD_DECORATION, decoration, null, lastDecorationNumber, -1);
}//addDecoration()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#removeDecoration(com.foundation.view.AbstractDecoration)
*/
public void removeDecoration(AbstractDecoration decoration) {
if(decoration != null) {
sendMessage(MESSAGE_REMOVE_DECORATION, null, null, decorationMap.remove(decoration), -1);
}//if//
}//removeDecoration()//
/* (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.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()//
}//AbstractComponent//

View File

@@ -0,0 +1,366 @@
/*
* 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.common.comparison.Comparator;
import com.foundation.view.*;
import com.foundation.view.resource.ResourceReference;
import com.foundation.tcv.model.LinkInfo;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.view.*;
public class Button extends Component implements IButton {
/** Called when the button is pressed (only used for push buttons). */
private IMethodAssociation selectionMethod = null;
/** The button's selection state resource. */
private SingleResourceAssociation selection = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_OBJECT, true, Boolean.FALSE);
/** The button's text resource. */
private SingleResourceAssociation text = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, "");
/** The button's image resource. */
private SingleResourceAssociation image = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGE, false, null);
/** The optional object that represents a selection of this button. Used for radio buttons only - to allow them to work on the same attribute. Never used for the linkages. */
private Object selectionData = 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;
/** The delay to be used when auto synchronizing changes to the text. */
private long autoSynchronizeSelectionDelay = 500;
/** Whether the view should be disabled while a selection event is processed. */
private boolean blockOnSelection = false;
/** Whether this is a stateful button. */
private final boolean isStateful;
/** Whether this is a radio button. */
private final boolean isRadio;
/** Whether this is a push button. */
private final boolean isPush;
/** Whether the validation code in the view controller should be executed after synchronizing the state. */
private boolean autoValidate = false;
/**
* Button 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 #STYLE_ARROW
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_RADIO
* @see #STYLE_TOGGLE
* @see #STYLE_FLAT
* @see #STYLE_LEFT
* @see #STYLE_RIGHT
* @see #STYLE_CENTER
* @see #STYLE_UP
* @see #STYLE_DOWN
*/
public Button(IAbstractContainer parent, String name, int style) {
super(parent, name, style);
isRadio = (style & STYLE_RADIO) > 0;
isStateful = isRadio || ((style & STYLE_TOGGLE) > 0) || ((style & STYLE_CHECK) > 0);
isPush = !isStateful;
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, null, null, ((AbstractComponent) parent).getNumber(), style);
//Don't set a delay for standard push buttons.//
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long((((style & STYLE_CHECK) > 0) || ((style & STYLE_RADIO) > 0) || ((style & STYLE_TOGGLE) > 0)) ? 500 : 0));
}//Button()//
/**
* Gets the optional selection data for the radio button (radio only).
* @return The data to use to determine whether this button is selected (within the group of radio buttons) and to pass to the model when selected.
*/
public Object getSelectionData() {
verifyThread();
return selectionData;
}//getSelectionData()//
/**
* Sets the optional selection data for the radio button (radio only).
* @param selectionData The data to use to determine whether this button is selected (within the group of radio buttons) and to pass to the model when selected.
*/
public void setSelectionData(Object selectionData) {
verifyThread();
if(isRadio && !isInitialized()) {
this.selectionData = selectionData;
}//if//
}//setSelectionData()//
/**
* Sets an 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 an 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 an 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()//
/**
* Sets the component text.
* @param text The text that will appear in the component.
*/
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 component image.
* @param image The image to be displayed by the component.
*/
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()//
/**
* Gets the component selection state.
* @return Whether the component is in the selected state.
*/
public Boolean getIsSelected() {
verifyThread();
return (Boolean) selection.getValue();
}//getIsSelected()//
/**
* Sets the component default selection state.
* @param isSelected Whether the component is in the selected state.
*/
public void setIsSelected(Boolean isSelected) {
verifyThread();
if(isStateful) {
selection.setDefaultValue(isSelected);
}//if//
}//setIsSelected()//
/**
* Sets the selection method called when the button is pressed (intended for push buttons).
* @param selectionMethod The method called when the button is selected.
*/
public void setSelectionMethod(IMethodAssociation selectionMethod) {
verifyThread();
if(isPush) {
this.selectionMethod = selectionMethod;
sendMessage(MESSAGE_SET_BLOCK_ON_SELECTIONS, selectionMethod != null ? Boolean.TRUE : Boolean.FALSE);
}//if//
}//setSelectionMethod()//
/**
* Sets whether validate routine is called after a synchronize.
* @param autoValidate Whether the validation code in the view controller will be called after synchronizing the state.
*/
public void setAutoValidate(boolean autoValidate) {
this.autoValidate = autoValidate;
}//setAutoValidate()//
/**
* 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((isStateful) && (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()//
/**
* Sets the delay for the auto synchronize selection.
* @param autoSynchronizeSelectionDelay The delay in terms of milliseconds between the value of zero and ten thousand. A zero value has no delay.
*/
public void setAutoSynchronizeSelectionDelay(long autoSynchronizeSelectionDelay) {
verifyThread();
if(autoSynchronizeSelectionDelay < 0) {
autoSynchronizeSelectionDelay = 0;
}//if//
else if(autoSynchronizeSelectionDelay > 10000) {
autoSynchronizeSelectionDelay = 10000;
}//else if//
if((isStateful) && (autoSynchronizeSelectionDelay != this.autoSynchronizeSelectionDelay)) {
this.autoSynchronizeSelectionDelay = autoSynchronizeSelectionDelay;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long(autoSynchronizeSelectionDelay));
}//if//
}//setAutoSynchronizeSelectionDelay()//
/**
* Sets whether the client views should be disabled while a selection event is processed.
* @param blockOnSelection Whether push style buttons stop user input while processing the selection event.
*/
public void setBlockOnSelection(boolean blockOnSelection) {
verifyThread();
if((!isStateful) && (blockOnSelection != this.blockOnSelection)) {
this.blockOnSelection = blockOnSelection;
sendMessage(MESSAGE_SET_BLOCK_ON_SELECTIONS, blockOnSelection ? Boolean.TRUE : Boolean.FALSE);
}//if//
}//setBlockOnSelection()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
text.initialize();
image.initialize();
selection.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
text.release();
image.release();
selection.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
internalViewRefreshSelection();
internalViewRefreshText();
internalViewRefreshImage();
}//internalViewRefresh()//
/**
* Refreshes the button image.
*/
protected void internalViewRefreshImage() {
if(image.refresh()) {
sendMessage(MESSAGE_SET_IMAGE, image.getValue());
}//if//
}//internalViewRefreshImage()//
/**
* Refreshes the button text.
*/
protected void internalViewRefreshText() {
if(text.refresh()) {
sendMessage(MESSAGE_SET_TEXT, text.getValue());
}//if//
}//internalViewRefreshText()//
/**
* Refreshes the selection.
*/
protected void internalViewRefreshSelection() {
if(selection.refresh()) {
Object value = selection.getValue();
Boolean isSelected;
if(value instanceof Boolean) {
isSelected = (Boolean) value;
}//if//
else if(selectionData != null) {
isSelected = Comparator.equals(selectionData, value) ? Boolean.TRUE : Boolean.FALSE;
}//else if//
else {
isSelected = value != null ? Boolean.TRUE : Boolean.FALSE;
}//else//
sendMessage(MESSAGE_SET_IS_SELECTED, isSelected);
}//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 == text) {
internalViewRefreshText();
}//else if//
else if(resourceAssociation == image) {
internalViewRefreshImage();
}//else if//
else if(resourceAssociation == selection) {
internalViewRefreshSelection();
}//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 result = null;
switch(viewMessage.getMessageNumber()) {
case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: {
Boolean selectionState = (Boolean) viewMessage.getMessageData();
//Call the selection method.//
if((!isStateful) && (selectionMethod != null)) {
selectionMethod.invoke(null, true);
}//if//
//Update the selection value.//
if(isStateful) {
boolean isSelected = selectionState.booleanValue();
if(isRadio && isSelected) {
//Only positive values are sent for radio buttons.//
selection.setValue(selectionData != null ? selectionData : Boolean.TRUE);
}//if//
else if(!isRadio) {
selection.setValue(isSelected ? Boolean.TRUE : Boolean.FALSE);
}//else if//
}//if//
if(autoValidate) {
postSynchronizeValidate();
}//if//
break;
}//case//
default: {
result = super.processMessage(viewMessage);
}//default//
}//switch//
return result;
}//processMessage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.Button";
}//getClientClassName()//
}//Button//

View File

@@ -0,0 +1,93 @@
/*
* 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//

View File

@@ -0,0 +1,34 @@
package com.foundation.tcv.swt.server;
public class CenterLayout extends Layout {
/**
* CenterLayout constructor.
* @param container The container that is using the layout.
*/
public CenterLayout(AbstractComponent container) {
super(container);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, getContainer().getNumber());
}//CenterLayout()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.CenterLayout";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#initialize()
*/
public void initialize() {
}//initialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#refresh()
*/
public void refresh() {
}//refresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#release()
*/
public void release() {
}//release()//
}//CenterLayout//

View File

@@ -0,0 +1,176 @@
/*
* 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.event.*;
import com.foundation.tcv.swt.*;
import com.foundation.view.JefImage;
import com.foundation.view.MultiAssociationContainer;
import com.foundation.view.MultiResourceAssociation;
import com.foundation.view.ResourceAssociation;
public class ComboBox extends IndexedCollectionComponent implements IEventListener, IComboBox {
/** The text limit set by the application. */
private Integer textLimit = null;
/** Converts the collection item to a string used to show the item to the user. */
protected MultiResourceAssociation itemText = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_TEXT, false, null);
/** Converts the collection item to an image used to show the item to the user. */
protected MultiResourceAssociation itemImage = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_IMAGE, false, null);
/**
* ComboBox 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 #STYLE_DROP_DOWN
* @see #STYLE_READ_ONLY
* @see #STYLE_SIMPLE
*/
public ComboBox(Container parent, String name, int style) {
super(parent, name, style);
setAllowUserItems(!((style & STYLE_READ_ONLY) > 0));
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//ComboBox()//
/**
* Sets the association container used to access the item text.
* @param container The item text association metadata.
*/
public void setItemTextAssociation(MultiAssociationContainer container) {
verifyThread();
this.itemText.setAssociations(container);
}//setItemTextAssociation()//
/**
* Sets the association container used to access the item image.
* @param container The item image association metadata.
*/
public void setItemImageAssociation(MultiAssociationContainer container) {
verifyThread();
this.itemImage.setAssociations(container);
}//setItemImageAssociation()//
/**
* Gets the component text size limit.
* @return The maximum number of characters allowed in the text.
*/
public Integer getTextLimit() {
return textLimit;
}//getTextLimit()//
/**
* Sets the component text size limit.
* @param textLimit The maximum number of characters allowed in the text.
*/
public void setTextLimit(Integer textLimit) {
this.textLimit = textLimit;
sendMessage(MESSAGE_SET_TEXT_LIMIT, textLimit);
}//setTextLimit()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
itemText.initialize();
itemImage.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
itemText.release();
itemImage.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object)
*/
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
if(resourceAssociation == itemText) {
internalViewRefreshItem(alteredItem);
}//if//
else if(resourceAssociation == itemImage) {
internalViewRefreshItem(alteredItem);
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, alteredItem, data, isUpdate);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#getItemData(com.foundation.tcv.swt.server.RowObject)
*/
protected Object getItemData(RowObject rowObject) {
return itemToString(rowObject.value);
}//getItemData()//
/**
* Converts an item in the collection to a string that can be displayed.
* @param item The collection item to convert.
* @return The string that can be displayed.
*/
protected String itemToString(Object item) {
String result = null;
if(item instanceof JefImage) {
return "";
}//if//
else {
itemText.refresh(item);
result = (String) itemText.getValue(item);
if(result == null) {
result = item != null ? item.toString() : "";
}//if//
}//if//
return result;
}//itemToString()//
/**
* Converts an item in the collection to an image that can be displayed.
* @param item The collection item to convert.
* @return The image that can be displayed.
*/
protected JefImage itemToImage(Object item) {
JefImage result = null;
if(item instanceof JefImage) {
result = (JefImage) item;
}//if//
else {
itemImage.refresh(item);
result = (JefImage) itemImage.getValue(item);
}//else//
return result;
}//itemToImage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#registerItem(java.lang.Object)
*/
protected void registerItem(RowObject rowObject) {
itemText.registerItem(rowObject.value);
itemImage.registerItem(rowObject.value);
super.registerItem(rowObject);
}//registerItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItem(java.lang.Object)
*/
protected void unregisterItem(RowObject rowObject) {
itemText.unregisterItem(rowObject.value);
itemImage.unregisterItem(rowObject.value);
super.unregisterItem(rowObject);
}//unregisterItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItems()
*/
protected void unregisterItems() {
itemText.unregisterAllItems();
itemImage.unregisterAllItems();
super.unregisterItems();
}//unregisterItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.ComboBox";
}//getClientClassName()//
}//Combobox//

View File

@@ -0,0 +1,846 @@
/*
* 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 org.eclipse.swt.SWT;
import com.common.util.IHashSet;
import com.common.util.IIterator;
import com.common.util.IList;
import com.common.util.LiteHashSet;
import com.common.util.LiteList;
import com.foundation.view.*;
import com.foundation.view.resource.ResourceReference;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.server.controller.*;
import com.foundation.tcv.view.*;
/*
* The component is the base class for all standard view components.
*/
public abstract class Component extends AbstractComponent implements IComponent {
/** Sends the component name to the client for debugging. */
private static final boolean DEBUG = false;
/** The parent associated with this component. Almost all components will have a parent. */
private IAbstractContainer container = null;
/** The reference to the popup menu. Not all components must allow a popup menu. */
private Menu menu = null;
/** The component's name. This allows lookup of components in the view by the name. */
private String name = null;
/** The resource defining the visible state for the component. */
private SingleResourceAssociation isVisible = null;
/** The resource defining the enabled state for the component. */
private SingleResourceAssociation isEnabled = null;
/** The resource defining the tool tip text for the component. */
private SingleResourceAssociation toolTipText = null;
/** The resource defining the component's background color. */
private SingleResourceAssociation backgroundColor = null;
/** The resource defining the component's foreground color. */
private SingleResourceAssociation foregroundColor = null;
/** The font used by the label. */
private SingleResourceAssociation font = null;
/** The container's title resource which may be used in different ways depending on the context (such as a frame title, or a tab title). */
private SingleResourceAssociation containerTitle = null;
/** The container's image resource which may be used in different ways depending on the context (such as a frame icon, or a tab image). */
private SingleResourceAssociation containerImage = null;
/** The container's background image resource. */
private SingleResourceAssociation backgroundImage = null;
/** The event associations for the focus gained event. */
private IHashSet gainFocusEventAssociations = null;
/** The set of key bindings in search order. */
private IList keyBindings = null;
/** The optional decimal scale to be used by the component if it deals with decimal values. */
private Integer decimalScale = null;
/**
* Component default constructor.
* <p>Warning: This is only for use by the framework. This should never be called to create a useable instance.</p>
*/
public Component() {
}//Component()//
/**
* Component constructor.
* @param controller The session view controller.
* @param parent The non-null parent container for this container.
* @param name The component's name. This allows lookup of components in the view by the name.
*/
public Component(IAbstractContainer parent, String name, int style) {
super(((AbstractComponent) parent).getSessionViewController());
this.container = parent;
this.name = name;
this.container.addComponent(this);
initialize();
if((style & SWT.NO_BACKGROUND) > 0) {
sendMessage(MESSAGE_USE_CUSTOM_BACKGROUND, null);
}//if//
}//Component()//
/**
* Component constructor.
* This constructor is used if this is the top level component and has no parent.
* @param sessionViewController The session view controller for this view.
* @param name The name of the component.
*/
public Component(SessionViewController sessionViewController, String name, int style) {
super(sessionViewController);
this.name = name;
this.container = null;
initialize();
}//Component()//
/**
* Initializes the component.
* <p>Note: This is separated so that a view can be instantiated via the default constructor for the purpose of determining the reflection metadata associated with the view. Any other call to the default constructor will create an invalid view.</p>
*/
private void initialize() {
isVisible = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, false, getDefaultVisibility() ? Boolean.TRUE : Boolean.FALSE);
isEnabled = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, false, Boolean.TRUE);
toolTipText = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, null);
backgroundColor = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_GRADIENT, false, null);
foregroundColor = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_COLOR, false, null);
font = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_FONT, false, null);
containerTitle = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, null);
containerImage = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGE, false, null);
backgroundImage = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGE, false, null);
if(DEBUG) {
//TEST CODE//
sendMessage(MESSAGE_SET_NAME, getName());
}//if//
}//initialize()//
/**
* Gets the window which contains this component.
* @return The window containing this component.
*/
public Window getContainingWindow() {
Component next = this;
while((next != null) && (!(next instanceof Window))) {
next = (Component) next.getContainer();
}//while//
return (Window) next;
}//getContainingWindow()//
/**
* Gets the frame which contains this component.
* <p>Note: This is usually the same as calling getContainingWindow. It is not the same if using MDI (Mulitple Document Interface) or floating frames inside another window.</p>
* @return The frame containing this component.
*/
public Frame getContainingFrame() {
Component next = this;
while((next != null) && (!(next instanceof Frame))) {
next = (Component) next.getContainer();
}//while//
return (Frame) next;
}//getContainingFrame()//
/**
* Displays the update decoration on the control letting the user know something changed on them.
*/
public void displayUpdateControlDecoration() {
sendMessage(MESSAGE_DISPLAY_UPDATE_CONTROL_DECORATION, null);
}//displayUpdateControlDecoration()//
/**
* Gets whether the component is visible by default.
* @return Whether or not the components implementation is visible by default.
*/
protected boolean getDefaultVisibility() {
return true;
}//getDefaultVisibility()//
/**
* Gets the parent container for this component.
* @return The view component containing this component.
*/
public IAbstractContainer getContainer() {
return container;
}//getContainer()//
/**
* Gets the popup menu for the component.
* @return The menu that appears if the user right clicks on the component.
*/
public Menu getMenu() {
verifyThread();
return menu;
}//getMenu()//
/**
* Sets the popup menu for the component.
* @param menu The menu that appears if the user right clicks on the component.
*/
public void setMenu(Menu menu) {
verifyThread();
if(isInitialized() && this.menu != null) {
this.menu.internalViewReleaseAll();
}//if//
this.menu = menu;
if((isInitialized()) && (menu != null)) {
menu.internalViewInitializeAll();
}//if//
}//setMenu()//
/**
* Gets the component's name.
* @return The name of this component.
*/
public String getName() {
return name;
}//getName()//
/**
* Sets the layout data for the component.
* @param layoutData The data that describes how the component is to be layed out within its parent.
*/
public void setLayoutData(Object layoutData) {
verifyThread();
sendMessage(MESSAGE_SET_LAYOUT_DATA, layoutData);
}//setLayoutData()//
/**
* Sets the component bounds.
* @param x The upper left point's X coordinate.
* @param y The upper left point's Y coordinate.
* @param width The number of pixels of width.
* @param height The number of pixels of height.
*/
public void setBounds(int x, int y, int width, int height) {
verifyThread();
sendMessage(MESSAGE_SET_BOUNDS, new int[] {x, y, width, height});
}//setBounds()//
/**
* Sets the component's location.
* @param x The upper left point's X coordinate.
* @param y The upper left point's Y coordinate.
*/
public void setLocation(int x, int y) {
verifyThread();
sendMessage(MESSAGE_SET_LOCATION, new int[] {x, y});
}//setLocation()//
/**
* Sets the component's size.
* @param width The number of pixels of width.
* @param height The number of pixels of height.
*/
public void setSize(int width, int height) {
verifyThread();
sendMessage(MESSAGE_SET_SIZE, new int[] {width, height});
}//setSize()//
/**
* Sets the focus to be on this component.
* @return Whether the component accepted the focus.
*/
public void setFocus() {
verifyThread();
sendMessage(MESSAGE_SET_FOCUS, null);
}//setFocus()//
/**
* Adds an association for the gain focus event.
* @param association The association.
*/
public void addGainFocusEventAssociation(IEventAssociation association) {
if(gainFocusEventAssociations == null) {
gainFocusEventAssociations = new LiteHashSet(4);
}//if//
association.setChangeListener(this);
gainFocusEventAssociations.add(association);
if(isInitialized()) {
association.register();
}//if//
}//setGainFocusEventAssociation()//
/**
* Adds a key binding to the component.
* @param keyBinding The key binding which will be notified when the key combination occurs.
*/
public void addKeyBinding(IKeyBinding keyBinding) {
if(keyBindings == null) {
keyBindings = new LiteList(10, 40);
}//if//
keyBindings.add(keyBinding);
sendMessage(MESSAGE_ADD_KEY_BINDING, new KeyBindingData(keyBinding.getModifiers(), keyBinding.getKeyCode()));
}//addKeyBinding()//
/**
* Sets the association container used to access whether the control is enabled.
* @param container The enabled state association metadata.
*/
public void setIsEnabledAssociation(SingleAssociationContainer container) {
verifyThread();
this.isEnabled.setAssociations(container);
}//setIsEnabledAssociation()//
/**
* Sets the association container used to access whether the control is visible.
* @param container The visible state association metadata.
*/
public void setIsVisibleAssociation(SingleAssociationContainer container) {
verifyThread();
this.isVisible.setAssociations(container);
}//setIsVisibleAssociation()//
/**
* Sets the association container used to access the foreground color.
* @param container The forground color association metadata.
*/
public void setForegroundColorAssociation(SingleAssociationContainer container) {
verifyThread();
this.foregroundColor.setAssociations(container);
}//setForegroundColorAssociation()//
/**
* Sets the association container used to access the background color.
* @param container The background color association metadata.
*/
public void setBackgroundColorAssociation(SingleAssociationContainer container) {
verifyThread();
this.backgroundColor.setAssociations(container);
}//setBackgroundColorAssociation()//
/**
* Sets the association container used to access the font.
* @param container The font association metadata.
*/
public void setFontAssociation(SingleAssociationContainer container) {
verifyThread();
this.font.setAssociations(container);
}//setFontAssociation()//
/**
* Sets the association container used to access the tool tip text.
* @param container The tool tip association metadata.
*/
public void setToolTipTextAssociation(SingleAssociationContainer container) {
verifyThread();
this.toolTipText.setAssociations(container);
}//setToolTipTextAssociation()//
/**
* Sets the association container used to access the title.
* @param container The title association metadata.
*/
public void setContainerTitleAssociation(SingleAssociationContainer container) {
verifyThread();
this.containerTitle.setAssociations(container);
}//setContainerTitleAssociation()//
/**
* Sets the association container used to access the image.
* @param container The image association metadata.
*/
public void setContainerImageAssociation(SingleAssociationContainer container) {
verifyThread();
this.containerImage.setAssociations(container);
}//setContainerImageAssociation()//
/**
* Sets the change decoration image.
* @param image The image to use for the change decoration.
*/
public void setDefaultChangeImage(JefImage image) {
verifyThread();
sendMessage(MESSAGE_SET_CHANGE_IMAGE, image);
}//setDefaultChangeImage()//
/**
* Sets the change decoration image.
* @param image The image to use for the change decoration.
*/
public void setDefaultChangeImage(ResourceReference image) {
verifyThread();
sendMessage(MESSAGE_SET_CHANGE_IMAGE, image);
}//setDefaultChangeImage()//
/**
* Sets the change decoration text.
* @param text The text to use for the change decoration.
*/
public void setDefaultChangeText(String text) {
verifyThread();
sendMessage(MESSAGE_SET_CHANGE_TEXT, text);
}//setDefaultChangeImage()//
/**
* Sets the change decoration text.
* @param text The text to use for the change decoration.
*/
public void setDefaultChangeText(ResourceReference text) {
verifyThread();
sendMessage(MESSAGE_SET_CHANGE_TEXT, text);
}//setDefaultChangeText()//
/**
* Sets the update decoration text.
* @param text The text to use for the update decoration.
*/
public void setDefaultUpdateText(String text) {
verifyThread();
sendMessage(MESSAGE_SET_UPDATE_TEXT, text);
}//setDefaultUpdateImage()//
/**
* Sets the update decoration text.
* @param text The text to use for the update decoration.
*/
public void setDefaultUpdateText(ResourceReference text) {
verifyThread();
sendMessage(MESSAGE_SET_UPDATE_TEXT, text);
}//setDefaultUpdateText()//
/**
* Sets the update decoration image.
* @param image The image to use for the update decoration.
*/
public void setDefaultUpdateImage(JefImage image) {
verifyThread();
sendMessage(MESSAGE_SET_UPDATE_IMAGE, image);
}//setDefaultUpdateImage()//
/**
* Sets the update decoration image.
* @param image The image to use for the update decoration.
*/
public void setDefaultUpdateImage(ResourceReference image) {
verifyThread();
sendMessage(MESSAGE_SET_UPDATE_IMAGE, image);
}//setDefaultUpdateImage()//
/**
* Sets the timeout for the update decoration.
* @param timeout The number of seconds before removing the update decoration.
*/
public void setDefaultUpdateTimeout(Integer updateTimeout) {
verifyThread();
sendMessage(MESSAGE_SET_UPDATE_TIMEOUT, updateTimeout);
}//setDefaultUpdateTimeout()//
/**
* Sets the visibility.
* @param isVisible Whether the user can see the component.
*/
public void setIsVisible(boolean isVisible) {
verifyThread();
this.isVisible.externalSetValue(isVisible ? Boolean.TRUE : Boolean.FALSE);
}//setIsVisible()//
/**
* Sets the enabled state.
* @param isEnabled Whether the user can interact with the component.
*/
public void setIsEnabled(boolean isEnabled) {
verifyThread();
this.isEnabled.externalSetValue(isEnabled ? Boolean.TRUE : Boolean.FALSE);
}//setIsEnabled()//
/**
* Sets the default enabled state.
* @param isEnabled Whether the user can interact with the component if no other value is provided.
*/
public void setDefaultIsEnabled(boolean isEnabled) {
verifyThread();
this.isEnabled.setDefaultValue(isEnabled ? Boolean.TRUE : Boolean.FALSE);
}//setDefaultIsEnabled()//
/**
* Sets the default enabled state resource.
* @param isEnabled Whether the user can interact with the component if no other value is provided.
*/
public void setDefaultIsEnabled(ResourceReference isEnabled) {
verifyThread();
this.isEnabled.setDefaultValue(isEnabled);
}//setDefaultIsEnabled()//
/**
* Sets the default visibility.
* @param isVisible Whether the user can see the component if no other value is provided.
*/
public void setDefaultIsVisible(boolean isVisible) {
verifyThread();
this.isVisible.setDefaultValue(isVisible ? Boolean.TRUE : Boolean.FALSE);
}//setDefaultIsVisible()//
/**
* Sets the default visibility resource.
* @param isVisible Whether the user can see the component if no other value is provided.
*/
public void setDefaultIsVisible(ResourceReference isVisible) {
verifyThread();
this.isVisible.setDefaultValue(isVisible);
}//setDefaultIsVisible()//
/**
* Sets the component's default tool tip text.
* @param tooltipText The tool tip text to be displayed by this component.
*/
public void setDefaultToolTipText(String toolTipText) {
verifyThread();
this.toolTipText.setDefaultValue(toolTipText);
}//setDefaultToolTipText()//
/**
* Sets the component's default tool tip text resource.
* @param tooltipText The tool tip text to be displayed by this component.
*/
public void setDefaultToolTipText(ResourceReference toolTipText) {
verifyThread();
this.toolTipText.setDefaultValue(toolTipText);
}//setDefaultToolTipText()//
/**
* Sets the component's default background color.
* @param backgroundColor The default background color.
*/
public void setDefaultBackgroundColor(JefGradient backgroundColor) {
verifyThread();
this.backgroundColor.setDefaultValue(backgroundColor);
}//setDefaultBackgroundColor()//
/**
* Sets the component's default background color resource.
* @param backgroundColor The default background color resource.
*/
public void setDefaultBackgroundColor(ResourceReference backgroundColor) {
verifyThread();
this.backgroundColor.setDefaultValue(backgroundColor);
}//setDefaultBackgroundColor()//
/**
* Sets the component's default foreground color.
* @param foregroundColor The default foreground color.
*/
public void setDefaultForegroundColor(JefColor foregroundColor) {
verifyThread();
this.foregroundColor.setDefaultValue(foregroundColor);
}//setDefaultForegroundColor()//
/**
* Sets the component's default foreground color resource.
* @param foregroundColor The default foreground color resource.
*/
public void setDefaultForegroundColor(ResourceReference foregroundColor) {
verifyThread();
this.foregroundColor.setDefaultValue(foregroundColor);
}//setDefaultForegroundColor()//
/**
* Sets the default font.
* @param font The default font.
*/
public void setDefaultFont(JefFont[] font) {
verifyThread();
this.font.setDefaultValue(font);
}//setDefaultFont()//
/**
* Sets the default font resource.
* @param font The default font resource.
*/
public void setDefaultFont(ResourceReference font) {
verifyThread();
this.font.setDefaultValue(font);
}//setDefaultFont()//
/**
* Gets the optional decimal scale to be used by the component if it deals with decimal values.
* @return The optional decimal scale which if negative by default should trim extra zeros (note that BigDecimal does not automatically do this).
*/
public Integer getDecimalScale() {
verifyThread();
return decimalScale;
}//getDecimalScale()//
/**
* Sets the optional decimal scale to be used by the component if it deals with decimal values.
* @param decimalScale The optional decimal scale which if negative by default should trim extra zeros (note that BigDecimal does not automatically do this).
*/
public void setDecimalScale(Integer decimalScale) {
verifyThread();
if(decimalScale != this.decimalScale) {
this.decimalScale = decimalScale;
sendMessage(MESSAGE_SET_DECIMAL_SCALE, decimalScale);
}//if//
}//setDecimalScale()//
/**
* Sets the container's title.
* @param title The container's title to be used when needed (example: a tab in a tab panel, or title bar of the window).
*/
public void setDefaultContainerTitle(String title) {
verifyThread();
this.containerTitle.setDefaultValue(title);
}//setDefaultContainerTitle()//
/**
* Sets the component's default title resource.
* @param title The title to be displayed by this component.
*/
public void setDefaultContainerTitle(ResourceReference title) {
verifyThread();
this.containerTitle.setDefaultValue(title);
}//setDefaultContainerTitle()//
/**
* Sets the component's default image resource.
* @param image The image to be displayed by this component.
*/
public void setDefaultContainerImage(ResourceReference image) {
verifyThread();
this.containerImage.setDefaultValue(image);
}//setDefaultContainerImage()//
/**
* Sets the container's default image.
* @param image The image data that will be displayed by the container when an image is needed to represent it (example: a tab in a tab panel).
*/
public void setDefaultContainerImage(JefImage image) {
verifyThread();
this.containerImage.setDefaultValue(image);
}//setDefaultContainerImage()//
/**
* Sets the component background image.
* @param image The image to be displayed by the component in the background.
*/
public void setDefaultBackgroundImage(JefImage image) {
verifyThread();
this.backgroundImage.setDefaultValue(image);
}//setDefaultBackgroundImage()//
/**
* Sets the component's background image resource.
* @param image The image to be displayed by this component in the background.
*/
public void setDefaultBackgroundImage(ResourceReference image) {
verifyThread();
this.backgroundImage.setDefaultValue(image);
}//setDefaultBackgroundImage()//
/**
* Sets an association container used to access the background image.
* @param container The image association metadata.
*/
public void setBackgroundImageAssociation(SingleAssociationContainer container) {
verifyThread();
this.backgroundImage.setAssociations(container);
}//setBackgroundImageAssociation()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
isVisible.initialize();
isEnabled.initialize();
toolTipText.initialize();
backgroundColor.initialize();
foregroundColor.initialize();
font.initialize();
containerTitle.initialize();
containerImage.initialize();
backgroundImage.initialize();
if(gainFocusEventAssociations != null) {
IIterator iterator = gainFocusEventAssociations.iterator();
while(iterator.hasNext()) {
((IEventAssociation) iterator.next()).register();
}//while//
}//if//
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
if(getMenu() != null) {
getMenu().internalViewInitializeAll();
}//if//
super.internalViewInitializeAll();
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
isVisible.release();
isEnabled.release();
toolTipText.release();
backgroundColor.release();
foregroundColor.release();
font.release();
containerTitle.release();
containerImage.release();
backgroundImage.release();
if(gainFocusEventAssociations != null) {
IIterator iterator = gainFocusEventAssociations.iterator();
while(iterator.hasNext()) {
((IEventAssociation) iterator.next()).unregister();
}//while//
}//if//
super.internalViewRelease();
if(getContainer() != null) {
getContainer().getComponents().remove(this);
}//if//
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewReleaseAll()
*/
protected void internalViewReleaseAll() {
if(getMenu() != null) {
getMenu().internalViewReleaseAll();
}//if//
super.internalViewReleaseAll();
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
internalViewRefreshIsVisible();
internalViewRefreshIsEnabled();
internalViewRefreshToolTipText();
internalViewRefreshBackgroundColor();
internalViewRefreshForegroundColor();
internalViewRefreshFont();
internalViewRefreshContainerTitle();
internalViewRefreshContainerImage();
internalViewRefreshBackgroundImage();
}//internalViewRefresh()//
/**
* Refreshes whether the component is enabled based on the attribute value or if null the default flag value.
*/
protected void internalViewRefreshIsEnabled() {
if(isEnabled.refresh()) {
sendMessage(MESSAGE_SET_IS_ENABLED, isEnabled.getValue());
}//if//
}//internalViewRefreshIsEnabled()//
/**
* Refreshes whether the component is visible based on the attribute value or if null the default flag value.
*/
protected void internalViewRefreshIsVisible() {
if(isVisible.refresh()) {
sendMessage(MESSAGE_SET_IS_VISIBLE, isVisible.getValue());
}//if//
}//internalViewRefreshIsVisible()//
/**
* Refreshes the tool tip text from the tool tip text attribute and the default tool tip text.
*/
protected void internalViewRefreshToolTipText() {
if(toolTipText.refresh()) {
sendMessage(MESSAGE_SET_TOOL_TIP_TEXT, toolTipText.getValue());
}//if//
}//internalViewRefreshToolTipText()//
/**
* Refreshes the component's background color.
*/
protected void internalViewRefreshBackgroundColor() {
if(backgroundColor.refresh()) {
sendMessage(MESSAGE_SET_BACKGROUND_COLOR, backgroundColor.getValue());
}//if//
}//internalViewRefreshBackgroundColor()//
/**
* Refreshes the component's foreground color.
*/
protected void internalViewRefreshForegroundColor() {
if(foregroundColor.refresh()) {
sendMessage(MESSAGE_SET_FOREGROUND_COLOR, foregroundColor.getValue());
}//if//
}//internalViewRefreshForegroundColor()//
/**
* Refreshes the component's font.
*/
protected void internalViewRefreshFont() {
if(font.refresh()) {
sendMessage(MESSAGE_SET_FONTS, font.getValue());
}//if//
}//internalViewRefreshFont()//
/**
* Refreshes the title from the title attribute and the default title.
*/
protected void internalViewRefreshContainerTitle() {
if(containerTitle.refresh()) {
sendMessage(MESSAGE_SET_CONTAINER_TITLE, containerTitle.getValue());
}//if//
}//internalViewRefreshContainerTitle()//
/**
* Refreshes the image from the image url attribute and the default image url.
*/
protected void internalViewRefreshContainerImage() {
if(containerImage.refresh()) {
sendMessage(MESSAGE_SET_CONTAINER_IMAGE, containerImage.getValue());
}//if//
}//internalViewRefreshContainerImage()//
/**
* Refreshes the image and sends it to the client.
*/
protected void internalViewRefreshBackgroundImage() {
if(backgroundImage.refresh()) {
sendMessage(MESSAGE_SET_BACKGROUND_IMAGE, backgroundImage.getValue());
}//if//
}//internalViewRefreshBackgroundImage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefreshAll()
*/
protected void internalViewRefreshAll() {
if(getMenu() != null) {
getMenu().internalViewRefreshAll();
}//if//
super.internalViewRefreshAll();
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == isVisible) {
internalViewRefreshIsVisible();
}//if//
else if(resourceAssociation == isEnabled) {
internalViewRefreshIsEnabled();
}//else if//
else if(resourceAssociation == toolTipText) {
internalViewRefreshToolTipText();
}//else if//
else if(resourceAssociation == foregroundColor) {
internalViewRefreshForegroundColor();
}//else if//
else if(resourceAssociation == backgroundColor) {
internalViewRefreshBackgroundColor();
}//else if//
else if(resourceAssociation == font) {
internalViewRefreshFont();
}//else if//
else if(resourceAssociation == containerTitle) {
internalViewRefreshContainerTitle();
}//else if//
else if(resourceAssociation == containerImage) {
internalViewRefreshContainerImage();
}//else if//
else if(resourceAssociation == backgroundImage) {
internalViewRefreshBackgroundImage();
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnEventFired(com.foundation.view.IEventAssociation, java.lang.Object[])
*/
protected void internalOnEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
if((gainFocusEventAssociations != null) && (gainFocusEventAssociations.containsValue(eventAssociation))) {
setFocus();
}//if//
else {
super.internalOnEventFired(eventAssociation, eventArguments);
}//else//
}//internalOnEventFired()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#processMessage(com.foundation.tcv.view.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object result = null;
switch(viewMessage.getMessageNumber()) {
case MESSAGE_INVOKE_KEY_BINDING: {
boolean found = false;
for(int index = 0; (!found) && (index < keyBindings.getSize()); index++) {
IKeyBinding keyBinding = (IKeyBinding) keyBindings.get(index);
int modifiers = viewMessage.getMessageInteger();
int character = viewMessage.getMessageSecondaryInteger();
if(keyBinding.getModifiers() == modifiers) {
if(keyBinding.getKeyCode() != null) {
if(keyBinding.getKeyCode().intValue() == character) {
keyBinding.invoke(new Object[] {new Integer(modifiers), new Integer(character)}, true);
found = true;
}//if//
}//if//
else {
//TODO: Can we detect a modifier key being pressed without a non-modifier key?
}//else//
}//if//
}//for//
}//case//
default: {
result = super.processMessage(viewMessage);
break;
}//default//
}//switch//
return result;
}//processMessage()//
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
return super.toString() + (getName() != null ? " (named: " + getName() + ")" : "");
}//toString()//
}//Component//

View File

@@ -0,0 +1,403 @@
/*
* 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.common.util.*;
import com.common.debug.*;
import com.common.thread.*;
import com.foundation.view.*;
import com.foundation.view.resource.AbstractResourceService;
import com.foundation.controller.AbstractViewController;
import com.foundation.event.IRequestHandler;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.server.controller.*;
import com.foundation.tcv.view.*;
public abstract class Container extends ScrollableComponent implements IContainer, IAbstractContainer {
/** A collection of components contained by this container. */
private IList components = null;
/** The component's controller. */
private AbstractViewController controller;
/** The container's layout. */
private Layout layout = null;
/**
* Container default constructor.
* <p>Warning: This is only for use by the framework. This should never be called to create a useable instance.</p>
*/
public Container() {
}//Container()//
/**
* Container constructor.
* @param parent The parent container.
* @param name The name of the component.
*/
public Container(IAbstractContainer parent, String name, int style) {
super(parent, name, style);
initialize();
}//Container()//
/**
* Container constructor.
* This constructor is used if this is the top level component and has no parent.
* @param sessionViewController The session view controller for this view.
* @param name The name of the component.
*/
public Container(SessionViewController sessionViewController, String name, int style) {
super(sessionViewController, name, style);
initialize();
}//Container()//
/**
* Initializes the container.
*/
private void initialize() {
components = new LiteList(10, 30);
}//initialize()//
/* (non-Javadoc)
* @see com.foundation.view.IMultiResourceAssociationChangeListener#getResourceService()
*/
public AbstractResourceService getResourceService() {
return getController().getApplication().getResourceService();
}//getResourceService()//
/* (non-Javadoc)
* @see com.foundation.view.IView#maximize()
*/
public void maximize() {
IAbstractContainer container = getContainer();
if(container != null) {
container.maximize();
}//if//
}//maximize()//
/* (non-Javadoc)
* @see com.foundation.view.IView#minimize()
*/
public void minimize() {
IAbstractContainer container = getContainer();
if(container != null) {
container.minimize();
}//if//
}//minimize()//
/* (non-Javadoc)
* @see com.foundation.view.IView#show()
*/
public void show() {
IAbstractContainer container = getContainer();
if(container != null) {
container.show();
}//if//
}//show()//
/* (non-Javadoc)
* @see com.foundation.view.IView#pack()
*/
public void pack() {
sendMessage(MESSAGE_PACK, null);
}//pack()//
/* (non-Javadoc)
* @see com.foundation.view.IView#getController()
*/
public AbstractViewController getController() {
if(controller == null) {
Container parent = (Container) getContainer();
while((parent != null) && (!(parent instanceof IView))) {
parent = (Container) parent.getContainer();
}//while//
controller = parent != null ? parent.getController() : null;
}//if//
return controller;
}//getController()//
/* (non-Javadoc)
* @see com.foundation.view.IView#setController(com.foundation.controller.AbstractViewController)
*/
public void setController(AbstractViewController controller) {
this.controller = controller;
}//setController()//
/**
* Sets the container layout.
* @param layout The layout for the container.
*/
public void setLayout(Layout layout) {
verifyThread();
if(this.layout != null) {
throw new RuntimeException("Cannot change the layout once set.");
}//if//
else if(isInitialized()) {
throw new RuntimeException("Cannot set the layout once the view is initialized.");
}//else if//
this.layout = layout;
}//setLayout()//
/**
* Gets the frame's default button.
* @return The default button in this container.
*/
public Button getDefaultButton() {
Component container = (Component) getContainer();
verifyThread();
while(!(container instanceof Frame)) {
container = (Component) container.getContainer();
}//while//
return ((Frame) container).getDefaultButton();
}//getDefaultButton()//
/**
* Sets the frame's default button.
* @param defaultButton The default button in this container.
*/
public void setDefaultButton(Button defaultButton) {
Component container = (Component) getContainer();
verifyThread();
while(!(container instanceof Frame)) {
container = (Component) container.getContainer();
}//while//
((Frame) container).setDefaultButton(defaultButton);
}//setDefaultButton()//
/* (non-Javadoc)
* @see com.foundation.view.IView#center()
*/
public void center() {
verifyThread();
sendMessage(MESSAGE_CENTER, null);
}//center()//
/* (non-Javadoc)
* @see com.foundation.view.IView#center(com.foundation.view.IView)
*/
public void center(IView view) {
Frame frame = null;
verifyThread();
if(view != null) {
frame = ((Container) view).getContainingFrame();
}//if//
sendMessage(MESSAGE_CENTER, frame != null ? frame.getIdentity() : null);
}//center()//
/**
* Tells the container to layout the components contained within it.
*/
public void layout() {
verifyThread();
sendMessage(MESSAGE_LAYOUT, null);
}//layout()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#suppressUpdates(boolean)
*/
public void suppressUpdates(boolean suppressUpdates) {
super.suppressUpdates(suppressUpdates);
//Set the flag on all contained components.//
for(int index = components.getSize() - 1; index >= 0; index--) {
((AbstractComponent) components.get(index)).suppressUpdates(suppressUpdates);
}//for//
}//suppressUpdates()//
/**
* Sets the tabbing order for the controls in the container.
* @param controls The collection of controls in the order they are to be tabbed over.
*/
public void setTabOrder(IList controls) {
int[] tabOrder = new int[controls.getSize()];
verifyThread();
for(int index = 0; index < tabOrder.length; index++) {
tabOrder[index] = ((AbstractComponent) controls.get(index)).getNumber();
}//for//
sendMessage(MESSAGE_SET_TAB_ORDER, tabOrder);
}//setTabOrder()//
/**
* Sets the background inheritance for all children.
* @param inherit Whether the background of this composite should be inherited by all child controls. The default value will cause children that don't specify otherwise to inherit the background.
* @see #INHERIT_NONE
* @see #INHERIT_DEFAULT
* @see #INHERIT_FORCE
*/
public void setInheritBackground(int inheritType) {
sendMessage(MESSAGE_INHERIT_BACKGROUND, null, null, inheritType, -1);
}//setInheritBackground()//
/**
* Adds a component as a child of this container.
* @param component The component to be contained by this container.
*/
public void addComponent(com.foundation.view.IAbstractComponent component) {
components.add(component);
}//addComponent()//
/**
* Removes a component that was child of this container.
* @param component The component to no longer be contained by this container.
*/
public void removeComponent(com.foundation.view.IAbstractComponent component) {
components.remove(component);
}//removeComponent()//
/**
* Gets the collection of components contained by this container.
* <p>TODO: Should make sure that the callers don't modify the collection. We could copy the collection or make it immutable, but then it might make adding and removing too much less efficient.
* @return The collection of all contained components.
*/
public IList getComponents() {
return components;
}//getComponents()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
super.internalViewInitializeAll();
try {
IList components = (IList) getComponents();
IIterator iterator = components.iterator();
//Initialize contained value holders first.//
while(iterator.hasNext()) {
AbstractComponent component = (AbstractComponent) iterator.next();
if(component instanceof ValueHolder) {
component.internalViewInitializeAll();
}//if//
}//for//
iterator.resetToFront();
//Initialize all contained components that are not value holders.//
while(iterator.hasNext()) {
AbstractComponent component = (AbstractComponent) iterator.next();
if(!(component instanceof ValueHolder)) {
component.internalViewInitializeAll();
}//if//
}//for//
}//try//
catch(Throwable e) {
Debug.log(e);
Debug.halt();
}//catch//
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewReleaseAll()
*/
protected void internalViewReleaseAll() {
IIterator iterator = new LiteList(getComponents()).iterator();
super.internalViewReleaseAll();
//Release sub-components.//
while(iterator.hasNext()) {
((AbstractComponent) iterator.next()).internalViewReleaseAll();
}//for//
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Component#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
if(layout != null) {
layout.refresh();
}//if//
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefreshAll()
*/
protected void internalViewRefreshAll() {
try {
IIterator iterator = null;
//Refresh this component.//
super.internalViewRefreshAll();
//Refresh the contained components.//
iterator = getComponents().iterator();
//Refresh value holders.//
while(iterator.hasNext()) {
AbstractComponent component = (AbstractComponent) iterator.next();
if(component instanceof ValueHolder) {
component.internalViewRefreshAll();
}//if//
}//while//
iterator = getComponents().iterator();
//Refresh sub-components.//
while(iterator.hasNext()) {
AbstractComponent component = (AbstractComponent) iterator.next();
if(!(component instanceof ValueHolder)) {
component.internalViewRefreshAll();
}//if//
}//while//
}//try//
catch(Throwable e) {
Debug.log(e);
Debug.halt();
}//catch//
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
if(layout != null) {
layout.initialize();
}//if//
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
if(layout != null) {
layout.release();
}//if//
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.view.IViewComponent#processMessage(com.foundation.tcv.model.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object result = null;
switch(viewMessage.getMessageNumber()) {
default: {
result = super.processMessage(viewMessage);
break;
}//default//
}//switch//
return result;
}//processMessage()//
/* (non-Javadoc)
* @see com.foundation.view.IView#execute(com.common.thread.IRunnable)
*/
public Object execute(IRunnable runnable) {
return getEventLoop().execute(runnable, true);
}//execute()//
/* (non-Javadoc)
* @see com.foundation.view.IView#executeAsynch(com.common.thread.IRunnable)
*/
public void executeAsync(IRunnable runnable) {
getEventLoop().execute(runnable, false);;
}//executeAsynch()//
/* (non-Javadoc)
* @see com.foundation.view.IView#getRequestHandler()
*/
public IRequestHandler getRequestHandler() {
return getEventLoop();
}//getRequestHandler()//
}//Container//

View File

@@ -0,0 +1,223 @@
/*
* 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.common.util.LiteList;
import com.foundation.tcv.swt.ICoolBar;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
public class CoolBar extends Container implements ICoolBar {
/** The collection of CoolItem instances contained by the cool bar. */
private LiteList coolItems = new LiteList(10, 20);
/**
* Encapsulates an item in the bar.
*/
public static class CoolItem extends AbstractComponent implements ICoolBar.ICoolItem {
private Container container = null;
/** The resource defining the visible state for the item. */
private SingleResourceAssociation isVisible = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, false, Boolean.TRUE);
/**
* CoolItem 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 #STYLE_DROP_DOWN
*/
public CoolItem(Container parent, String name, int style) {
super(parent.getSessionViewController());
container = parent;
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
((CoolBar) parent).addCoolItem(this);
}//CoolItem()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return "__CoolBarItem__";
}//getName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
isVisible.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
isVisible.release();
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
internalViewRefreshIsVisible();
sendMessage(MESSAGE_AUTO_SIZE, null);
}//internalViewRefresh()//
/**
* Refreshes whether the component is visible based on the attribute value or if null the default flag value.
*/
protected void internalViewRefreshIsVisible() {
if(isVisible.refresh()) {
sendMessage(MESSAGE_IS_VISIBLE, isVisible.getValue() == null ? Boolean.TRUE : (Boolean) isVisible.getValue());
}//if//
}//internalViewRefreshIsVisible()//
/* (non-Javadoc)
* @see com.foundation.view.swt.Component#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == isVisible) {
internalViewRefreshIsVisible();
}//if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/**
* Sets the association container used to access the visibility.
* @param container The visibility association metadata.
*/
public void setIsVisibleAssociation(SingleAssociationContainer container) {
verifyThread();
this.isVisible.setAssociations(container);
}//setIsVisibleAssociation()//
/**
* Sets whether the component is visible (by default if an attribute is bound to this value).
* @param isVisible Whether the user can see the component.
*/
public void setIsVisible(boolean isVisible) {
verifyThread();
this.isVisible.setDefaultValue(isVisible ? Boolean.TRUE : Boolean.FALSE);
}//setIsVisible()//
/**
* Sets the cool item initial size.
* @param width
* @param height
*/
public void setSize(int width, int height) {
sendMessage(MESSAGE_SET_SIZE, new int[] {width, height});
}//setSize()//
/**
* Sets the cool item minimum size.
* @param width
* @param height
*/
public void setMinimumSize(int width, int height) {
sendMessage(MESSAGE_SET_MINIMUM_SIZE, new int[] {width, height});
}//setMinimumSize()//
/**
* Sets the cool item preferred size.
* @param width
* @param height
*/
public void setPreferredSize(int width, int height) {
sendMessage(MESSAGE_SET_PREFERRED_SIZE, new int[] {width, height});
}//setPreferredSize()//
/**
* Sets the control used by the cool item.
* @param control The cool item's control.
*/
public void setControl(Component control) {
sendMessage(MESSAGE_SET_CONTROL, new int[] {control.getNumber()});
}//setControl()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.CoolBar$CoolItem";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getContainer()
*/
public IAbstractContainer getContainer() {
return container;
}//getContainer()//
}//CoolItem//
/**
* Button 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 #STYLE_ARROW
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_RADIO
* @see #STYLE_TOGGLE
* @see #STYLE_FLAT
* @see #STYLE_LEFT
* @see #STYLE_RIGHT
* @see #STYLE_CENTER
* @see #STYLE_UP
* @see #STYLE_DOWN
*/
public CoolBar(Container parent, String name, int style) {
super(parent, name, style);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//CoolBar()//
/**
* Adds a cool item to the bar.
* @param coolItem The item to be added.
*/
protected void addCoolItem(CoolItem coolItem) {
coolItems.add(coolItem);
if(isInitialized()) {
//TODO: Initialize the cool item.
//Will the cool item's component already be initilialized?
//Would this ever occur?
}//if//
}//addCoolItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
super.internalViewInitializeAll();
//Initialize all the cool items.//
for(int index = 0; index < coolItems.getSize(); index++) {
((CoolItem) coolItems.get(index)).internalViewInitialize();
}//for//
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewReleaseAll()
*/
protected void internalViewReleaseAll() {
//Release all the cool items.//
for(int index = 0; index < coolItems.getSize(); index++) {
((CoolItem) coolItems.get(index)).internalViewRelease();
}//for//
super.internalViewReleaseAll();
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefreshAll()
*/
protected void internalViewRefreshAll() {
super.internalViewRefreshAll();
//Refresh all the cool items.//
for(int index = 0; index < coolItems.getSize(); index++) {
((CoolItem) coolItems.get(index)).internalViewRefresh();
}//for//
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.CoolBar";
}//getClientClassName()//
}//CoolBar//

View File

@@ -0,0 +1,180 @@
/*
* 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 java.util.Date;
import com.common.util.ICollection;
import com.foundation.tcv.swt.IDateTime;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IMethodAssociation;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
public class DateTime extends Component implements IDateTime {
/** The date/time selection. */
private SingleResourceAssociation selection = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_DATE, true, null);
/** Called when the user double clicks on a date in the calendar. */
private IMethodAssociation doubleClickMethod = null;
/** Whether the selection state is auto synchronized. */
private boolean autoSynchronizeSelection = false;
/** The delay to be used when auto synchronizing changes to the text. */
private long autoSynchronizeSelectionDelay = 500;
/**
* DateTime 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 #STYLE_DATE
* @see #STYLE_TIME
* @see #STYLE_CALENDAR
* @see #STYLE_SHORT
* @see #STYLE_MEDIUM
* @see #STYLE_LONG
*/
public DateTime(IAbstractContainer parent, String name, int style) {
super(parent, name, style);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, null, null, ((AbstractComponent) parent).getNumber(), style);
}//DateTime()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.DateTime";
}//getClientClassName()//
/**
* Sets an association container used to access the selection.
* @param container The selection association metadata.
*/
public void setSelectionAssociation(SingleAssociationContainer container) {
verifyThread();
this.selection.setAssociations(container);
}//setSelectionAssociation()//
/**
* Sets whether the control auto synchronizes the selection.
* @param autoSynchronizeSelection Whether the control 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()//
/**
* Sets the delay for the auto synchronize selection.
* @param autoSynchronizeSelectionDelay The delay in terms of milliseconds between the value of zero and ten thousand. A zero value has no delay.
*/
public void setAutoSynchronizeSelectionDelay(long autoSynchronizeSelectionDelay) {
verifyThread();
if(autoSynchronizeSelectionDelay < 0) {
autoSynchronizeSelectionDelay = 0;
}//if//
else if(autoSynchronizeSelectionDelay > 10000) {
autoSynchronizeSelectionDelay = 10000;
}//else if//
if(autoSynchronizeSelectionDelay != this.autoSynchronizeSelectionDelay) {
this.autoSynchronizeSelectionDelay = autoSynchronizeSelectionDelay;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long(autoSynchronizeSelectionDelay));
}//if//
}//setAutoSynchronizeSelectionDelay()//
/**
* Gets the method called to handle a double click.
* @return The method called when a calendar date is double clicked.
*/
protected IMethodAssociation getDoubleClickMethod() {
return doubleClickMethod;
}//getDoubleClickMethod()//
/**
* Sets the method called to handle a double click.
* @param doubleClickMethod The method called when a calendar date is double clicked.
*/
public void setDoubleClickMethod(IMethodAssociation doubleClickMethod) {
verifyThread();
this.doubleClickMethod = doubleClickMethod;
sendMessage(MESSAGE_SEND_DOUBLE_CLICK, doubleClickMethod != null ? Boolean.TRUE : Boolean.FALSE);
}//setDoubleClickMethod()//
/* (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_VIEW_REFRESH_SELECTION, (Date) 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 result = null;
switch(viewMessage.getMessageNumber()) {
case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: {
Date selectionState = (Date) viewMessage.getMessageData();
//Update the selection value.//
selection.setValue(selectionState);
break;
}//case//
case MESSAGE_DOUBLE_CLICK: {
if(getDoubleClickMethod() != null) {
if(getDoubleClickMethod().getIsValueHolderAssociated()) {
getDoubleClickMethod().invoke(null, new Object[] {selection.getValue()}, true);
}//if//
}//if//
break;
}//case//
default: {
result = super.processMessage(viewMessage);
}//default//
}//switch//
return result;
}//processMessage()//
}//DateTime//

View File

@@ -0,0 +1,107 @@
/*
* 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.tcv.swt.*;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.tcv.server.controller.*;
public abstract class Dialog extends AbstractComponent implements IDialog {
/** The text displayed in the dialog title bar. */
private String text = null;
/** Identifies which dialog button was pressed. */
private Integer pressedButton = null;
/**
* Dialog constructor.
*/
public Dialog(SessionViewController sessionViewController) {
super(sessionViewController);
}//Dialog()//
/**
* Dialog constructor.
*/
public Dialog(IView parent) {
super(((Container) parent).getSessionViewController());
}//Dialog()//
/**
* Gets the text displayed by the dialog.
* @return The dialog text.
*/
public String getText() {
return text;
}//getText()//
/**
* Sets the dialog text.
* @param text The text to be displayed in the dialog.
*/
public void setText(String text) {
this.text = text;
sendMessage(MESSAGE_SET_TEXT, text);
}//setText()//
/**
* Opens the dialog making it visible to the user.
* <p>Note: this call will block until the user closes the dialog.</p>
* @return The id of the button pressed.
*/
public int open() {
//Initialize the view.//
viewInitializeAll();
//Send the dialog open message.//
sendRoundTripMessage(MESSAGE_OPEN, null);
//Release the view.//
viewReleaseAll();
//Ensure that pressed button is never null.//
if(pressedButton == null) {
throw new RuntimeException("Error: Invalid pressedButton in Dialog.");
}//if//
return pressedButton.intValue();
}//open()//
/**
* Gets the id of the button used to close the dialog.
* <p>Example MessageDialog.STYLE_OK.</p>
* @return The button id, or null if the dialog has not been opened.
*/
public Integer getPressedButton() {
verifyThread();
return pressedButton;
}//getPressedButton()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
}//internalViewRelease()//
/* (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_SET_PRESSED_BUTTON: {
pressedButton = (Integer) viewMessage.getMessageData();
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
}//default//
}//switch//
return retVal;
}//processMessage()//
}//Dialog//

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2008,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.server.controller.SessionViewController;
import com.foundation.view.IAbstractContainer;
public class DynamicMenu extends AbstractComponent {
/**
* DynamicMenu constructor.
*/
public DynamicMenu() {
}
/**
* DynamicMenu constructor.
* @param sessionViewController
*/
public DynamicMenu(SessionViewController sessionViewController) {
super(sessionViewController);
}
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return null;
}
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getContainer()
*/
public IAbstractContainer getContainer() {
return null;
}
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return null;
}
}

View File

@@ -0,0 +1,184 @@
/*
* 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.foundation.tcv.swt.IEnhancedList;
import com.foundation.view.JefImage;
import com.foundation.view.MultiAssociationContainer;
import com.foundation.view.MultiResourceAssociation;
import com.foundation.view.ResourceAssociation;
import com.foundation.view.resource.ResourceReference;
public class EnhancedList extends TableComponent implements IEnhancedList {
/** Converts the collection item to a string used to show the item to the user. */
protected MultiResourceAssociation itemText = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_TEXT, false, null);
/** Converts the collection item to an image used to show the item to the user. */
protected MultiResourceAssociation itemImage = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_IMAGE, false, null);
/**
* EnhancedList 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 #STYLE_MULTI
* @see #STYLE_SINGLE
*/
public EnhancedList(Container parent, String name, int style) {
super(parent, name, style);
setAllowMultiSelection(((style & STYLE_MULTI) > 0));
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//EnhancedList()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#getAllowUserItems()
*/
protected boolean getAllowUserItems() {
return false;
}//getAllowUserItems()//
/**
* Sets the association container used to access the item text.
* @param container The item text association metadata.
*/
public void setItemTextAssociation(MultiAssociationContainer container) {
verifyThread();
this.itemText.setAssociations(container);
}//setItemTextAssociation()//
/**
* Sets the association container used to access the item text.
* @param container The item text association metadata.
*/
public void setItemImageAssociation(MultiAssociationContainer container) {
verifyThread();
this.itemImage.setAssociations(container);
}//setItemImageAssociation()//
/**
* Sets the row image resource.
* @param image The image to be displayed for each row.
*/
public void setDefaultItemImage(JefImage image) {
verifyThread();
this.itemImage.setDefaultValue(image);
}//setDefaultItemImage()//
/**
* Sets the row image resource.
* @param image The image to be displayed for each row.
*/
public void setDefaultItemImage(ResourceReference image) {
verifyThread();
this.itemImage.setDefaultValue(image);
}//setDefaultItemImage()//
/**
* Adjusts the visible range of items to show some or all of the selections.
*/
public void showSelection() {
verifyThread();
sendMessage(MESSAGE_SHOW_SELECTION, null);
}//showSelection()//
/**
* Sets the index of the top most visible item.
* @parma topIndex The top most visible item's index.
*/
public void setTopIndex(Integer topIndex) {
verifyThread();
sendMessage(MESSAGE_SET_TOP_INDEX, null, null, topIndex.intValue(), -1);
}//setTopIndex()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.TableComponent#getRowHeaderCellData(java.lang.Object)
*/
protected Object getRowHeaderCellData(Object item) {
return null;
}//getRowHeaderCellData()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object)
*/
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
if(isInitialized()) {
if(resourceAssociation == itemText) {
//Verify that the item cell data has actually been altered.//
if(itemText.refresh(alteredItem)) {
RowObject node = getRowObject(alteredItem);
sendMessage(MESSAGE_SET_CELL_TEXT, itemText.getValue(alteredItem), null, -1, node.objectId);
}//if//
}//if//
else if(resourceAssociation == itemImage) {
//Verify that the item cell data has actually been altered.//
if(itemImage.refresh(alteredItem)) {
RowObject node = getRowObject(alteredItem);
sendMessage(MESSAGE_SET_CELL_IMAGE, itemImage.getValue(alteredItem), null, -1, node.objectId);
}//if//
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, alteredItem, data, isUpdate);
}//else//
}//if//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
itemText.initialize();
itemImage.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewRelease()
*/
protected void internalViewRelease() {
itemText.release();
itemImage.release();
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.TableComponent#collectRowData(com.foundation.tcv.swt.server.RowObject, com.foundation.tcv.swt.ITableComponent.TableRowData)
*/
protected void collectRowData(RowObject rowObject, TableRowData rowData) {
itemText.refresh(rowObject.value);
rowData.setText((String) itemText.getValue(rowObject.value));
itemImage.refresh(rowObject.value);
rowData.setImage(itemImage.getValue(rowObject.value));
super.collectRowData(rowObject, rowData);
}//collectRowData()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#itemAllRemoved()
*/
protected void itemAllRemoved() {
unregisterItems();
super.itemAllRemoved();
}//itemAllRemoved()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.TableComponent#registerItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void registerItem(RowObject rowObject) {
itemText.registerItem(rowObject.value, rowObject);
itemImage.registerItem(rowObject.value, rowObject);
super.registerItem(rowObject);
}//registerItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.IndexedCollectionComponent#unregisterItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void unregisterItem(RowObject rowObject) {
itemText.unregisterItem(rowObject.value);
itemImage.unregisterItem(rowObject.value);
super.unregisterItem(rowObject);
}//unregisterItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.IndexedCollectionComponent#unregisterItems()
*/
protected void unregisterItems() {
itemText.unregisterAllItems();
itemImage.unregisterAllItems();
super.unregisterItems();
}//unregisterItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.EnhancedList";
}//getClientClassName()//
}//EnhancedList//

View File

@@ -0,0 +1,599 @@
/*
* 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.common.debug.Debug;
import com.common.util.ICollection;
import com.common.util.IIterator;
import com.common.util.IList;
import com.common.util.LiteHashMap;
import com.common.util.LiteList;
import com.foundation.controller.DecorationManager;
import com.foundation.controller.ViewController;
import com.foundation.tcv.swt.IExpandBar;
import com.foundation.util.IInlineCollectionObservable;
import com.foundation.util.IInlineCollectionObserver;
import com.foundation.util.IInlineIndexedCollectionObservable;
import com.foundation.util.IInlineIndexedCollectionObserver;
import com.foundation.view.AbstractDecoration;
import com.foundation.view.IAbstractComponent;
import com.foundation.view.ISingleResourceAssociationChangeListener;
import com.foundation.view.ResourceAssociation;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
import com.foundation.view.resource.AbstractResourceService;
/**
* This item panel allows for static items and dynamic items where dynamic items are tied to the model which supplies the view controller's for each dynamic item.
* The panel was designed such that any ordering of static and dynamic items can be given. The dynamic item is created by calling the addItems() method which allows associations to be added.
* The ItemsHolder (returned by addItems()) then manages the item or collection of item view controllers.
* <p>TODO: Add some way of sending the selected item to the view controller, and some way for the view controller to programatically select a item.</p>
*/
public class ExpandBar extends Container implements IExpandBar {
/** A collection of Component and ItemsHolder instances which define the items in this item folder. */
private IList items = new LiteList(10, 50);
/** A flag to suspend the customized behavior when adding a control. This lets the item holder add and remove items without the item panel attempting to add and remove items also. */
private boolean suspendCustomComponentBehavior = false;
/** The spacing used by the bar. */
private SingleResourceAssociation spacing = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, null);
/**
* The public interface for interacting with the items holder.
*/
public interface IItemsHolder {
/**
* Sets the association container used to access the items.
* @param container The items association metadata.
*/
public void setItemsAssociation(SingleAssociationContainer container);
}//IItemsHolder//
/**
* A place holder for zero or more items which are set based on a resource association which can return a view controller or a list of view controllers, one for each item.
*/
private class ItemsHolder implements IItemsHolder, ISingleResourceAssociationChangeListener, IInlineIndexedCollectionObserver, IInlineCollectionObserver {
/** Allows one association to return either a collection of controllers, or one controller which will be turned into a item item. */
private SingleResourceAssociation items = new SingleResourceAssociation(ExpandBar.this, this, getViewContext(), SingleResourceAssociation.TYPE_OBJECT, false, null);
/** The ItemsHolder or Component which the items in this ItemsHolder follow in the item order. */
private Object followsComponent = null;
/** The previous collection of view controllers. */
private IList viewControllers = new LiteList(1, 15);
/** A two way (one to one) mapping between the Component instances and their ViewController instances. */
private LiteHashMap componentControllerMapping = new LiteHashMap(30);
/** Temporarily suspends processing of events fired by registered collections. */
private boolean suspendCollectionEvents = false;
public ItemsHolder(Object followsComponent) {
this.followsComponent = followsComponent;
}//ItemsHolder()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.ExpandBar.IItemsHolder#setItemsAssociation(com.foundation.view.SingleAssociationContainer)
*/
public void setItemsAssociation(SingleAssociationContainer container) {
verifyThread();
this.items.setAssociations(container);
}//setItemsAssociation()//
public void initialize() {
items.initialize();
refreshItems();
}//initialize()//
public void release() {
IIterator iterator = viewControllers.iterator();
items.release();
//Release the item resources and cleanup the mappings and listeners.//
while(iterator.hasNext()) {
internalRemoveItem((ViewController) iterator.next());
}//while//
componentControllerMapping.removeAll();
componentControllerMapping = null;
viewControllers.removeAll();
viewControllers = null;
followsComponent = null;
items = null;
}//release()//
/**
* Gets the Component that the items of this holder follow.
* @return The component that the components related to this holder follow in the ordering.
*/
public Component getPreviousComponent() {
Component result = null;
if(followsComponent instanceof ItemsHolder) {
result = ((ItemsHolder) followsComponent).getLastComponent();
}//if//
else if(followsComponent instanceof Component) {
result = (Component) followsComponent;
}//else if//
return result;
}//getPreviousComponent()//
/**
* Gets the last item item for this holder.
* @return The last ItemItem instance which can be used as the previous ItemItem for the component that follows this holder. This will only be null if there are no items in this holder and there are no items in front of this holder.
*/
public Component getLastComponent() {
Component result = null;
if(viewControllers.getSize() > 0) {
result = (Component) componentControllerMapping.get(viewControllers.getLast());
}//if//
else {
result = getPreviousComponent();
}//else//
return result;
}//getLastComponent()//
/**
* Gets the number of items currently represented by this holder.
* @return The number of item items created by the holder.
*/
public int getItemCount() {
return viewControllers.getSize();
}//getItemCount()//
/**
* Gets the zero based index of the first item in this holder's collection, which is also the count of items preceeding those generated by this holder.
* @return The holder's first item's zero based index.
*/
public int getPreceedingItemCount() {
int result = 0;
IList items = ExpandBar.this.items;
for(int itemIndex = 0; (itemIndex < items.getSize()) && (items.get(itemIndex) != this); itemIndex++) {
Object item = items.get(itemIndex);
if(item instanceof ItemsHolder) {
result += ((ItemsHolder) item).getItemCount();
}//if//
else if(item instanceof Component) {
result++;
}//else if//
}//for//
return result;
}//getPreceedingItemCount()//
/**
* Refreshes the items represented by this holder.
*/
protected void refreshItems() {
Object oldValue = items.getValue();
if(items.refresh()) {
Object newValue = items.getValue();
//Component previous = getPreviousComponent();
int firstItemIndex = getPreceedingItemCount();
//int previousIndex = previous != null ? getSwtItemFolder().indexOf(previous) + 1 : 0;
//Remove listeners from the old value.//
if(oldValue instanceof IInlineIndexedCollectionObservable) {
((IInlineIndexedCollectionObservable) oldValue).removeCollectionObserver(this);
}//if//
else if(oldValue instanceof IInlineCollectionObservable) {
((IInlineCollectionObservable) oldValue).removeCollectionObserver(this);
}//else if//
//If the new value is a collection or object then add and remove items as required, and add listeners as required.//
if(newValue instanceof ICollection) {
IIterator iterator = ((ICollection) newValue).iterator();
int itemCounter = 0;
//Add items for all the view controllers.//
while(iterator.hasNext()) {
Object next = iterator.next();
//Ignore non-view controller objects.//
if(next instanceof ViewController) {
ViewController controller = (ViewController) next;
int index = viewControllers != null ? viewControllers.getIndexOf(controller) : -1;
if(index != -1) {
sendMessage(MESSAGE_REPOSITION_ITEM, new int[] {((Component) controller.getView()).getNumber(), firstItemIndex + itemCounter});
viewControllers.remove(controller);
}//if//
else {
internalAddItem(controller, firstItemIndex + itemCounter);
}//else//
}//if//
itemCounter++;
}//while//
//Remove the previous view controller(s).//
removeOldItems(viewControllers);
//Add the controllers to the list of view controllers.//
viewControllers.addAll((ICollection) newValue);
//Prevent collection events from notifying us of existing items in the collection.//
suspendCollectionEvents = true;
//Add a listener to the collection so we get change events.//
if(newValue instanceof IInlineIndexedCollectionObservable) {
((IInlineIndexedCollectionObservable) newValue).addCollectionObserver(this);
}//if//
else if(newValue instanceof IInlineCollectionObservable) {
((IInlineCollectionObservable) newValue).addCollectionObserver(this);
}//else if//
//Re-enable the collection events.//
suspendCollectionEvents = false;
}//if//
else if(newValue instanceof ViewController) {
ViewController controller = (ViewController) newValue;
//Add the controller's item.//
internalAddItem(controller, firstItemIndex);
//Remove the previous view controller(s).//
removeOldItems(viewControllers);
//Add the one controller to the list of view controllers.//
viewControllers.add(controller);
}//else if//
}//if//
}//refreshItems()//
/**
* Removes the old items from the item panel.
* @param viewControllers The collection of view controllers no longer in the item panel.
* @param oldValue The previous value
*/
private void removeOldItems(IList viewControllers) {
while(viewControllers.getSize() > 0) {
ViewController controller = (ViewController) viewControllers.remove(viewControllers.getSize() - 1);
//Remove each controller's item and close the controller.//
internalRemoveItem(controller);
controller.close();
}//while//
}//removeOldItems()//
/**
* Adds a item to the panel for the given view controller.
* @param viewController The view controller whose view component will be displayed in the item.
* @param index The index of this item item, which will be used to set the item item ordering.
*/
protected void internalAddItem(ViewController viewController, int index) {
suspendCustomComponentBehavior = true;
try {
if(viewController != null) {
Component component = null;
viewController.openPartial(ExpandBar.this, getViewContext());
component = (Component) viewController.getView();
if(component != null) {
sendMessage(MESSAGE_ADD_ITEM, null, null, component.getNumber(), index);
}//if//
else {
Debug.log("Error: Invalid component. Unable to add the component as a item in the item panel.");
}//else//
componentControllerMapping.put(viewController, component);
componentControllerMapping.put(component, viewController);
}//if//
else {
Debug.log("Error: Invalid component. Unable to add the component as a item in the item panel.");
}//else//
}//try//
finally {
suspendCustomComponentBehavior = false;
}//finally//
}//internalAddItem()//
/**
* Removes a item from the panel for the given related view component.
* @param viewController The view controller whose view component's item will be removed.
*/
protected void internalRemoveItem(ViewController viewController) {
suspendCustomComponentBehavior = true;
try {
Component component = (Component) viewController.getView();
if(component == null) {
component = (Component) componentControllerMapping.get(viewController);
}//if//
//Unregister the component data listener.//
if(component != null) {
sendMessage(MESSAGE_REMOVE_ITEM, new Integer(component.getNumber()));
componentControllerMapping.remove(component);
}//if//
componentControllerMapping.remove(viewController);
}//try//
finally {
suspendCustomComponentBehavior = false;
}//finally//
}//internalRemoveItem()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#addMessageHold()
*/
public void addMessageHold() {
ExpandBar.this.addMessageHold();
}//addMessageHold()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#removeMessageHold()
*/
public void removeMessageHold() {
ExpandBar.this.removeMessageHold();
}//removeMessageHold()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#onValueChanged(com.foundation.view.ResourceAssociation, int)
*/
public void onValueChanged(ResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == items) {
refreshItems();
}//if//
}//onValueChanged()//
/* (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.util.IInlineIndexedCollectionObserver#startChanges(int)
*/
public void startChanges(int changeCount) {
ExpandBar.this.addMessageHold();
}//startChanges()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#stopChanges()
*/
public void stopChanges() {
ExpandBar.this.removeMessageHold();
}//stopChanges()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#valueAdded(java.lang.Object)
*/
public void valueAdded(Object value) {
if((!suspendCollectionEvents) && (value instanceof ViewController)) {
int itemIndex = getPreceedingItemCount() + getItemCount();
internalAddItem((ViewController) value, itemIndex);
}//if//
}//valueAdded()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueAdded(java.lang.Object, int)
*/
public void valueAdded(Object value, int index) {
if((!suspendCollectionEvents) && (value instanceof ViewController)) {
int itemIndex = getPreceedingItemCount() + index;
internalAddItem((ViewController) value, itemIndex);
}//if//
}//valueAdded()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#valueRemoved(java.lang.Object)
*/
public void valueRemoved(Object value) {
if((!suspendCollectionEvents) && (value instanceof ViewController)) {
internalRemoveItem((ViewController) value);
}//if//
}//valueRemoved()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueRemoved(java.lang.Object, int)
*/
public void valueRemoved(Object value, int index) {
valueRemoved(value);
}//valueRemoved()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#removingAll()
*/
public void removingAll() {
if(!suspendCollectionEvents) {
IIterator iterator = viewControllers.iterator();
startChanges(viewControllers.getSize());
while(iterator.hasNext()) {
valueRemoved(iterator.next());
}//while//
stopChanges();
}//if//
}//removingAll()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valuesSorted(int[])
*/
public void valuesSorted(int[] mapping) {
if(!suspendCollectionEvents) {
sendMessage(MESSAGE_SORT_ITEMS, new Object[] {new Integer(getPreceedingItemCount()), mapping});
}//if//
}//valuesSorted()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#getResourceService()
*/
public AbstractResourceService getResourceService() {
return ExpandBar.this.getResourceService();
}//getResourceService()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#getDecorationManager()
*/
public DecorationManager getDecorationManager() {
return ExpandBar.this.getDecorationManager();
}//getDecorationManager()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#addDecoration(com.foundation.view.AbstractDecoration)
*/
public void addDecoration(AbstractDecoration decoration) {
}//addDecoration()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#removeDecoration(com.foundation.view.AbstractDecoration)
*/
public void removeDecoration(AbstractDecoration decoration) {
}//removeDecoration()//
}//ItemsHolder//
/**
* ExpandBar 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 #STYLE_NO_BACKGROUND
* @see #STYLE_NO_FOCUS
* @see #STYLE_NO_MERGE_PAINTS
* @see #STYLE_NO_REDRAW_RESIZE
* @see #STYLE_NO_RADIO_GROUP
* @see #STYLE_H_SCROLL
* @see #STYLE_V_SCROLL
* @see #STYLE_BORDER
* @see #STYLE_LEFT_TO_RIGHT
* @see #STYLE_RIGHT_TO_LEFT
* @see #STYLE_TOP
* @see #STYLE_BOTTOM
*/
public ExpandBar(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//ExpandBar()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.ExpandBar";
}//getClientClassName()//
/**
* Sets the spacing.
* @param spacing The spacing that will be used by the component.
*/
public void setSpacing(Integer spacing) {
verifyThread();
this.spacing.setDefaultValue(spacing);
}//setSpacing()//
/**
* Sets the association container used to access the spacing.
* @param container The spacing association metadata.
*/
public void setSpacingAssociation(SingleAssociationContainer container) {
verifyThread();
this.spacing.setAssociations(container);
}//setSpacingAssociation()//
/**
* Adds N items to the item panel, where the items come from an association with the model.
* @return The item holder which can be used to add associations.
*/
public IItemsHolder addItems() {
ItemsHolder holder = new ItemsHolder(items.getSize() > 0 ? items.getLast() : null);
items.add(holder);
return holder;
}//addItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#addComponent(com.foundation.view.IAbstractComponent)
*/
public void addComponent(IAbstractComponent component) {
super.addComponent(component);
if(!suspendCustomComponentBehavior) {
items.add(component);
internalAddItem((Component) component);
}//if//
}//addComponent()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#removeComponent(com.foundation.view.IAbstractComponent)
*/
public void removeComponent(IAbstractComponent component) {
if(!suspendCustomComponentBehavior) {
internalRemoveItem((Component) component);
items.remove(component);
}//if//
super.removeComponent(component);
}//removeComponent()//
/**
* Adds a item to the panel for the given view component.
* @param component The view component that will be displayed in the item.
*/
protected void internalAddItem(Component component) {
if(component != null) {
sendMessage(MESSAGE_ADD_ITEM, null, null, component.getNumber(), -1);
}//if//
else {
Debug.log("Error: Invalid component. Unable to add the component as a item in the item panel.");
}//else//
}//internalAddItem()//
/**
* Removes a item from the panel for the given related view component.
* @param component The view component associated with the item to be removed.
*/
protected void internalRemoveItem(Component component) {
sendMessage(MESSAGE_REMOVE_ITEM, new Integer(component.getNumber()));
}//internalRemoveItem()//
/* (non-Javadoc)
* @see com.foundation.view.IView#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
IIterator iterator = null;
//Note: We are using the initialize all to setup the items so that they can be released before releasing the children.//
super.internalViewInitializeAll();
iterator = items.iterator();
//Initialize the items.//
while(iterator.hasNext()) {
Object item = iterator.next();
if(item instanceof ItemsHolder) {
((ItemsHolder) item).initialize();
}//if//
else {
//Ignore the component.//
}//else//
}//for//
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.view.IView#viewReleaseAll()
*/
protected void internalViewReleaseAll() {
IIterator iterator = items.iterator();
//Note: We are using the release all to release the items so that they can be released before releasing the children.//
while(iterator.hasNext()) {
Object item = iterator.next();
if(item instanceof Component) {
internalRemoveItem((Component) item);
}//if//
else if(item instanceof ItemsHolder) {
((ItemsHolder) item).release();
}//else if//
else {
//Ignore the component.//
}//else//
}//for//
super.internalViewReleaseAll();
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.view.swt.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
for(int index = 0; index < items.getSize(); index++) {
Object item = items.get(index);
if(item instanceof ItemsHolder) {
((ItemsHolder) item).refreshItems();
}//if//
else {
//Ignore the component.//
}//else//
}//for//
super.internalViewRefresh();
internalViewRefreshSpacing();
}//internalViewRefresh()//
/**
* Refreshes the spacing.
*/
protected void internalViewRefreshSpacing() {
if(spacing.refresh()) {
Integer spacing = (Integer) this.spacing.getValue();
sendMessage(MESSAGE_SET_SPACING, spacing);
}//if//
}//internalViewRefreshSpacing()//
}//ExpandBar//

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 2004,2007 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.IFillLayout;
public class FillLayout extends Layout implements IFillLayout {
/**
* FillLayout constructor.
* @param container The container that is using the layout.
*/
public FillLayout(AbstractComponent container) {
super(container);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, getContainer().getNumber());
}//FillLayout()//
/**
* Sets the layout type.
* @param type The layout type.
*/
public void setType(int type) {
sendMessage(MESSAGE_SET_TYPE, type);
}//setType()//
/**
* 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 the layout spacing.
* @param spacing The layout spacing.
*/
public void setSpacing(int spacing) {
sendMessage(MESSAGE_SET_SPACING, spacing);
}//setSpacing()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.FillLayout";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#initialize()
*/
public void initialize() {
}//initialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#refresh()
*/
public void refresh() {
}//refresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#release()
*/
public void release() {
}//release()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#synchronize()
*/
public void synchronize() {
}//synchronize()//
}//FillLayout//

View File

@@ -0,0 +1,143 @@
/*
* 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//

View File

@@ -0,0 +1,143 @@
/*
* 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 FontSizeComboBox extends Component implements IFontSizeComboBox {
/** 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;
/**
* FontSizeComboBox 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 FontSizeComboBox(Container parent, String name, int style) {
super(parent, name, style);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//FontSizeComboBox()//
/**
* 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 Integer getSelection() {
verifyThread();
return (Integer) selection.getValue();
}//getSelection()//
/**
* Sets the component default selection.
* @param selection The component's selection.
*/
public void setSelection(Integer 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: {
Integer selection = (Integer) 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.FontSizeComboBox";
}//getClientClassName()//
}//FontSizeComboBox//

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2004,2007 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.IFillLayout;
public class FormLayout extends Layout implements IFillLayout {
/**
* FormLayout constructor.
* @param container The container that is using the layout.
*/
public FormLayout(AbstractComponent container) {
super(container);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, getContainer().getNumber());
}//FormLayout()//
/**
* 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 the layout spacing.
* @param spacing The layout spacing.
*/
public void setSpacing(int spacing) {
sendMessage(MESSAGE_SET_SPACING, spacing);
}//setSpacing()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.FormLayout";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#initialize()
*/
public void initialize() {
}//initialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#refresh()
*/
public void refresh() {
}//refresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#release()
*/
public void release() {
}//release()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#synchronize()
*/
public void synchronize() {
}//synchronize()//
}//FormLayout//

View File

@@ -0,0 +1,318 @@
/*
* 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.common.debug.*;
import com.foundation.view.*;
import com.foundation.view.resource.ResourceReference;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.server.controller.*;
import com.foundation.tcv.view.ViewMessage;
public class Frame extends Container implements IFrame, IDecoration {
/** The container's images resource (similar to component's containerImage, but allows multiple images to be specified). */
private SingleResourceAssociation containerImages;
/** The optional method which will be called when the frame is closed. */
private IMethodAssociation closedMethod = null;
/** The optional method which will be called when the frame is activated. */
private IMethodAssociation activatedMethod = null;
/** The optional method which will be called when the frame is deactivated. */
private IMethodAssociation deactivatedMethod = null;
/** The optional menu bar for the frame. */
private Menu menuBar = null;
/** A cached reference to the button that is the default button for the frame. */
private Button currentDefaultButton = null;
/** Whether the server has already requested minimize/maximize events from the client. */
private boolean isRequestingActivationEvents = false;
/**
* Frame default constructor.
* <p>Warning: This is only for use by the framework. This should never be called to create a useable instance.</p>
*/
public Frame() {
}//Frame()//
/**
* Frame constructor.
* This constructor is only used by the Window subclass.
* @param sessionViewController The view controller for the current client session.
* @param name The unique component name.
*/
protected Frame(SessionViewController sessionViewController, String name, int style) {
super(sessionViewController, name, style);
containerImages = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGES, false, null);
}//Frame()//
/**
* Frame constructor.
* @param parent The parent frame.
* @param name The unique component name.
* @param style The frame style.
* @see #STYLE_BORDER
* @see #STYLE_H_SCROLL
* @see #STYLE_V_SCROLL
* @see #STYLE_BORDER
* @see #STYLE_LEFT_TO_RIGHT
* @see #STYLE_RIGHT_TO_LEFT
* @see #STYLE_NO_BACKGROUND
* @see #STYLE_NO_FOCUS
* @see #STYLE_NO_MERGE_PAINTS
* @see #STYLE_NO_REDRAW_RESIZE
* @see #STYLE_NO_RADIO_GROUP
* @see #STYLE_CLOSE
* @see #STYLE_MIN
* @see #STYLE_MAX
* @see #STYLE_RESIZE
* @see #STYLE_TITLE
* @see #STYLE_NO_TRIM
* @see #STYLE_SHELL_TRIM
* @see #STYLE_DIALOG_TRIM
* @see #STYLE_ON_TOP
* @see #STYLE_TOOL
*/
public Frame(Container parent, String name, int style) {
super(parent, name, style);
containerImages = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGES, false, null);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//Frame()//
/**
* Sets the association container used to access the image array.
* @param container The images association metadata.
*/
public void setContainerImagesAssociation(SingleAssociationContainer container) {
verifyThread();
this.containerImages.setAssociations(container);
}//setContainerImagesAssociation()//
/**
* Sets the component's default image array resource.
* @param images The images to be displayed by this component.
*/
public void setDefaultContainerImages(ResourceReference images) {
verifyThread();
this.containerImages.setDefaultValue(images);
}//setDefaultContainerImages()//
/**
* Sets the container's default images.
* @param images The image data array that will be displayed by the container when an image is needed to represent it (example: a tab in a tab panel).
*/
public void setDefaultContainerImages(JefImage[] images) {
verifyThread();
this.containerImages.setDefaultValue(images);
}//setDefaultContainerImages()//
/**
* Refreshes the images for the frame.
*/
protected void internalViewRefreshContainerImages() {
if(containerImages.refresh()) {
sendMessage(MESSAGE_SET_CONTAINER_IMAGES, containerImages.getValue());
}//if//
}//internalViewRefreshContainerImages()//
/* (non-Javadoc)
* @see com.foundation.view.IView#maximize()
*/
public void maximize() {
sendMessage(MESSAGE_MAXIMIZE, null);
}//maximize()//
/* (non-Javadoc)
* @see com.foundation.view.IView#minimize()
*/
public void minimize() {
sendMessage(MESSAGE_MINIMIZE, null);
}//minimize()//
/* (non-Javadoc)
* @see com.foundation.view.IView#show()
*/
public void show() {
sendMessage(MESSAGE_SHOW, null);
}//show()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Component#getDefaultVisibility()
*/
protected boolean getDefaultVisibility() {
return false;
}//getDefaultVisibility()//
/**
* Sets the method to be called when the frame is closed.
* @param closedMethod The method to notify when the close function is performed.
*/
public void setClosedMethod(IMethodAssociation closedMethod) {
this.closedMethod = closedMethod;
sendMessage(MESSAGE_REQUEST_CLOSED_NOTIFICATION, closedMethod != null ? Boolean.TRUE : Boolean.FALSE);
}//setClosedMethod()//
/**
* Sets the method to be called when the frame is activated.
* @param activatedMethod The method to notify when the activated function is performed.
*/
public void setActivatedMethod(IMethodAssociation activatedMethod) {
this.activatedMethod = activatedMethod;
if((activatedMethod != null) && (!isRequestingActivationEvents)) {
sendMessage(MESSAGE_SEND_ACTIVATED_EVENTS, Boolean.TRUE);
isRequestingActivationEvents = true;
}//if//
}//setActivatedMethod()//
/**
* Sets the method to be called when the frame is deactivated.
* @param deactivatedMethod The method to notify when the deactivated function is performed.
*/
public void setDeactivatedMethod(IMethodAssociation deactivatedMethod) {
this.deactivatedMethod = deactivatedMethod;
if((activatedMethod != null) && (!isRequestingActivationEvents)) {
sendMessage(MESSAGE_SEND_ACTIVATED_EVENTS, Boolean.TRUE);
isRequestingActivationEvents = true;
}//if//
}//setDeactivatedMethod()//
/**
* Gets the frame's default button.
* @return The default button in this container.
*/
public Button getDefaultButton() {
return currentDefaultButton;
}//getDefaultButton()//
/**
* Sets the frame's default button.
* @param defaultButton The default button in this container.
*/
public void setDefaultButton(Button defaultButton) {
currentDefaultButton = defaultButton;
sendMessage(MESSAGE_SET_DEFAULT_BUTTON, defaultButton != null ? new Integer(((Button) defaultButton).getNumber()) : null);
}//setDefaultButton()//
/* (non-Javadoc)
* @see com.foundation.view.swt.IDecoration#getMenuBar()
*/
public Menu getMenuBar() {
verifyThread();
return menuBar;
}//getMenuBar()//
/* (non-Javadoc)
* @see com.foundation.view.swt.IDecoration#setMenuBar(com.foundation.view.swt.Menu)
*/
public void setMenuBar(Menu menuBar) {
verifyThread();
if(isInitialized() && this.menuBar != null) {
this.menuBar.internalViewReleaseAll();
}//if//
this.menuBar = menuBar;
if(isInitialized()) {
menuBar.internalViewInitializeAll();
}//if//
}//setMenuBar()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
super.internalViewInitializeAll();
//Initialize the menu bar if there is one.//
if(getMenuBar() != null) {
getMenuBar().internalViewInitializeAll();
}//if//
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewReleaseAll()
*/
protected void internalViewReleaseAll() {
super.internalViewReleaseAll();
if(getMenuBar() != null) {
getMenuBar().internalViewReleaseAll();
}//if//
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefreshAll()
*/
protected void internalViewRefreshAll() {
super.internalViewRefreshAll();
if(getMenuBar() != null) {
getMenuBar().internalViewRefreshAll();
}//if//
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
containerImages.initialize();
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
containerImages.release();
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
try {
internalViewRefreshContainerImages();
super.internalViewRefresh();
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Component#internalOnValueChanged(com.foundation.view.SingleResourceAssociation, boolean)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == containerImages) {
internalViewRefreshContainerImages();
}//if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#processMessage(com.foundation.tcv.model.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object retVal = null;
switch(viewMessage.getMessageNumber()) {
case MESSAGE_IS_CLOSED: {
if(closedMethod != null) {
closedMethod.invoke(null, false);
}//if//
break;
}//case//
case MESSAGE_IS_ACTIVATED: {
Boolean isActivated = (Boolean) viewMessage.getMessageData();
if(isActivated.booleanValue()) {
if(activatedMethod != null) {
activatedMethod.invoke(null, false);
}//if//
}//if//
else {
if(deactivatedMethod != null) {
deactivatedMethod.invoke(null, false);
}//if//
}//else//
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
break;
}//default//
}//switch//
return retVal;
}//processMessage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.Frame";
}//getClientClassName()//
}//Frame//

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 2004,2007 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.IGridLayout;
public class GridLayout extends Layout implements IGridLayout {
/**
* GridLayout constructor.
* @param container The container that is using the layout.
*/
public GridLayout(AbstractComponent container) {
super(container);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, getContainer().getNumber());
}//GridLayout()//
/**
* Sets the layout column count.
* @param type The layout column count.
*/
public void setNumColumns(int numColumns) {
sendMessage(MESSAGE_SET_NUM_COLUMNS, numColumns);
}//setNumColumns()//
/**
* 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 whether the layout columns have the same widths.
* @param makeColumnsEqualWidth Whether the layout columns are equal width.
*/
public void setMakeColumnsEqualWidth(boolean makeColumnsEqualWidth) {
sendMessage(MESSAGE_SET_MAKE_COLUMNS_EQUAL_WIDTH, makeColumnsEqualWidth ? 1 : 0);
}//setMakeColumnsEqualWidth()//
/**
* Sets the layout horizontal spacing.
* @param horizontalSpacing The layout horizontal spacing.
*/
public void setHorizontalSpacing(int horizontalSpacing) {
sendMessage(MESSAGE_SET_HORIZONTAL_SPACING, horizontalSpacing);
}//setHorizontalSpacing()//
/**
* Sets the layout vertical spacing.
* @param verticalSpacing The layout vertical spacing.
*/
public void setVerticalSpacing(int verticalSpacing) {
sendMessage(MESSAGE_SET_VERTICAL_SPACING, verticalSpacing);
}//setVerticalSpacing()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.GridLayout";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#initialize()
*/
public void initialize() {
}//initialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#refresh()
*/
public void refresh() {
}//refresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#release()
*/
public void release() {
}//release()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#synchronize()
*/
public void synchronize() {
}//synchronize()//
}//GridLayout//

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2003,2007 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.*;
import com.foundation.tcv.view.*;
public class Group extends Container implements IGroup {
/**
* Group default constructor.
* <p>Warning: This is only for use by the framework. This should never be called to create a useable instance.</p>
*/
public Group() {
}//Group()//
/**
* Group 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 #STYLE_SHADOW_ETCHED_IN
* @see #STYLE_SHADOW_ETCHED_OUT
* @see #STYLE_SHADOW_IN
* @see #STYLE_SHADOW_OUT
* @see #STYLE_SHADOW_NONE
*/
public Group(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//Group()//
/* (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.Group";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
}//internalViewRefresh()//
}//Group//

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2006,2007 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.util.IIterator;
import com.foundation.tcv.swt.server.cell.CellComponent;
import com.foundation.view.IAbstractContainer;
public interface ICellContainer {
/**
* Gets the row object metadata for the given object identifier.
* @param item The collection item whose metadata is desired.
* @return The row object for the given collection item.
*/
public RowObject getRowObject(Object item);
/**
* Gets the row object metadata for the given object identifier.
* @param objectId The identifying number for the desired collection item's metadata.
* @return The row object for the given identifer.
*/
public RowObject getRowObject(int objectId);
/**
* Gets an iterator over all row objects.
* @return The iterator containing all the row objects.
*/
public IIterator getRowObjects();
/**
* Gets the container for this cell container.
* @return The container object for the cell container, which is often the same object.
*/
public IAbstractContainer getContainer();
/**
* Adds a cell component as a child of this container.
* @param component The cell component to be contained by this container.
*/
public void addCellComponent(CellComponent component);
}//ICellContainer//

View File

@@ -0,0 +1,19 @@
/*
* 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;
/**
* Implementors must be able to display them selves with a menu bar.
*/
public interface IDecoration {
/**
* Sets the decoration's menu bar.
* @param menu The menu to be displayed in the menu bar.
*/
public void setMenuBar(Menu menu);
}//IDecoration//

View File

@@ -0,0 +1,298 @@
/*
* 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.common.util.*;
import com.common.util.optimized.*;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.view.*;
/*
* Extends the CollectionComponent to provide indexing of the collection items.
* This is an abstract class that is meant to reduce the end control complexity.
*/
public abstract class IndexedCollectionComponent extends CollectionComponent implements IIndexedCollectionComponent {
/**
* IndexedCollectionComponent constructor.
* @param parent The parent container.
* @param name The name of the component.
*/
public IndexedCollectionComponent(Container parent, String name, int style) {
super(parent, name, style);
}//IndexedCollectionComponent()//
/**
* Refreshes the item data.
* @param item The collection item whose data needs refreshing.
*/
protected void internalViewRefreshItem(Object item) {
RowObject rowObject = getRowObject(item);
if(rowObject != null) {
sendMessage(MESSAGE_SET_ITEM, new Object[] {new Integer(rowObject.objectId), getItemData(rowObject)});
}//if//
else {
//Do nothing. It may simply be a stray event (fired before we removed event listeners, but received after they were removed).//
}//else//
}//internalViewRefreshItem()//
/* (non-Javadoc)
* @see com.foundation.view.swt.CollectionComponent#internalViewRefreshCollection(com.common.util.ICollection, com.common.util.ICollection)
*/
protected void internalViewRefreshCollection(ICollection newCollection, ICollection oldCollection) {
//Remove all listeners, mappings, and metadata.//
itemAllRemoved();
if((newCollection != null) && (newCollection.getSize() > 0)) {
IIterator iterator = newCollection.iterator();
// Object[] itemData = newCollection.getSize() > 0 ? new Object[newCollection.getSize()] : null;
// Object[] hiddenData = newCollection.getSize() > 0 && getHiddenDataCount() > 0 ? new Object[newCollection.getSize()][getHiddenDataCount()] : null;
// int[] objectIds = itemData != null ? new int[itemData.length] : null;
int index = 0;
//Get the array of strings representing the list contents.//
while(iterator.hasNext()) {
Object value = iterator.next();
itemAdded(value, index++, true);
// RowObject rowObject = itemAdded(value, index, false);
//
// //Add the item mappings without notifying the client.//
// if(rowObject.isFirstReference()) {
// //Add the value to the item array.//
// itemData[index] = getItemData(rowObject);
//
// if(hiddenData != null) {
// hiddenData[index] = getItemHiddenData(value);
// }//if//
// }//if//
//
// objectIds[index] = rowObject.objectId;
//
// index++;
}//while//
//Set the collection contents.//
// sendMessage(MESSAGE_SET_ITEMS, new Object[] {itemData, objectIds, hiddenData});
//If the selection was invalid previously then refresh the selection since it may no longer be invalid.//
if(isSelectionInvalid) {
internalViewRefreshSelection();
}//if//
}//if//
else {
//Remove all collection contents.//
sendMessage(MESSAGE_REMOVE_ALL, null);
}//else//
}//internalViewRefreshCollection()//
/* (non-Javadoc)
* @see com.foundation.view.swt.CollectionComponent#internalViewRefreshSelection(java.lang.Object)
*/
protected void internalViewRefreshSelection(Object selectedItem) {
//Send selection index or indices to the remote control where it will determine whether the selection should be changed.//
//Again: What to do about impossible selections?//
Object currentSelection = getModelSelection();
int objectId;
if(currentSelection != null) {
RowObject rowObject = getRowObject(currentSelection);
objectId = rowObject == null ? INVALID_OBJECT_ID : rowObject.objectId;
if((objectId == -1) && (getAllowUserItems())) {
sendMessage(MESSAGE_SET_SELECTION, currentSelection.toString());
}//if//
else if(objectId == -1) {
isSelectionInvalid = true;
//Note: We are no longer invalidating the model selection since this may be a valid action given that the selection may be attached to an attribute that is also attached to another component.//
sendMessage(MESSAGE_SET_SELECTION, null);
}//else if//
else {
isSelectionInvalid = false;
//Send selection.//
sendMessage(MESSAGE_SET_SELECTION, new int[] {objectId});
}//else//
}//if//
else {
//No selection.//
sendMessage(MESSAGE_SET_SELECTION, null);
}//else//
}//internalViewRefreshSelection()//
/* (non-Javadoc)
* @see com.foundation.view.swt.CollectionComponent#internalViewRefreshSelections(com.common.util.ICollection, com.common.util.ICollection)
*/
protected void internalViewRefreshSelections(ICollection newSelections, ICollection oldSelections) {
//Collect indexes and collections of indexes for each selection and send all to control. Control will then apply necessary changes.//
//How to deal with impossible selections? We could send back a deselect message?//
if(newSelections != null) {
IntArray selectionIndices = new IntArray(newSelections.getSize());
IIterator modelSelectionIterator = null;
modelSelectionIterator = newSelections.iterator();
//Apply differences between the selection collection and the control selection. Also remove all impossible selections.//
while(modelSelectionIterator.hasNext()) {
Object modelSelection = modelSelectionIterator.next();
RowObject rowObject = getRowObject(modelSelection);
if(rowObject == null) {
//An invalid selection because the selection is not in the collection of displayed values.//
modelSelectionIterator.remove();
}//if//
else {
selectionIndices.add(rowObject.objectId);
}//else//
}//while//
sendMessage(MESSAGE_SET_SELECTION, selectionIndices.toArray());
}//if//
else {
//Remove all selections.//
sendMessage(MESSAGE_REMOVE_SELECTIONS, null);
}//else//
}//internalViewRefreshSelections()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#registerItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void registerItem(RowObject rowObject) {
super.registerItem(rowObject);
}//registerItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void unregisterItem(RowObject rowObject) {
super.unregisterItem(rowObject);
}//unregisterItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItems()
*/
protected void unregisterItems() {
super.unregisterItems();
}//unregisterItems()//
/* (non-Javadoc)
* @see com.foundation.view.swt.CollectionComponent#itemSorted(int[])
*/
protected void itemSorted(int[] mapping) {
//TODO: Re-order the indicies in the control and rebuild the mappings.//
}//itemSorted()//
/* (non-Javadoc)
* @see com.foundation.view.swt.CollectionComponent#selectionAdded(java.lang.Object)
*/
protected void selectionAdded(Object value) {
RowObject rowObject = getRowObject(value);
if(rowObject != null) {
sendMessage(MESSAGE_ADD_SELECTION, new int[] {rowObject.objectId});
}//if//
}//selectionAdded()//
/* (non-Javadoc)
* @see com.foundation.view.swt.CollectionComponent#selectionRemoved(java.lang.Object)
*/
protected void selectionRemoved(Object value) {
RowObject rowObject = getRowObject(value);
if(rowObject != null) {
sendMessage(MESSAGE_REMOVE_SELECTION, new int[] {rowObject.objectId});
}//if//
}//selectionRemoved()//
/* (non-Javadoc)
* @see com.foundation.view.swt.CollectionComponent#selectionAllRemoved()
*/
protected void selectionAllRemoved() {
sendMessage(MESSAGE_REMOVE_SELECTIONS, null);
}//selectionAllRemoved()//
/* (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: { //Receive the selection information from the client.//
Object messageData = viewMessage.getMessageData();
if(getAllowMultiSelection()) {
int[] selectionObjectIds = (int[]) messageData;
ICollection modelSelections = getModelSelections();
//Prevent the selection additions from causing a feedback loop.//
suspendSelectionHooks = true;
try {
if(modelSelections != null) {
Object[] controlSelectionObjects = new Object[selectionObjectIds.length];
boolean[] markedControlSelections = new boolean[controlSelectionObjects.length];
IIterator modelSelectionIterator = modelSelections.iterator();
LiteList removed = new LiteList(modelSelections.getSize());
LiteList added = new LiteList(selectionObjectIds.length);
for(int index = 0; index < selectionObjectIds.length; index++) {
controlSelectionObjects[index] = getRowObject(selectionObjectIds[index]).value;
markedControlSelections[index] = false;
}//for//
//Add selected items to the selection collection.//
while(modelSelectionIterator.hasNext()) {
Object modelSelection = modelSelectionIterator.next();
boolean found = false;
for(int index = 0; (!found) && (index < markedControlSelections.length); index++) {
if(!markedControlSelections[index]) {
if(controlSelectionObjects[index] == modelSelection) {
markedControlSelections[index] = true;
found = true;
}//if//
}//if//
}//for//
if(!found) {
removed.add(modelSelection);
}//if//
}//while//
for(int index = 0; index < markedControlSelections.length; index++) {
if(!markedControlSelections[index]) {
added.add(controlSelectionObjects[index]);
}//if//
}//for//
modelSelections.replaceAll(removed, added);
}//if//
}//try//
finally {
suspendSelectionHooks = false;
}//finally//
}//if//
else {
int selectedObjectId = (messageData != null) && !(messageData instanceof String) ? ((Integer) messageData).intValue() : -1;
if(selectedObjectId == -1) {
if((getAllowUserItems()) && (((String) messageData).length() > 0)) { //TODO: If the user wants numbers only, should the conversion occur on the server or the client?//
//Set the custom value.//
setModelSelection((String) messageData);
}//if//
else {
setModelSelection(null);
}//else//
}//if//
else {
setModelSelection(getRowObject(selectedObjectId).value);
}//else//
}//else//
if(getAutoValidate()) {
postSynchronizeValidate();
}//if//
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
}//default//
}//switch//
return retVal;
}//processMessage()//
}//IndexedCollectionComponent//

View File

@@ -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//

View File

@@ -0,0 +1,195 @@
/*
* 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//

View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 2005,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.ILink;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.IMethodAssociation;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
public class Link extends Component implements ILink {
/** Called when the link is pressed. */
private IMethodAssociation selectionMethod = null;
/** The button's text resource. */
private SingleResourceAssociation text = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, "");
/**
* Link 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 Link(Container parent, String name, int style) {
super(parent, name, style);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//Link()//
/**
* Sets the selection method called when the link is pressed.
* @param selectionMethod The method called when the link is pressed.
*/
public void setSelectionMethod(IMethodAssociation selectionMethod) {
verifyThread();
this.selectionMethod = selectionMethod;
}//setSelectionMethod()//
/**
* Sets the component text.
* @param text The text that will appear in the component.
*/
public void setText(String 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()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
text.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
internalViewRefreshText();
}//internalViewRefresh()//
/**
* Refreshes the link text.
*/
protected void internalViewRefreshText() {
if(text.refresh()) {
sendMessage(MESSAGE_SET_TEXT, (String) text.getValue());
}//if//
}//internalViewRefreshText()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
text.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.view.swt.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == text) {
internalViewRefreshText();
}//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()) {
case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: {
//Call the selection method.//
selectionMethod.invoke(null, true);
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.Link";
}//getClientClassName()//
}//Link//

View File

@@ -0,0 +1,231 @@
/*
* 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.common.util.*;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.view.*;
import com.foundation.view.JefImage;
import com.foundation.view.MultiAssociationContainer;
import com.foundation.view.MultiResourceAssociation;
import com.foundation.view.ResourceAssociation;
public class ListBox extends IndexedCollectionComponent implements IListBox {
/** Track the last synchronized top index. */
private Integer currentTopIndex = new Integer(0);
/** Converts the collection item to a string used to show the item to the user. */
protected MultiResourceAssociation itemText = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_TEXT, false, null);
/** Converts the collection item to an image used to show the item to the user. */
protected MultiResourceAssociation itemImage = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_IMAGE, false, null);
/**
* ListBox 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 #STYLE_MULTI
* @see #STYLE_SINGLE
*/
public ListBox(Container parent, String name, int style) {
super(parent, name, style);
setAllowMultiSelection(((style & STYLE_MULTI) > 0));
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//ListBox()//
/**
* Sets the association container used to access the item text.
* @param container The item text association metadata.
*/
public void setItemTextAssociation(MultiAssociationContainer container) {
verifyThread();
this.itemText.setAssociations(container);
}//setItemTextAssociation()//
/**
* Sets the association container used to access the item text.
* @param container The item text association metadata.
*/
public void setItemImageAssociation(MultiAssociationContainer container) {
verifyThread();
this.itemImage.setAssociations(container);
}//setItemImageAssociation()//
/**
* Adjusts the visible range of items to show some or all of the selections.
*/
public void showSelection() {
sendMessage(MESSAGE_SHOW_SELECTION, null);
}//showSelection()//
/**
* Gets the index of the top most visible item.
* @return The top most visible item's index.
*/
public Integer getTopIndex() {
return currentTopIndex;
}//getTopIndex()//
/**
* Sets the index of the top most visible item.
* @parma topIndex The top most visible item's index.
*/
public void setTopIndex(Integer topIndex) {
//Tell the client list to update.//
sendMessage(MESSAGE_SET_TOP_INDEX, topIndex);
//Save the current top index.//
this.currentTopIndex = topIndex;
}//setTopIndex()//
/* (non-Javadoc)
* @see com.foundation.view.IViewComponent#viewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
itemText.initialize();
itemImage.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.view.IViewComponent#viewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
itemText.release();
itemImage.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object)
*/
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
if(resourceAssociation == itemText) {
internalViewRefreshItem(alteredItem);
}//if//
else if(resourceAssociation == itemImage) {
internalViewRefreshItem(alteredItem);
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, alteredItem, data, isUpdate);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.IndexedCollectionComponent#getItemData(com.foundation.tcv.swt.server.RowObject)
*/
protected Object getItemData(RowObject rowObject) {
return itemToString(rowObject.value);
}//getItemData()//
/* (non-Javadoc)
* @see com.foundation.tcv.view.IAbstractViewComponent#processMessage(com.foundation.tcv.view.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object retVal = null;
switch(viewMessage.getMessageNumber()) {
case MESSAGE_SYNCHRONIZE_TOP_INDEX: {
currentTopIndex = (Integer) viewMessage.getMessageData();
break;
}//case//
case MESSAGE_DOUBLE_CLICK: {
if(getDoubleClickMethod() != null) {
if(getDoubleClickMethod().getIsValueHolderAssociated()) {
getDoubleClickMethod().invoke(null, true); //For now we will assume no parameters. It would be nice to pass the selection perhaps.//
}//if//
else {
Object selection = null;
//Determine which selection to invoke the method on.//
if(getAllowMultiSelection()) {
ICollection selections = getModelSelections();
if((selections != null) && (selections.getSize() > 0)) {
selection = selections.iterator().next();
}//if//
}//if//
else {
selection = getModelSelection();
}//else//
if(selection != null) {
//Invoke the method on the selection object if there is one.//
getDoubleClickMethod().invoke(selection, null, true);
}//if//
}//else//
}//if//
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
break;
}//default//
}//switch//
return retVal;
}//processMessage()//
/**
* Converts an item in the collection to a string that can be displayed.
* @param item The collection item to convert.
* @return The string that can be displayed.
*/
protected String itemToString(Object item) {
String result = null;
if(item instanceof JefImage) {
return "";
}//if//
else {
itemText.refresh(item);
result = (String) itemText.getValue(item);
if(result == null) {
result = item != null ? item.toString() : "";
}//if//
}//if//
return result;
}//itemToString()//
/**
* Converts an item in the collection to an image that can be displayed.
* @param item The collection item to convert.
* @return The image that can be displayed.
*/
protected JefImage itemToImage(Object item) {
JefImage result = null;
if(item instanceof JefImage) {
result = (JefImage) item;
}//if//
else {
itemImage.refresh(item);
result = (JefImage) itemImage.getValue(item);
}//else//
return result;
}//itemToImage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#registerItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void registerItem(RowObject rowObject) {
itemText.registerItem(rowObject.value, rowObject);
itemImage.registerItem(rowObject.value, rowObject);
super.registerItem(rowObject);
}//registerItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void unregisterItem(RowObject rowObject) {
itemText.unregisterItem(rowObject.value);
itemImage.unregisterItem(rowObject.value);
super.unregisterItem(rowObject);
}//unregisterItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItems()
*/
protected void unregisterItems() {
itemText.unregisterAllItems();
itemImage.unregisterAllItems();
super.unregisterItems();
}//unregisterItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.ListBox";
}//getClientClassName()//
}//ListBox//

View File

@@ -0,0 +1,583 @@
/*
* 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.common.util.*;
import com.common.debug.*;
import com.foundation.view.*;
import com.foundation.view.resource.ResourceReference;
import com.foundation.tcv.model.LinkInfo;
import com.foundation.tcv.swt.IMenu;
import com.foundation.tcv.view.*;
public class Menu extends AbstractComponent implements IMenu {
/** The menu's parent component which may be another menu. */
private AbstractComponent parent = null;
/** An internal flag to assist in determining whether this menu is allowed to have sub-menus. */
private boolean canHaveSubMenus = false;
/** A collection of sub menus. */
private IList subMenus = null;
/** The menu's name. */
private String name = null;
/** Called when the button is pressed. */
private IMethodAssociation selectionMethod = null;
/** The menu's selection state resource. */
private SingleResourceAssociation selection;
/** The menu's title resource. */
private SingleResourceAssociation text;
/** The menu's image resource. */
private SingleResourceAssociation image;
/** The resource defining the visible state for the menu. */
private SingleResourceAssociation isVisible;
/** The resource defining the enabled state for the menu. */
private SingleResourceAssociation isEnabled;
/** The current accelerator character used to activate the menu. */
private Integer currentAccelerator = null;
/** Whether the menu is a push menu which doesn't retain a selection state. */
private final boolean isPushMenu;
/** Whether the menu is a radio or check style menu which retains a selection state. */
private final boolean isRadioCheckMenu;
/** Whether the method called when the menu is pressed should be performed on the UI thread. */
private boolean synchronousSelection = false;
/** A reusable single value array. */
private Object[] reusableArrayOne = new Object[1];
/**
* Menu constructor.
* @param parent The component containing the menu. There are only a few components that allow a menu bar. All components may have one popup menu.
* @param name The optional name for the menu.
* @param style The menu style. The menu may be a bar, popup, or cascade if it contains other menus.
* @see #STYLE_BAR
* @see #STYLE_POPUP
* @see #STYLE_CASCADE
* @see #STYLE_RADIO
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_SEPARATOR
* @see #STYLE_RIGHT_TO_LEFT
* @see #STYLE_LEFT_TO_RIGHT
*/
public Menu(com.foundation.view.IAbstractComponent parent, String name, int style) {
super(((AbstractComponent) parent).getSessionViewController());
this.parent = (AbstractComponent) parent;
this.name = name;
this.isPushMenu = (style & STYLE_PUSH) > 0;
this.isRadioCheckMenu = ((style & STYLE_RADIO) > 0) || ((style & STYLE_CHECK) > 0);
if(!(((style & STYLE_BAR) > 0) || ((style & STYLE_POPUP) > 0))) {
throw new IllegalArgumentException("The parent must be another menu for this menu style.");
}//if//
canHaveSubMenus = true;
if((style & STYLE_BAR) > 0) {
if(parent instanceof IDecoration) {
((IDecoration) parent).setMenuBar(this);
}//if//
else {
Debug.log("Error: Cannot assign a menu bar to a non-IDecoration component.");
}//else//
}//if//
else if((style & STYLE_POPUP) > 0) {
if(this.parent instanceof AbstractComponent) {
((AbstractComponent) this.parent).setMenu(this);
}//if//
}//if//
initialize();
//Initialize the client control.//
sendMessage(MESSAGE_INITIALIZE, null, null, this.parent.getNumber(), style);
}//Menu()//
/**
* Menu constructor.
* @param parent The menu containing the menu.
* @param name The optional name for the menu.
* @param style The menu style. The menu may be a bar, popup, or cascade if it contains other menus.
* @see #STYLE_BAR
* @see #STYLE_POPUP
* @see #STYLE_CASCADE
* @see #STYLE_RADIO
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_SEPARATOR
* @see #STYLE_RIGHT_TO_LEFT
* @see #STYLE_LEFT_TO_RIGHT
*/
public Menu(Menu parent, String name, int style) {
super(parent.getSessionViewController());
this.parent = parent;
this.name = name;
this.isPushMenu = (style & STYLE_PUSH) > 0;
this.isRadioCheckMenu = ((style & STYLE_RADIO) > 0) || ((style & STYLE_CHECK) > 0);
if(((style & STYLE_BAR) > 0) || ((style & STYLE_POPUP) > 0)) {
throw new IllegalArgumentException("The parent may not be another menu for this menu style.");
}//if//
if((style & STYLE_CASCADE) > 0) {
canHaveSubMenus = true;
}//if//
parent.getSubMenus().add(this);
initialize();
sendMessage(MESSAGE_INITIALIZE, null, null, parent.getNumber(), style);
}//Menu()//
/**
* Initializes the view component.
*/
protected void initialize() {
selection = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, true, Boolean.FALSE);
text = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, "");
image = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGE, false, null);
isVisible = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, false, Boolean.TRUE);
isEnabled = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, false, Boolean.TRUE);
}//initialize()//
/**
* Gets the collection of all sub menus.
* @return A collection of menus, or null if this menu cannot hold other menus.
*/
private IList getSubMenus() {
if((canHaveSubMenus) && (subMenus == null)) {
subMenus = new LiteList(4, 8);
}//if//
return subMenus;
}//getSubMenus()//
/**
* Gets the parent component for this component.
* @return The view component containing this component. This will not be null, and may be a Component or another Menu instance.
*/
public AbstractComponent getParent() {
return parent;
}//getParent()//
/**
* Gets the container nearest the menu.
* @return The nearest container to this menu.
*/
public IAbstractContainer getContainer() {
AbstractComponent component = getParent();
while(component instanceof Menu) {
component = ((Menu) component).getParent();
}//while//
return component instanceof IAbstractContainer ? (IAbstractContainer) component : ((IAbstractComponent) component).getContainer();
}//getContainer()//
/**
* Gets the component's name.
* @return The name of this component.
*/
public String getName() {
return name;
}//getName()//
/**
* Gets the accelerator character for the menu.
* @return The menu accelerator key.
*/
public int getAccelerator() {
verifyThread();
return currentAccelerator.intValue();
}//setAccelerator()//
/**
* Sets the accelerator character for the menu.
* @param accelerator The menu accelerator key.
*/
public void setAccelerator(int accelerator) {
verifyThread();
if((currentAccelerator == null) || (currentAccelerator.intValue() != accelerator)) {
currentAccelerator = new Integer(accelerator);
sendMessage(MESSAGE_SET_ACCELERATOR, currentAccelerator);
}//if//
}//setAccelerator()//
/**
* Gets the component selection state.
* @return Whether the component is in the selected state.
*/
public Boolean getIsSelected() {
verifyThread();
return (Boolean) this.selection.getDefaultValue();
}//getIsSelected()//
/**
* Sets the menu's default selection state.
* @param isSelected Whether the menu is selected by default.
*/
public void setIsSelected(Boolean isSelected) {
verifyThread();
if(isRadioCheckMenu) {
this.selection.setDefaultValue(isSelected);
}//if//
}//setIsSelected()//
/**
* Sets the selection method called when the menu is pressed (intended for push menus).
* <p>TODO: Currently this may not be changed after initializing the control. Make this changeable? or throw an error if it is changed?</p>
* @param selectionMethod The method called when the menu is selected.
*/
public void setSelectionMethod(IMethodAssociation selectionMethod) {
verifyThread();
if(isPushMenu) {
this.selectionMethod = selectionMethod;
}//if//
}//setSelectionMethod()//
/**
* 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()//
/**
* Sets an 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 an 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 an association container used to access the selection.
* @param container The selection association metadata.
*/
public void setSelectionAssociation(SingleAssociationContainer container) {
verifyThread();
this.selection.setAssociations(container);
}//setSelectionAssociation()//
/**
* Sets the association container used to access whether the menu is enabled.
* @param container The enabled state association metadata.
*/
public void setIsEnabledAssociation(SingleAssociationContainer container) {
verifyThread();
this.isEnabled.setAssociations(container);
}//setIsEnabledAssociation()//
/**
* Sets the association container used to access whether the menu is visible.
* @param container The visible state association metadata.
*/
public void setIsVisibleAssociation(SingleAssociationContainer container) {
verifyThread();
this.isVisible.setAssociations(container);
}//setIsVisibleAssociation()//
/**
* Sets whether the selection synchronization should wait for a reply before returning control to the user.
* @param synchronousSelection Whether the selection is synchronous.
*/
public void setSynchronousSelection(boolean synchronousSelection) {
verifyThread();
if(isPushMenu) {
if(this.synchronousSelection != synchronousSelection) {
this.synchronousSelection = synchronousSelection;
sendMessage(MESSAGE_SET_SYNCHRONOUS_SELECTION, synchronousSelection ? Boolean.TRUE : Boolean.FALSE);
}//if//
}//if//
}//setSynchronousSelection()//
/**
* Sets the component text.
* @param text The text that will appear in the component.
*/
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 component image.
* @param image The image to be displayed by the component.
*/
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()//
/**
* Sets whether the menu is visible by default.
* @param isVisible The default visiblity for the menu.
*/
public void setIsVisible(boolean isVisible) {
verifyThread();
this.isVisible.setDefaultValue(isVisible ? Boolean.TRUE : Boolean.FALSE);
}//setIsVisible()//
/**
* Sets the default visibility resource.
* @param isVisible Whether the user can see the component.
*/
public void setIsVisible(ResourceReference isVisible) {
verifyThread();
this.isVisible.setDefaultValue(isVisible);
}//setIsVisible()//
/**
* Sets the default enabled state of the menu.
* @param isEnabled Whether the menu is enabled by default.
*/
public void setIsEnabled(boolean isEnabled) {
verifyThread();
this.isEnabled.setDefaultValue(isEnabled ? Boolean.TRUE : Boolean.FALSE);
}//setIsEnabled()//
/**
* Sets the default enabled state resource.
* @param isEnabled Whether the user can interact with the component.
*/
public void setIsEnabled(ResourceReference isEnabled) {
verifyThread();
this.isEnabled.setDefaultValue(isEnabled);
}//setIsEnabled()//
/**
* Sets the menu location.
* @param x The upper left point's X coordinate.
* @param y The upper left point's Y coordinate.
*/
public void setLocation(int x, int y) {
verifyThread();
sendMessage(MESSAGE_SET_LOCATION, new int[] {x, y});
}//setLocation()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
super.internalViewInitializeAll();
try {
//Initialize sub-menus.//
if((getSubMenus() != null) && (getSubMenus().getSize() > 0)) {
IIterator iterator = getSubMenus().iterator();
while(iterator.hasNext()) {
Menu next = (Menu) iterator.next();
next.internalViewInitializeAll();
}//while//
}//if//
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewReleaseAll()
*/
protected void internalViewReleaseAll() {
super.internalViewReleaseAll();
try {
//Release sub-menus.//
if((getSubMenus() != null) && (getSubMenus().getSize() > 0)) {
IIterator iterator = getSubMenus().iterator();
while(iterator.hasNext()) {
Menu next = (Menu) iterator.next();
next.internalViewReleaseAll();
}//while//
}//if//
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefreshAll()
*/
protected void internalViewRefreshAll() {
//Refresh this component.//
super.internalViewRefreshAll();
try {
//Refresh sub-menus.//
if((getSubMenus() != null) && (getSubMenus().getSize() > 0)) {
IIterator iterator = getSubMenus().iterator();
while(iterator.hasNext()) {
Menu next = (Menu) iterator.next();
next.internalViewRefreshAll();
}//while//
}//if//
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
text.initialize();
image.initialize();
isVisible.initialize();
isEnabled.initialize();
selection.initialize();
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
text.release();
image.release();
isVisible.release();
isEnabled.release();
selection.release();
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
addMessageHold();
try {
internalViewRefreshSelection();
internalViewRefreshText();
internalViewRefreshImage();
internalViewRefreshIsVisible();
internalViewRefreshIsEnabled();
super.internalViewRefresh();
}//try//
finally {
removeMessageHold();
}//finally//
}//internalViewRefresh()//
/**
* Refreshes the selection.
*/
protected void internalViewRefreshSelection() {
if(selection.refresh()) {
sendMessage(MESSAGE_SET_IS_SELECTED, selection.getValue());
}//if//
}//internalViewRefreshSelection()//
/**
* Refreshes the text from the text attribute and the default text.
*/
protected void internalViewRefreshText() {
if(text.refresh()) {
sendMessage(MESSAGE_SET_TEXT, (String) text.getValue());
}//if//
}//internalViewRefreshText()//
/**
* Refreshes the image from the image url attribute and the default image url.
*/
protected void internalViewRefreshImage() {
if(image.refresh()) {
sendMessage(MESSAGE_SET_IMAGE, (JefImage) image.getValue());
}//if//
}//internalViewRefreshImage()//
/**
* Refreshes whether the menu is enabled based on the attribute value or if null the default flag value.
*/
protected void internalViewRefreshIsEnabled() {
if(isEnabled.refresh()) {
sendMessage(MESSAGE_SET_IS_ENABLED, isEnabled.getValue() == null ? Boolean.TRUE : (Boolean) isEnabled.getValue());
}//if//
}//internalViewRefreshIsEnabled()//
/**
* Refreshes whether the menu is visible based on the attribute value or if null the default flag value.
*/
protected void internalViewRefreshIsVisible() {
if(isVisible.refresh()) {
sendMessage(MESSAGE_SET_IS_VISIBLE, isVisible.getValue() == null ? Boolean.TRUE : (Boolean) isVisible.getValue());
}//if//
}//internalViewRefreshIsVisible()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == isVisible) {
internalViewRefreshIsVisible();
}//if//
else if(resourceAssociation == isEnabled) {
internalViewRefreshIsEnabled();
}//else if//
else if(resourceAssociation == text) {
internalViewRefreshText();
}//else if//
else if(resourceAssociation == image) {
internalViewRefreshImage();
}//else if//
else if(resourceAssociation == selection) {
internalViewRefreshSelection();
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnEventFired(com.foundation.tcv.swt.server.IEventAssociation, java.lang.Object[])
*/
protected void internalOnEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
super.internalOnEventFired(eventAssociation, eventArguments);
}//internalOnEventFired()//
/* (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: {
Boolean selectionState = (Boolean) viewMessage.getMessageData();
//Call the selection method. This is usually set for push menus.//
if((isPushMenu) && (selectionMethod != null)) {
reusableArrayOne[0] = selectionState;
selectionMethod.invoke(reusableArrayOne, synchronousSelection);
}//if//
//Call the selection attribute's setter. This is usually set for non-push menus.//
if(isRadioCheckMenu) {
selection.setValue(selectionState);
}//if//
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.Menu";
}//getClientClassName()//
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
return super.toString() + (getName() != null ? " (named: " + getName() + ")" : "");
}//toString()//
}//Menu//

View File

@@ -0,0 +1,97 @@
/*
* Copyright (c) 2004,2008 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.swt.*;
import com.foundation.tcv.view.ViewMessage;
public class MessageDialog extends Dialog implements IMessageDialog {
/** The message displayed in the message dialog. */
private String message = null;
/**
* MessageDialog constructor.
* @param parent The dialog's parent view.
*/
public MessageDialog(IView parent) {
super(((Container) parent).getSessionViewController());
//this.parent = (Container) parent;
sendMessage(MESSAGE_INITIALIZE, new int[] {((Container) parent).getNumber()});
}//MessageDialog()//
/**
* MessageDialog constructor.
* @param parent The dialog's parent view.
* @param style The dialog styles.
*/
public MessageDialog(IView parent, int style) {
super(((Container) parent).getSessionViewController());
//this.parent = (Container) parent;
sendMessage(MESSAGE_INITIALIZE, new int[] {((Container) parent).getNumber(), style});
}//MessageDialog()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return "__MessageDialog__";
}//getName()//
/**
* Gets the message to be displayed to the user.
* @return The dialog message.
*/
public String getMessage() {
return message;
//return getSwtMessageDialog().getMessage();
}//getMessage()//
/**
* Sets the message to be displayed to the user.
* @param message The dialog message.
*/
public void setMessage(String message) {
this.message = message;
sendMessage(MESSAGE_SET_MESSAGE, message);
}//setMessage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
}//internalViewRelease()//
/* (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.MessageDialog";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getContainer()
*/
public IAbstractContainer getContainer() {
//TODO: Verify this is not called for a dialog.//
return null;
}//getContainer()//
}//MessageDialog//

View File

@@ -0,0 +1,270 @@
/*
* 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.common.util.*;
import com.common.debug.*;
import com.foundation.util.*;
import com.foundation.view.*;
import com.foundation.controller.*;
import com.foundation.event.*;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.view.*;
public class Panel extends Container implements IPanel {
/** The attribute that provides the collection of internal view controllers. */
private IAttributeAssociation internalViewsAttribute = null;
/** A support for receiving collection change events. */
private EventSupport eventSupport = new EventSupport(null);
/** The collection of internal view controllers. */
private ICollection internalViewControllers = null;
/** The collection of internal view controllers currently open. Maintaining this collection is necessary in the event that all view controllers are removed from the collection. */
private LiteList openViewControllers = null;
/** The next location. This was used for allowing floating frames, but that is currently disabled. */
//private int nextLocation = 0;
/** The location increment. This was used for allowing floating frames, but that is currently disabled. */
//private int locationIncrement = 20;
/**
* Panel default constructor.
* <p>Warning: This is only for use by the framework. This should never be called to create a useable instance.</p>
*/
public Panel() {
}//Panel()//
/**
* Panel 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 #STYLE_NO_BACKGROUND
* @see #STYLE_NO_FOCUS
* @see #STYLE_NO_MERGE_PAINTS
* @see #STYLE_NO_REDRAW_RESIZE
* @see #STYLE_NO_RADIO_GROUP
* @see #STYLE_EMBEDDED
* @see #STYLE_DOUBLE_BUFFERED
* @see #STYLE_H_SCROLL
* @see #STYLE_V_SCROLL
* @see #STYLE_BORDER
* @see #STYLE_LEFT_TO_RIGHT
* @see #STYLE_RIGHT_TO_LEFT
*/
public Panel(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, null, null, parent.getNumber(), style);
}//Panel()//
/* (non-Javadoc)
* @see com.foundation.view.swt.Component#internalOnValueChanged(com.foundation.view.swt.IAttributeAssociation)
*/
protected void internalOnValueChanged(IAttributeAssociation attributeAssociation) {
if(attributeAssociation == internalViewsAttribute) {
internalViewRefresh();
}//if//
else {
super.internalOnValueChanged(attributeAssociation);
}//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.Panel";
}//getClientClassName()//
/**
* Sets the internal view controller collection.
* @param internalViewsAttribute The attribute containing the collection of view controllers representing views that exist within this panel.
*/
public void setInternalViewsAttribute(IAttributeAssociation internalViewsAttribute) {
this.internalViewsAttribute = internalViewsAttribute;
}//setInternalViewsAttribute()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalEvaluate(com.foundation.event.IEventEmitter, int, java.lang.Object[])
*/
protected void internalEvaluate(IEventEmitter eventEmitter, int eventNumber, Object[] arguments) {
//Add, remove, or replace items from the list.//
if(eventEmitter == internalViewControllers) {
if(eventNumber == IManagedCollection.EVENT.getNumber()) {
CollectionChangeEvent event = (CollectionChangeEvent) arguments[0];
if(event.hasAdds()) {
if(event.getAddedObjects() != null) {
IIterator iterator = event.getAddedObjects().iterator();
while(iterator.hasNext()) {
Object next = iterator.next();
openView((ViewController) next);
}//while//
}//if//
else {
openView((ViewController) event.getAddedObject());
}//else//
}//if//
if(event.hasRemoves()) {
if(event.getRemovedObjects() != null) {
IIterator iterator = event.getRemovedObjects().iterator();
while(iterator.hasNext()) {
Object next = iterator.next();
openViewControllers.remove(next);
closeView((ViewController) next);
}//while//
}//if//
else {
openViewControllers.remove(event.getRemovedObject());
closeView((ViewController) event.getRemovedObject());
}//else//
//if((arguments != null) && (arguments.length > 0) && (arguments[0] != null)) {
//}//if//
//else {
//Could optimize if removing all values, but there is no way to know if all values are being removed.//
// closeAllViews();
//}//else//
}//if//
}//if//
}//if//
}//internalEvaluate()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
if(internalViewsAttribute != null) {
openViewControllers = new LiteList(10, 50);
internalViewsAttribute.register();
}//if//
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
if(internalViewsAttribute != null) {
internalViewsAttribute.unregister();
eventSupport.unregisterAll();
closeAllViews();
}//if//
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
if(internalViewsAttribute != null) {
ICollection internalViewControllers = (ICollection) internalViewsAttribute.getAttributeValue();
ICollection copy = null;
if(this.internalViewControllers != internalViewControllers) {
//Unregister the old event hooks.//
if(this.internalViewControllers instanceof IEventEmitter) {
eventSupport.unregisterAll((IEventEmitter) this.internalViewControllers);
}//if//
closeAllViews();
//Save a reference to the current collection in the model.//
this.internalViewControllers = internalViewControllers;
//Register the new event hooks.//
synchronized(internalViewControllers) {
if(internalViewControllers instanceof IManagedCollection) {
eventSupport.register(((IManagedCollection) internalViewControllers), IManagedCollection.EVENT.getNumber(), this, true);
}//if//
copy = new LiteList(internalViewControllers);
}//synchronized//
}//if//
if(copy != null) {
IIterator iterator = copy.iterator();
while(iterator.hasNext()) {
Object next = iterator.next();
if(next instanceof ViewController) {
openView((ViewController) next);
}//if//
else {
Debug.log("Error: Only view controllers may populate the collection of internal frames attached to the panel.");
}//else//
}//while//
}//if//
}//if//
}//internalViewRefresh()//
/**
* Opens the view for the associated view controller.
* @param viewController The view controller that will provide the view.
*/
private void openView(ViewController viewController) {
IView view = null;
addMessageHold();
openViewControllers.add(viewController);
view = viewController.openPartial(this, null);
if(view instanceof Frame) {
/*
int location = nextLocation;
if(location + ((Frame) view).getSwtControl().getSize().x > getSwtControl().getSize().x) {
location = 0;
}//if//
else if(location + ((Frame) view).getSwtControl().getSize().y > getSwtControl().getSize().y) {
location = 0;
}//else if//
nextLocation = location + locationIncrement;
((Frame) view).setLocation(location, location);
*/
}//if//
else {
//I could at some point wrapper the view component with a frame.//
Debug.log("Error: The view must be a frame for it to be a valid internal view.");
}//else//
removeMessageHold();
}//openView()//
/**
* Closes the view for the associated view controller.
* @param viewController The view controller that provided the view.
*/
private void closeView(ViewController viewController) {
viewController.close();
}//closeView()//
/**
* Closes all the internal views.
*/
private void closeAllViews() {
IIterator iterator = openViewControllers.iterator();
while(iterator.hasNext()) {
closeView((ViewController) iterator.next());
}//while//
openViewControllers.removeAll();
}//closeAllViews()//
}//Panel//

View File

@@ -0,0 +1,134 @@
/*
* Copyright (c) 2005,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.controller.RemoteViewController;
import com.foundation.tcv.swt.IPanelViewer;
import com.foundation.view.ResourceAssociation;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
public class PanelViewer extends Container implements IPanelViewer {
/** The association that provides a view controller whose view will be displayed in this panel. */
private SingleResourceAssociation controllerAssociation = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_OBJECT, false, null);
/** The view controller whose view is currently displayed. */
private RemoteViewController viewController = null;
/** Whether the panel viewer should allow the focus to change when the viewed contents change. */
private boolean changeFocus = true;
/**
* PanelViewer 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 #STYLE_ARROW
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_RADIO
* @see #STYLE_TOGGLE
* @see #STYLE_FLAT
* @see #STYLE_LEFT
* @see #STYLE_RIGHT
* @see #STYLE_CENTER
* @see #STYLE_UP
* @see #STYLE_DOWN
*/
public PanelViewer(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, null, null, parent.getNumber(), style);
}//PanelViewer()//
/**
* Sets the association container used to access the controller.
* @param container The controller association metadata.
*/
public void setControllerAssociation(SingleAssociationContainer container) {
controllerAssociation.setAssociations(container);
}//setControllerAssociation()//
/**
* Sets whether the focus should be allowed to change to the viewer's component when the contents of the viewer changes.
* @param changeFocus Whether focus changes should be allowed when changing the viewer contents.
*/
public void setChangeFocus(boolean changeFocus) {
if(this.changeFocus != changeFocus) {
this.changeFocus = changeFocus;
sendMessage(MESSAGE_SET_CHANGE_FOCUS, changeFocus ? Boolean.TRUE : Boolean.FALSE);
}//if//
}//setChangeFocus()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
controllerAssociation.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
internalViewRefreshController();
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
controllerAssociation.release();
}//internalViewRelease()//
/**
* Refreshes the controller association.
*/
protected void internalViewRefreshController() {
if(controllerAssociation.refresh()) {
Object value = controllerAssociation.getValue();
addMessageHold();
try {
sendMessage(MESSAGE_BEGIN_CHANGE_CONTENTS, null);
//Close the previous view.//
if(viewController != null) {
viewController.close();
viewController = null;
}//if//
//Open the new view.//
if(value instanceof RemoteViewController) {
viewController = (RemoteViewController) value;
viewController.openPartial(this, getViewContext());
}//if//
sendMessage(MESSAGE_END_CHANGE_CONTENTS, null);
}//try//
finally {
removeMessageHold();
}//finally//
}//if//
}//internalViewRefreshController()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == controllerAssociation) {
internalViewRefreshController();
}//if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.PanelViewer";
}//getClientClassName()//
}//PanelViewer//

View File

@@ -0,0 +1,181 @@
/*
* 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 java.math.BigDecimal;
import com.foundation.view.*;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.view.*;
public class Progress extends Component implements IProgress {
/** The progress' maximum resource which bounds the progress states. */
private SingleResourceAssociation maximum = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' minimum resource which bounds the progress states. */
private SingleResourceAssociation minimum = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' progress resource which defines the current progress state. */
private SingleResourceAssociation progress = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BIG_DECIMAL, false, new Integer(0));
/**
* Progress 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 #STYLE_SMOOTH
* @see #STYLE_HORIZONTAL
* @see #STYLE_VERTICAL
* @see #STYLE_INDETERMINATE
*/
public Progress(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//Progress()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.Progress";
}//getClientClassName()//
/**
* Sets the multiplier used to construct an integer from the progress value.
* @param multiplier The progress multiplier.
*/
public void setMultiplier(BigDecimal multiplier) {
sendMessage(MESSAGE_SET_MULTIPLIER, multiplier, null, 0, 0);
}//setMultiplier()//
/**
* Sets the component maximum progress value.
* @param maximum The maximum value in the progress range.
*/
public void setMaximum(Integer maximum) {
verifyThread();
this.maximum.setDefaultValue(maximum);
}//setMaximum()//
/**
* Sets the component minimum progress value.
* @param minimum The minimum value in the progress range. This must be greater than or equal to zero.
*/
public void setMinimum(Integer minimum) {
verifyThread();
this.minimum.setDefaultValue(minimum);
}//setMinimum()//
/**
* Sets the component progress value.
* @param progress The current progress value. This must be greater than or equal to the minimum and less than or equal to the maximum.
*/
public void setProgress(BigDecimal progress) {
verifyThread();
this.progress.setDefaultValue(progress);
}//setProgress()//
/**
* Sets the association container used to access the maximum value.
* @param container The maximum value association metadata.
*/
public void setMaximumAssociation(SingleAssociationContainer container) {
verifyThread();
this.maximum.setAssociations(container);
}//setMaximumAssociation()//
/**
* Sets the association container used to access the minimum value.
* @param container The minimum value association metadata.
*/
public void setMinimumAssociation(SingleAssociationContainer container) {
verifyThread();
this.minimum.setAssociations(container);
}//setMinimumAssociation()//
/**
* Sets the association container used to access the progress value.
* @param container The progress value association metadata.
*/
public void setProgressAssociation(SingleAssociationContainer container) {
verifyThread();
this.progress.setAssociations(container);
}//setProgressAssociation()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
maximum.initialize();
minimum.initialize();
progress.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
maximum.release();
minimum.release();
progress.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
internalViewRefreshMaximum();
internalViewRefreshMinimum();
internalViewRefreshProgress();
}//internalViewRefresh()//
/**
* Refreshes the progress maximum.
*/
protected void internalViewRefreshMaximum() {
if(maximum.refresh()) {
sendMessage(MESSAGE_SET_MAXIMUM, (Integer) maximum.getValue());
}//if//
}//internalViewRefreshMaximum()//
/**
* Refreshes the progress maximum.
*/
protected void internalViewRefreshMinimum() {
if(minimum.refresh()) {
sendMessage(MESSAGE_SET_MINIMUM, (Integer) minimum.getValue());
}//if//
}//internalViewRefreshMinimum()//
/**
* Refreshes the current progress.
*/
protected void internalViewRefreshProgress() {
if(progress.refresh()) {
sendMessage(MESSAGE_SET_PROGRESS, (BigDecimal) progress.getValue());
}//if//
}//internalViewRefreshProgress()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == maximum) {
internalViewRefreshMaximum();
}//if//
else if(resourceAssociation == minimum) {
internalViewRefreshMinimum();
}//else if//
else if(resourceAssociation == progress) {
internalViewRefreshProgress();
}//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()//
}//Progress//

View File

@@ -0,0 +1,140 @@
/*
* Copyright (c) 2004,2007 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 org.eclipse.swt.SWT;
import com.foundation.tcv.swt.IRowLayout;
public class RowLayout extends Layout implements IRowLayout {
public static final int HORIZONTAL = SWT.HORIZONTAL;
public static final int VERTICAL = SWT.VERTICAL;
public static final int CENTER = SWT.CENTER;
public static final int BEGINNING = SWT.BEGINNING;
public static final int END = SWT.END;
public static final int FILL = SWT.FILL;
/**
* RowLayout constructor.
* @param container The container that is using the layout.
*/
public RowLayout(AbstractComponent container) {
super(container);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, getContainer().getNumber());
}//RowLayout()//
/**
* Sets the layout type.
* @param type The layout type.
*/
public void setType(int type) {
sendMessage(MESSAGE_SET_TYPE, type);
}//setType()//
/**
* 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 the layout spacing.
* @param spacing The layout spacing.
*/
public void setSpacing(int spacing) {
sendMessage(MESSAGE_SET_SPACING, spacing);
}//setSpacing()//
/**
* Sets the layout wrap.
* @param wrap The layout wrap.
*/
public void setWrap(boolean wrap) {
sendMessage(MESSAGE_SET_WRAP, wrap ? 1 : 0);
}//setWrap()//
/**
* Sets the layout pack.
* @param pack The layout pack.
*/
public void setPack(boolean pack) {
sendMessage(MESSAGE_SET_PACK, pack ? 1 : 0);
}//setPack()//
/**
* Sets the layout alignment which lays out the component in the axis opposite the type (direction of flow).
* @param alignment The layout alignment.
*/
public void setAlignment(int alignment) {
sendMessage(MESSAGE_SET_ALIGNMENT, alignment);
}//setAlignment()//
/**
* Sets the layout justify.
* @param justify The layout justify.
*/
public void setJustify(boolean justify) {
sendMessage(MESSAGE_SET_JUSTIFY, justify ? 1 : 0);
}//setJustify()//
/**
* Sets the layout margin top.
* @param marginTop The layout margin top.
*/
public void setMarginTop(int marginTop) {
sendMessage(MESSAGE_SET_MARGIN_TOP, marginTop);
}//setMarginTop()//
/**
* Sets the layout margin bottom.
* @param marginBottom The layout margin bottom.
*/
public void setMarginBottom(int marginBottom) {
sendMessage(MESSAGE_SET_MARGIN_BOTTOM, marginBottom);
}//setMarginBottom()//
/**
* Sets the layout margin right.
* @param marginRight The layout margin right.
*/
public void setMarginRight(int marginRight) {
sendMessage(MESSAGE_SET_MARGIN_RIGHT, marginRight);
}//setMarginRight()//
/**
* Sets the layout margin left.
* @param marginLeft The layout margin left.
*/
public void setMarginLeft(int marginLeft) {
sendMessage(MESSAGE_SET_MARGIN_LEFT, marginLeft);
}//setMarginLeft()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.RowLayout";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#initialize()
*/
public void initialize() {
}//initialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#refresh()
*/
public void refresh() {
}//refresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#release()
*/
public void release() {
}//release()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Layout#synchronize()
*/
public void synchronize() {
}//synchronize()//
}//RowLayout//

View File

@@ -0,0 +1,33 @@
/*
* 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;
/**
* The base class for all row objects used by cell containers such as lists, tables, and trees.
*/
public class RowObject {
public Object value = null;
public int objectId = -1;
public int referenceCount = 1;
/**
* RowObject constructor.
* @param value The row value.
* @param objectId The row's object identifier.
*/
public RowObject(Object value, int objectId) {
this.value = value;
this.objectId = objectId;
}//RowObject()//
/**
* Determines whether this row object is only referenced once.
* @return Whether the row has only been added once to the collection. A row can be added repeatedly to a collection, but the data only gets sent to the view once.
*/
public boolean isFirstReference() {
return referenceCount == 1;
}//isFirstReference()//
}//RowObject//

View File

@@ -0,0 +1,87 @@
/*
* 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.tcv.swt.*;
import com.foundation.tcv.view.*;
public class Sash extends Component implements ISash {
private boolean hasSetAttachments = false;
/**
* Sash 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 #STYLE_ARROW
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_RADIO
* @see #STYLE_TOGGLE
* @see #STYLE_FLAT
* @see #STYLE_LEFT
* @see #STYLE_RIGHT
* @see #STYLE_CENTER
* @see #STYLE_UP
* @see #STYLE_DOWN
*/
public Sash(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//Sash()//
/**
* Sets the components on either side of the sash.
* @param attachment1 The first of two components.
* @param attachment2 The second of two components.
* @throws IllegalArgumentException If this method is called more than once.
*/
public void setAttachments(Component attachment1, Component attachment2) {
verifyThread();
if(!hasSetAttachments) {
sendMessage(MESSAGE_SET_ATTACHMENTS, new int[] {attachment1.getNumber(), attachment2.getNumber()});
hasSetAttachments = true;
}//if//
else {
throw new IllegalArgumentException("Cannot set the attachments more than once.");
}//else//
}//setAttachments()//
/* (non-Javadoc)
* @see com.foundation.view.swt.Component#internalOnValueChanged(com.foundation.view.swt.IAttributeAssociation)
*/
protected void internalOnValueChanged(IAttributeAssociation attributeAssociation) {
super.internalOnValueChanged(attributeAssociation);
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnEventFired(com.foundation.tcv.swt.server.IEventAssociation, java.lang.Object[])
*/
protected void internalOnEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
super.internalOnEventFired(eventAssociation, eventArguments);
}//internalOnEventFired()//
/* (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.Sash";
}//getClientClassName()//
}//Sash//

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2005,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.ISashForm;
/*
* The sash form lays out the contained components and separates them by sashes.
*/
public class SashForm extends Container implements ISashForm {
/**
* SashForm 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 #STYLE_HORIZONTAL
* @see #STYLE_VERTICAL
* @see #STYLE_SMOOTH
*/
public SashForm(Container parent, String name, int style) {
super(parent, name, style);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//SashForm()//
/**
* Sets the weights for the contained components.
* @param weights The component's weights.
*/
public void setWeights(int[] weights) {
sendMessage(MESSAGE_SET_WEIGHTS, weights);
}//setWeights()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.SashForm";
}//getClientClassName()//
}//SashForm//

View File

@@ -0,0 +1,53 @@
/*
* 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.tcv.server.controller.SessionViewController;
import com.foundation.tcv.swt.IScrollableComponent;
import com.foundation.tcv.view.*;
import com.foundation.view.IAbstractContainer;
public abstract class ScrollableComponent extends Component implements IScrollableComponent {
/**
* ScrollableComponent default constructor.
* <p>Warning: This is only for use by the framework. This should never be called to create a useable instance.</p>
*/
public ScrollableComponent() {
}//ScrollableComponent()//
/**
* ScrollableComponent constructor.
* @param parent The parent container.
* @param name The name of the component.
*/
public ScrollableComponent(IAbstractContainer parent, String name, int style) {
super(parent, name, style);
}//ScrollableComponent()//
/**
* ScrollableComponent constructor.
* This constructor is used if this is the top level component and has no parent.
* @param sessionViewController The session view controller for this view.
* @param name The name of the component.
*/
public ScrollableComponent(SessionViewController sessionViewController, String name, int style) {
super(sessionViewController, name, style);
}//ScrollableComponent()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Component#processMessage(com.foundation.tcv.view.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object retVal = null;
switch(viewMessage.getMessageNumber()) {
default: {
retVal = super.processMessage(viewMessage);
}//default//
}//switch//
return retVal;
}//processMessage()//
}//ScrollableComponent//

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,322 @@
/*
* 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.tcv.swt.ISlider;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
public class Slider extends Component implements ISlider {
/** The progress' maximum resource which bounds the progress states. */
private SingleResourceAssociation maximum = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' minimum resource which bounds the progress states. */
private SingleResourceAssociation minimum = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' progress resource which defines the current progress state. */
private SingleResourceAssociation selection = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, true, new Integer(0));
/** The progress' progress resource which defines the increment state. */
private SingleResourceAssociation increment = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' progress resource which defines the page increment state. */
private SingleResourceAssociation pageIncrement = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' progress resource which defines the thumb state. */
private SingleResourceAssociation thumb = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** Whether the value is automatically synchronized as the user edits the value. Otherwise the field must be manually synchronized. */
private boolean autoSynchronizeSelection = false;
/** The delay used when auto synchronizing the value. A zero value means there will be no delay. The value must be on the range of [0..10,000]. */
private long autoSynchronizeSelectionDelay = 500;
/**
* Slider 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 #STYLE_HORIZONTAL
* @see #STYLE_VERTICAL
*/
public Slider(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//Slider()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.Slider";
}//getClientClassName()//
/**
* Sets the component maximum selection value.
* @param maximum The maximum value in the selection range.
*/
public void setMaximum(Integer maximum) {
verifyThread();
this.maximum.setDefaultValue(maximum);
}//setMaximum()//
/**
* Sets the component minimum selection value.
* @param minimum The minimum value in the progress range. This must be greater than or equal to zero.
*/
public void setMinimum(Integer minimum) {
verifyThread();
this.minimum.setDefaultValue(minimum);
}//setMinimum()//
/**
* Sets the component selection value.
* @param selection The current selection value. This must be greater than or equal to the minimum and less than or equal to the maximum.
*/
public void setSelection(Integer selection) {
verifyThread();
this.selection.setDefaultValue(selection);
}//setSelection()//
/**
* Sets the slider increment.
* @param increment The increment value for the range.
*/
public void setIncrement(Integer increment) {
verifyThread();
this.increment.setDefaultValue(increment);
}//setIncrement()//
/**
* Sets the slider page increment.
* @param pageIncrement The page increment value for the range.
*/
public void setPageIncrement(Integer pageIncrement) {
verifyThread();
this.pageIncrement.setDefaultValue(pageIncrement);
}//setIncrement()//
/**
* Sets the slider thumb size.
* @param thumb The thumb size.
*/
public void setThumb(Integer thumb) {
verifyThread();
this.thumb.setDefaultValue(thumb);
}//setThumb()//
/**
* Sets the association container used to access the maximum value.
* @param container The maximum value association metadata.
*/
public void setMaximumAssociation(SingleAssociationContainer container) {
verifyThread();
this.maximum.setAssociations(container);
}//setMaximumAssociation()//
/**
* Sets the association container used to access the minimum value.
* @param container The minimum value association metadata.
*/
public void setMinimumAssociation(SingleAssociationContainer container) {
verifyThread();
this.minimum.setAssociations(container);
}//setMinimumAssociation()//
/**
* Sets the association container used to access the selected value.
* @param container The selected value association metadata.
*/
public void setSelectionAssociation(SingleAssociationContainer container) {
verifyThread();
this.selection.setAssociations(container);
}//setSelectionAssociation()//
/**
* Sets the association container used to access the increment size.
* @param container The increment size association metadata.
*/
public void setIncrementAssociation(SingleAssociationContainer container) {
verifyThread();
this.increment.setAssociations(container);
}//setIncrementAssociation()//
/**
* Sets the association container used to access the page increment size.
* @param container The page increment size association metadata.
*/
public void setPageIncrementAssociation(SingleAssociationContainer container) {
verifyThread();
this.pageIncrement.setAssociations(container);
}//setPageIncrementAssociation()//
/**
* Sets the association container used to access the thumb size.
* @param container The thumb size association metadata.
*/
public void setThumbAssociation(SingleAssociationContainer container) {
verifyThread();
this.thumb.setAssociations(container);
}//setThumbAssociation()//
/**
* Gets whether the selection will automatically synchronize.
* @return Whether the selection is automatically synchronized from the view to the model when changed, or whether it must be manually synchronized.
*/
protected boolean getAutoSynchronizeSelection() {
return autoSynchronizeSelection;
}//getAutoSynchronizeSelection()//
/**
* Sets whether the selection will automatically synchronize.
* @param autoSynchronizeSelection Whether the selection is automatically synchronized from the view to the model when changed, or whether it must be manually synchronized.
*/
public void setAutoSynchronizeSelection(boolean autoSynchronizeSelection) {
verifyThread();
if(this.autoSynchronizeSelection != autoSynchronizeSelection) {
this.autoSynchronizeSelection = autoSynchronizeSelection;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION, autoSynchronizeSelection ? Boolean.TRUE : Boolean.FALSE);
}//if//
}//setAutoSynchronizeSelection()//
/**
* Gets the number of milliseconds to wait before automatically synchronizing selection changes. This must be a number between zero and ten thousand where zero synchronizes without delay.
* @return The number of milliseconds of delay when auto synchronizing the selection.
*/
protected long getAutoSynchronizeSelectionDelay() {
return autoSynchronizeSelectionDelay;
}//getAutoSynchronizeSelectionDelay()//
/**
* Sets the number of milliseconds to wait before automatically synchronizing selection changes. This must be a number between zero and ten thousand where zero synchronizes without delay.
* @param autoSynchronizeSelectionDelay The number of milliseconds of delay when auto synchronizing the selection.
*/
public void setAutoSynchronizeSelectionDelay(long autoSynchronizeSelectionDelay) {
verifyThread();
if(autoSynchronizeSelectionDelay < 0) {
autoSynchronizeSelectionDelay = 0;
}//if//
else if(autoSynchronizeSelectionDelay > 10000) {
autoSynchronizeSelectionDelay = 10000;
}//else if//
if(this.autoSynchronizeSelectionDelay != autoSynchronizeSelectionDelay) {
this.autoSynchronizeSelectionDelay = autoSynchronizeSelectionDelay;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long(autoSynchronizeSelectionDelay));
}//if//
}//setAutoSynchronizeSelectionDelay()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
maximum.initialize();
minimum.initialize();
selection.initialize();
increment.initialize();
pageIncrement.initialize();
thumb.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
maximum.release();
minimum.release();
selection.release();
increment.release();
pageIncrement.release();
thumb.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
internalViewRefreshMaximum();
internalViewRefreshMinimum();
internalViewRefreshSelection();
internalViewRefreshIncrement();
internalViewRefreshPageIncrement();
internalViewRefreshThumb();
}//internalViewRefresh()//
/**
* Refreshes the selection maximum.
*/
protected void internalViewRefreshMaximum() {
if(maximum.refresh()) {
sendMessage(MESSAGE_SET_MAXIMUM, (Integer) maximum.getValue());
}//if//
}//internalViewRefreshMaximum()//
/**
* Refreshes the selection maximum.
*/
protected void internalViewRefreshMinimum() {
if(minimum.refresh()) {
sendMessage(MESSAGE_SET_MINIMUM, (Integer) minimum.getValue());
}//if//
}//internalViewRefreshMinimum()//
/**
* Refreshes the current selection.
*/
protected void internalViewRefreshSelection() {
if(selection.refresh()) {
sendMessage(MESSAGE_SET_SELECTION, (Integer) selection.getValue());
}//if//
}//internalViewRefreshSelection()//
/**
* Refreshes the increment.
*/
protected void internalViewRefreshIncrement() {
if(selection.refresh()) {
sendMessage(MESSAGE_SET_INCREMENT, (Integer) increment.getValue());
}//if//
}//internalViewRefreshIncrement()//
/**
* Refreshes the page increment.
*/
protected void internalViewRefreshPageIncrement() {
if(selection.refresh()) {
sendMessage(MESSAGE_SET_PAGE_INCREMENT, (Integer) pageIncrement.getValue());
}//if//
}//internalViewRefreshPageIncrement()//
/**
* Refreshes the thumb.
*/
protected void internalViewRefreshThumb() {
if(selection.refresh()) {
sendMessage(MESSAGE_SET_THUMB, (Integer) thumb.getValue());
}//if//
}//internalViewRefreshThumb()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == maximum) {
internalViewRefreshMaximum();
}//if//
else if(resourceAssociation == minimum) {
internalViewRefreshMinimum();
}//else if//
else if(resourceAssociation == selection) {
internalViewRefreshSelection();
}//else if//
else if(resourceAssociation == increment) {
internalViewRefreshIncrement();
}//else if//
else if(resourceAssociation == pageIncrement) {
internalViewRefreshPageIncrement();
}//else if//
else if(resourceAssociation == thumb) {
internalViewRefreshThumb();
}//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()) {
case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: {
Object selection = (Object) viewMessage.getMessageData();
this.selection.setValue(selection);
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
}//default//
}//switch//
return retVal;
}//processMessage()//
}//Slider//

View File

@@ -0,0 +1,282 @@
/*
* 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.tcv.swt.ISpinner;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
public class Spinner extends Component implements ISpinner {
/** The progress' maximum resource which bounds the progress states. */
private SingleResourceAssociation maximum = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' minimum resource which bounds the progress states. */
private SingleResourceAssociation minimum = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' progress resource which defines the current progress state. */
private SingleResourceAssociation selection = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, true, new Integer(0));
/** The progress' progress resource which defines the increment state. */
private SingleResourceAssociation increment = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' progress resource which defines the page increment state. */
private SingleResourceAssociation pageIncrement = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** Whether the value is automatically synchronized as the user edits the value. Otherwise the field must be manually synchronized. */
private boolean autoSynchronizeSelection = false;
/** The delay used when auto synchronizing the value. A zero value means there will be no delay. The value must be on the range of [0..10,000]. */
private long autoSynchronizeSelectionDelay = 500;
/**
* Spinner 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 #STYLE_WRAP
* @see #STYLE_READ_ONLY
*/
public Spinner(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//Spinner()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.Spinner";
}//getClientClassName()//
/**
* Sets the component maximum selection value.
* @param maximum The maximum value in the selection range.
*/
public void setMaximum(Integer maximum) {
verifyThread();
this.maximum.setDefaultValue(maximum);
}//setMaximum()//
/**
* Sets the component minimum selection value.
* @param minimum The minimum value in the selection range. This must be greater than or equal to zero.
*/
public void setMinimum(Integer minimum) {
verifyThread();
this.minimum.setDefaultValue(minimum);
}//setMinimum()//
/**
* Sets the slider increment.
* @param increment The increment value for the range.
*/
public void setIncrement(Integer increment) {
verifyThread();
this.increment.setDefaultValue(increment);
}//setIncrement()//
/**
* Sets the slider page increment.
* @param pageIncrement The page increment value for the range.
*/
public void setPageIncrement(Integer pageIncrement) {
verifyThread();
this.pageIncrement.setDefaultValue(pageIncrement);
}//setIncrement()//
/**
* Sets the association container used to access the maximum value.
* @param container The maximum value association metadata.
*/
public void setMaximumAssociation(SingleAssociationContainer container) {
verifyThread();
this.maximum.setAssociations(container);
}//setMaximumAssociation()//
/**
* Sets the association container used to access the minimum value.
* @param container The minimum value association metadata.
*/
public void setMinimumAssociation(SingleAssociationContainer container) {
verifyThread();
this.minimum.setAssociations(container);
}//setMinimumAssociation()//
/**
* Sets the association container used to access the selected value.
* @param container The selected value association metadata.
*/
public void setSelectionAssociation(SingleAssociationContainer container) {
verifyThread();
this.selection.setAssociations(container);
}//setSelectionAssociation()//
/**
* Sets the association container used to access the increment size.
* @param container The increment size association metadata.
*/
public void setIncrementAssociation(SingleAssociationContainer container) {
verifyThread();
this.increment.setAssociations(container);
}//setIncrementAssociation()//
/**
* Sets the association container used to access the page increment size.
* @param container The page increment size association metadata.
*/
public void setPageIncrementAssociation(SingleAssociationContainer container) {
verifyThread();
this.pageIncrement.setAssociations(container);
}//setPageIncrementAssociation()//
/**
* Gets whether the selection will automatically synchronize.
* @return Whether the selection is automatically synchronized from the view to the model when changed, or whether it must be manually synchronized.
*/
protected boolean getAutoSynchronizeSelection() {
return autoSynchronizeSelection;
}//getAutoSynchronizeSelection()//
/**
* Sets whether the selection will automatically synchronize.
* @param autoSynchronizeSelection Whether the selection is automatically synchronized from the view to the model when changed, or whether it must be manually synchronized.
*/
public void setAutoSynchronizeSelection(boolean autoSynchronizeSelection) {
verifyThread();
if(this.autoSynchronizeSelection != autoSynchronizeSelection) {
this.autoSynchronizeSelection = autoSynchronizeSelection;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION, autoSynchronizeSelection ? Boolean.TRUE : Boolean.FALSE);
}//if//
}//setAutoSynchronizeSelection()//
/**
* Gets the number of milliseconds to wait before automatically synchronizing selection changes. This must be a number between zero and ten thousand where zero synchronizes without delay.
* @return The number of milliseconds of delay when auto synchronizing the selection.
*/
protected long getAutoSynchronizeSelectionDelay() {
return autoSynchronizeSelectionDelay;
}//getAutoSynchronizeSelectionDelay()//
/**
* Sets the number of milliseconds to wait before automatically synchronizing selection changes. This must be a number between zero and ten thousand where zero synchronizes without delay.
* @param autoSynchronizeSelectionDelay The number of milliseconds of delay when auto synchronizing the selection.
*/
public void setAutoSynchronizeSelectionDelay(long autoSynchronizeSelectionDelay) {
verifyThread();
if(autoSynchronizeSelectionDelay < 0) {
autoSynchronizeSelectionDelay = 0;
}//if//
else if(autoSynchronizeSelectionDelay > 10000) {
autoSynchronizeSelectionDelay = 10000;
}//else if//
if(this.autoSynchronizeSelectionDelay != autoSynchronizeSelectionDelay) {
this.autoSynchronizeSelectionDelay = autoSynchronizeSelectionDelay;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long(autoSynchronizeSelectionDelay));
}//if//
}//setAutoSynchronizeSelectionDelay()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
maximum.initialize();
minimum.initialize();
selection.initialize();
increment.initialize();
pageIncrement.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
maximum.release();
minimum.release();
selection.release();
increment.release();
pageIncrement.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
internalViewRefreshMaximum();
internalViewRefreshMinimum();
internalViewRefreshSelection();
internalViewRefreshIncrement();
internalViewRefreshPageIncrement();
}//internalViewRefresh()//
/**
* Refreshes the selection maximum.
*/
protected void internalViewRefreshMaximum() {
if(maximum.refresh()) {
sendMessage(MESSAGE_SET_MAXIMUM, (Integer) maximum.getValue());
}//if//
}//internalViewRefreshMaximum()//
/**
* Refreshes the selection maximum.
*/
protected void internalViewRefreshMinimum() {
if(minimum.refresh()) {
sendMessage(MESSAGE_SET_MINIMUM, (Integer) minimum.getValue());
}//if//
}//internalViewRefreshMinimum()//
/**
* Refreshes the current selection.
*/
protected void internalViewRefreshSelection() {
if(selection.refresh()) {
sendMessage(MESSAGE_SET_SELECTION, (Integer) selection.getValue());
}//if//
}//internalViewRefreshSelection()//
/**
* Refreshes the increment.
*/
protected void internalViewRefreshIncrement() {
if(selection.refresh()) {
sendMessage(MESSAGE_SET_INCREMENT, (Integer) increment.getValue());
}//if//
}//internalViewRefreshIncrement()//
/**
* Refreshes the page increment.
*/
protected void internalViewRefreshPageIncrement() {
if(selection.refresh()) {
sendMessage(MESSAGE_SET_PAGE_INCREMENT, (Integer) pageIncrement.getValue());
}//if//
}//internalViewRefreshPageIncrement()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == maximum) {
internalViewRefreshMaximum();
}//if//
else if(resourceAssociation == minimum) {
internalViewRefreshMinimum();
}//else if//
else if(resourceAssociation == selection) {
internalViewRefreshSelection();
}//else if//
else if(resourceAssociation == increment) {
internalViewRefreshIncrement();
}//else if//
else if(resourceAssociation == pageIncrement) {
internalViewRefreshPageIncrement();
}//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()) {
case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: {
Object selection = (Object) viewMessage.getMessageData();
this.selection.setValue(selection);
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
}//default//
}//switch//
return retVal;
}//processMessage()//
}//Spinner()//

View File

@@ -0,0 +1,303 @@
/*
* Copyright (c) 2005,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.util.ICollection;
import com.common.util.IIterator;
import com.common.util.IList;
import com.common.util.LiteList;
import com.foundation.util.IInlineCollectionObservable;
import com.foundation.util.IInlineCollectionObserver;
import com.foundation.util.IInlineIndexedCollectionObservable;
import com.foundation.util.IInlineIndexedCollectionObserver;
import com.foundation.view.*;
import com.foundation.controller.RemoteViewController;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.view.*;
/*
* Displays components in a stack such that only one component is visible at a time.
*/
public class StackViewer extends Container implements IStackViewer, IInlineIndexedCollectionObserver, IInlineCollectionObserver {
/** The association that results in a collection of view controllers. */
private SingleResourceAssociation views = null;
/** The association that tracks which view is being displayed. */
private SingleResourceAssociation visibleView = null;
/** The previous collection of view controllers. */
private IList viewControllers = new LiteList(1, 15);
/** Temporarily suspends processing of events fired by registered collections. */
private boolean suspendCollectionEvents = false;
/**
* StackViewer 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 #STYLE_NO_BACKGROUND
* @see #STYLE_NO_FOCUS
* @see #STYLE_NO_MERGE_PAINTS
* @see #STYLE_NO_REDRAW_RESIZE
* @see #STYLE_NO_RADIO_GROUP
* @see #STYLE_H_SCROLL
* @see #STYLE_V_SCROLL
* @see #STYLE_BORDER
* @see #STYLE_LEFT_TO_RIGHT
* @see #STYLE_RIGHT_TO_LEFT
*/
public StackViewer(Container parent, String name, int style) {
super(parent, name, style);
this.views = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_OBJECT, false, null);
this.visibleView = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_OBJECT, false, null);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//StackViewer()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#setLayout(com.foundation.tcv.swt.Layout)
*/
public void setLayout(Layout layout) {
//Does nothing. It does not make sense to change the layout of the wizard since it can only use the stack layout.//
}//setLayout()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Component#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation association, int flags) {
if(association == visibleView) {
internalRefreshVisibleView();
}//if//
else if(association == views) {
internalRefreshViews();
}//else if//
else {
super.internalOnValueChanged(association, flags);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnEventFired(com.foundation.tcv.swt.server.IEventAssociation, java.lang.Object[])
*/
protected void internalOnEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
super.internalOnEventFired(eventAssociation, eventArguments);
}//internalOnEventFired()//
/* (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()//
/**
* Sets the association container used to access the views in the stack.
* @param container The views association metadata.
*/
public void setViewsAssociation(SingleAssociationContainer container) {
verifyThread();
this.views.setAssociations(container);
}//setViewsAssociation()//
/**
* Sets the association container used to access the visible view.
* @param container The visible view association metadata.
*/
public void setVisibleViewAssociation(SingleAssociationContainer container) {
verifyThread();
this.visibleView.setAssociations(container);
}//setVisibleViewAssociation()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.StackViewer";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
views.initialize();
visibleView.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
views.release();
visibleView.release();
for(int index = 0; index < viewControllers.getSize(); index++) {
((RemoteViewController) viewControllers.get(index)).close();
}//for//
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
internalRefreshViews();
internalRefreshVisibleView();
}//internalViewRefresh()//
/**
* Refreshes the currently visible component.
*/
protected void internalRefreshViews() {
Object oldValue = views.getValue();
if(views.refresh()) {
addMessageHold();
try {
Object newValue = views.getValue();
//Remove listeners from the old value.//
if(oldValue instanceof IInlineIndexedCollectionObservable) {
((IInlineIndexedCollectionObservable) oldValue).removeCollectionObserver(this);
}//if//
else if(oldValue instanceof IInlineCollectionObservable) {
((IInlineCollectionObservable) oldValue).removeCollectionObserver(this);
}//else if//
//Close the old view controllers.//
for(int index = 0; index < viewControllers.getSize(); index++) {
((RemoteViewController) viewControllers.get(index)).close();
}//for//
viewControllers.removeAll();
//If the new value is a collection or object then add and remove pages as required, and add listeners as required.//
if(newValue instanceof ICollection) {
IIterator iterator = ((ICollection) newValue).iterator();
//Add tabs for all the view controllers.//
while(iterator.hasNext()) {
Object next = iterator.next();
//Ignore non-view controller objects.//
if(next instanceof RemoteViewController) {
RemoteViewController controller = (RemoteViewController) next;
controller.openPartial(this, getViewContext());
}//if//
else {
throw new RuntimeException("Expecting a view controller.");
}//else//
}//while//
//Add the controllers to the list of view controllers.//
viewControllers.addAll((ICollection) newValue);
//Prevent collection events from notifying us of existing items in the collection.//
suspendCollectionEvents = true;
//Add a listener to the collection so we get change events.//
if(newValue instanceof IInlineIndexedCollectionObservable) {
((IInlineIndexedCollectionObservable) newValue).addCollectionObserver(this);
}//if//
else if(newValue instanceof IInlineCollectionObservable) {
((IInlineCollectionObservable) newValue).addCollectionObserver(this);
}//else if//
//Re-enable the collection events.//
suspendCollectionEvents = false;
}//if//
else if(newValue instanceof RemoteViewController) {
RemoteViewController controller = (RemoteViewController) newValue;
controller.openPartial(this, getViewContext());
//Add the one controller to the list of view controllers.//
viewControllers.add(controller);
}//else if//
}//try//
finally {
removeMessageHold();
}//finally//
}//if//
}//internalRefreshViews()//
/**
* Refreshes the currently visible component.
*/
protected void internalRefreshVisibleView() {
if(visibleView.refresh()) {
Object view = (Object) visibleView.getValue();
int index = viewControllers.getIndexOf(view);
if(index >= 0) {
sendMessage(MESSAGE_CHANGE_COMPONENT, null, null, index, -1);
}//if//
}//if//
}//internalRefreshVisibleView()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#startChanges(int)
*/
public void startChanges(int changeCount) {
addMessageHold();
//suspendRedraw();
}//startChanges()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#stopChanges()
*/
public void stopChanges() {
//resumeRedraw();
removeMessageHold();
}//stopChanges()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#valueAdded(java.lang.Object)
*/
public void valueAdded(Object value) {
if((!suspendCollectionEvents) && (value instanceof RemoteViewController)) {
viewControllers.add(value);
((RemoteViewController) value).openPartial(this, getViewContext());
}//if//
}//valueAdded()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueAdded(java.lang.Object, int)
*/
public void valueAdded(Object value, int index) {
valueAdded(value);
}//valueAdded()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#valueRemoved(java.lang.Object)
*/
public void valueRemoved(Object value) {
if((!suspendCollectionEvents) && (viewControllers.remove(value))) {
((RemoteViewController) value).close();
}//if//
}//valueRemoved()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueRemoved(java.lang.Object, int)
*/
public void valueRemoved(Object value, int index) {
valueRemoved(value);
}//valueRemoved()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#removingAll()
*/
public void removingAll() {
if(!suspendCollectionEvents) {
IIterator iterator = viewControllers.iterator();
startChanges(viewControllers.getSize());
try {
while(iterator.hasNext()) {
valueRemoved(iterator.next());
}//while//
}//try//
finally {
stopChanges();
}//finally//
}//if//
}//removingAll()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valuesSorted(int[])
*/
public void valuesSorted(int[] mapping) {
//Does nothing.//
}//valuesSorted()//
}//StackViewer//

View File

@@ -0,0 +1,657 @@
/*
* Copyright (c) 2005,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 org.eclipse.swt.SWT;
import com.common.debug.Debug;
import com.common.util.ICollection;
import com.common.util.IIterator;
import com.common.util.IList;
import com.common.util.LiteHashMap;
import com.common.util.LiteList;
import com.foundation.controller.DecorationManager;
import com.foundation.controller.RemoteViewController;
import com.foundation.util.IInlineCollectionObservable;
import com.foundation.util.IInlineCollectionObserver;
import com.foundation.util.IInlineIndexedCollectionObservable;
import com.foundation.util.IInlineIndexedCollectionObserver;
import com.foundation.view.AbstractDecoration;
import com.foundation.view.ISingleResourceAssociationChangeListener;
import com.foundation.view.ResourceAssociation;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
import com.foundation.view.resource.AbstractResourceService;
import com.foundation.tcv.swt.ITabPanel;
import com.foundation.tcv.swt.server.Component;
import com.foundation.tcv.swt.server.Container;
/*
* This tab panel allows for static pages and dynamic pages where dynamic pages are tied to the model which supplies the view controller's for each dynamic page.
* The panel was designed such that any ordering of static and dynamic pages can be given. The dynamic page is created by calling the addPages() method which allows associations to be added.
* The PagesHolder (returned by addPages()) then manages the page or collection of page view controllers.
* <p>TODO: Add some way of sending the selected page to the view controller, and some way for the view controller to programatically select a page.</p>
*/
public class TabPanel extends Container implements ITabPanel {
public static final int STYLE_TOP = SWT.TOP;
public static final int STYLE_BOTTOM = SWT.BOTTOM;
/** A collection of Component and PagesHolder instances which define the tabs in this tab folder. */
private IList pages = new LiteList(10, 50);
/** A flag to suspend the customized behavior when adding a control. This lets the page holder add and remove tabs without the tab panel attempting to add and remove tabs also. */
private boolean suspendCustomComponentBehavior = false;
/**
* The public interface for interacting with the pages holder.
*/
public interface IPagesHolder {
/**
* Sets the association container used to access the tab pages.
* @param container The tab pages association metadata.
*/
public void setPagesAssociation(SingleAssociationContainer container);
}//IPagesHolder//
/**
* A place holder for zero or more pages which are set based on a resource association which can return a view controller or a list of view controllers, one for each page.
*/
private class PagesHolder implements IPagesHolder, ISingleResourceAssociationChangeListener, IInlineIndexedCollectionObserver, IInlineCollectionObserver {
/** Allows one association to return either a collection of controllers, or one controller which will be turned into a tab page. */
private SingleResourceAssociation pages = new SingleResourceAssociation(TabPanel.this, this, getViewContext(), SingleResourceAssociation.TYPE_OBJECT, false, null);
/** The PagesHolder or Component which the pages in this PagesHolder follow in the tab order. */
private Object followsComponent = null;
/** The previous collection of view controllers. */
private IList viewControllers = new LiteList(1, 15);
/** A two way (one to one) mapping between the Component instances and their ViewController instances. */
private LiteHashMap componentControllerMapping = new LiteHashMap(30);
/** Temporarily suspends processing of events fired by registered collections. */
private boolean suspendCollectionEvents = false;
public PagesHolder(Object followsComponent) {
this.followsComponent = followsComponent;
}//PagesHolder()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.TabPanel.IPagesHolder#setPagesAssociation(com.foundation.view.SingleAssociationContainer)
*/
public void setPagesAssociation(SingleAssociationContainer container) {
verifyThread();
this.pages.setAssociations(container);
}//setPagesAssociation()//
/**
* Initializes the pages.
*/
public void initialize() {
pages.initialize();
}//initialize()//
/**
* Releases the pages.
*/
public void release() {
IIterator iterator = viewControllers.iterator();
pages.release();
//Release the tab resources and cleanup the mappings and listeners.//
while(iterator.hasNext()) {
RemoteViewController next = (RemoteViewController) iterator.next();
internalRemoveTab(next);
next.close();
}//while//
componentControllerMapping.removeAll();
componentControllerMapping = null;
viewControllers.removeAll();
viewControllers = null;
followsComponent = null;
pages = null;
}//release()//
/**
* Refreshes the pages.
*/
public void refresh() {
//Not necessary since it is handled by the Container base class.//
//for(int index = 0; index < viewControllers.getSize(); index++) {
// ((AbstractComponent) ((RemoteViewController) viewControllers.get(index)).getView()).internalViewRefreshAll();
//}//for//
refreshPages();
}//initialize()//
/**
* Synchronizes the pages.
*/
public void synchronize() {
//Not necessary since it is handled by the Container base class.//
//for(int index = 0; index < viewControllers.getSize(); index++) {
// ((AbstractComponent) ((RemoteViewController) viewControllers.get(index)).getView()).internalViewSynchronizeAll();
//}//for//
}//initialize()//
/**
* Gets the Component that the pages of this holder follow.
* @return The component that the components related to this holder follow in the ordering.
*/
public Component getPreviousComponent() {
Component result = null;
if(followsComponent instanceof PagesHolder) {
result = ((PagesHolder) followsComponent).getLastComponent();
}//if//
else if(followsComponent instanceof Component) {
result = (Component) followsComponent;
}//else if//
return result;
}//getPreviousComponent()//
/**
* Gets the last tab item for this holder.
* @return The last TabItem instance which can be used as the previous TabItem for the component that follows this holder. This will only be null if there are no pages in this holder and there are no pages in front of this holder.
*/
public Component getLastComponent() {
Component result = null;
if(viewControllers.getSize() > 0) {
result = (Component) componentControllerMapping.get(viewControllers.getLast());
}//if//
else {
result = getPreviousComponent();
}//else//
return result;
}//getLastComponent()//
/**
* Gets the number of pages currently represented by this holder.
* @return The number of tab pages created by the holder.
*/
public int getPageCount() {
return viewControllers.getSize();
}//getPageCount()//
/**
* Gets the zero based index of the first tab in this holder's collection, which is also the count of pages preceeding those generated by this holder.
* @return The holder's first tab's zero based index.
*/
public int getPreceedingPageCount() {
int result = 0;
IList pages = TabPanel.this.pages;
for(int pageIndex = 0; (pageIndex < pages.getSize()) && (pages.get(pageIndex) != this); pageIndex++) {
Object page = pages.get(pageIndex);
if(page instanceof PagesHolder) {
result += ((PagesHolder) page).getPageCount();
}//if//
else if(page instanceof Component) {
result++;
}//else if//
}//for//
return result;
}//getPreceedingPageCount()//
/**
* Refreshes the pages represented by this holder.
*/
protected void refreshPages() {
Object oldValue = pages.getValue();
if(pages.refresh()) {
startChanges(0);
try {
Object newValue = pages.getValue();
//Component previous = getPreviousComponent();
int firstPageIndex = getPreceedingPageCount();
//int previousIndex = previous != null ? getSwtTabFolder().indexOf(previous) + 1 : 0;
//Remove listeners from the old value.//
if(oldValue instanceof IInlineIndexedCollectionObservable) {
((IInlineIndexedCollectionObservable) oldValue).removeCollectionObserver(this);
}//if//
else if(oldValue instanceof IInlineCollectionObservable) {
((IInlineCollectionObservable) oldValue).removeCollectionObserver(this);
}//else if//
//If the new value is a collection or object then add and remove pages as required, and add listeners as required.//
if(newValue instanceof ICollection) {
IIterator iterator = ((ICollection) newValue).iterator();
int pageCounter = 0;
LiteList newViewControllers = new LiteList(((ICollection) newValue).getSize());
//Add tabs for all the view controllers.//
while(iterator.hasNext()) {
Object next = iterator.next();
//Ignore non-view controller objects.//
if(next instanceof RemoteViewController) {
RemoteViewController controller = (RemoteViewController) next;
int index = viewControllers != null ? viewControllers.getIndexOf(controller) : -1;
if(index != -1) {
sendMessage(MESSAGE_REPOSITION_TAB, new int[] {((Component) controller.getView()).getNumber(), firstPageIndex + pageCounter});
viewControllers.remove(controller);
}//if//
else {
internalAddTab(controller, firstPageIndex + pageCounter);
}//else//
newViewControllers.add(controller);
}//if//
else {
//Don't allow non-view controller objects since it will mess up the valuesSorted(..) method.//
throw new RuntimeException("Expecting a view controller.");
}//else//
pageCounter++;
}//while//
//Remove the previous view controller(s).//
removeOldPages(viewControllers);
//Add the controllers to the list of view controllers.//
viewControllers.addAll(newViewControllers);
//Prevent collection events from notifying us of existing items in the collection.//
suspendCollectionEvents = true;
//Add a listener to the collection so we get change events.//
if(newValue instanceof IInlineIndexedCollectionObservable) {
((IInlineIndexedCollectionObservable) newValue).addCollectionObserver(this);
}//if//
else if(newValue instanceof IInlineCollectionObservable) {
((IInlineCollectionObservable) newValue).addCollectionObserver(this);
}//else if//
//Re-enable the collection events.//
suspendCollectionEvents = false;
}//if//
else if(newValue instanceof RemoteViewController) {
RemoteViewController controller = (RemoteViewController) newValue;
int index = viewControllers != null ? viewControllers.getIndexOf(controller) : -1;
if(index != -1) {
sendMessage(MESSAGE_REPOSITION_TAB, new int[] {((Component) controller.getView()).getNumber(), firstPageIndex});
viewControllers.remove(index);
}//if//
else {
internalAddTab(controller, firstPageIndex);
}//else//
//Remove the previous view controller(s).//
removeOldPages(viewControllers);
//Add the one controller to the list of view controllers.//
viewControllers.add(controller);
}//else if//
else {
removeOldPages(viewControllers);
}//else//
}//try//
finally {
stopChanges();
}//finally//
}//if//
}//refreshPages()//
/**
* Removes the old pages from the tab panel.
* @param viewControllers The collection of view controllers no longer in the tab panel.
* @param oldValue The previous value
*/
private void removeOldPages(IList viewControllers) {
while(viewControllers.getSize() > 0) {
RemoteViewController controller = (RemoteViewController) viewControllers.remove(viewControllers.getSize() - 1);
//Remove each controller's page and close the controller.//
internalRemoveTab(controller);
controller.close();
}//while//
}//removeOldPages()//
/**
* Adds a tab to the panel for the given view controller.
* @param viewController The view controller whose view component will be displayed in the tab.
* @param index The index of this tab item, which will be used to set the tab item ordering.
*/
protected void internalAddTab(RemoteViewController viewController, int index) {
suspendCustomComponentBehavior = true;
try {
if(viewController != null) {
Component component = null;
viewController.openPartial(TabPanel.this, getViewContext());
component = (Component) viewController.getView();
if(component != null) {
sendMessage(MESSAGE_ADD_TAB, new int[] {component.getNumber(), index});
}//if//
else {
Debug.log("Error: Invalid component. Unable to add the component as a tab in the tab panel.");
}//else//
componentControllerMapping.put(viewController, component);
componentControllerMapping.put(component, viewController);
}//if//
else {
Debug.log("Error: Invalid component. Unable to add the component as a tab in the tab panel.");
}//else//
}//try//
finally {
suspendCustomComponentBehavior = false;
}//finally//
}//internalAddTab()//
/**
* Removes a tab from the panel for the given related view component.
* @param viewController The view controller whose view component's tab will be removed.
*/
protected void internalRemoveTab(RemoteViewController viewController) {
suspendCustomComponentBehavior = true;
try {
Component component = (Component) viewController.getView();
if(component == null) {
component = (Component) componentControllerMapping.get(viewController);
}//if//
//Unregister the component data listener.//
if(component != null) {
sendMessage(MESSAGE_REMOVE_TAB, new Integer(component.getNumber()));
componentControllerMapping.remove(component);
}//if//
componentControllerMapping.remove(viewController);
}//try//
finally {
suspendCustomComponentBehavior = false;
}//finally//
}//internalRemoveTab()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#onValueChanged(com.foundation.view.ResourceAssociation, int)
*/
public void onValueChanged(ResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == pages) {
refreshPages();
}//if//
}//onValueChanged()//
/* (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#addMessageHold()
*/
public void addMessageHold() {
TabPanel.this.addMessageHold();
}//addMessageHold()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#removeMessageHold()
*/
public void removeMessageHold() {
TabPanel.this.removeMessageHold();
}//removeMessageHold()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#startChanges(int)
*/
public void startChanges(int changeCount) {
TabPanel.this.addMessageHold();
//suspendRedraw();
}//startChanges()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#stopChanges()
*/
public void stopChanges() {
//resumeRedraw();
TabPanel.this.removeMessageHold();
}//stopChanges()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#valueAdded(java.lang.Object)
*/
public void valueAdded(Object value) {
if((!suspendCollectionEvents) && (value instanceof RemoteViewController)) {
int tabIndex = getPreceedingPageCount() + getPageCount();
internalAddTab((RemoteViewController) value, tabIndex);
viewControllers.add(tabIndex, value);
}//if//
}//valueAdded()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueAdded(java.lang.Object, int)
*/
public void valueAdded(Object value, int index) {
if((!suspendCollectionEvents) && (value instanceof RemoteViewController)) {
int tabIndex = getPreceedingPageCount() + index;
internalAddTab((RemoteViewController) value, tabIndex);
viewControllers.add(tabIndex, value);
}//if//
}//valueAdded()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#valueRemoved(java.lang.Object)
*/
public void valueRemoved(Object value) {
if((!suspendCollectionEvents) && (value instanceof RemoteViewController)) {
internalRemoveTab((RemoteViewController) value);
viewControllers.remove(value);
((RemoteViewController) value).close();
}//if//
}//valueRemoved()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueRemoved(java.lang.Object, int)
*/
public void valueRemoved(Object value, int index) {
valueRemoved(value);
}//valueRemoved()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#removingAll()
*/
public void removingAll() {
if(!suspendCollectionEvents) {
IIterator iterator = viewControllers.iterator();
startChanges(viewControllers.getSize());
try {
while(iterator.hasNext()) {
valueRemoved(iterator.next());
}//while//
}//try//
finally {
stopChanges();
}//finally//
}//if//
}//removingAll()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valuesSorted(int[])
*/
public void valuesSorted(int[] mapping) {
if(!suspendCollectionEvents) {
sendMessage(MESSAGE_SORT_TABS, new Object[] {new Integer(getPreceedingPageCount()), mapping});
}//if//
}//valuesSorted()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#getResourceService()
*/
public AbstractResourceService getResourceService() {
return TabPanel.this.getResourceService();
}//getResourceService()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#getDecorationManager()
*/
public DecorationManager getDecorationManager() {
return TabPanel.this.getDecorationManager();
}//getDecorationManager()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#addDecoration(com.foundation.view.AbstractDecoration)
*/
public void addDecoration(AbstractDecoration decoration) {
}//addDecoration()//
/* (non-Javadoc)
* @see com.foundation.view.ISingleResourceAssociationChangeListener#removeDecoration(com.foundation.view.AbstractDecoration)
*/
public void removeDecoration(AbstractDecoration decoration) {
}//removeDecoration()//
}//PagesHolder//
/**
* TabPanel 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 #STYLE_NO_BACKGROUND
* @see #STYLE_NO_FOCUS
* @see #STYLE_NO_MERGE_PAINTS
* @see #STYLE_NO_REDRAW_RESIZE
* @see #STYLE_NO_RADIO_GROUP
* @see #STYLE_H_SCROLL
* @see #STYLE_V_SCROLL
* @see #STYLE_BORDER
* @see #STYLE_LEFT_TO_RIGHT
* @see #STYLE_RIGHT_TO_LEFT
* @see #STYLE_TOP
* @see #STYLE_BOTTOM
*/
public TabPanel(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//TabPanel()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.TabPanel";
}//getClientClassName()//
/**
* Adds N pages to the tab panel, where the pages come from an association with the model.
* @return The page holder which can be used to add associations.
*/
public IPagesHolder addPages() {
PagesHolder holder = new PagesHolder(pages.getSize() > 0 ? pages.getLast() : null);
pages.add(holder);
return holder;
}//addPages()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#addComponent(com.foundation.view.IAbstractComponent)
*/
public void addComponent(com.foundation.view.IAbstractComponent component) {
super.addComponent(component);
if(component instanceof Component && !suspendCustomComponentBehavior) {
pages.add(component);
if(isInitialized()) {
internalAddTab((Component) component);
}//if//
}//if//
}//addComponent()//
public void removeComponent(com.foundation.view.IAbstractComponent component) {
if(component instanceof Component && !suspendCustomComponentBehavior) {
internalRemoveTab((Component) component);
pages.remove(component);
}//if//
super.removeComponent(component);
}//removeComponent()//
/**
* Adds a tab to the panel for the given view component.
* @param component The view component that will be displayed in the tab.
*/
protected void internalAddTab(Component component) {
if(component != null) {
sendMessage(MESSAGE_ADD_TAB, new int[] {component.getNumber()});
}//if//
else {
Debug.log("Error: Invalid component. Unable to add the component as a tab in the tab panel.");
}//else//
}//internalAddTab()//
/**
* Removes a tab from the panel for the given related view component.
* @param component The view component associated with the tab to be removed.
*/
protected void internalRemoveTab(Component component) {
sendMessage(MESSAGE_REMOVE_TAB, new Integer(component.getNumber()));
}//internalRemoveTab()//
/* (non-Javadoc)
* @see com.foundation.view.IView#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
IIterator iterator = null;
//Note: We are using the initialize all to setup the tabs so that they can be released before releasing the children.//
super.internalViewInitializeAll();
iterator = pages.iterator();
//Initialize the tabs.//
while(iterator.hasNext()) {
Object page = iterator.next();
if(page instanceof PagesHolder) {
((PagesHolder) page).initialize();
}//if//
else {
//Not necessary since it is handled by the Container base class.//
//((Component) page).internalViewInitializeAll();
internalAddTab((Component) page);
}//else//
}//for//
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.view.IView#viewReleaseAll()
*/
protected void internalViewReleaseAll() {
IIterator iterator = pages.iterator();
//Note: We are using the release all to release the tabs so that they can be released before releasing the children.//
while(iterator.hasNext()) {
Object page = iterator.next();
if(page instanceof Component) {
//Not necessary since it is handled by the Container base class.//
//((Component) page).internalViewReleaseAll();
internalRemoveTab((Component) page);
}//if//
else {
((PagesHolder) page).release();
}//else//
}//for//
super.internalViewReleaseAll();
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#internalViewRefreshAll()
*/
public void internalViewRefreshAll() {
for(int index = 0; index < pages.getSize(); index++) {
Object page = pages.get(index);
if(page instanceof PagesHolder) {
((PagesHolder) page).refresh();
}//if//
else if(page instanceof Component) {
//Not necessary since it is handled by the Container base class.//
//((Component) page).internalViewRefreshAll();
}//else//
}//for//
super.internalViewRefreshAll();
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewSynchronizeAll()
*/
public void internalViewSynchronizeAll() {
for(int index = 0; index < pages.getSize(); index++) {
Object page = pages.get(index);
if(page instanceof PagesHolder) {
((PagesHolder) page).synchronize();
}//if//
else if(page instanceof Component) {
//Not necessary since it is handled by the Container base class.//
//((Component) page).internalViewSynchronizeAll();
}//else//
}//for//
super.internalViewSynchronizeAll();
}//internalViewSynchronizeAll()//
}//TabPanel//

View File

@@ -0,0 +1,860 @@
/*
* 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.common.comparison.Comparator;
import com.common.util.*;
import com.common.util.optimized.IntArray;
import com.foundation.metadata.Attribute;
import com.foundation.tcv.swt.ITableComponent;
import com.foundation.tcv.view.IAbstractRemoteViewComponent;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.*;
import com.foundation.view.resource.ResourceReference;
/*
* The simple table is a very simple implementation of a basic table.
* Initialy this contains just text with no extra formatting using the native table component.
*/
public abstract class TableComponent extends CollectionComponent implements ITableComponent {
/** The font resource for the control rows. (Note: This overrides the base font for the control defined by the Component class.) */
private MultiResourceAssociation rowFont = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_FONT, false, null);
/** The background color resource for the control. */
private MultiResourceAssociation rowBackgroundColorCustom = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
/** The foreground color resource for the control. */
private MultiResourceAssociation rowForegroundColorCustom = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
/** The background color resource for the control. */
private SingleResourceAssociation rowBackgroundColor = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
/** The foreground color resource for the control. */
private SingleResourceAssociation rowForegroundColor = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
/** The background color resource for the control. */
private SingleResourceAssociation rowBackgroundColorAlt = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
/** The foreground color resource for the control. */
private SingleResourceAssociation rowForegroundColorAlt = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
/** The selection color resource for the control. */
private VariableResourceAssociation rowSelectionGradient = new VariableResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_GRADIENT, false, null);
/** The row height used. */
private SingleResourceAssociation rowHeight = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_INTEGER, false, null);
/** The collection of columns in order of appearance (left to right). */
private IList tableColumns = new LiteList(16);
/** Tracks whether or not to try updating the selection if the collection changed. */
private boolean isSelectionInvalid = false;
/** The mapping of image decoration data by the decoration object. This is used to improve efficiency when placing a decoration on multiple rows. */
protected IHashMap decorationDataMap = null;
/** The last used decoration data identifier. The identifier is used to tell the client which decoration is being talked about. */
private int nextDecorationDataId = 0;
/**
* Maintains the reference counter and ID for each decoration in the decoration data map. Also allows a decoration to be shared by multiple rows.
*/
protected class DecorationData {
/** The data identifier used to notify the client about this decoration's change in status. */
private int decorationId = nextDecorationDataId++;
/** The number of times the data is being referenced (by rows displaying it). */
private int referenceCount = 1;
/**
* DecorationData constructor.
* @param decoration The decoration this data object supports.
*/
public DecorationData(ImageDecoration decoration) {
}//DecorationData()//
/**
* Increments the reference counter for the decoration.
*/
public void incrementReferenceCount() {
referenceCount++;
}//incrementReferenceCount()//
/**
* Decrements the reference counter for the decoration.
* @return The reference count for the decoration data.
*/
public int decrementReferenceCount() {
return --referenceCount;
}//decrementReferenceCount()//
}//DecorationData//
/**
* Encapsulates all the data pertaining to a single column in the table component.
*/
public static abstract class AbstractColumn implements IAbstractComponent, IAbstractRemoteViewComponent {
/**
* Registers an item in the collection with this column.
* <p>An item can be registered more than once, but must be unregistered just as many times.</p>
* @param rowObject The row to be registered.
*/
protected void registerItem(RowObject rowObject) {
}//registerItem()//
/**
* Unregisters an item that had been previously registered.
* @param rowObject The row to be unregistered.
*/
protected void unregisterItem(RowObject rowObject) {
}//unregisterItem()//
/**
* Unregisters all items that had been previously registered.
*/
protected void unregisterAllItems() {
}//unregisterAllItems()//
/**
* Refreshes the value for the cell(s) denoted by the item representing the row(s) and this column.
* @param rowObject The row data containing the row's value and metadata.
* @return Whether the cell data was altered by the refresh.
*/
protected abstract boolean refreshCellData(RowObject rowObject);
/**
* Collects the cell data for the given row and this column.
* @param rowObject The row data containing the row's value and metadata.
* @param cellData The table cell data structure to be filled in.
*/
protected void collectCellData(RowObject rowObject, TableCellData cellData) {
}//collectCellData()//
/**
* Gets the column's creation index.
* @return The index assigned to this column and used to facilitate communication with the actual column resource in the display.
*/
protected abstract int getIndex();
/**
* Sets the column's creation index.
* @param index The index assigned to this column and used to facilitate communication with the actual column resource in the display.
*/
protected abstract void setIndex(int index);
/**
* Initializes the column before the table component is initialized.
*/
protected abstract void initialize();
/**
* Refreshes the column.
*/
protected abstract void refresh();
/**
* Releases the column before the table component is released.
*/
protected abstract void release();
/* (non-Javadoc)
* @see com.foundation.tcv.view.IAbstractViewComponent#processMessage(com.foundation.tcv.view.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
return null;
}//processMessage()//
}//AbstractColumn//
/**
* TableComponent constructor.
* @param parent The parent container for this component.
* @param name The name of the component.
*/
public TableComponent(Container parent, String name, int style) {
super(parent, name, style);
}//TableComponent()//
/**
* Adds a column to the component.
* @param column The column to be added.
*/
protected void addColumn(AbstractColumn column) {
if(isInitialized()) {
//Allow the collection to suspend activites that would adversly affect performance while the collection make large scale changes.//
preChangeCollection();
}//if//
try {
tableColumns.add(column.getIndex(), column);
//Update the other column indices.//
for(int index = column.getIndex() + 1; index < tableColumns.getSize(); index++) {
((AbstractColumn) tableColumns.get(index)).setIndex(index);
}//for//
//Notify the client.//
sendMessage(MESSAGE_ADD_COLUMN, new Integer(column.getIndex()));
}//try//
finally {
if(isInitialized()) {
//Allow the table to refresh its self.//
postChangeCollection();
}//if//
}//finally//
}//addColumn()//
/**
* Gets the number of columns in the table.
* @return The count of columns.
*/
protected int getColumnCount() {
return tableColumns.getSize();
}//getColumnCount()//
/**
* Gets the column at the given index.
* @param index The zero based column index.
* @return The column at the given index.
*/
protected AbstractColumn getColumn(int index) {
return (AbstractColumn) tableColumns.get(index);
}//getColumn()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewRefreshCollection(com.common.util.ICollection, com.common.util.ICollection)
*/
protected void internalViewRefreshCollection(ICollection newCollection, ICollection oldCollection) {
itemAllRemoved();
if(newCollection != null) {
// TableRowData[] data = new TableRowData[newCollection.getSize()];
// Object[] hiddenData = new Object[newCollection.getSize()];
IIterator itemIterator = newCollection.iterator();
int itemIndex = 0;
//Get the array of strings representing the list contents.//
while(itemIterator.hasNext()) {
Object item = itemIterator.next();
itemAdded(item, itemIndex++, true);
// RowObject rowObject = itemAdded(value, index, false);
//
// //Add the item mappings without notifying the client.//
// if(rowObject.isFirstReference()) {
// data[itemIndex] = new TableRowData(getRowObject(item).objectId, itemIndex, null, null);
// hiddenData[itemIndex] = getItemHiddenData(item);
// }//if//
// else {
// data[itemIndex] = new TableRowData(getRowObject(item).objectId, itemIndex, getItemData(rowObject));
// hiddenData[itemIndex] = null;
// }//else//
}//while//
//TODO: It would probably be more efficient to send many small messages and allow the sending code to take care of bundling to the optimum size.
//addMessageHold(); Use this to block message sending until finished? May not need it since the messages should bundle up anyway.
// sendMessage(MESSAGE_SET_ITEMS, data, hiddenData, -1, -1);
}//if//
//If the selection was invalid previously then refresh the selection since it may no longer be invalid.//
if(isSelectionInvalid) {
internalViewRefreshSelection();
}//if//
}//internalViewRefreshCollection()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#getItemData(com.foundation.tcv.swt.server.RowObject)
*/
protected Object getItemData(RowObject rowObject) {
TableRowData rowData = createTableRowData();
TableCellData[] cellDatas = rowData.getColumnData();
collectRowData(rowObject, rowData);
for(int index = 0; index < cellDatas.length; index++) {
AbstractColumn column = (AbstractColumn) tableColumns.get(index);
if(column != null) {
column.refreshCellData(rowObject);
cellDatas[index] = createTableCellData();
column.collectCellData(rowObject, cellDatas[index]);
}//if//
}//for//
return rowData;
}//getItemData()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewRefreshSelection(java.lang.Object)
*/
protected void internalViewRefreshSelection(Object selectedItem) {
if(selectedItem != null) {
RowObject rowObject = (RowObject) getRowObject(selectedItem);
if(rowObject == null) {
isSelectionInvalid = true;
sendMessage(MESSAGE_SET_SELECTION, null);
}//if//
else {
isSelectionInvalid = false;
sendMessage(MESSAGE_SET_SELECTION, new int[] {rowObject.objectId});
}//else//
}//if//
else {
//No selection.//
sendMessage(MESSAGE_SET_SELECTION, null);
}//else//
}//internalViewRefreshSelection()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewRefreshSelections(com.common.util.ICollection, com.common.util.ICollection)
*/
protected void internalViewRefreshSelections(ICollection newSelections, ICollection oldSelections) {
if(newSelections != null) {
IntArray selectionObjectIds = new IntArray(newSelections.getSize());
IIterator selectionIterator = newSelections.iterator();
//Apply differences between the selection collection and the control selection. Also remove all impossible selections.//
while(selectionIterator.hasNext()) {
Object selection = selectionIterator.next();
RowObject rowObject = (RowObject) getRowObject(selection);
if(rowObject == null) {
//An invalid selection because the selection is not in the collection of displayed values.//
selectionIterator.remove();
}//if//
else {
selectionObjectIds.add(rowObject.objectId);
}//else//
}//while//
sendMessage(MESSAGE_SET_SELECTION, selectionObjectIds.toArray());
}//if//
else {
//Remove all selections.//
sendMessage(MESSAGE_REMOVE_ALL_SELECTIONS, null);
}//else//
}//internalViewRefreshSelections()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
rowBackgroundColor.initialize();
rowForegroundColor.initialize();
rowBackgroundColorAlt.initialize();
rowForegroundColorAlt.initialize();
rowSelectionGradient.initialize();
rowBackgroundColorCustom.initialize();
rowForegroundColorCustom.initialize();
rowFont.initialize();
rowHeight.initialize();
//Initialize all the columns.//
for(int columnIndex = 0; columnIndex < tableColumns.getSize(); columnIndex++) {
((AbstractColumn) tableColumns.get(columnIndex)).initialize();
}//for//
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
sendMessage(MESSAGE_SUSPEND_ROW_COLOR_UPDATES, null, null, -1, -1);
internalViewRefreshRowHeight();
if(rowSelectionGradient.isSingle() && rowSelectionGradient.refresh(null)) {
sendMessage(MESSAGE_SET_ROW_SELECTION_GRADIENT, rowSelectionGradient.getValue(null), null, -1, -1);
}//if//
if(rowBackgroundColor.refresh()) {
sendMessage(MESSAGE_SET_ROW_BACKGROUND_COLOR, rowBackgroundColor.getValue(), null, -1, -1);
}//if//
if(rowForegroundColor.refresh()) {
sendMessage(MESSAGE_SET_ROW_FOREGROUND_COLOR, rowForegroundColor.getValue(), null, -1, -1);
}//if//
if(rowBackgroundColorAlt.refresh()) {
sendMessage(MESSAGE_SET_ROW_BACKGROUND_COLOR_ALT, rowBackgroundColorAlt.getValue(), null, -1, -1);
}//if//
if(rowForegroundColorAlt.refresh()) {
sendMessage(MESSAGE_SET_ROW_FOREGROUND_COLOR_ALT, rowForegroundColorAlt.getValue(), null, -1, -1);
}//if//
sendMessage(MESSAGE_RESUME_ROW_COLOR_UPDATES, null, null, -1, -1);
super.internalViewRefresh();
//Refresh all the columns.//
for(int columnIndex = 0; columnIndex < tableColumns.getSize(); columnIndex++) {
((AbstractColumn) tableColumns.get(columnIndex)).refresh();
}//for//
}//internalViewRefresh()//
/**
* Refreshes the component's row height.
*/
protected void internalViewRefreshRowHeight() {
if(rowHeight.refresh()) {
Integer height = (Integer) rowHeight.getValue();
//Reset to the default height if null but was previously non-null.//
sendMessage(MESSAGE_SET_ROW_HEIGHT, height, null, -1, -1);
}//if//
}//internalViewRefreshRowHeight()//
/* (non-Javadoc)
* @see com.foundation.view.swt.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
//Release all the columns.//
for(int columnIndex = 0; columnIndex < tableColumns.getSize(); columnIndex++) {
((AbstractColumn) tableColumns.get(columnIndex)).release();
}//for//
rowBackgroundColor.release();
rowForegroundColor.release();
rowBackgroundColorAlt.release();
rowForegroundColorAlt.release();
rowSelectionGradient.release();
rowBackgroundColorCustom.release();
rowForegroundColorCustom.release();
rowFont.release();
rowHeight.release();
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object, java.lang.Object, boolean)
*/
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object item, Object data, boolean isUpdate) {
if(isInitialized()) {
if(resourceAssociation == rowBackgroundColorCustom) {
//Verify that the item cell data has actually been altered.//
if(rowBackgroundColorCustom.refresh(item)) {
sendMessage(MESSAGE_SET_ROW_CUSTOM_BACKGROUND_COLOR, rowBackgroundColorCustom.getValue(item), null, -1, -1);
}//if//
}//if//
else if(resourceAssociation == rowForegroundColorCustom) {
//Verify that the item cell data has actually been altered.//
if(rowForegroundColorCustom.refresh(item)) {
sendMessage(MESSAGE_SET_ROW_CUSTOM_FOREGROUND_COLOR, rowForegroundColorCustom.getValue(item), null, -1, -1);
}//if//
}//else if//
else if(rowSelectionGradient.hasAssociation(resourceAssociation)) {
//Verify that the item cell data has actually been altered.//
if(rowSelectionGradient.refresh(item)) {
sendMessage(MESSAGE_SET_ROW_SELECTION_GRADIENT, rowSelectionGradient.getValue(item), null, -1, -1);
}//if//
}//else if//
else if(resourceAssociation == rowFont) {
//Verify that the item cell data has actually been altered.//
if(rowFont.refresh(item)) {
sendMessage(MESSAGE_SET_ROW_FONT, rowFont.getValue(item), null, -1, -1);
}//if//
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, item, data, isUpdate);
}//else//
}//if//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation, boolean)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(isInitialized()) {
if(resourceAssociation == rowHeight) {
sendMessage(MESSAGE_SET_ROW_HEIGHT, rowHeight.getValue(), null, -1, -1);
}//if//
else if(resourceAssociation == rowBackgroundColor) {
sendMessage(MESSAGE_SET_ROW_BACKGROUND_COLOR, rowBackgroundColor.getValue(), null, -1, -1);
}//else if//
else if(resourceAssociation == rowForegroundColor) {
sendMessage(MESSAGE_SET_ROW_FOREGROUND_COLOR, rowForegroundColor.getValue(), null, -1, -1);
}//else if//
else if(resourceAssociation == rowBackgroundColorAlt) {
sendMessage(MESSAGE_SET_ROW_BACKGROUND_COLOR_ALT, rowBackgroundColorAlt.getValue(), null, -1, -1);
}//else if//
else if(resourceAssociation == rowForegroundColorAlt) {
sendMessage(MESSAGE_SET_ROW_FOREGROUND_COLOR_ALT, rowForegroundColorAlt.getValue(), null, -1, -1);
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//if//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#itemSorted(int[])
*/
protected void itemSorted(int[] mapping) {
sendMessage(MESSAGE_ORDER_ROWS, mapping);
}//itemSorted()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#selectionAdded(java.lang.Object)
*/
protected void selectionAdded(Object value) {
RowObject rowObject = getRowObject(value);
if(rowObject != null) {
sendMessage(MESSAGE_ADD_SELECTION, null, null, rowObject.objectId, -1);
}//if//
}//selectionAdded()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#selectionRemoved(java.lang.Object)
*/
protected void selectionRemoved(Object value) {
RowObject rowObject = getRowObject(value);
if(rowObject != null) {
sendMessage(MESSAGE_REMOVE_SELECTION, null, null, rowObject.objectId, -1);
}//if//
}//selectionRemoved()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#selectionAllRemoved()
*/
protected void selectionAllRemoved() {
sendMessage(MESSAGE_REMOVE_ALL_SELECTIONS, null);
}//selectionAllRemoved()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#registerItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void registerItem(RowObject rowObject) {
super.registerItem(rowObject);
//Add the item to each of the columns so we receive updates.//
for(int index = 0; index < tableColumns.getSize(); index++) {
((AbstractColumn) tableColumns.get(index)).registerItem(rowObject);
}//for//
}//registerItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void unregisterItem(RowObject rowObject) {
super.unregisterItem(rowObject);
//Unregister the value with the columns so we stop receiving updates.//
for(int index = 0; index < tableColumns.getSize(); index++) {
((AbstractColumn) tableColumns.get(index)).unregisterItem(rowObject);
}//for//
}//unregisterItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItems()
*/
protected void unregisterItems() {
super.unregisterItems();
//Unregister the items from the columns so we stop recieving updates.//
for(int index = 0; index < tableColumns.getSize(); index++) {
((AbstractColumn) tableColumns.get(index)).unregisterAllItems();
}//for//
}//unregisterItems()//
/**
* Collects the data for the given row item.
* @param rowObject The row data containing the row's value and metadata.
* @param rowData The row data container.
*/
protected void collectRowData(RowObject rowObject, TableRowData rowData) {
Object item = rowObject.value;
rowBackgroundColorCustom.refresh(item);
rowData.setBackgroundColor(rowBackgroundColorCustom.getValue(item));
rowForegroundColorCustom.refresh(item);
rowData.setForegroundColor(rowForegroundColorCustom.getValue(item));
rowFont.refresh(item);
rowData.setFont(rowFont.getValue(item));
}//collectRowData()//
/**
* Creates a new data container for the table row.
* <p>Subclasses that add row data elements should override this.</p>
* @return The new container for row data.
*/
protected TableRowData createTableRowData() {
return new TableRowData(new TableCellData[getColumnCount()]);
}//createTableRowData()//
/**
* Creates a new data container for the table cell.
* <p>Subclasses that add row data elements should override this.</p>
* @return The new container for cell data.
*/
protected TableCellData createTableCellData() {
return new TableCellData();
}//createTableRowData()//
/* (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: { //Receive the selection information from the client.//
Object messageData = viewMessage.getMessageData();
if(getAllowMultiSelection()) {
int[] selectionObjectIds = (int[]) messageData;
ICollection modelSelections = getModelSelections();
//Prevent the selection additions from causing a feedback loop.//
suspendSelectionHooks = true;
try {
//We require that the collection for the selections be created by the model.//
if(modelSelections != null) {
if(selectionObjectIds != null) {
LiteHashSet selectedRowSet = new LiteHashSet(selectionObjectIds.length, LiteHashSet.DEFAULT_LOAD_FACTOR, Comparator.getIdentityComparator(), LiteHashSet.STYLE_ADD_DUPLICATES);
IIterator iterator = modelSelections.iterator();
LiteList removed = new LiteList(modelSelections.getSize());
for(int index = 0; index < selectionObjectIds.length; index++) {
selectedRowSet.add(getRowObject(selectionObjectIds[index]).value);
}//for//
//Iterate over the model's selections, removing those that are not currently selected and tracking those not yet in the model selection collection.//
while(iterator.hasNext()) {
Object nextValue = iterator.next();
RowObject nextRowObject = nextValue == null ? null : getRowObject(nextValue);
if(nextRowObject != null) {
//Check to see if the model selection is in the view.//
if(!selectedRowSet.remove(nextRowObject.value)) {
//Remove the selection from the model if it is not currently selected in the view.//
removed.add(nextValue);
}//if//
}//if//
else {
//Remove the model selection since it is invalid.//
removed.add(nextValue);
}//else//
}//while//
//Add any selections not already in the model selection collection.//
modelSelections.replaceAll(removed, selectedRowSet);
}//if//
else {
modelSelections.removeAll();
}//else//
}//if//
}//try//
finally {
suspendSelectionHooks = false;
}//finally//
}//if//
else {
int selectedObjectId = messageData != null ? ((Integer) messageData).intValue() : -1;
RowObject selectedRowObject = (RowObject) (selectedObjectId >= 0 ? getRowObject(selectedObjectId) : null);
setModelSelection(selectedRowObject == null ? null : selectedRowObject.value);
}//else//
if(getAutoValidate()) {
postSynchronizeValidate();
}//if//
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
}//default//
}//switch//
return retVal;
}//processMessage()//
/**
* Sets the component's default background color.
* @param backgroundColor The default background color.
*/
public void setRowBackgroundColor(JefColor backgroundColor) {
verifyThread();
this.rowBackgroundColor.setDefaultValue(backgroundColor);
}//setRowHeaderBackgroundColor()//
/**
* Sets the component's default background color.
* @param backgroundColor The default background color.
*/
public void setRowBackgroundColor(ResourceReference backgroundColor) {
verifyThread();
this.rowBackgroundColor.setDefaultValue(backgroundColor);
}//setRowHeaderBackgroundColor()//
/**
* Sets the component's default foreground color.
* @param foregroundColor The default foreground color.
*/
public void setRowForegroundColor(JefColor foregroundColor) {
verifyThread();
this.rowForegroundColor.setDefaultValue(foregroundColor);
}//setRowHeaderForegroundColor()//
/**
* Sets the component's default foreground color.
* @param foregroundColor The default foreground color.
*/
public void setRowForegroundColor(ResourceReference foregroundColor) {
verifyThread();
this.rowForegroundColor.setDefaultValue(foregroundColor);
}//setRowHeaderForegroundColor()//
/**
* Sets the component's default background alternate color.
* @param backgroundColorAlt The default background alternate color.
*/
public void setRowBackgroundColorAlt(JefColor backgroundColorAlt) {
verifyThread();
this.rowBackgroundColorAlt.setDefaultValue(backgroundColorAlt);
}//setRowHeaderBackgroundColorAlt()//
/**
* Sets the component's default background alternate color.
* @param backgroundColorAlt The default background alternate color.
*/
public void setRowBackgroundColorAlt(ResourceReference backgroundColorAlt) {
verifyThread();
this.rowBackgroundColorAlt.setDefaultValue(backgroundColorAlt);
}//setRowHeaderBackgroundColorAlt()//
/**
* Sets the component's default foreground alternate color.
* @param foregroundColorAlt The default foreground alternate color.
*/
public void setRowForegroundColorAlt(JefColor foregroundColorAlt) {
verifyThread();
this.rowForegroundColorAlt.setDefaultValue(foregroundColorAlt);
}//setRowHeaderForegroundColorAlt()//
/**
* Sets the component's default foreground alternate color.
* @param foregroundColorAlt The default foreground alternate color.
*/
public void setRowForegroundColorAlt(ResourceReference foregroundColorAlt) {
verifyThread();
this.rowForegroundColorAlt.setDefaultValue(foregroundColorAlt);
}//setRowHeaderForegroundColorAlt()//
/**
* Sets the component's default selection gradient.
* @param selectionGradient The default selection gradient.
*/
public void setRowSelectionGradient(JefGradient selectionGradient) {
verifyThread();
this.rowSelectionGradient.setDefaultValue(selectionGradient);
}//setRowHeaderSelectionGradient()//
/**
* Sets the component's default selection gradient.
* @param selectionGradient The default selection gradient.
*/
public void setRowSelectionGradient(ResourceReference selectionGradient) {
verifyThread();
this.rowSelectionGradient.setDefaultValue(selectionGradient);
}//setRowSelectionGradient()//
/**
* Sets the font for the row header. This will be the default font if there is a font attribute associated with this component.
* @param font The default font metadata.
*/
public void setRowFont(JefFont[] font) {
verifyThread();
this.rowFont.setDefaultValue(font);
}//setRowHeaderFont()//
/**
* Sets the font for the row header. This will be the default font if there is a font attribute associated with this component.
* @param font The default font metadata.
*/
public void setRowFont(ResourceReference font) {
verifyThread();
this.rowFont.setDefaultValue(font);
}//setRowHeaderFont()//
/**
* Sets the height for the rows.
* @param height The row height in pixels.
*/
public void setRowHeight(Integer height) {
verifyThread();
this.rowHeight.setDefaultValue(height);
}//setRowHeight()//
/**
* Sets the association container used to access the row background color for each row.
* <p>The resulting value will override the row's normal color.</p>
* @param container The row background color association metadata.
*/
public void setRowBackgroundColorCustomAssociation(MultiAssociationContainer container) {
verifyThread();
this.rowBackgroundColorCustom.setAssociations(container);
}//setRowBackgroundColorCustomAssociation()//
/**
* Sets the association container used to access the row foreground color for each row.
* <p>The resulting value will override the row's normal color.</p>
* @param container The row foreground color association metadata.
*/
public void setRowForegroundColorCustomAssociation(MultiAssociationContainer container) {
verifyThread();
this.rowForegroundColorCustom.setAssociations(container);
}//setRowForegroundColorCustomAssociation()//
/**
* Sets the association container used to access the row background color.
* @param container The row background color association metadata.
*/
public void setRowBackgroundColorAssociation(SingleAssociationContainer container) {
verifyThread();
this.rowBackgroundColor.setAssociations(container);
}//setRowBackgroundColorAssociation()//
/**
* Sets the association container used to access the row foreground color.
* @param container The row foreground color association metadata.
*/
public void setRowForegroundColorAssociation(SingleAssociationContainer container) {
verifyThread();
this.rowForegroundColor.setAssociations(container);
}//setRowForegroundColorAssociation()//
/**
* Sets the association container used to access the alternate row background color.
* @param container The alternate row background color association metadata.
*/
public void setRowBackgroundColorAltAssociation(SingleAssociationContainer container) {
verifyThread();
this.rowBackgroundColorAlt.setAssociations(container);
}//setRowBackgroundColorAltAssociation()//
/**
* Sets the association container used to access the alternate row foreground color.
* @param container The alternate row foreground color association metadata.
*/
public void setRowForegroundColorAltAssociation(SingleAssociationContainer container) {
verifyThread();
this.rowForegroundColorAlt.setAssociations(container);
}//setRowForegroundColorAltAssociation()//
/**
* Sets the association container used to access the row selection color.
* @param container The row selection color association metadata.
*/
public void setRowSelectionGradientAssociation(AssociationContainer container) {
verifyThread();
this.rowSelectionGradient.setAssociations(container);
}//setRowSelectionGradientAssociation()//
/**
* Sets the association container used to access the row font.
* @param container The row font association metadata.
*/
public void setRowFontAssociation(MultiAssociationContainer container) {
verifyThread();
this.rowFont.setAssociations(container);
}//setRowFontAssociation()//
/**
* Sets the association container used to access the row height.
* @param container The row font association metadata.
*/
public void setRowHeightAssociation(SingleAssociationContainer container) {
verifyThread();
this.rowHeight.setAssociations(container);
}//setRowHeightAssociation()//
/**
* Determines whether the control is capable of processing collection item decorations.
* @return Whether the control can handle collection item decorations.
*/
protected boolean canDecorate() {
return true;
}//canDecorate()//
/* (non-Javadoc)
* @see com.foundation.controller.IDecorationMultiListener#isListening(java.lang.Class, java.lang.Object, com.foundation.metadata.Attribute)
*/
public boolean isListening(Class decorationType, Object object, Attribute attribute) {
return super.isListening(decorationType, object, attribute) && (HighlightDecoration.class.isAssignableFrom(decorationType) || ImageDecoration.class.isAssignableFrom(decorationType));
}//isListening()//
/* (non-Javadoc)
* @see com.foundation.controller.IDecorationMultiListener#addDecoration(com.foundation.view.AbstractDecoration, java.lang.Object, com.foundation.metadata.Attribute)
*/
public void addDecoration(AbstractDecoration decoration, Object object, Attribute attribute) {
if(decoration instanceof HighlightDecoration) {
sendMessage(MESSAGE_ADD_ROW_HIGHLIGHT_DECORATION, decoration, null, getRowObject(object).objectId, -1);
}//if//
else if(decoration instanceof ImageDecoration) { //TODO: Support ControlDecoration also or instead?
DecorationData decorationData = (DecorationData) decorationDataMap.get(decoration);
if(decorationData == null) {
decorationData = new DecorationData((ImageDecoration) decoration);
decorationDataMap.put(decoration, decorationData);
sendMessage(MESSAGE_ADD_ROW_IMAGE_DECORATION, decoration, null, getRowObject(object).objectId, decorationData.decorationId);
}//if//
else {
decorationData.incrementReferenceCount();
sendMessage(MESSAGE_ADD_ROW_IMAGE_DECORATION, null, null, getRowObject(object).objectId, decorationData.decorationId);
}//else//
}//else if//
}//addDecoration()//
/* (non-Javadoc)
* @see com.foundation.controller.IDecorationMultiListener#removeDecoration(com.foundation.view.AbstractDecoration, java.lang.Object, com.foundation.metadata.Attribute)
*/
public void removeDecoration(AbstractDecoration decoration, Object object, Attribute attribute) {
if(decoration instanceof HighlightDecoration) {
sendMessage(MESSAGE_REMOVE_ROW_HIGHLIGHT_DECORATION, null, null, getRowObject(object).objectId, -1);
}//if//
else if(decoration instanceof ImageDecoration) {
DecorationData decorationData = (DecorationData) decorationDataMap.get(decoration);
if(decorationData.decrementReferenceCount() == 0) {
decorationDataMap.remove(decoration);
}//if//
sendMessage(MESSAGE_REMOVE_ROW_IMAGE_DECORATION, null, null, getRowObject(object).objectId, decorationData.decorationId);
}//else if//
}//removeDecoration()//
}//TableComponent//

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,634 @@
/*
* 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.common.util.LiteList;
import com.foundation.tcv.model.LinkInfo;
import com.foundation.tcv.swt.IToolBar;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IMethodAssociation;
import com.foundation.view.JefImage;
import com.foundation.view.LinkData;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
import com.foundation.view.resource.ResourceReference;
public class ToolBar extends Container implements IToolBar {
/** The collection of ToolItem instances contained by the tool bar. */
private LiteList toolItems = new LiteList(10, 20);
/** The collection of Menu instances associated with tool items. */
private LiteList menus = new LiteList(10, 20);
/**
* This tool item can be extended to provide customized tool item behavior.
*/
public static abstract class AbstractToolItem extends AbstractComponent implements IToolBar.IAbstractToolItem {
private Container container = null;
/** The item's tool tip text resource. */
private SingleResourceAssociation toolTipText = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, null);
/** The resource defining the enabled state for the component. */
private SingleResourceAssociation isEnabled = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, false, Boolean.TRUE);
/** Whether this is a stateful item. */
protected final boolean isStateful;
/** Whether this is a push item. */
protected final boolean isPush;
/**
* AbstractToolItem 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 #STYLE_DROP_DOWN
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_RADIO
* @see #STYLE_SEPARATOR
*/
public AbstractToolItem(Container parent, int style) {
super(parent.getSessionViewController());
container = parent;
isStateful = ((style & STYLE_RADIO) > 0) || ((style & STYLE_CHECK) > 0);
isPush = ((style & STYLE_PUSH) > 0);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
((ToolBar) parent).addToolItem(this);
}//AbstractToolItem()//
/**
* Sets the association container used to access the tool tip.
* @param container The tool tip association metadata.
*/
public void setToolTipTextAssociation(SingleAssociationContainer container) {
verifyThread();
this.toolTipText.setAssociations(container);
}//setToolTipTextAssociation()//
/**
* Sets the association container used to access the enabled state.
* @param container The enabled state association metadata.
*/
public void setIsEnabledAssociation(SingleAssociationContainer container) {
verifyThread();
this.isEnabled.setAssociations(container);
}//setIsEnabledAssociation()//
/**
* Sets the component tool tip text.
* @param toolTipText The tool tip text that will appear in the component.
*/
public void setToolTipText(String toolTipText) {
verifyThread();
this.toolTipText.setDefaultValue(toolTipText);
}//setToolTipText()//
/**
* Sets the component's default tool tip text resource.
* @return The tool tip text to be displayed by this component.
*/
public void setToolTipText(ResourceReference toolTipText) {
verifyThread();
this.toolTipText.setDefaultValue(toolTipText);
}//setToolTipText()//
/**
* Sets whether the component is enabled (by default if an attribute is bound to this value).
* @param isEnabled Whether the user can interact with the component.
*/
public void setIsEnabled(boolean isEnabled) {
verifyThread();
this.isEnabled.setDefaultValue(isEnabled ? Boolean.TRUE : Boolean.FALSE);
}//setIsEnabled()//
/**
* Sets the default enabled state resource.
* @param isEnabled Whether the user can interact with the component.
*/
public void setIsEnabled(ResourceReference isEnabled) {
verifyThread();
this.isEnabled.setDefaultValue(isEnabled);
}//setIsEnabled()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
toolTipText.initialize();
isEnabled.initialize();
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
toolTipText.release();
isEnabled.release();
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
internalViewRefreshToolTipText();
internalViewRefreshIsEnabled();
super.internalViewRefresh();
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == toolTipText) {
internalViewRefreshToolTipText();
}//if//
else if(resourceAssociation == isEnabled) {
internalViewRefreshIsEnabled();
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/**
* Refreshes the item tool tip text.
*/
protected void internalViewRefreshToolTipText() {
if(toolTipText.refresh()) {
sendMessage(MESSAGE_SET_TOOL_TIP_TEXT, (String) toolTipText.getValue());
}//if//
}//internalViewRefreshToolTipText()//
/**
* Refreshes whether the component is enabled based on the attribute value or if null the default flag value.
*/
protected void internalViewRefreshIsEnabled() {
if(isEnabled.refresh()) {
sendMessage(MESSAGE_SET_IS_ENABLED, (Boolean) isEnabled.getValue());
}//if//
}//internalViewRefreshIsEnabled()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getContainer()
*/
public IAbstractContainer getContainer() {
return container;
}//getContainer()//
}//AbstractToolItem//
/**
* Encapsulates an item in the bar.
*/
public static class ToolItem extends AbstractToolItem implements IToolBar.IToolItem {
/** Called when the button is pressed (only used for push items). */
private IMethodAssociation selectionMethod = null;
/** The item's selection state resource. */
private SingleResourceAssociation selection = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, true, Boolean.FALSE);
/** The item's text resource. */
private SingleResourceAssociation text = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, "");
/** The item's image resource. */
private SingleResourceAssociation image = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGE, false, null);
/** The item's image resource. */
private SingleResourceAssociation disabledImage = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGE, false, null);
/** The item's hot image resource. */
private SingleResourceAssociation hotImage = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGE, false, null);
/** Whether the selection state is auto synchronized. */
private boolean autoSynchronizeSelection = true;
/** The delay to be used when auto synchronizing changes to the text. */
private long autoSynchronizeSelectionDelay = 0;
/**
* ToolItem 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 #STYLE_DROP_DOWN
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_RADIO
* @see #STYLE_SEPARATOR
*/
public ToolItem(Container parent, String name, int style) {
super(parent, style);
}//ToolItem()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return "__ToolItem__";
}//getName()//
/**
* 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 association container used to access the hot image.
* @param container The hot image association metadata.
*/
public void setHotImageAssociation(SingleAssociationContainer container) {
verifyThread();
this.hotImage.setAssociations(container);
}//setHotImageAssociation()//
/**
* Sets the association container used to access the disabled image.
* @param container The disabled image association metadata.
*/
public void setDisabledImageAssociation(SingleAssociationContainer container) {
verifyThread();
this.disabledImage.setAssociations(container);
}//setDisabledImageAssociation()//
/**
* 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()//
/**
* Sets the component text.
* @param text The text that will appear in the component.
*/
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 component image.
* @param image The image to be displayed by the component.
*/
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()//
/**
* Sets the component hot image.
* @param image The hot image to be displayed by the component.
*/
public void setHotImage(JefImage image) {
verifyThread();
this.hotImage.setDefaultValue(image);
}//setHotImage()//
/**
* Sets the component's default hot image resource.
* @param image The hot image to be displayed by this component.
*/
public void setHotImage(ResourceReference image) {
verifyThread();
this.hotImage.setDefaultValue(image);
}//setHotImage()//
/**
* Sets the component disabled image.
* @param image The disabled image to be displayed by the component.
*/
public void setDisabledImage(JefImage image) {
verifyThread();
this.disabledImage.setDefaultValue(image);
}//setDisabledImage()//
/**
* Sets the component's default disabled image resource.
* @param image The disabled image to be displayed by this component.
*/
public void setDisabledImage(ResourceReference image) {
verifyThread();
this.disabledImage.setDefaultValue(image);
}//setDisabledImage()//
/**
* Sets the component default selection state.
* @param isSelected Whether the component is in the selected state.
*/
public void setIsSelected(Boolean isSelected) {
verifyThread();
if(isStateful) {
selection.setDefaultValue(isSelected);
}//if//
}//setIsSelected()//
/**
* Sets the selection method called when the button is pressed (intended for push buttons).
* @param selectionMethod The method called when the button is selected.
*/
public void setSelectionMethod(IMethodAssociation selectionMethod) {
verifyThread();
if(isPush) {
this.selectionMethod = selectionMethod;
sendMessage(MESSAGE_SET_BLOCK_ON_SELECTIONS, selectionMethod != null ? Boolean.TRUE : Boolean.FALSE);
}//if//
}//setSelectionMethod()//
/**
* 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((isStateful) && (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()//
/**
* Sets the delay for the auto synchronize selection.
* @param autoSynchronizeSelectionDelay The delay in terms of milliseconds between the value of zero and ten thousand. A zero value has no delay.
*/
public void setAutoSynchronizeSelectionDelay(long autoSynchronizeSelectionDelay) {
verifyThread();
if(autoSynchronizeSelectionDelay < 0) {
autoSynchronizeSelectionDelay = 0;
}//if//
else if(autoSynchronizeSelectionDelay > 10000) {
autoSynchronizeSelectionDelay = 10000;
}//else if//
if((isStateful) && (autoSynchronizeSelectionDelay != this.autoSynchronizeSelectionDelay)) {
this.autoSynchronizeSelectionDelay = autoSynchronizeSelectionDelay;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long(autoSynchronizeSelectionDelay));
}//if//
}//setAutoSynchronizeSelectionDelay()//
/**
* Sets the custom width for the item.
* @param width The item's width which is used if the item is a separator.
*/
public void setWidth(int width) {
sendMessage(MESSAGE_SET_WIDTH, new Integer(width));
}//setWidth()//
/* (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: {
Boolean selectionState = (Boolean) viewMessage.getMessageData();
//Call the selection method.//
if((!isStateful) && (selectionMethod != null)) {
selectionMethod.invoke(new Object[] {selectionState}, true);
}//if//
//Update the selection value.//
if(isStateful) {
selection.setValue(selectionState);
}//if//
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
}//default//
}//switch//
return retVal;
}//processMessage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
text.initialize();
image.initialize();
hotImage.initialize();
disabledImage.initialize();
selection.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
text.release();
image.release();
hotImage.release();
disabledImage.release();
selection.release();
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
internalViewRefreshSelection();
internalViewRefreshText();
internalViewRefreshImage();
internalViewRefreshHotImage();
internalViewRefreshDisabledImage();
sendMessage(MESSAGE_AUTO_SIZE, null);
}//internalViewRefresh()//
/* (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 if(resourceAssociation == selection) {
internalViewRefreshSelection();
}//else if//
else if(resourceAssociation == hotImage) {
internalViewRefreshHotImage();
}//else if//
else if(resourceAssociation == disabledImage) {
internalViewRefreshDisabledImage();
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/**
* Refreshes the item selection.
*/
protected void internalViewRefreshSelection() {
if((isStateful) && (selection.refresh())) {
sendMessage(MESSAGE_SET_IS_SELECTED, selection.getValue());
}//if//
}//internalViewRefreshSelection()//
/**
* Refreshes the item hot image.
*/
protected void internalViewRefreshHotImage() {
if(hotImage.refresh()) {
sendMessage(MESSAGE_SET_HOT_IMAGE, (JefImage) hotImage.getValue());
}//if//
}//internalViewRefreshHotImage()//
/**
* Refreshes the item disabled image.
*/
protected void internalViewRefreshDisabledImage() {
if(disabledImage.refresh()) {
sendMessage(MESSAGE_SET_DISABLED_IMAGE, (JefImage) disabledImage.getValue());
}//if//
}//internalViewRefreshDisabledImage()//
/**
* Refreshes the item image.
*/
protected void internalViewRefreshImage() {
if(image.refresh()) {
sendMessage(MESSAGE_SET_IMAGE, (JefImage) image.getValue());
}//if//
}//internalViewRefreshImage()//
/**
* Refreshes the item text.
*/
protected void internalViewRefreshText() {
if(text.refresh()) {
sendMessage(MESSAGE_SET_TEXT, (String) text.getValue());
}//if//
}//internalViewRefreshText()//
/**
* Sets the control used by the tool item.
* @param control The tool item's control.
*/
public void setControl(Component control) {
sendMessage(MESSAGE_SET_CONTROL, new int[] {control.getNumber()});
}//setControl()//
/**
* Sets the control used by the tool item.
* @param control The tool item's control.
*/
public void setMenu(Menu menu) {
sendMessage(MESSAGE_SET_MENU, new int[] {menu.getNumber()});
}//setMenu()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.ToolBar$ToolItem";
}//getClientClassName()//
}//ToolItem//
/**
* Button 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 #STYLE_ARROW
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_RADIO
* @see #STYLE_TOGGLE
* @see #STYLE_FLAT
* @see #STYLE_LEFT
* @see #STYLE_RIGHT
* @see #STYLE_CENTER
* @see #STYLE_UP
* @see #STYLE_DOWN
*/
public ToolBar(Container parent, String name, int style) {
super(parent, name, style);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//ToolBar()//
/**
* Adds a tool item to the bar.
* @param toolItem The item to be added.
*/
protected void addToolItem(AbstractToolItem toolItem) {
toolItems.add(toolItem);
if(isInitialized()) {
//TODO: Initialize the tool item.
//Will the tool item's component already be initilialized?
//Would this ever occur?
}//if//
}//addToolItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
super.internalViewInitializeAll();
//Initialize all the tool items.//
for(int index = 0; index < toolItems.getSize(); index++) {
((AbstractToolItem) toolItems.get(index)).internalViewInitialize();
}//for//
//Initialize all the menus.//
for(int index = 0; index < menus.getSize(); index++) {
((Menu) menus.get(index)).internalViewInitializeAll();
}//for//
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewReleaseAll()
*/
protected void internalViewReleaseAll() {
//Release all the tool items.//
for(int index = 0; index < toolItems.getSize(); index++) {
((AbstractToolItem) toolItems.get(index)).internalViewRelease();
}//for//
//Release all the menus.//
for(int index = 0; index < menus.getSize(); index++) {
((Menu) menus.get(index)).internalViewReleaseAll();
}//for//
super.internalViewReleaseAll();
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefreshAll()
*/
protected void internalViewRefreshAll() {
super.internalViewRefreshAll();
//Refresh all the tool items.//
for(int index = 0; index < toolItems.getSize(); index++) {
((AbstractToolItem) toolItems.get(index)).internalViewRefresh();
}//for//
//Refresh all the menus.//
for(int index = 0; index < menus.getSize(); index++) {
((Menu) menus.get(index)).internalViewRefreshAll();
}//for//
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Component#setMenu(com.foundation.tcv.swt.server.Menu)
*/
public void setMenu(Menu menu) {
verifyThread();
menus.add(menu);
//A tool bar can have multiple menus associated with it. Each menu is tied to a drop down tool item. Since the tool item is not a control, the menu is linked to the bar instead.//
if((isInitialized()) && (menu != null)) {
menu.internalViewInitializeAll();
}//if//
}//setMenu()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.ToolBar";
}//getClientClassName()//
}//ToolBar//

View File

@@ -0,0 +1,158 @@
/*
* 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.tcv.model.LinkInfo;
import com.foundation.tcv.swt.IToolItemDropColor;
import com.foundation.tcv.swt.server.ToolBar.AbstractToolItem;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.JefColor;
import com.foundation.view.LinkData;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
import com.foundation.view.resource.ResourceReference;
public class ToolItemDropColor extends AbstractToolItem implements IToolItemDropColor {
/** The item's selection state resource. */
private SingleResourceAssociation selection = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_COLOR, true, null);
/**
* ToolItemDropColor 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 ToolItemDropColor(Container parent, String name, int style) {
super(parent, style);
}//ToolItemDropColor()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return "__ToolItem:DropColor__";
}//getName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.ToolItemDropColor";
}//getClientClassName()//
/* (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 color selection.
*/
protected void internalViewRefreshSelection() {
if(selection.refresh()) {
JefColor selectedColor = (JefColor) selection.getValue();
sendMessage(MESSAGE_REFRESH_SELECTION, selectedColor);
}//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()//
/**
* 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 selected color.
* @param link The local linkage for the selected color.
*/
public void addColorLink(LinkData link) {
sendMessage(MESSAGE_ADD_COLOR_LINK, new LinkInfo(((AbstractComponent) link.getComponent()).getNumber(), link.getTarget(), link.getData(), link.isBoolean(), link.invertLogic(), link.nullValue()));
}//addColorLink()//
/**
* Sets the selected color.
* @param color The color selected.
*/
public void setColor(JefColor color) {
verifyThread();
this.selection.setDefaultValue(color);
}//setColor()//
/**
* Sets the selected color.
* @param color The color resource reference.
*/
public void setColor(ResourceReference color) {
this.selection.setDefaultValue(color);
}//setColor()//
/**
* 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) {
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION, autoSynchronizeSelection ? Boolean.TRUE : Boolean.FALSE);
}//setAutoSynchronizeSelection()//
/**
* Sets the color image width.
* @param width The width of the image in the tool item.
*/
public void setWidth(int width) {
sendMessage(MESSAGE_SET_WIDTH, new Integer(width));
}//setWidth()//
/**
* Sets the color image height.
* @param height The height of the image in the tool item.
*/
public void setHeight(int height) {
sendMessage(MESSAGE_SET_HEIGHT, new Integer(height));
}//setHeight()//
/* (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_SYNCHRONIZE_SELECTION: {
JefColor selectionState = (JefColor) viewMessage.getMessageData();
//Update the selection value.//
selection.setValue(selectionState);
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
}//default//
}//switch//
return retVal;
}//processMessage()//
}//ToolItemDropColor//

View File

@@ -0,0 +1,465 @@
/*
* 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.thread.IRunnable;
import com.common.util.IIterator;
import com.common.util.IList;
import com.common.util.LiteList;
import com.foundation.controller.AbstractViewController;
import com.foundation.event.IRequestHandler;
import com.foundation.tcv.model.LinkInfo;
import com.foundation.tcv.server.controller.SessionViewController;
import com.foundation.tcv.swt.ITrayItem;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.IAbstractComponent;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IMethodAssociation;
import com.foundation.view.IView;
import com.foundation.view.JefImage;
import com.foundation.view.LinkData;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
import com.foundation.view.resource.ResourceReference;
public class TrayItem extends AbstractComponent implements ITrayItem, IAbstractContainer {
/** The reference to the popup menu. Not all components must allow a popup menu. */
private Menu menu = null;
/** The component's name. This allows lookup of components in the view by the name. */
private String name = null;
/** The resource defining the visible state for the component. */
private SingleResourceAssociation isVisible = null;
/** The resource defining the tool tip text for the component. */
private SingleResourceAssociation toolTipText = null;
/** The image resource. */
private SingleResourceAssociation image = null;
/** The component's controller. */
private AbstractViewController controller = null;
/** A collection of components contained by this container. */
private IList components = new LiteList(10, 30);
/** Called when the item is pressed. */
private IMethodAssociation selectionMethod = null;
/**
* TrayItem default constructor.
* <p>Warning: This is only for use by the framework. This should never be called to create a useable instance.</p>
*/
public TrayItem() {
}//TrayItem()//
/**
* TrayItem constructor.
* @param controller The session view controller.
* @param parent The non-null parent container for this container.
* @param name The component's name. This allows lookup of components in the view by the name.
* @param style No styles are possible here.
*/
public TrayItem(SessionViewController sessionViewController, String name, int style) {
super(sessionViewController);
this.name = name;
initialize();
sendMessage(MESSAGE_INITIALIZE, null, null, style, -1);
}//TrayItem()//
/**
* Initializes the component.
* <p>Note: This is separated so that a view can be instantiated via the default constructor for the purpose of determining the reflection metadata associated with the view. Any other call to the default constructor will create an invalid view.</p>
*/
private void initialize() {
isVisible = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, false, Boolean.TRUE);
toolTipText = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, null);
image = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_IMAGE, false, null);
}//initialize()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractContainer#addComponent(com.foundation.view.IAbstractComponent)
*/
public void addComponent(IAbstractComponent component) {
components.add((AbstractComponent) component);
}//addComponent()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractContainer#removeComponent(com.foundation.view.IAbstractComponent)
*/
public void removeComponent(IAbstractComponent component) {
components.remove((AbstractComponent) component);
}//removeComponent()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractContainer#getComponents()
*/
public IList getComponents() {
return components;
}//getComponents()//
/* (non-Javadoc)
* @see com.foundation.view.IView#layout()
*/
public void layout() {
//Does nothing.//
}//layout()//
/* (non-Javadoc)
* @see com.foundation.view.IView#getController()
*/
public AbstractViewController getController() {
return controller;
}//getController()//
/* (non-Javadoc)
* @see com.foundation.view.IView#setController(com.foundation.controller.AbstractViewController)
*/
public void setController(AbstractViewController controller) {
this.controller = controller;
}//setController()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.TrayItem";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getContainer()
*/
public IAbstractContainer getContainer() {
return null;
}//getContainer()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return name;
}//getName()//
/**
* Gets the popup menu for the tray.
* @return The menu that appears if the user right clicks on the tray.
*/
public Menu getMenu() {
verifyThread();
return menu;
}//getMenu()//
/**
* Sets the popup menu for the tray.
* @param menu The menu that appears if the user right clicks on the tray.
*/
public void setMenu(Menu menu) {
verifyThread();
if(isInitialized() && this.menu != null) {
this.menu.internalViewReleaseAll();
}//if//
this.menu = menu;
if((isInitialized()) && (menu != null)) {
menu.internalViewInitializeAll();
}//if//
}//setMenu()//
/**
* 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()//
/**
* Sets the selection method called when the item is pressed.
* @param selectionMethod The method called when the tray item is pressed (left clicked).
*/
public void setSelectionMethod(IMethodAssociation selectionMethod) {
verifyThread();
this.selectionMethod = selectionMethod;
sendMessage(MESSAGE_SET_SYNCHRONIZE_SELECTIONS, selectionMethod != null ? Boolean.TRUE : Boolean.FALSE);
}//setSelectionMethod()//
/**
* Sets the association container used to access whether the control is visible.
* @param container The visible state association metadata.
*/
public void setIsVisibleAssociation(SingleAssociationContainer container) {
verifyThread();
this.isVisible.setAssociations(container);
}//setIsVisibleAssociation()//
/**
* Sets the association container used to access the tool tip text.
* @param container The tool tip association metadata.
*/
public void setToolTipTextAssociation(SingleAssociationContainer container) {
verifyThread();
this.toolTipText.setAssociations(container);
}//setToolTipTextAssociation()//
/**
* 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 visibility.
* @param isVisible Whether the user can see the component.
*/
public void setIsVisible(boolean isVisible) {
verifyThread();
this.isVisible.externalSetValue(isVisible ? Boolean.TRUE : Boolean.FALSE);
}//setIsVisible()//
/**
* Sets the default visibility.
* @param isVisible Whether the user can see the component if no other value is provided.
*/
public void setDefaultIsVisible(boolean isVisible) {
verifyThread();
this.isVisible.setDefaultValue(isVisible ? Boolean.TRUE : Boolean.FALSE);
}//setDefaultIsVisible()//
/**
* Sets the default visibility resource.
* @param isVisible Whether the user can see the component if no other value is provided.
*/
public void setDefaultIsVisible(ResourceReference isVisible) {
verifyThread();
this.isVisible.setDefaultValue(isVisible);
}//setDefaultIsVisible()//
/**
* Sets the component's default tool tip text.
* @param tooltipText The tool tip text to be displayed by this component.
*/
public void setDefaultToolTipText(String toolTipText) {
verifyThread();
this.toolTipText.setDefaultValue(toolTipText);
}//setDefaultToolTipText()//
/**
* Sets the component's default tool tip text resource.
* @param tooltipText The tool tip text to be displayed by this component.
*/
public void setDefaultToolTipText(ResourceReference toolTipText) {
verifyThread();
this.toolTipText.setDefaultValue(toolTipText);
}//setDefaultToolTipText()//
/**
* Sets the default image resource.
* @param image The image to be displayed.
*/
public void setDefaultImage(ResourceReference image) {
verifyThread();
this.image.setDefaultValue(image);
}//setDefaultImage()//
/**
* Sets the default image.
* @param image The image data that will be displayed.
*/
public void setDefaultImage(JefImage image) {
verifyThread();
this.image.setDefaultValue(image);
}//setDefaultImage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
isVisible.initialize();
toolTipText.initialize();
image.initialize();
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
IIterator iterator = components.iterator();
super.internalViewInitializeAll();
//Initialize contained value holders first.//
while(iterator.hasNext()) {
AbstractComponent component = (AbstractComponent) iterator.next();
if(component instanceof ValueHolder) {
component.internalViewInitializeAll();
}//if//
}//for//
if(menu != null) {
menu.internalViewInitializeAll();
}//if//
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
isVisible.release();
toolTipText.release();
image.release();
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewReleaseAll()
*/
protected void internalViewReleaseAll() {
IIterator iterator = new LiteList(getComponents()).iterator();
if(getMenu() != null) {
getMenu().internalViewReleaseAll();
}//if//
//Release sub-components.//
while(iterator.hasNext()) {
AbstractComponent component = (AbstractComponent) iterator.next();
component.internalViewReleaseAll();
}//for//
super.internalViewReleaseAll();
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
internalViewRefreshIsVisible();
internalViewRefreshToolTipText();
internalViewRefreshImage();
super.internalViewRefresh();
}//internalViewRefresh()//
/**
* Refreshes whether the component is visible based on the attribute value or if null the default flag value.
*/
protected void internalViewRefreshIsVisible() {
if(isVisible.refresh()) {
sendMessage(MESSAGE_SET_IS_VISIBLE, isVisible.getValue());
}//if//
}//internalViewRefreshIsVisible()//
/**
* Refreshes the tool tip text from the tool tip text attribute and the default tool tip text.
*/
protected void internalViewRefreshToolTipText() {
if(toolTipText.refresh()) {
sendMessage(MESSAGE_SET_TOOL_TIP_TEXT, toolTipText.getValue());
}//if//
}//internalViewRefreshToolTipText()//
/**
* Refreshes the image from the image url attribute and the default image url.
*/
protected void internalViewRefreshImage() {
if(image.refresh()) {
sendMessage(MESSAGE_SET_IMAGE, image.getValue());
}//if//
}//internalViewRefreshContainerImage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefreshAll()
*/
protected void internalViewRefreshAll() {
IIterator iterator = components.iterator();
//Refresh value holders.//
while(iterator.hasNext()) {
AbstractComponent component = (AbstractComponent) iterator.next();
if(component instanceof ValueHolder) {
component.internalViewRefreshAll();
}//if//
}//for//
if(getMenu() != null) {
getMenu().internalViewRefreshAll();
}//if//
super.internalViewRefreshAll();
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(resourceAssociation == isVisible) {
internalViewRefreshIsVisible();
}//if//
else if(resourceAssociation == toolTipText) {
internalViewRefreshToolTipText();
}//else 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 result = null;
switch(viewMessage.getMessageNumber()) {
case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: {
if(selectionMethod != null) {
selectionMethod.invoke(new Object[] {new Integer(viewMessage.getMessageInteger()), new Integer(viewMessage.getMessageSecondaryInteger())}, true);
}//if//
break;
}//case//
default: {
result = super.processMessage(viewMessage);
}//default//
}//switch//
return result;
}//processMessage()//
/* (non-Javadoc)
* @see com.foundation.view.IView#center()
*/
public void center() {
}//center()//
/* (non-Javadoc)
* @see com.foundation.view.IView#center(com.foundation.view.IView)
*/
public void center(IView centerOnView) {
}//center()//
/* (non-Javadoc)
* @see com.foundation.view.IView#execute(com.common.thread.IRunnable)
*/
public Object execute(IRunnable runnable) {
return getSessionViewController().execute(runnable);
}//execute()//
/* (non-Javadoc)
* @see com.foundation.view.IView#executeAsynch(com.common.thread.IRunnable)
*/
public void executeAsync(IRunnable runnable) {
getSessionViewController().executeAsync(runnable);
}//executeAsynch()//
/* (non-Javadoc)
* @see com.foundation.view.IView#getRequestHandler()
*/
public IRequestHandler getRequestHandler() {
return getSessionViewController().getViewRequestHandler();
}//getRequestHandler()//
/* (non-Javadoc)
* @see com.foundation.view.IView#maximize()
*/
public void maximize() {
}//maximize()//
/* (non-Javadoc)
* @see com.foundation.view.IView#minimize()
*/
public void minimize() {
}//minimize()//
/* (non-Javadoc)
* @see com.foundation.view.IView#pack()
*/
public void pack() {
}//pack()//
/* (non-Javadoc)
* @see com.foundation.view.IView#setFocus()
*/
public void setFocus() {
}//setFocus()//
/* (non-Javadoc)
* @see com.foundation.view.IView#setIsEnabled(boolean)
*/
public void setIsEnabled(boolean isEnabled) {
}//setIsEnabled()//
/* (non-Javadoc)
* @see com.foundation.view.IView#show()
*/
public void show() {
}//show()//
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
return super.toString() + (getName() != null ? " (named: " + getName() + ")" : "");
}//toString()//
}//TrayItem//

View File

@@ -0,0 +1,460 @@
/*
* 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.common.util.ICollection;
import com.common.util.IIterator;
import com.common.util.IList;
import com.common.util.LiteList;
import com.common.util.optimized.IntArray;
import com.foundation.tcv.swt.ITreeComponent;
import com.foundation.tcv.swt.server.SimpleTreeTable.SimpleNodeData;
import com.foundation.tcv.view.IAbstractRemoteViewComponent;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.IAbstractComponent;
/*
* Tries to push as much common tree component code down to a reusable base class.
*/
public abstract class TreeComponent extends CollectionComponent implements ITreeComponent {
/** The collection of columns (AbstractColumn) in server order. */
private IList tableColumns = new LiteList(16);
/**
* Encapsulates all the data pertaining to a single column in the table component.
*/
public static abstract class AbstractColumn implements IAbstractComponent, IAbstractRemoteViewComponent {
/**
* Registers an item in the collection with this column.
* <p>An item can be registered more than once, but must be unregistered just as many times.</p>
* @param rowObject The row to be registered.
*/
protected void registerItem(RowObject rowObject) {
}//registerItem()//
/**
* Unregisters an item that had been previously registered.
* @param rowObject The row to be unregistered.
*/
protected void unregisterItem(RowObject rowObject) {
}//unregisterItem()//
/**
* Unregisters all items that had been previously registered.
*/
protected void unregisterAllItems() {
}//unregisterAllItems()//
/**
* Refreshes the value for the cell(s) denoted by the item representing the row(s) and this column.
* @param item The item that represents the row(s).
* @return Whether the cell data was altered by the refresh.
*/
protected abstract boolean refreshCellData(Object item);
/**
* Gets the value for the cell(s) denoted by the item representing the row(s) and this column.
* @param item The item that represents the row(s).
* @return The cell value.
*/
protected abstract Object getCellData(Object item);
/**
* Gets the column's creation index.
* @return The index assigned to this column and used to facilitate communication with the actual column resource in the display.
*/
protected abstract int getIndex();
/**
* Sets the column's creation index.
* @param index The index assigned to this column and used to facilitate communication with the actual column resource in the display.
*/
protected abstract void setIndex(int index);
/**
* Initializes the column before the table component is initialized.
*/
protected abstract void initialize();
/**
* Refreshes the column.
*/
protected abstract void refresh();
/**
* Initializes the column before the table component is released.
*/
protected abstract void release();
/* (non-Javadoc)
* @see com.foundation.tcv.view.IAbstractViewComponent#processMessage(com.foundation.tcv.view.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
return null;
}//processMessage()//
}//AbstractColumn//
/**
* TreeComponent constructor.
* @param parent The parent container for this component.
* @param name The name of the component.
*/
public TreeComponent(Container parent, String name, int style) {
super(parent, name, style);
}//TreeComponent()//
/**
* Adds a column to the component.
* @param column The column to be added.
*/
protected void addColumn(AbstractColumn column) {
tableColumns.add(column.getIndex(), column);
//Update the other column indices.//
for(int index = column.getIndex() + 1; index < tableColumns.getSize(); index++) {
((AbstractColumn) tableColumns.get(index)).setIndex(index);
}//for//
//Notify the client.//
sendMessage(MESSAGE_ADD_COLUMN, new Integer(column.getIndex()));
//TODO: Support columns added after the display is showing.//
if(isInitialized()) {
//Note: While it would be nice to send the header and cell data, we can't because the column hasn't been setup yet.//
//TODO: Send the initial header data.//
//TODO: Need to send the initial cell data.//
}//if//
}//addColumn()//
/**
* Gets the number of columns in the table.
* @return The count of columns.
*/
protected int getColumnCount() {
return tableColumns.getSize();
}//getColumnCount()//
/**
* Gets the column at the given index.
* @param index The zero based column index.
* @return The column at the given index.
*/
protected AbstractColumn getColumn(int index) {
return (AbstractColumn) tableColumns.get(index);
}//getColumn()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewRefreshCollection(com.common.util.ICollection, com.common.util.ICollection)
*/
protected void internalViewRefreshCollection(ICollection newCollection, ICollection oldCollection) {
sendMessage(MESSAGE_SAVE_VIEW_STATE, null);
//Clear the old data.//
primaryCollectionItemsRemoved();
//Rebuild the tree.//
if(newCollection != null) {
IIterator itemIterator = newCollection.iterator();
//Get the array of strings representing the list contents.//
while(itemIterator.hasNext()) {
Object item = itemIterator.next();
placeItem(null, item);
}//while//
}//if//
//If the selection was invalid previously then refresh the selection since it may no longer be invalid.//
if(isSelectionInvalid) {
internalViewRefreshSelection();
}//if//
sendMessage(MESSAGE_RESTORE_VIEW_STATE, null);
}//internalViewRefreshCollection()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewRefreshSelection(java.lang.Object)
*/
protected void internalViewRefreshSelection(Object selectedItem) {
if(selectedItem != null) {
RowObject rowObject = (RowObject) getRowObject(selectedItem);
if(rowObject == null) {
isSelectionInvalid = true;
sendMessage(MESSAGE_SET_SELECTION, null);
}//if//
else {
isSelectionInvalid = false;
sendMessage(MESSAGE_SET_SELECTION, new int[] {rowObject.objectId});
}//else//
}//if//
else {
//No selection.//
sendMessage(MESSAGE_SET_SELECTION, null);
}//else//
}//internalViewRefreshSelection()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewRefreshSelections(com.common.util.ICollection, com.common.util.ICollection)
*/
protected void internalViewRefreshSelections(ICollection newSelections, ICollection oldSelections) {
if(newSelections != null) {
IntArray selectionObjectIds = new IntArray(newSelections.getSize());
IIterator selectionIterator = newSelections.iterator();
//Apply differences between the selection collection and the control selection. Also remove all impossible selections.//
while(selectionIterator.hasNext()) {
Object selection = selectionIterator.next();
RowObject rowObject = (RowObject) getRowObject(selection);
if(rowObject == null) {
//An invalid selection because the selection is not in the collection of displayed values.//
selectionIterator.remove();
}//if//
else {
selectionObjectIds.add(rowObject.objectId);
}//else//
}//while//
sendMessage(MESSAGE_SET_SELECTION, selectionObjectIds.toArray());
}//if//
else {
//Remove all selections.//
sendMessage(MESSAGE_REMOVE_SELECTIONS, null);
}//else//
}//internalViewRefreshSelections()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
//Initialize all the columns.//
for(int columnIndex = 0; columnIndex < tableColumns.getSize(); columnIndex++) {
((AbstractColumn) tableColumns.get(columnIndex)).initialize();
}//for//
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
//Refresh all the columns.//
for(int columnIndex = 0; columnIndex < tableColumns.getSize(); columnIndex++) {
((AbstractColumn) tableColumns.get(columnIndex)).refresh();
}//for//
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.view.swt.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
//Release all the columns.//
for(int columnIndex = 0; columnIndex < tableColumns.getSize(); columnIndex++) {
((AbstractColumn) tableColumns.get(columnIndex)).release();
}//for//
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#itemSorted(int[])
*/
protected void itemSorted(int[] mapping) {
//TODO: Should this be implemented?
//sendMessage(MESSAGE_ORDER_ROWS, mapping);
}//itemSorted()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#selectionAdded(java.lang.Object)
*/
protected void selectionAdded(Object value) {
RowObject rowObject = getRowObject(value);
if(rowObject != null) {
sendMessage(MESSAGE_ADD_SELECTION, null, null, rowObject.objectId, -1);
}//if//
}//selectionAdded()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#selectionRemoved(java.lang.Object)
*/
protected void selectionRemoved(Object value) {
RowObject rowObject = getRowObject(value);
if(rowObject != null) {
sendMessage(MESSAGE_REMOVE_SELECTION, null, null, rowObject.objectId, -1);
}//if//
}//selectionRemoved()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#selectionAllRemoved()
*/
protected void selectionAllRemoved() {
sendMessage(MESSAGE_REMOVE_ALL_SELECTIONS, null);
}//selectionAllRemoved()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#registerItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void registerItem(RowObject rowObject) {
super.registerItem(rowObject);
//Add the item to each of the columns so we receive updates.//
for(int index = 0; index < tableColumns.getSize(); index++) {
((AbstractColumn) tableColumns.get(index)).registerItem(rowObject);
}//for//
}//registerItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItem(com.foundation.tcv.swt.server.RowObject)
*/
protected void unregisterItem(RowObject rowObject) {
super.unregisterItem(rowObject);
//Unregister the value with the columns so we stop receiving updates.//
for(int index = 0; index < tableColumns.getSize(); index++) {
((AbstractColumn) tableColumns.get(index)).unregisterItem(rowObject);
}//for//
}//unregisterItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#unregisterItems()
*/
protected void unregisterItems() {
super.unregisterItems();
//Unregister the items from the columns so we stop recieving updates.//
for(int index = 0; index < tableColumns.getSize(); index++) {
((AbstractColumn) tableColumns.get(index)).unregisterAllItems();
}//for//
}//unregisterItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#getItemData(com.foundation.tcv.swt.server.RowObject)
*/
protected Object getItemData(RowObject rowObject) {
Object[] result = new Object[tableColumns.getSize() + 1];
refreshRowHeaderCellData(rowObject.value);
result[0] = getRowHeaderCellData(rowObject.value);
for(int index = 0; index < result.length; index++) {
AbstractColumn column = (AbstractColumn) tableColumns.get(index);
if(column != null) {
column.refreshCellData(rowObject.value);
result[index + 1] = column.getCellData(rowObject.value);
}//if//
}//for//
return result;
}//getItemData()//
protected void sendAddItemMessage(RowObject rowObject, int itemIndex) {
//Don't send duplicate messages since the client doesn't care.//
if(rowObject.isFirstReference()) {
//TODO: Figure out how to get whether the value can have children from the row object. Send 0 if no children, 1 if can have children.
sendMessage(MESSAGE_ADD_ITEM, getItemData(rowObject), getItemHiddenData(rowObject.value), rowObject.objectId, canHaveChildren(rowObject.value) ? 1 : 0);
}//if//
}//sendAddItemMessage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.CollectionComponent#sendRemoveItemMessage(com.foundation.tcv.swt.server.CollectionComponent.RowObject, int, boolean)
*/
protected void sendRemoveItemMessage(RowObject rowObject, int itemIndex, boolean isRemovedEntirely) {
if(isRemovedEntirely) {
sendMessage(MESSAGE_REMOVE_ITEM, null, null, rowObject.objectId, itemIndex);
}//if//
}//sendRemoveItemMessage()//
/**
* Refreshes the row header cell data and determines whether there were substantial alterations.
* @param item The row item.
* @return Whether the cell data was changed.
*/
protected abstract boolean refreshRowHeaderCellData(Object item);
/**
* Gets the row header cell data.
* @param item The row item.
* @return The cell data for the row's row header.
*/
protected abstract Object getRowHeaderCellData(Object item);
/**
* Determines whether the passed item might have children.
* @param item The item to check.
* @return Whether the item could have children.
*/
protected abstract boolean canHaveChildren(Object item);
/**
* Places the item as a child of the given node. It may be grouped so that it is an indirect child of the given node.
* @param node The node that will have the item as a child. This may be null if the item is at the root of the tree.
* @param item The non-grouping item that is placed under the node.
*/
protected abstract void placeItem(SimpleNodeData node, Object item);
/* (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: { //Receive the selection information from the client.//
Object messageData = viewMessage.getMessageData();
if(getAllowMultiSelection()) {
int[] selectionObjectIds = (int[]) messageData;
boolean[] selectionMarks = new boolean[selectionObjectIds.length];
ICollection modelSelections = getModelSelections();
//Prevent the selection additions from causing a feedback loop.//
suspendSelectionHooks = true;
try {
if(modelSelections != null) {
IIterator iterator = modelSelections.iterator();
LiteList removed = new LiteList(modelSelections.getSize());
LiteList added = new LiteList(selectionObjectIds.length);
//Initialize the bit field.//
for(int index = 0; index < selectionMarks.length; index++) {
selectionMarks[index] = false;
}//for//
//For each previous selection, try to find a matching current selection, otherwise remove it. Mark all used current selections.//
while(iterator.hasNext()) {
Object next = iterator.next();
RowObject rowObject = getRowObject(next);
if(rowObject != null) {
int nextObjectId = rowObject.objectId;
boolean found = false;
for(int index = 0; (!found) && (index < selectionObjectIds.length); index++) {
if((selectionObjectIds[index] == nextObjectId) && (!selectionMarks[index])) {
selectionMarks[index] = true;
found = true;
}//if//
}//for//
//If the selection wasn't found in the view then remove it from the model.//
if(!found) {
removed.add(next);
}//if//
//Add the selections that were in the view but not in the model.//
for(int index = 0; index < selectionMarks.length; index++) {
if(!selectionMarks[index]) {
RowObject wrapper = (RowObject) getRowObject(selectionObjectIds[index]);
if(wrapper != null) {
added.add(wrapper.value);
}//if//
}//if//
}//for//
}//if//
}//while//
modelSelections.replaceAll(removed, added);
}//if//
}//try//
finally {
suspendSelectionHooks = false;
}//finally//
}//if//
else {
int selectedObjectId = messageData != null ? ((Integer) messageData).intValue() : -1;
RowObject selectedRowObject = (RowObject) (selectedObjectId >= 0 ? getRowObject(selectedObjectId) : null);
setModelSelection(selectedRowObject == null ? null : selectedRowObject.value);
}//else//
if(getAutoValidate()) {
postSynchronizeValidate();
}//if//
break;
}//case//
default: {
retVal = super.processMessage(viewMessage);
}//default//
}//switch//
return retVal;
}//processMessage()//
}//TreeComponent//

View File

@@ -0,0 +1,251 @@
/*
* Copyright (c) 2002,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.util.*;
import com.common.debug.*;
import com.foundation.view.*;
import com.foundation.controller.IController;
import com.foundation.event.*;
/*
* Encapsulates an object reference used by the view system at runtime, and the class of the runtime reference to allow design type automation.
*/
public class ValueHolder extends Component implements IValueHolder {
/** The class of value held by this value holder. */
private Class heldType = null;
/** The current value held by this value holder. */
private IEventEmitter value = null;
/** The collection of listeners listening for held value events. */
private LiteHashSet eventListeners = new LiteHashSet(5);
/** The collection of listeners listening for held value events. */
private LiteHashSet valueHolderListeners = new LiteHashSet(5, LiteHashSet.DEFAULT_LOAD_FACTOR, LiteHashSet.DEFAULT_COMPARATOR, LiteHashSet.STYLE_COUNT_DUPLICATES);
/** The event support used by value holder related associations to listen for held value events. */
private EventSupport eventSupport = null;
/** The parent resource from which this holder's value is derived. */
private SingleResourceAssociation parent = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_OBJECT, false, null);
/** Whether the value holder gets its value from a parent. */
private boolean hasParent = false;
/** Whether to not warn when an attempt is made to place a value that is not of the correct type. */
private boolean ignoreWarnings = false;
/**
* ValueHolder constructor.
* @param parent The parent container.
* @param name The view unqiue name of the component.
* @param heldType The type of object to be held by the value holder.
*/
public ValueHolder(IAbstractContainer parent, String name, Class heldType) {
super(parent, name, 0);
this.heldType = heldType;
}//ValueHolder()//
/**
* Sets whether the holder supresses warnings relating to attempts at setting the value to an invalid object type.
* @param ignoreWarnings Whether to not warn when an attempt is made to place a value that is not of the correct type.
*/
public void ignoreWarnings(boolean ignoreWarnings) {
this.ignoreWarnings = ignoreWarnings;
}//ignoreWarnings()//
/**
* Sets the association container used to access the parent value holder.
* @param container The parent association metadata.
*/
public void setParentAssociation(SingleAssociationContainer container) {
verifyThread();
this.parent.setAssociations(container);
this.hasParent = true;
}//setParentAssociation()//
/**
* Gets the support object that provides event listening functionality.
* @return Will be used to listen for events from IEventEmitter objects.
*/
protected EventSupport getEventSupport() {
if(eventSupport == null) {
eventSupport = new EventSupport(null);
}//if//
return eventSupport;
}//getEventSupport()//
/**
* Gets the value being held by this holder.
* @return The currently held value.
*/
public IEventEmitter getValue() {
return value;
}//getValue()//
/**
* Gets the class for the values held by this value holder.
* @return The held value type.
*/
public Class getHeldType() {
return heldType;
}//getHeldType()//
/* (non-Javadoc)
* @see com.foundation.view.IValueHolder#registerListener(com.foundation.view.IEventCapableAssociation)
*/
public void registerListener(IEventCapableAssociation eventAssociation) {
IEventEmitter value = getValue();
if((value != null) && (eventAssociation.getEventNumber() != -1) && ((eventAssociation.getValueHolderHeldType() == null) || (eventAssociation.getValueHolderHeldType().isAssignableFrom(value.getClass())))) {
getEventSupport().register(value, eventAssociation.getEventNumber(), eventAssociation, true);
}//if//
eventListeners.add(eventAssociation);
}//registerListener()//
/* (non-Javadoc)
* @see com.foundation.view.IValueHolder#unregisterListener(com.foundation.view.IEventCapableAssociation)
*/
public void unregisterListener(IEventCapableAssociation eventAssociation) {
IEventEmitter value = getValue();
if((value != null) && (eventAssociation.getEventNumber() != -1) && ((eventAssociation.getValueHolderHeldType() == null) || (eventAssociation.getValueHolderHeldType().isAssignableFrom(value.getClass())))) {
getEventSupport().unregister(value, eventAssociation.getEventNumber(), eventAssociation);
}//if//
eventListeners.remove(eventAssociation);
}//unregisterListener()//
/* (non-Javadoc)
* @see com.foundation.view.IValueHolder#registerListener(com.foundation.view.IValueHolderListener)
*/
public void registerListener(IValueHolderListener listener) {
valueHolderListeners.add(listener);
}//registerListener()//
/* (non-Javadoc)
* @see com.foundation.view.IValueHolder#unregisterListener(com.foundation.view.IValueHolderListener)
*/
public void unregisterListener(IValueHolderListener listener) {
valueHolderListeners.remove(listener);
}//unregisterListener()//
/**
* Updates the registered listeners so that they are registered with the new held value and are notified that their attributes may have changed.
* @param oldHeldValue The old value held by this value holder.
* @param newHeldValue The new value held by this value holder.
*/
public synchronized void updateRegisteredListeners(IEventEmitter oldHeldValue, IEventEmitter newHeldValue) {
IIterator iterator = new LiteHashSet(eventListeners).iterator();
//Unregister and reregister handlers.//
while(iterator.hasNext()) {
IEventCapableAssociation eventAssociation = (IEventCapableAssociation) iterator.next();
if((oldHeldValue != null) && ((eventAssociation.getValueHolderHeldType() == null) || (eventAssociation.getValueHolderHeldType().isAssignableFrom(value.getClass())))) {
getEventSupport().unregister(oldHeldValue, eventAssociation.getEventNumber(), eventAssociation);
}//if//
if((newHeldValue != null) && ((eventAssociation.getValueHolderHeldType() == null) || (eventAssociation.getValueHolderHeldType().isAssignableFrom(value.getClass())))) {
getEventSupport().register(newHeldValue, eventAssociation.getEventNumber(), eventAssociation, true);
}//if//
}//while//
iterator.resetToFront();
while(iterator.hasNext()) {
IEventCapableAssociation eventAssociation = (IEventCapableAssociation) iterator.next();
eventAssociation.evaluate(eventAssociation.getEventNumber(), null, 0);
}//while//
//Notify the listeners so their user can update.//
if(valueHolderListeners.getSize() > 0) {
Object[] listeners = valueHolderListeners.toArray();
for(int index = 0; index < listeners.length; index++) {
IValueHolderListener listener = (IValueHolderListener) listeners[index];
listener.heldValueChanged();
}//while//
}//if//
}//updateRegisteredListeners()//
/**
* Sets the value being held.
* @param value The held value.
*/
protected void setValue(IEventEmitter value) {
if(value != this.value) {
IEventEmitter oldValue = this.value;
this.value = value;
updateRegisteredListeners(oldValue, value);
}//if//
}//setValue()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
parent.initialize();
isInitialized(true);
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
public void internalViewRelease() {
parent.release();
if(getContainer() != null) {
getContainer().getComponents().remove(this);
}//if//
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
if(isInitialized()) {
if(hasParent) {
if(parent.refresh()) {
Object value = parent.getValue();
if((value == null) || (value instanceof IEventEmitter) && (heldType.isAssignableFrom(value.getClass()))) {
setValue((IEventEmitter) value);
}//if//
else if(!ignoreWarnings) {
if(value instanceof IEventEmitter) {
Debug.log("Invalid held object. Received a " + value.getClass().getName() + " and was expecting a " + heldType.getName() + " in the ValueHolder named " + getName() + ".");
}//if//
else {
Debug.log("Invalid held object. The class " + value.getClass().getName() + " does not implement " + IEventEmitter.class.getName() + " in the ValueHolder named " + getName() + ".");
}//else//
}//else if//
}//if//
}//if//
else {
IAbstractContainer parent = getContainer();
IController controller = null;
while((parent != null) && (controller == null)) {
if(parent instanceof IView) {
controller = ((IView) parent).getController();
}//if//
else {
parent = parent.getContainer();
}//else//
}//while//
if((controller != null) && (controller.getClass().isAssignableFrom(heldType))) {
setValue((IEventEmitter) controller);
}//if//
else if(!controller.getClass().isAssignableFrom(heldType)) {
Debug.log("Invalid controller object. Received a " + controller.getClass().getName() + " and was expecting a " + heldType.getName() + " in the ValueHolder named " + getName() + ".");
}//else if//
}//else//
}//if//
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(isInitialized()) {
internalViewRefresh();
}//if//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return StringSupport.EMPTY_STRING;
}//getClientClassName()//
}//ValueHolder//

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2007 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.IViewContainer;
public class ViewContainer extends Container implements IViewContainer {
/**
* ViewContainer 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 #STYLE_ARROW
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_RADIO
* @see #STYLE_TOGGLE
* @see #STYLE_FLAT
* @see #STYLE_LEFT
* @see #STYLE_RIGHT
* @see #STYLE_CENTER
* @see #STYLE_UP
* @see #STYLE_DOWN
*/
public ViewContainer(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, null, null, parent.getNumber(), style);
}//ViewContainer()//
/**
* Sets the view controller's class name.
* @param controllerClassName The name of the view controller that will provide the contained view.
*/
public void setControllerClassName(String controllerClassName) {
if(isInitialized()) {
throw new RuntimeException("Cannot set the controller class name after the view container has been initialized.");
}//if//
sendMessage(MESSAGE_SET_CONTROLLER_CLASS_NAME, controllerClassName);
}//setControllerClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.ViewContainer";
}//getClientClassName()//
}//ViewContainer//

View File

@@ -0,0 +1,121 @@
/*
* 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 org.eclipse.swt.SWT;
import com.foundation.view.*;
import com.foundation.controller.AbstractViewController;
import com.foundation.controller.RemoteViewController;
import com.foundation.tcv.swt.*;
import com.foundation.tcv.server.controller.*;
import com.foundation.tcv.view.*;
public class Window extends Frame implements IWindow {
/**
* Window default constructor.
* <p>Warning: This is only for use by the framework. This should never be called to create a useable instance.</p>
*/
public Window() {
}//Window()//
/**
* Window constructor.
* @param parent The parent window, or nu.
* @param sessionViewController The non-null view context (passed to the createView method as the context).
* @param name
* @param style
* @see #STYLE_BORDER
* @see #STYLE_H_SCROLL
* @see #STYLE_V_SCROLL
* @see #STYLE_BORDER
* @see #STYLE_LEFT_TO_RIGHT
* @see #STYLE_RIGHT_TO_LEFT
* @see #STYLE_NO_BACKGROUND
* @see #STYLE_NO_FOCUS
* @see #STYLE_NO_MERGE_PAINTS
* @see #STYLE_NO_REDRAW_RESIZE
* @see #STYLE_NO_RADIO_GROUP
* @see #STYLE_CLOSE
* @see #STYLE_MIN
* @see #STYLE_MAX
* @see #STYLE_RESIZE
* @see #STYLE_TITLE
* @see #STYLE_NO_TRIM
* @see #STYLE_SHELL_TRIM
* @see #STYLE_DIALOG_TRIM
* @see #STYLE_ON_TOP
* @see #STYLE_TOOL
* @see #STYLE_MODELESS
* @see #STYLE_PRIMARY_MODAL
* @see #STYLE_APPLICATION_MODAL
* @see #STYLE_SYSTEM_MODAL
*/
public Window(Window parent, SessionViewController sessionViewController, String name, int style, RemoteViewController viewController) {
super(sessionViewController != null ? sessionViewController : parent.getSessionViewController(), name, style);
setController(viewController);
//Set the modal flag.//
switch(viewController.getOptions()) {
case AbstractViewController.OPTION_MODELESS: {
style |= SWT.MODELESS;
break;
}//case//
case AbstractViewController.OPTION_MODAL: {
style |= SWT.PRIMARY_MODAL;
break;
}//case//
case AbstractViewController.OPTION_APPLICATION_MODAL: {
style |= SWT.APPLICATION_MODAL;
break;
}//case//
case AbstractViewController.OPTION_SYSTEM_MODAL: {
style |= SWT.SYSTEM_MODAL;
break;
}//case//
default: {
//Does nothing.//
}//default//
}//switch//
sendMessage(MESSAGE_INITIALIZE, parent != null ? parent.getIdentity() : null, null, style, -1);
}//Window()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#processMessage(com.foundation.tcv.model.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object retVal = null;
switch(viewMessage.getMessageNumber()) {
default: {
retVal = super.processMessage(viewMessage);
break;
}//default//
}//switch//
return retVal;
}//processMessage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnEventFired(com.foundation.tcv.swt.server.IEventAssociation, java.lang.Object[])
*/
public void internalOnEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
super.internalOnEventFired(eventAssociation, eventArguments);
}//internalOnEventFired()//
/* (non-Javadoc)
* @see com.foundation.view.swt.Component#internalOnValueChanged(com.foundation.view.swt.IAttributeAssociation)
*/
public void internalOnValueChanged(IAttributeAssociation attributeAssociation) {
super.internalOnValueChanged(attributeAssociation);
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.Window";
}//getClientClassName()//
}//Window//

View File

@@ -0,0 +1,144 @@
/*
* 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.tcv.swt.*;
import com.foundation.tcv.view.*;
public class Wizard extends Container implements IWizard {
/** The attribute that tracks which page number is being displayed. */
private IAttributeAssociation pageAttribute = null;
/** The index of the currently visible 'page' component. */
private int currentPageNumber = -1;
/**
* Wizard 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 #STYLE_NO_BACKGROUND
* @see #STYLE_NO_FOCUS
* @see #STYLE_NO_MERGE_PAINTS
* @see #STYLE_NO_REDRAW_RESIZE
* @see #STYLE_NO_RADIO_GROUP
* @see #STYLE_H_SCROLL
* @see #STYLE_V_SCROLL
* @see #STYLE_BORDER
* @see #STYLE_LEFT_TO_RIGHT
* @see #STYLE_RIGHT_TO_LEFT
*/
public Wizard(Container parent, String name, int style) {
super(parent, name, style);
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
}//Wizard()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.Container#setLayout(com.foundation.tcv.swt.Layout)
*/
public void setLayout(Layout layout) {
//Does nothing. It does not make sense to change the layout of the wizard since it can only use the stack layout.//
}//setLayout()//
/* (non-Javadoc)
* @see com.foundation.view.swt.Component#internalOnValueChanged(com.foundation.view.swt.IAttributeAssociation)
*/
protected void internalOnValueChanged(IAttributeAssociation attributeAssociation) {
if(attributeAssociation == pageAttribute) {
internalRefreshPage();
}//if//
else {
super.internalOnValueChanged(attributeAssociation);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnEventFired(com.foundation.tcv.swt.server.IEventAssociation, java.lang.Object[])
*/
protected void internalOnEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
super.internalOnEventFired(eventAssociation, eventArguments);
}//internalOnEventFired()//
/* (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()//
/**
* Sets the currently displayed page number attribute.
* @param pageAttribute The attribute referencing the currently displayed page's number.
*/
public void setPageAttribute(IAttributeAssociation pageAttribute) {
if((isInitialized()) && (this.pageAttribute != null)) {
this.pageAttribute.unregister();
}//if//
this.pageAttribute = pageAttribute;
if(isInitialized()) {
pageAttribute.register();
internalRefreshPage();
}//if//
}//setPageAttribute()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.Wizard";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
if(pageAttribute != null) {
pageAttribute.register();
}//if//
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
if(pageAttribute != null) {
pageAttribute.unregister();
}//if//
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
internalRefreshPage();
}//internalViewRefresh()//
/**
* Refreshes the currently visible wizard page.
*/
protected void internalRefreshPage() {
if(pageAttribute != null) {
Number pageNumber = (Number) pageAttribute.getAttributeValue();
if(pageNumber == null) {
pageNumber = new Integer(0);
pageAttribute.setAttributeValue(pageNumber);
}//if//
if(currentPageNumber != pageNumber.intValue()) {
currentPageNumber = pageNumber.intValue();
sendMessage(MESSAGE_CHANGE_PAGE, pageNumber);
}//if//
}//if//
}//internalRefreshPage()//
}//Wizard//

View File

@@ -0,0 +1,359 @@
/*
* 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.cell;
import com.foundation.tcv.swt.cell.ICellButton;
import com.foundation.tcv.swt.server.AbstractComponent;
import com.foundation.tcv.swt.server.ICellContainer;
import com.foundation.tcv.swt.server.RowObject;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.AssociationContainer;
import com.foundation.view.IMethodAssociation;
import com.foundation.view.JefImage;
import com.foundation.view.MultiAssociationContainer;
import com.foundation.view.MultiResourceAssociation;
import com.foundation.view.SingleResourceAssociation;
import com.foundation.view.VariableResourceAssociation;
import com.foundation.view.resource.ResourceReference;
public class CellButton extends CellComponent implements ICellButton {
/** Called when the button is pressed (only used for push buttons). */
private IMethodAssociation selectionMethod = null;
/** The button's selection state resource. */
private MultiResourceAssociation selection = new MultiResourceAssociation(this, this, getViewContext(), MultiResourceAssociation.TYPE_BOOLEAN, true, Boolean.FALSE);
/** The button's text resource. */
private VariableResourceAssociation text = new VariableResourceAssociation(this, this, getViewContext(), MultiResourceAssociation.TYPE_TEXT, false, "");
/** The button's image resource. */
private VariableResourceAssociation image = new VariableResourceAssociation(this, this, getViewContext(), MultiResourceAssociation.TYPE_IMAGE, false, null);
/** The delay to be used when auto synchronizing changes to the text. */
private long autoSynchronizeSelectionDelay = 500;
/** Whether the button's selection state (for check boxes and the like) should be synchronized by the client when changed. */
private boolean autoSynchronizeSelection = false;
/** Whether the view should be disabled while a selection event is processed. */
private boolean blockOnSelection = false;
/** Whether this is a stateful button. */
private final boolean isStateful;
/**
* CellButton 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 #STYLE_ARROW
* @see #STYLE_CHECK
* @see #STYLE_PUSH
* @see #STYLE_RADIO
* @see #STYLE_TOGGLE
* @see #STYLE_FLAT
* @see #STYLE_LEFT
* @see #STYLE_RIGHT
* @see #STYLE_CENTER
* @see #STYLE_UP
* @see #STYLE_DOWN
*/
public CellButton(ICellContainer parent, String name, int style) {
super(parent, name);
isStateful = ((style & STYLE_RADIO) > 0) || ((style & STYLE_TOGGLE) > 0) || ((style & STYLE_CHECK) > 0);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {((AbstractComponent) parent).getNumber(), style});
//Don't set a delay for standard push buttons.//
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long((((style & STYLE_CHECK) > 0) || ((style & STYLE_RADIO) > 0) || ((style & STYLE_TOGGLE) > 0)) ? 500 : 0));
}//CellButton()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return "__CellButton__";
}//getName()//
/**
* Sets the association container used to access the text.
* @param container The text association metadata.
*/
public void setTextAssociation(AssociationContainer 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(AssociationContainer container) {
verifyThread();
this.image.setAssociations(container);
}//setImageAssociation()//
/**
* Sets the association container used to access the selection.
* @param container The selection association metadata.
*/
public void setSelectionAssociation(MultiAssociationContainer container) {
verifyThread();
this.selection.setAssociations(container);
}//setSelectionAssociation()//
/**
* Sets the selection method called when the button is pressed (intended only for push buttons).
* @param selectionMethod The method called when the button is pressed.
*/
public void setSelectionMethod(IMethodAssociation selectionMethod) {
verifyThread();
if(!isStateful) {
this.selectionMethod = selectionMethod;
}//if//
}//setSelectionMethod()//
/**
* Sets the component text.
* @param text The text that will appear in the component.
*/
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 component image.
* @param image The image to be displayed by the component.
*/
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()//
/**
* Sets whether the client views should be disabled while a selection event is processed.
* @param blockOnSelection Whether push style buttons stop user input while processing the selection event.
*/
public void setBlockOnSelection(boolean blockOnSelection) {
verifyThread();
if((!isStateful) && (blockOnSelection != this.blockOnSelection)) {
this.blockOnSelection = blockOnSelection;
sendMessage(MESSAGE_SET_BLOCK_ON_SELECTIONS, blockOnSelection ? Boolean.TRUE : Boolean.FALSE);
}//if//
}//setBlockOnSelection()//
/**
* Sets the delay for the auto synchronize selection.
* @param autoSynchronizeSelectionDelay The delay in terms of milliseconds between the value of zero and ten thousand. A zero value has no delay.
*/
public void setAutoSynchronizeSelectionDelay(long autoSynchronizeSelectionDelay) {
verifyThread();
if(autoSynchronizeSelectionDelay < 0) {
autoSynchronizeSelectionDelay = 0;
}//if//
else if(autoSynchronizeSelectionDelay > 10000) {
autoSynchronizeSelectionDelay = 10000;
}//else if//
if((isStateful) && (autoSynchronizeSelectionDelay != this.autoSynchronizeSelectionDelay)) {
this.autoSynchronizeSelectionDelay = autoSynchronizeSelectionDelay;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long(autoSynchronizeSelectionDelay));
}//if//
}//setAutoSynchronizeSelectionDelay()//
/**
* 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((isStateful) && (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.cell.CellComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
text.initialize();
image.initialize();
selection.initialize();
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
text.release();
image.release();
selection.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
internalViewRefreshText();
internalViewRefreshImage();
super.internalViewRefresh();
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRefresh(com.foundation.tcv.swt.server.RowObject)
*/
protected void internalViewRefresh(RowObject rowObject) {
internalViewRefreshText(rowObject);
internalViewRefreshImage(rowObject);
internalViewRefreshSelection(rowObject);
super.internalViewRefresh(rowObject);
}//internalViewRefresh()//
/**
* Refreshes the image.
* @param rowObject The row whose state is being updated.
*/
protected void internalViewRefreshImage(RowObject rowObject) {
if(image.isMulti() && image.refresh(rowObject.value)) {
sendMessage(MESSAGE_SET_IMAGE, image.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshImage()//
/**
* Refreshes the button image.
*/
protected void internalViewRefreshImage() {
if(image.isSingle() && image.refresh(null)) {
sendMessage(MESSAGE_SET_IMAGE, image.getValue(null), null, -1, 0);
}//if//
}//internalViewRefreshImage()//
/**
* Refreshes the text.
* @param rowObject The row whose state is being updated.
*/
protected void internalViewRefreshText(RowObject rowObject) {
if(text.isMulti() && text.refresh(rowObject.value)) {
sendMessage(MESSAGE_SET_TEXT, text.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshText()//
/**
* Refreshes the button text.
*/
protected void internalViewRefreshText() {
if(text.isSingle() && text.refresh(null)) {
sendMessage(MESSAGE_SET_TEXT, text.getValue(null), null, -1, 0);
}//if//
}//internalViewRefreshText()//
/**
* Refreshes the selection.
* @param rowObject The row whose state is being updated.
*/
protected void internalViewRefreshSelection(RowObject rowObject) {
if((isStateful) && (selection.refresh(rowObject.value))) {
sendMessage(MESSAGE_SET_IS_SELECTED, selection.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshSelection()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(text.hasAssociation(resourceAssociation)) {
internalViewRefreshText();
}//else if//
else if(image.hasAssociation(resourceAssociation)) {
internalViewRefreshImage();
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object)
*/
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
if(text.hasAssociation(resourceAssociation)) {
internalViewRefreshText(getCellContainer().getRowObject(alteredItem));
}//if//
else if(image.hasAssociation(resourceAssociation)) {
internalViewRefreshImage(getCellContainer().getRowObject(alteredItem));
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, alteredItem, data, isUpdate);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#processMessage(com.foundation.tcv.view.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object result = null;
switch(viewMessage.getMessageNumber()) {
case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: {
Boolean selectionState = (Boolean) viewMessage.getMessageData();
RowObject rowObject = getCellContainer().getRowObject(viewMessage.getMessageInteger());
//Call the selection method.//
if((!isStateful) && (selectionMethod != null)) {
if(selectionMethod.getIsValueHolderAssociated()) {
selectionMethod.invoke(new Object[] {rowObject.value}, true);
}//if//
else {
selectionMethod.invoke(rowObject.value, null, true);
}//else//
}//if//
//Update the selection value.//
if(isStateful) {
selection.setValue(selectionState, rowObject.value);
}//if//
break;
}//case//
default: {
result = super.processMessage(viewMessage);
}//default//
}//switch//
return result;
}//processMessage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#registerRowItem(com.foundation.tcv.swt.server.RowObject)
*/
public void registerRowItem(RowObject rowObject) {
super.registerRowItem(rowObject);
text.registerItem(rowObject.value, rowObject);
image.registerItem(rowObject.value, rowObject);
selection.registerItem(rowObject.value, rowObject);
}//registerRowItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#unregisterRowItem(com.foundation.tcv.swt.server.RowObject)
*/
public void unregisterRowItem(RowObject rowObject) {
super.unregisterRowItem(rowObject);
text.unregisterItem(rowObject.value);
image.unregisterItem(rowObject.value);
selection.unregisterItem(rowObject.value);
}//unregisterRowItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#unregisterRowItems()
*/
public void unregisterRowItems() {
super.unregisterRowItems();
text.unregisterAllItems();
image.unregisterAllItems();
selection.unregisterAllItems();
}//unregisterRowItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.cell.CellButton";
}//getClientClassName()//
}//CellButton//

View File

@@ -0,0 +1,828 @@
/*
* 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.cell;
import com.common.debug.Debug;
import com.common.util.ICollection;
import com.common.util.IIterator;
import com.common.util.LiteHashMap;
import com.common.util.LiteList;
import com.common.util.optimized.IntObjectHashMap;
import com.foundation.tcv.swt.cell.IComboBox;
import com.foundation.tcv.swt.server.AbstractComponent;
import com.foundation.tcv.swt.server.ICellContainer;
import com.foundation.tcv.swt.server.RowObject;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.util.IInlineCollectionObservable;
import com.foundation.util.IInlineCollectionObserver;
import com.foundation.util.IInlineIndexedCollectionObservable;
import com.foundation.util.IInlineIndexedCollectionObserver;
import com.foundation.view.*;
public class CellComboBox extends CellComponent implements IComboBox {
/** The association containing the collection of items displayed to the user. */
private SingleResourceAssociation collection = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_OBJECT, false, null);
/** The association containing the selected collection item(s). */
private MultiResourceAssociation selection = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_OBJECT, true, null);
/** Converts the collection item to a string used to show the item to the user. */
private MultiResourceAssociation itemText = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_TEXT, false, null);
/** The text limit set by the application. */
private Integer textLimit = null;
/** Whether the user can type a custom selection. If this is true and the selection attribute is not a String type then the user input must match a list item's text. */
private boolean allowUserItems = false;
/** Whether the selection should be automatically synchronized from the view to the model when altered in the view. */
private boolean autoSynchronizeSelection = false;
/** The number of milliseconds of delay before auto synchronizing the selection. */
private long autoSynchronizeSelectionDelay = 500;
/** A reference to the last item collection known to this component. */
private ICollection currentCollection = null;
/** A handler that will redirect collection events to this collection component. */
private final CollectionHandler collectionHandler = new CollectionHandler();
/** A flag indicating whether the collection event hooks should ignore input temporarily. */
protected boolean suspendCollectionHooks = false;
/** A flag indicating whether the selection event hooks should ignore input temporarily. */
protected boolean suspendSelectionHooks = false;
/** Tracks whether or not to try updating the selection if the collection changed. */
protected boolean isSelectionInvalid = false;
/** A mapping of row objects by the unique object identifiers. */
private IntObjectHashMap rowObjectByObjectIdMap = new IntObjectHashMap(100);
/** A mapping of row objects by the collection value the row object represents. */
private LiteHashMap rowObjectByValueMap = new LiteHashMap(100, com.common.comparison.Comparator.getIdentityComparator(), null);
/** The next object identifier available for association with an object. -1 is not a valid value. */
private int nextAvailableObjectId = 0;
/**
* Captures and directs item collection changes.
*/
private final class CollectionHandler implements IInlineCollectionObserver, IInlineIndexedCollectionObserver {
/**
* CollectionHandler constructor.
*/
private CollectionHandler() {
}//CollectionHandler()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueAdded(java.lang.Object, int)
*/
public void valueAdded(Object value, int index) {
if(!suspendCollectionHooks) {
itemAdded(value, index);
}//if//
}//valueAdded()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#valueAdded(java.lang.Object)
*/
public void valueAdded(Object value) {
if(!suspendCollectionHooks) {
itemAdded(value, -1);
}//if//
}//valueAdded()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueRemoved(java.lang.Object, int)
*/
public void valueRemoved(Object value, int index) {
if(!suspendCollectionHooks) {
itemRemoved(value, index);
}//if//
}//valueRemoved()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#valueRemoved(java.lang.Object)
*/
public void valueRemoved(Object value) {
if(!suspendCollectionHooks) {
itemRemoved(value, -1);
}//if//
}//valueRemoved()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#removingAll()
*/
public void removingAll() {
if(!suspendCollectionHooks) {
itemAllRemoved();
}//if//
}//removingAll()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineIndexedCollectionObserver#valuesSorted(int[])
*/
public void valuesSorted(int[] mapping) {
if(!suspendCollectionHooks) {
itemSorted(mapping);
}//if//
}//valuesSorted()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#startChanges(int)
*/
public void startChanges(int changeCount) {
addMessageHold();
}//startChanges()//
/* (non-Javadoc)
* @see com.foundation.util.IInlineCollectionObserver#stopChanges()
*/
public void stopChanges() {
removeMessageHold();
}//stopChanges()//
}//CollectionHandler//
/**
* ComboBox 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 #STYLE_DROP_DOWN
* @see #STYLE_READ_ONLY
* @see #STYLE_SIMPLE
*/
public CellComboBox(ICellContainer parent, String name, int style) {
super(parent, name);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {((AbstractComponent) parent).getNumber(), style});
}//ComboBox()//
/**
* Gets the row object metadata for the given object identifier.
* @param objectId The identifying number for the desired collection item's metadata.
* @return The row object for the given identifer.
*/
protected RowObject getRowObject(int objectId) {
return (RowObject) rowObjectByObjectIdMap.get(objectId);
}//getRowObject()//
/**
* Gets the row object metadata for the given object identifier.
* @param item The collection item whose metadata is desired.
* @return The row object for the given collection item.
*/
protected RowObject getRowObject(Object item) {
return (RowObject) rowObjectByValueMap.get(item);
}//getRowObject()//
/**
* Sets the association container used to access the displayed collection.
* @param container The collection association metadata.
*/
public void setCollectionAssociation(SingleAssociationContainer container) {
verifyThread();
this.collection.setAssociations(container);
}//setCollectionAssociation()//
/**
* Sets the association container used to access the selection.
* @param container The selection association metadata.
*/
public void setSelectionAssociation(MultiAssociationContainer container) {
verifyThread();
this.selection.setAssociations(container);
}//setSelectionAssociation()//
/**
* Sets the association container used to access the item text.
* @param container The item text association metadata.
*/
public void setItemTextAssociation(MultiAssociationContainer container) {
verifyThread();
this.itemText.setAssociations(container);
}//setItemTextAssociation()//
/**
* Gets whether the selection will automatically synchronize.
* @return Whether the selection is automatically synchronized from the view to the model when changed, or whether it must be manually synchronized.
*/
protected boolean getAutoSynchronizeSelection() {
return autoSynchronizeSelection;
}//getAutoSynchronizeSelection()//
/**
* Sets whether the selection will automatically synchronize.
* @param autoSynchronizeSelection Whether the selection is automatically synchronized from the view to the model when changed, or whether it must be manually synchronized.
*/
public void setAutoSynchronizeSelection(boolean autoSynchronizeSelection) {
verifyThread();
if(this.autoSynchronizeSelection != autoSynchronizeSelection) {
this.autoSynchronizeSelection = autoSynchronizeSelection;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION, autoSynchronizeSelection ? Boolean.TRUE : Boolean.FALSE);
}//if//
}//setAutoSynchronizeSelection()//
/**
* Gets the number of milliseconds to wait before automatically synchronizing selection changes. This must be a number between zero and ten thousand where zero synchronizes without delay.
* @return The number of milliseconds of delay when auto synchronizing the selection.
*/
protected long getAutoSynchronizeSelectionDelay() {
return autoSynchronizeSelectionDelay;
}//getAutoSynchronizeSelectionDelay()//
/**
* Sets the number of milliseconds to wait before automatically synchronizing selection changes. This must be a number between zero and ten thousand where zero synchronizes without delay.
* @param autoSynchronizeSelectionDelay The number of milliseconds of delay when auto synchronizing the selection.
*/
public void setAutoSynchronizeSelectionDelay(long autoSynchronizeSelectionDelay) {
verifyThread();
if(autoSynchronizeSelectionDelay < 0) {
autoSynchronizeSelectionDelay = 0;
}//if//
else if(autoSynchronizeSelectionDelay > 10000) {
autoSynchronizeSelectionDelay = 10000;
}//else if//
if(this.autoSynchronizeSelectionDelay != autoSynchronizeSelectionDelay) {
this.autoSynchronizeSelectionDelay = autoSynchronizeSelectionDelay;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long(autoSynchronizeSelectionDelay));
}//if//
}//setAutoSynchronizeSelectionDelay()//
/**
* Gets the component text size limit.
* @return The maximum number of characters allowed in the text.
*/
public Integer getTextLimit() {
return textLimit;
}//getTextLimit()//
/**
* Sets the component text size limit.
* @param textLimit The maximum number of characters allowed in the text.
*/
public void setTextLimit(Integer textLimit) {
this.textLimit = textLimit;
sendMessage(MESSAGE_SET_TEXT_LIMIT, textLimit);
}//setTextLimit()//
/**
* Determines whether the control allows the user to type in custom items (combobox).
* @return Whether users will be allowed to type in a custom value.
*/
protected boolean getAllowUserItems() {
return allowUserItems;
}//getAllowUserItems()//
/**
* Determines whether the control allows the user to type in custom items (combobox).
* @param allowUserItems Whether users will be allowed to type in a custom value.
*/
protected void setAllowUserItems(boolean allowUserItems) {
this.allowUserItems = allowUserItems;
}//setAllowUserItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
collection.initialize();
selection.initialize();
itemText.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
collection.release();
selection.release();
itemText.release();
//Remove all mappings.//
rowObjectByObjectIdMap.removeAll();
rowObjectByValueMap.removeAll();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
internalViewRefreshCollection();
super.internalViewRefresh();
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRefresh(com.foundation.tcv.swt.server.RowObject)
*/
protected void internalViewRefresh(RowObject rowObject) {
internalViewRefreshSelection(rowObject);
internalViewRefreshItemText(rowObject);
super.internalViewRefresh(rowObject);
}//internalViewRefresh()//
/**
* Refreshes the collection.
*/
protected final void internalViewRefreshCollection() {
if(collection.refresh()) {
ICollection oldCollection = currentCollection;
if((collection.getValue() == null) || (collection.getValue() instanceof ICollection)) {
currentCollection = (ICollection) collection.getValue();
}//if//
else if(collection.getValue() instanceof Object[]) {
currentCollection = new LiteList((Object[]) collection.getValue());
}//else if//
else {
currentCollection = new LiteList(collection.getValue());
}//else//
if(oldCollection != null) {
unregisterCollectionItems();
unregisterCollectionHooks(oldCollection, collectionHandler);
}//if//
if(currentCollection != null) {
suspendCollectionHooks = true;
registerCollectionHooks(currentCollection, collectionHandler);
suspendCollectionHooks = false;
}//if//
internalViewRefreshCollection(currentCollection, oldCollection);
//Force the selection to be updated.//
internalViewRefreshSelection(true);
}//if//
}//internalViewRefreshCollection()//
/**
* Refreshes the collection.
* <p>Note: The implementor must call itemAllRemoved() and itemAdded(Object) to remove the old items and unregister them and to add the new items and register them.</p>
* @param newCollection The new collection of items in the component.
* @param oldCollection The old collection of items in the component.
*/
protected void internalViewRefreshCollection(ICollection newCollection, ICollection oldCollection) {
//Remove all listeners, mappings, and metadata.//
itemAllRemoved();
if((newCollection != null) && (newCollection.getSize() > 0)) {
IIterator iterator = newCollection.iterator();
String[] itemData = newCollection.getSize() > 0 ? new String[newCollection.getSize()] : null;
int[] objectIds = itemData != null ? new int[itemData.length] : null;
int index = 0;
//Get the array of strings representing the list contents.//
while(iterator.hasNext()) {
Object value = iterator.next();
//Add the item mappings without notifying the client.//
if(itemAdded(value, index, false)) {
itemData[index] = null;
}//if//
else {
//Add the value to the item array.//
itemData[index] = getItemText(value);
}//else//
objectIds[index] = getRowObject(value).objectId;
index++;
}//while//
//Set the collection contents.//
sendMessage(MESSAGE_SET_ITEMS, itemData, objectIds, -1, -1);
//If the selection was invalid previously then refresh the selection since it may no longer be invalid.//
if(isSelectionInvalid) {
internalViewRefreshSelection(false);
}//if//
}//if//
else {
//Remove all collection contents.//
sendMessage(MESSAGE_REMOVE_ALL, null);
}//else//
}//internalViewRefreshCollection()//
/**
* Refreshes the selection for all rows.
* @param force Whether the selection refresh should be forced even if the selection shouldn't need refreshing. This allows the collection refresh to insist that the selection get refreshed after the collection has been changed to ensure that the state is correct.
*/
protected final void internalViewRefreshSelection(boolean force) {
IIterator iterator = getCellContainer().getRowObjects();
//TODO: Should we make this more efficient by bulk sending the data?
while(iterator.hasNext()) {
RowObject rowObject = (RowObject) iterator.next();
if(selection.isRegistered(rowObject.value) && (selection.refresh(rowObject.value) || isSelectionInvalid || force)) {
Object selectedItem = selection.getValue(rowObject.value);
internalViewRefreshSelection(rowObject, selectedItem);
}//if//
}//while//
}//internalViewRefreshSelection()//
/**
* Refreshes the selection.
* @param rowObject The row object referencing the model object for the row in which the combo box resides whose selection we are refreshing.
*/
protected final void internalViewRefreshSelection(RowObject rowObject) {
if(selection.refresh(rowObject.value) || isSelectionInvalid) {
Object selectedItem = selection.getValue(rowObject.value);
internalViewRefreshSelection(rowObject, selectedItem);
}//if//
}//internalViewRefreshSelection()//
/**
* Refreshes the selection.
* @param rowObject The row object referencing the model object for the row in which the combo box resides whose selection we are refreshing.
* @param selectedItem The new selected item.
*/
protected void internalViewRefreshSelection(RowObject rowObject, Object selectedItem) {
//Send selection index or indices to the remote control where it will determine whether the selection should be changed.//
//Again: What to do about impossible selections?//
int objectId;
if(selectedItem != null) {
RowObject selectionRowObject = getRowObject(selectedItem);
objectId = selectionRowObject == null ? INVALID_OBJECT_ID : selectionRowObject.objectId;
if((objectId == -1) && (getAllowUserItems())) {
sendMessage(MESSAGE_SET_SELECTION, selectedItem.toString(), null, -1, rowObject.objectId);
}//if//
else if(objectId == -1) {
isSelectionInvalid = true;
//Note: We are no longer invalidating the model selection since this may be a valid action given that the selection may be attached to an attribute that is also attached to another component.//
sendMessage(MESSAGE_SET_SELECTION, null, null, -1, rowObject.objectId);
}//else if//
else {
isSelectionInvalid = false;
//Send selection.//
sendMessage(MESSAGE_SET_SELECTION, null, null, objectId, rowObject.objectId);
}//else//
}//if//
else {
//No selection.//
sendMessage(MESSAGE_SET_SELECTION, null, null, -1, rowObject.objectId);
}//else//
}//internalViewRefreshSelection()//
/**
* Refreshes the item text.
* @param rowObject The collection row whose state is being updated.
*/
protected void internalViewRefreshItemText(RowObject rowObject) {
if(itemText.refresh(rowObject.value)) {
sendMessage(MESSAGE_SET_ITEM_TEXT, itemText.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshItemText()//
/**
* Registers the collection hooks that allow the component to receive collection changes.
* @param collection The collection whose associated hooks are to be added.
*/
protected void registerCollectionHooks(ICollection collection, Object listener) {
if(collection instanceof IInlineIndexedCollectionObservable) {
((IInlineIndexedCollectionObservable) collection).addCollectionObserver((IInlineIndexedCollectionObserver) listener);
}//if//
else if(collection instanceof IInlineCollectionObservable) {
((IInlineCollectionObservable) collection).addCollectionObserver((IInlineCollectionObserver) listener);
}//else if//
}//registerCollectionHooks()//
/**
* Unregisters the collection hooks that allow the component to receive collection changes.
* @param collection The collection whose associated hooks are to be removed.
*/
protected void unregisterCollectionHooks(ICollection collection, Object listener) {
if(collection instanceof IInlineIndexedCollectionObservable) {
((IInlineIndexedCollectionObservable) collection).removeCollectionObserver((IInlineIndexedCollectionObserver) listener);
}//if//
else if(collection instanceof IInlineCollectionObservable) {
((IInlineCollectionObservable) collection).removeCollectionObserver((IInlineCollectionObserver) listener);
}//else if//
}//unregisterCollectionHooks()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(collection == resourceAssociation) {
internalViewRefreshCollection();
}//if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object)
*/
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
if(selection == resourceAssociation) {
internalViewRefreshSelection(getCellContainer().getRowObject(alteredItem));
}//else if//
else if(itemText == resourceAssociation) {
internalViewRefreshItemText(getCellContainer().getRowObject(alteredItem));
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, alteredItem, data, isUpdate);
}//else//
}//internalOnValueChanged()//
/**
* Registers the collection item with any necessary listeners.
* @param item The item in the collection being displayed.
*/
protected void registerCollectionItem(Object item) {
itemText.registerItem(item);
}//registerCollectionItem()//
/**
* Unregisters the collection item with any listeners previously registered.
* @param item The item no longer in the collection being displayed.
*/
protected void unregisterCollectionItem(Object item) {
itemText.unregisterItem(item);
}//unregisterCollectionItem()//
/**
* Unregisters all the collection items with any listeners previously registered.
*/
protected void unregisterCollectionItems() {
itemText.unregisterAllItems();
}//unregisterCollectionItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#registerRowItem(com.foundation.tcv.swt.server.RowObject)
*/
public void registerRowItem(RowObject rowObject) {
selection.registerItem(rowObject.value, rowObject);
super.registerRowItem(rowObject);
}//registerRowItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#unregisterRowItem(com.foundation.tcv.swt.server.RowObject)
*/
public void unregisterRowItem(RowObject rowObject) {
selection.unregisterItem(rowObject.value);
super.unregisterRowItem(rowObject);
}//unregisterRowItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#unregisterRowItems()
*/
public void unregisterRowItems() {
selection.unregisterAllItems();
super.unregisterRowItems();
}//unregisterRowItems()//
/**
* Called when an item is added to the collection.
* @param item The item added.
* @return Whether the item was previously added and is a duplicate. This is handy information if the client is being bulk notified.
*/
protected boolean itemAdded(Object item) {
return itemAdded(item, -1, true);
}//itemAdded()//
/**
* Called when an item is added to the collection.
* @param item The item added.
* @param notifyClient Whether the client should be notified. This can be false if the client will be notified separately as done when bulk adding.
* @return Whether the item was previously added and is a duplicate. This is handy information if the client is being bulk notified.
*/
protected boolean itemAdded(Object item, boolean notifyClient) {
return itemAdded(item, -1, notifyClient);
}//itemAdded()//
/**
* Called when an item is added to the collection.
* @param item The item added.
* @param itemIndex The index of the item which may be used by the client to order the item.
* @return Whether the item was previously added and is a duplicate. This is handy information if the client is being bulk notified.
*/
protected boolean itemAdded(Object item, int itemIndex) {
return itemAdded(item, itemIndex, true);
}//itemAdded()//
/**
* Called when an item is added to the collection.
* @param item The item added.
* @param itemIndex The index of the item which may be used by the client to order the item.
* @param notifyClient Whether the client should be notified. This can be false if the client will be notified separately as done when bulk adding.
* @return Whether the item was previously added and is a duplicate. This is handy information if the client is being bulk notified.
*/
protected boolean itemAdded(Object item, int itemIndex, boolean notifyClient) {
RowObject rowObject = (RowObject) rowObjectByValueMap.get(item);
boolean alreadyAdded = false;
//Add a row object as necessary.//
if(rowObject != null) {
//Increment the reference count so we know when to release the item metadata.//
rowObject.referenceCount++;
if(notifyClient) {
//Notify the client of the item's addition.//
sendAddItemMessage(rowObject, itemIndex, false);
}//if//
//Notify the caller that the item was previously added.//
alreadyAdded = true;
}//if//
else {
//Create a new row object to contain the metadata for the item.//
rowObject = createRowObject(item, nextAvailableObjectId++);
//Add the object to the mappings.//
rowObjectByObjectIdMap.put(rowObject.objectId, rowObject);
rowObjectByValueMap.put(item, rowObject);
//Register the item with any handlers.//
registerCollectionItem(item);
if(notifyClient) {
//Notify the client of the item's addition.//
sendAddItemMessage(rowObject, itemIndex, true);
}//if//
}//else//
return alreadyAdded;
}//itemAdded()//
/**
* Called when an item is added to the collection and the row object metadata should not be mapped by the item reference.
* @param item The item added.
* @param itemIndex The index of the item which may be used by the client to order the item.
* @param notifyClient Whether the client should be notified. This can be false if the client will be notified separately as done when bulk adding.
* @return The row object that was created for the item.
*/
protected RowObject unmappedItemAdded(Object item, int itemIndex, boolean notifyClient) {
RowObject rowObject = createRowObject(item, nextAvailableObjectId++);
//Add the object to the mappings.//
rowObjectByObjectIdMap.put(rowObject.objectId, rowObject);
rowObjectByValueMap.put(item, rowObject);
//Register the item with any handlers.//
registerCollectionItem(item);
if(notifyClient) {
//Notify the client of the item's addition.//
sendAddItemMessage(rowObject, itemIndex, false);
}//if//
return rowObject;
}//unmappedItemAdded()//
/**
* Called when an item is removed from the collection.
* @param item The item removed.
*/
protected void itemRemoved(Object item) {
itemRemoved(item, -1, true);
}//itemRemoved()//
/**
* Called when an item is removed from the collection.
* @param item The item removed.
* @param itemIndex The item's index which can be -1 if not valid.
*/
protected void itemRemoved(Object item, int itemIndex) {
itemRemoved(item, itemIndex, true);
}//itemRemoved()//
/**
* Called when an item is removed from the collection.
* @param item The item removed.
* @param itemIndex The index of the item which may be used by the client to order the item.
* @return Whether the item was completely removed. This may be false if the item was added multiple times.
*/
protected boolean itemRemoved(Object item, int itemIndex, boolean notifyClient) {
RowObject rowObject = (RowObject) rowObjectByValueMap.get(item);
//Verify that the item was previously added.//
if(rowObject != null) {
//Unregister the item with any handlers.//
unregisterCollectionItem(item);
//Release the row object or decrement the row object reference count.//
if(rowObject.referenceCount == 1) {
rowObjectByObjectIdMap.remove(rowObject.objectId);
rowObjectByValueMap.remove(item);
rowObject.value = null;
}//if//
else {
rowObject.referenceCount--;
}//else//
if(notifyClient) {
//Notify the client of the item's removal.//
sendRemoveItemMessage(rowObject, itemIndex, rowObject.referenceCount == 0);
}//if//
}//if//
else {
Debug.log(new RuntimeException("Error: Couldn't find the collection item being removed."));
}//else//
return rowObject.referenceCount == 0;
}//itemRemoved()//
/**
* Called when an item is removed from the collection.
* @param item The item removed.
* @param itemIndex The index of the item which may be used by the client to order the item.
* @param notifyClient Whether the client should be notified. This allows the caller to bulk send notifications.
*/
protected void unmappedItemRemoved(RowObject rowObject, int itemIndex, boolean notifyClient) {
//Unregister the item with any handlers.//
unregisterCollectionItem(rowObject.value);
//Release the row object or decrement the row object reference count.//
if(rowObject.referenceCount == 1) {
rowObjectByObjectIdMap.remove(rowObject.objectId);
rowObject.value = null;
}//if//
else {
Debug.log(new RuntimeException("Error: Cannot allow a reference counter > 1 for an unmapped item!"));
}//else//
if(notifyClient) {
//Notify the client of the item's removal.//
sendRemoveItemMessage(rowObject, itemIndex, true);
}//if//
}//unmappedItemRemoved()//
/**
* Sends the MESSAGE_ADD_ITEM message to the client.
* <p>This can be overloaded to send additional data as required by the client control.</p>
* @param rowObject The row object that is being added.
* @param itemIndex The optional index for the item, or -1 if not valid.
* @param isBrandNew Whether the item is completely new, otherwise the item was previously added and this add just increments the counter.
*/
protected void sendAddItemMessage(RowObject rowObject, int itemIndex, boolean isBrandNew) {
sendMessage(MESSAGE_ADD_ITEM, !isBrandNew ? null : getItemText(rowObject.value), null, rowObject.objectId, itemIndex);
}//sendAddItemMessage()//
/**
* Sends the MESSAGE_REMOVED_ITEM message to the client.
* <p>This can be overloaded to send additional data as required by the client control.</p>
* @param rowObject The row object that is being removed.
* @param itemIndex The optional index for the item, or -1 if not valid.
* @param isRemovedEntirely Whether the item has been completely removed from the collection. Otherwise the item's reference count has simply been decremented.
*/
protected void sendRemoveItemMessage(RowObject rowObject, int itemIndex, boolean isRemovedEntirely) {
sendMessage(MESSAGE_REMOVE_ITEM, null, null, rowObject.objectId, itemIndex);
}//sendRemoveItemMessage()//
/**
* Called when all the items are removed from the collection.
*/
protected void itemAllRemoved() {
//Unregister the items with any handlers.//
unregisterCollectionItems();
//Remove all mappings.//
rowObjectByObjectIdMap.removeAll();
rowObjectByValueMap.removeAll();
//Remove all existing items.//
sendMessage(MESSAGE_REMOVE_ALL, null);
}//itemAllRemoved()//
/**
* Creates a new row object that will encapsulate the row metadata.
* <p>Note: This method does not need to check for an existing row object.</p>
* @param item The item the row object represents.
* @param objectId The object identifier assigned to the item.
* @return The row object for the item.
*/
protected RowObject createRowObject(Object item, int objectId) {
return new RowObject(item, objectId);
}//createRowObject()//
/**
* Gets the text associated with the given collection item for use in the display.
* @param item The item whose data is to be collected.
* @return The text that represents the item in the display.
*/
protected String getItemText(Object item) {
String result = null;
itemText.refresh(item);
result = (String) itemText.getValue(item);
if(result == null) {
result = item != null ? item.toString() : "";
}//if//
return result;
}//getItemText()//
/**
* Called when the items have been externally sorted.
* @param mapping A mapping of new positions to old positions. The index is the new position and the value is the old position.
*/
protected void itemSorted(int[] mapping) {
//TODO: Implement if necessary.
}//itemSorted()//
/**
* Refreshes the item data.
* @param item The collection item whose data needs refreshing.
*/
protected void internalViewRefreshItem(Object item) {
//TODO: Should this be called somewhere?
RowObject rowObject = getRowObject(item);
if(rowObject != null) {
sendMessage(MESSAGE_SET_ITEM_TEXT, getItemText(item), null, rowObject.objectId, -1);
}//if//
else {
//Do nothing. It may simply be a stray event (fired before we removed event listeners, but received after they were removed).//
}//else//
}//internalViewRefreshItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#processMessage(com.foundation.tcv.view.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object retVal = null;
switch(viewMessage.getMessageNumber()) {
case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: { //Receive the selection information from the client.//
String text = (String) viewMessage.getMessageData();
int selectionObjectId = viewMessage.getMessageInteger();
int externalObjectId = viewMessage.getMessageSecondaryInteger();
RowObject externalRowObject = getCellContainer().getRowObject(externalObjectId);
if(externalObjectId == -1) {
//TODO: If the user wants numbers only, should the conversion occur on the server or the client?
if((getAllowUserItems()) && (text.length() > 0)) {
//Set the custom value.//
selection.setValue(externalRowObject.value, (String) text);
}//if//
else {
selection.setValue(externalRowObject.value, null);
}//else//
}//if//
else {
selection.setValue(externalRowObject.value, getRowObject(selectionObjectId).value);
}//else//
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.cell.CellComboBox";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return "__CellComboBox__";
}//getName()//
}//ComboBox//

View File

@@ -0,0 +1,456 @@
/*
* 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.cell;
import com.common.util.IIterator;
import com.foundation.tcv.swt.cell.ICellComponent;
import com.foundation.tcv.swt.server.AbstractComponent;
import com.foundation.tcv.swt.server.ICellContainer;
import com.foundation.tcv.swt.server.RowObject;
import com.foundation.view.AssociationContainer;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IVariableResourceAssociationChangeListener;
import com.foundation.view.JefColor;
import com.foundation.view.JefFont;
import com.foundation.view.MultiAssociationContainer;
import com.foundation.view.MultiResourceAssociation;
import com.foundation.view.SingleResourceAssociation;
import com.foundation.view.VariableResourceAssociation;
import com.foundation.view.resource.ResourceReference;
/**
* Provides a base for all cell oriented components used in such controls as the table for rendering and/or editing.
*/
public abstract class CellComponent extends AbstractComponent implements IVariableResourceAssociationChangeListener, ICellComponent {
/** The container for the cell components. This container provides access to the row object metadata. */
private ICellContainer cellContainer = null;
/** The resource defining the enabled state for the component. */
private MultiResourceAssociation isEnabled;
/** The resource defining the tool tip text for the component. */
private VariableResourceAssociation toolTipText;
/** The resource defining the component's background color. */
private VariableResourceAssociation backgroundColor;
/** The resource defining the component's foreground color. */
private VariableResourceAssociation foregroundColor;
/** The font used by the component. */
private VariableResourceAssociation font;
/** The optional decimal scale to be used by the component if it deals with decimal values. */
private Integer decimalScale = null;
/**
* CellComponent default constructor.
* <p>Warning: This is only for use by the framework. This should never be called to create a useable instance.</p>
*/
public CellComponent() {
}//CellComponent()//
/**
* CellComponent constructor.
* @param parent The non-null parent container for this container.
* @param name The component's name. This allows lookup of components in the view by the name.
*/
public CellComponent(ICellContainer parent, String name) {
super(((AbstractComponent) parent).getSessionViewController());
cellContainer = (ICellContainer) parent;
cellContainer.addCellComponent(this);
isEnabled = new MultiResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_BOOLEAN, false, Boolean.TRUE);
toolTipText = new VariableResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_TEXT, false, null);
backgroundColor = new VariableResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_COLOR, false, null);
foregroundColor = new VariableResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_COLOR, false, null);
font = new VariableResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_FONT, false, null);
}//CellComponent()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getContainer()
*/
public IAbstractContainer getContainer() {
return cellContainer.getContainer();
}//getContainer()//
/**
* Gets the cell container which provides row metadata.
* @return The cell container for the cell component.
*/
public ICellContainer getCellContainer() {
return cellContainer;
}//getCellContainer()//
/**
* Sets the association container used to access the enabled state.
* @param container The enabled state association metadata.
*/
public void setIsEnabledAssociation(MultiAssociationContainer container) {
verifyThread();
this.isEnabled.setAssociations(container);
}//setIsEnabledAssociation()//
/**
* Sets the association container used to access the foreground color.
* @param container The foreground color association metadata.
*/
public void setForegroundColorAssociation(AssociationContainer container) {
verifyThread();
this.foregroundColor.setAssociations(container);
}//setForegroundColorAssociation()//
/**
* Sets the association container used to access the background color.
* @param container The background color association metadata.
*/
public void setBackgroundColorAssociation(AssociationContainer container) {
verifyThread();
this.backgroundColor.setAssociations(container);
}//setBackgroundColorAssociation()//
/**
* Sets the association container used to access the font.
* @param container The font association metadata.
*/
public void setFontAssociation(AssociationContainer container) {
verifyThread();
this.font.setAssociations(container);
}//setFontAssociation()//
/**
* Sets the association container used to access the tool tip.
* @param container The tool tip association metadata.
*/
public void setToolTipTextAssociation(AssociationContainer container) {
verifyThread();
this.toolTipText.setAssociations(container);
}//setToolTipTextAssociation()//
/**
* Sets whether the component is enabled (by default if an attribute is bound to this value).
* @param isEnabled Whether the user can interact with the component.
*/
public void setIsEnabled(boolean isEnabled) {
verifyThread();
this.isEnabled.setDefaultValue(isEnabled ? Boolean.TRUE : Boolean.FALSE);
}//setIsEnabled()//
/**
* Sets the default enabled state resource.
* @param isEnabled Whether the user can interact with the component.
*/
public void setIsEnabled(ResourceReference isEnabled) {
verifyThread();
this.isEnabled.setDefaultValue(isEnabled);
}//setIsEnabled()//
/**
* Sets the component's default tool tip text.
* @param toolTipText The tool tip text to be displayed by this component.
*/
public void setToolTipText(String toolTipText) {
verifyThread();
this.toolTipText.setDefaultValue(toolTipText);
}//setToolTipText()//
/**
* Sets the component's default tool tip text resource.
* @param tooltipText The tool tip text to be displayed by this component.
*/
public void setToolTipText(ResourceReference toolTipText) {
verifyThread();
this.toolTipText.setDefaultValue(toolTipText);
}//setToolTipText()//
/**
* Sets the component's default background color.
* @param backgroundColor The default background color.
*/
public void setBackgroundColor(JefColor backgroundColor) {
verifyThread();
this.backgroundColor.setDefaultValue(backgroundColor);
}//setBackgroundColor()//
/**
* Sets the component's default background color resource.
* @param backgroundColor The default background color resource.
*/
public void setBackgroundColor(ResourceReference backgroundColor) {
verifyThread();
this.backgroundColor.setDefaultValue(backgroundColor);
}//setBackgroundColor()//
/**
* Sets the component's default foreground color.
* @param foregroundColor The default foreground color.
*/
public void setForegroundColor(JefColor foregroundColor) {
verifyThread();
this.foregroundColor.setDefaultValue(foregroundColor);
}//setForegroundColor()//
/**
* Sets the component's default foreground color resource.
* @param foregroundColor The default foreground color resource.
*/
public void setForegroundColor(ResourceReference foregroundColor) {
verifyThread();
this.foregroundColor.setDefaultValue(foregroundColor);
}//setForegroundColor()//
/**
* Sets the default font.
* @param font The default font.
*/
public void setFont(JefFont[] font) {
verifyThread();
this.font.setDefaultValue(font);
}//setFont()//
/**
* Sets the default font resource.
* @param font The default font resource.
*/
public void setFont(ResourceReference font) {
verifyThread();
this.font.setDefaultValue(font);
}//setFont()//
/**
* Gets the optional decimal scale to be used by the component if it deals with decimal values.
* @return The optional decimal scale which if negative by default should trim extra zeros (note that BigDecimal does not automatically do this).
*/
public Integer getDecimalScale() {
verifyThread();
return decimalScale;
}//getDecimalScale()//
/**
* Sets the optional decimal scale to be used by the component if it deals with decimal values.
* @param decimalScale The optional decimal scale which if negative by default should trim extra zeros (note that BigDecimal does not automatically do this).
*/
public void setDecimalScale(Integer decimalScale) {
verifyThread();
if(decimalScale != this.decimalScale) {
this.decimalScale = decimalScale;
sendMessage(MESSAGE_SET_DECIMAL_SCALE, decimalScale);
}//if//
}//setDecimalScale()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
super.internalViewInitializeAll();
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefreshAll()
*/
protected void internalViewRefreshAll() {
super.internalViewRefreshAll();
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewReleaseAll()
*/
protected void internalViewReleaseAll() {
super.internalViewReleaseAll();
}//internalViewReleaseAll()//
/* (non-Javadoc)
* @see com.foundation.view.swt.AbstractComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
backgroundColor.initialize();
foregroundColor.initialize();
font.initialize();
isEnabled.initialize();
toolTipText.initialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.view.swt.AbstractComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
IIterator iterator;
super.internalViewRefresh();
//Refresh any single resource associations.//
internalViewRefreshToolTipText();
internalViewRefreshBackgroundColor();
internalViewRefreshForegroundColor();
internalViewRefreshFont();
iterator = getCellContainer().getRowObjects();
//Refresh any multi resource associations.//
while(iterator.hasNext()) {
internalViewRefresh((RowObject) iterator.next());
}//while//
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.view.swt.AbstractComponent#internalViewRelease()
*/
protected void internalViewRelease() {
backgroundColor.release();
foregroundColor.release();
font.release();
isEnabled.release();
toolTipText.release();
super.internalViewRelease();
}//internalViewRelease()//
/**
* Refreshes the component for the given row.
* @param rowObject The object representing the row to be refreshed.
*/
public final void viewRefresh(RowObject rowObject) {
internalViewRefresh(rowObject);
}//viewRefresh()//
/**
* Refreshes the given cell control.
* @param rowObject The row to update with the latest state.
*/
protected void internalViewRefresh(RowObject rowObject) {
//Refresh the background, foreground, font, enabled state, and tool tip text.//
internalViewRefreshIsEnabled(rowObject);
internalViewRefreshToolTipText(rowObject);
internalViewRefreshBackgroundColor(rowObject);
internalViewRefreshForegroundColor(rowObject);
internalViewRefreshFont(rowObject);
}//internalViewRefresh()//
/**
* Refreshes whether the component is enabled based on the attribute value or if null the default flag value.
* @param cellControl The control to update with the latest state.
*/
protected void internalViewRefreshIsEnabled(RowObject rowObject) {
if(isEnabled.refresh(rowObject.value)) {
sendMessage(MESSAGE_SET_IS_ENABLED, isEnabled.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshIsEnabled()//
/**
* Refreshes the tool tip text from the tool tip text attribute and the default tool tip text.
* @param cellControl The control to update with the latest state.
*/
protected void internalViewRefreshToolTipText(RowObject rowObject) {
if(toolTipText.isMulti() && toolTipText.refresh(rowObject.value)) {
sendMessage(MESSAGE_SET_TOOL_TIP_TEXT, toolTipText.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshToolTipText()//
/**
* Refreshes the tool tip text from the tool tip text attribute and the default tool tip text.
*/
protected void internalViewRefreshToolTipText() {
if(toolTipText.isSingle() && toolTipText.refresh(null)) {
sendMessage(MESSAGE_SET_TOOL_TIP_TEXT, toolTipText.getValue(null), null, -1, 0);
}//if//
}//internalViewRefreshToolTipText()//
/**
* Refreshes the component's background color.
* @param cellControl The control to update with the latest state.
*/
protected void internalViewRefreshBackgroundColor(RowObject rowObject) {
if(backgroundColor.isMulti() && backgroundColor.refresh(rowObject.value)) {
sendMessage(MESSAGE_SET_BACKGROUND_COLOR, backgroundColor.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshBackgroundColor()//
/**
* Refreshes the component's background color.
*/
protected void internalViewRefreshBackgroundColor() {
if(backgroundColor.isSingle() && backgroundColor.refresh(null)) {
sendMessage(MESSAGE_SET_BACKGROUND_COLOR, backgroundColor.getValue(null), null, -1, 0);
}//if//
}//internalViewRefreshBackgroundColor()//
/**
* Refreshes the component's foreground color.
* @param cellControl The control to update with the latest state.
*/
protected void internalViewRefreshForegroundColor(RowObject rowObject) {
if(foregroundColor.isMulti() && foregroundColor.refresh(rowObject.value)) {
sendMessage(MESSAGE_SET_FOREGROUND_COLOR, foregroundColor.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshForegroundColor()//
/**
* Refreshes the component's foreground color.
*/
protected void internalViewRefreshForegroundColor() {
if(foregroundColor.isSingle() && foregroundColor.refresh(null)) {
sendMessage(MESSAGE_SET_FOREGROUND_COLOR, foregroundColor.getValue(null), null, -1, 0);
}//if//
}//internalViewRefreshForegroundColor()//
/**
* Refreshes the component's font.
* @param cellControl The control to update with the latest state.
*/
protected void internalViewRefreshFont(RowObject rowObject) {
if(font.isMulti() && font.refresh(rowObject.value)) {
sendMessage(MESSAGE_SET_FONTS, font.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshFont()//
/**
* Refreshes the component's font.
*/
protected void internalViewRefreshFont() {
if(font.isSingle() && font.refresh(null)) {
sendMessage(MESSAGE_SET_FONTS, font.getValue(null), null, -1, 0);
}//if//
}//internalViewRefreshFont()//
/* (non-Javadoc)
* @see com.foundation.view.swt.AbstractComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object)
*/
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
if(resourceAssociation == isEnabled) {
internalViewRefreshIsEnabled(getCellContainer().getRowObject(alteredItem));
}//if//
else if(toolTipText.hasAssociation(resourceAssociation)) {
internalViewRefreshToolTipText(getCellContainer().getRowObject(alteredItem));
}//else if//
else if(backgroundColor.hasAssociation(resourceAssociation)) {
internalViewRefreshBackgroundColor(getCellContainer().getRowObject(alteredItem));
}//else if//
else if(foregroundColor.hasAssociation(resourceAssociation)) {
internalViewRefreshForegroundColor(getCellContainer().getRowObject(alteredItem));
}//else if//
else if(font.hasAssociation(resourceAssociation)) {
internalViewRefreshFont(getCellContainer().getRowObject(alteredItem));
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, alteredItem, data, isUpdate);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.view.swt.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(toolTipText.hasAssociation(resourceAssociation)) {
internalViewRefreshToolTipText();
}//if//
else if(backgroundColor.hasAssociation(resourceAssociation)) {
internalViewRefreshBackgroundColor();
}//else if//
else if(foregroundColor.hasAssociation(resourceAssociation)) {
internalViewRefreshForegroundColor();
}//else if//
else if(font.hasAssociation(resourceAssociation)) {
internalViewRefreshFont();
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/**
* Registers a row object with the component.
* @param rowObject The row metadata.
*/
public void registerRowItem(RowObject rowObject) {
toolTipText.registerItem(rowObject.value, rowObject);
isEnabled.registerItem(rowObject.value, rowObject);
backgroundColor.registerItem(rowObject.value, rowObject);
foregroundColor.registerItem(rowObject.value, rowObject);
font.registerItem(rowObject.value, rowObject);
}//registerRowItem()//
/**
* Unregisters a row item from the component.
* @param rowObject The row metadata.
*/
public void unregisterRowItem(RowObject rowObject) {
toolTipText.unregisterItem(rowObject.value);
isEnabled.unregisterItem(rowObject.value);
backgroundColor.unregisterItem(rowObject.value);
foregroundColor.unregisterItem(rowObject.value);
font.unregisterItem(rowObject.value);
}//unregisterRowItem()//
/**
* Unregisters all row items from the component.
*/
public void unregisterRowItems() {
toolTipText.unregisterAllItems();
isEnabled.unregisterAllItems();
backgroundColor.unregisterAllItems();
foregroundColor.unregisterAllItems();
font.unregisterAllItems();
}//unregisterRowItems()//
/**
* Sets the layout data for the component.
* @param layoutData The data that describes how the component is to be layed out within its parent.
*/
public void setLayoutData(Object layoutData) {
verifyThread();
sendMessage(MESSAGE_SET_LAYOUT_DATA, layoutData);
}//setLayoutData()//
}//CellComponent//

View File

@@ -0,0 +1,177 @@
/*
* 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.cell;
import com.common.util.IIterator;
import com.common.util.IList;
import com.common.util.LiteList;
import com.foundation.tcv.swt.server.ICellContainer;
import com.foundation.tcv.swt.server.Layout;
import com.foundation.tcv.swt.server.RowObject;
public abstract class CellContainer extends CellComponent implements ICellContainer, com.foundation.tcv.swt.cell.ICellContainer {
/** A collection of components contained by this container. */
private IList cellComponents = null;
/** The container's layout. */
private Layout layout = null;
/**
* CellContainer constructor.
*/
public CellContainer() {
}//CellContainer()//
/**
* CellContainer constructor.
* @param parent The non-null parent container for this container.
* @param name The component's name. This allows lookup of components in the view by the name.
*/
public CellContainer(ICellContainer parent, String name) {
super(parent, name);
}//CellContainer()//
/**
* Sets the container layout.
* @param layout The layout for the container.
*/
public void setLayout(Layout layout) {
verifyThread();
if(this.layout != null) {
throw new RuntimeException("Cannot change the layout once set.");
}//if//
else if(isInitialized()) {
throw new RuntimeException("Cannot set the layout once the view is initialized.");
}//else if//
this.layout = layout;
}//setLayout()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
super.internalViewInitialize();
if(layout != null) {
layout.initialize();
}//if//
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
super.internalViewRefresh();
if(layout != null) {
layout.refresh();
}//if//
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRelease()
*/
protected void internalViewRelease() {
if(layout != null) {
layout.release();
}//if//
super.internalViewRelease();
}//internalViewRelease()//
/**
* Sets the tabbing order for the controls in the container.
* @param tabOrder The collection of controls in the order they are to be tabbed over.
*/
public void setTabOrder(CellComponent[] tabOrder) {
int[] tabOrderNumbers = new int[tabOrder.length];
verifyThread();
for(int index = 0; index < tabOrder.length; index++) {
tabOrderNumbers[index] = tabOrder[index].getNumber();
}//for//
sendMessage(MESSAGE_SET_TAB_ORDER, tabOrderNumbers);
}//setTabOrder()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.ICellContainer#getRowObject(int)
*/
public RowObject getRowObject(int objectId) {
return getCellContainer().getRowObject(objectId);
}//getRowObject()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.ICellContainer#getRowObject(java.lang.Object)
*/
public RowObject getRowObject(Object item) {
return getCellContainer().getRowObject(item);
}//getRowObject()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.ICellContainer#getRowObjects()
*/
public IIterator getRowObjects() {
return getCellContainer().getRowObjects();
}//getRowObjects()//
/* (non-Javadoc)
* @see com.foundation.view.swt.ICompositeCellContainer#addCellComponent(com.foundation.view.swt.cell.CellComponent)
*/
public void addCellComponent(CellComponent component) {
if(cellComponents == null) {
cellComponents = new LiteList(10, 20);
}//if//
cellComponents.add(component);
}//addCellComponent()//
/**
* Gets the collection of cell components for this container.
* @return The cell components contained within this container.
*/
public IList getCellComponents() {
return cellComponents == null ? LiteList.EMPTY_LIST : cellComponents;
}//getCellComponents()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitializeAll()
*/
protected void internalViewInitializeAll() {
super.internalViewInitializeAll();
if(cellComponents != null) {
for(int index = 0; index < cellComponents.getSize(); index++) {
((CellComponent) cellComponents.get(index)).internalViewInitializeAll();
}//for//
}//if//
}//internalViewInitializeAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRefreshAll()
*/
protected void internalViewRefreshAll() {
super.internalViewRefreshAll();
if(cellComponents != null) {
for(int index = 0; index < cellComponents.getSize(); index++) {
((CellComponent) cellComponents.get(index)).internalViewRefreshAll();
}//for//
}//if//
}//internalViewRefreshAll()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewReleaseAll()
*/
protected void internalViewReleaseAll() {
super.internalViewReleaseAll();
if(cellComponents != null) {
for(int index = 0; index < cellComponents.getSize(); index++) {
((CellComponent) cellComponents.get(index)).internalViewReleaseAll();
}//for//
}//if//
}//internalViewReleaseAll()//
/**
* Sets the background inheritance for all children.
* @param inherit Whether the background of this composite should be inherited by all child controls. The default value will cause children that don't specify otherwise to inherit the background.
* @see #INHERIT_NONE
* @see #INHERIT_DEFAULT
* @see #INHERIT_FORCE
*/
public void setInheritBackground(int inheritType) {
sendMessage(MESSAGE_SET_INHERIT_BACKGROUND, null, null, inheritType, -1);
}//setInheritBackground()//
}//CellContainer//

View File

@@ -0,0 +1,172 @@
/*
* 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.cell;
import java.util.Date;
import com.foundation.tcv.swt.cell.ICellDateTime;
import com.foundation.tcv.swt.server.AbstractComponent;
import com.foundation.tcv.swt.server.ICellContainer;
import com.foundation.tcv.swt.server.RowObject;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.MultiAssociationContainer;
import com.foundation.view.MultiResourceAssociation;
public class CellDateTime extends CellComponent implements ICellDateTime {
/** The control's selection state resource. */
private MultiResourceAssociation selection = new MultiResourceAssociation(this, this, getViewContext(), MultiResourceAssociation.TYPE_DATE, true, null);
/** The delay to be used when auto synchronizing changes. */
private long autoSynchronizeSelectionDelay = 500;
/** Whether the button's selection state (for check boxes and the like) should be synchronized by the client when changed. */
private boolean autoSynchronizeSelection = false;
/**
* CellDateTime 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 #STYLE_DATE
* @see #STYLE_TIME
* @see #STYLE_CALENDAR
* @see #STYLE_SHORT
* @see #STYLE_MEDIUM
* @see #STYLE_LONG
*/
public CellDateTime(ICellContainer parent, String name, int style) {
super(parent, name);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, null, null, ((AbstractComponent) parent).getNumber(), style);
}//CellDateTime()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return "__CellDateTime__";
}//getName()//
/**
* Sets the association container used to access the selection.
* @param container The selection association metadata.
*/
public void setSelectionAssociation(MultiAssociationContainer container) {
verifyThread();
this.selection.setAssociations(container);
}//setSelectionAssociation()//
/**
* Sets the delay for the auto synchronize selection.
* @param autoSynchronizeSelectionDelay The delay in terms of milliseconds between the value of zero and ten thousand. A zero value has no delay.
*/
public void setAutoSynchronizeSelectionDelay(long autoSynchronizeSelectionDelay) {
verifyThread();
if(autoSynchronizeSelectionDelay < 0) {
autoSynchronizeSelectionDelay = 0;
}//if//
else if(autoSynchronizeSelectionDelay > 10000) {
autoSynchronizeSelectionDelay = 10000;
}//else if//
if(autoSynchronizeSelectionDelay != this.autoSynchronizeSelectionDelay) {
this.autoSynchronizeSelectionDelay = autoSynchronizeSelectionDelay;
sendMessage(MESSAGE_SET_AUTO_SYNCHRONIZE_SELECTION_DELAY, new Long(autoSynchronizeSelectionDelay));
}//if//
}//setAutoSynchronizeSelectionDelay()//
/**
* 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.cell.CellComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
selection.initialize();
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
selection.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRefresh(com.foundation.tcv.swt.server.RowObject)
*/
protected void internalViewRefresh(RowObject rowObject) {
internalViewRefreshSelection(rowObject);
super.internalViewRefresh(rowObject);
}//internalViewRefresh()//
/**
* Refreshes the selection.
* @param rowObject The row whose state is being updated.
*/
protected void internalViewRefreshSelection(RowObject rowObject) {
if(selection.refresh(rowObject.value)) {
sendMessage(MESSAGE_VIEW_REFRESH_SELECTION, selection.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshSelection()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#processMessage(com.foundation.tcv.view.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object result = null;
switch(viewMessage.getMessageNumber()) {
case MESSAGE_VIEW_SYNCHRONIZE_SELECTION: {
Date date = (Date) viewMessage.getMessageData();
RowObject rowObject = getCellContainer().getRowObject(viewMessage.getMessageInteger());
//Update the selection value.//
selection.setValue(date, rowObject.value);
break;
}//case//
default: {
result = super.processMessage(viewMessage);
}//default//
}//switch//
return result;
}//processMessage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#registerRowItem(com.foundation.tcv.swt.server.RowObject)
*/
public void registerRowItem(RowObject rowObject) {
super.registerRowItem(rowObject);
selection.registerItem(rowObject.value, rowObject);
}//registerRowItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#unregisterRowItem(com.foundation.tcv.swt.server.RowObject)
*/
public void unregisterRowItem(RowObject rowObject) {
super.unregisterRowItem(rowObject);
selection.unregisterItem(rowObject.value);
}//unregisterRowItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#unregisterRowItems()
*/
public void unregisterRowItems() {
super.unregisterRowItems();
selection.unregisterAllItems();
}//unregisterRowItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.cell.CellDateTime";
}//getClientClassName()//
}//CellDateTime//

View File

@@ -0,0 +1,51 @@
/*
* 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.cell;
import com.foundation.tcv.swt.cell.ICellPanel;
import com.foundation.tcv.swt.server.AbstractComponent;
import com.foundation.tcv.swt.server.ICellContainer;
public class CellPanel extends CellContainer implements ICellPanel {
/**
* CellPanel 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 #STYLE_NO_BACKGROUND
* @see #STYLE_NO_FOCUS
* @see #STYLE_NO_MERGE_PAINTS
* @see #STYLE_NO_REDRAW_RESIZE
* @see #STYLE_NO_RADIO_GROUP
* @see #STYLE_EMBEDDED
* @see #STYLE_DOUBLE_BUFFERED
* @see #STYLE_H_SCROLL
* @see #STYLE_V_SCROLL
* @see #STYLE_BORDER
* @see #STYLE_LEFT_TO_RIGHT
* @see #STYLE_RIGHT_TO_LEFT
*/
public CellPanel(ICellContainer parent, String name, int style) {
super(parent, name);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {((AbstractComponent) parent).getNumber(), style});
}//CellPanel()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.cell.CellPanel";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return "__CellPanel__";
}//getName()//
}//CellPanel//

View File

@@ -0,0 +1,228 @@
/*
* 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.cell;
import java.math.BigDecimal;
import com.foundation.tcv.swt.cell.IProgress;
import com.foundation.tcv.swt.server.AbstractComponent;
import com.foundation.tcv.swt.server.ICellContainer;
import com.foundation.tcv.swt.server.RowObject;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.MultiAssociationContainer;
import com.foundation.view.MultiResourceAssociation;
import com.foundation.view.SingleAssociationContainer;
import com.foundation.view.SingleResourceAssociation;
public class CellProgress extends CellComponent implements IProgress {
/** The progress' maximum resource which bounds the progress states. */
private SingleResourceAssociation maximum = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' minimum resource which bounds the progress states. */
private SingleResourceAssociation minimum = new SingleResourceAssociation(this, this, getViewContext(), SingleResourceAssociation.TYPE_INTEGER, false, new Integer(0));
/** The progress' progress resource which defines the current progress state. */
private MultiResourceAssociation progress = new MultiResourceAssociation(this, this, getViewContext(), MultiResourceAssociation.TYPE_BIG_DECIMAL, false, new Integer(0));
/**
* Progress 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 CellProgress(ICellContainer parent, String name, int style) {
super(parent, name);
//Initialize the client component.//
sendMessage(MESSAGE_INITIALIZE, new int[] {((AbstractComponent) parent).getNumber(), style});
}//Progress()//
/**
* Sets the multiplier used to construct an integer from the progress value.
* @param multiplier The progress multiplier.
*/
public void setMultiplier(BigDecimal multiplier) {
sendMessage(MESSAGE_SET_MULTIPLIER, multiplier, null, 0, 0);
}//setMultiplier()//
/**
* Sets the component maximum progress value.
* @param maximum The maximum value in the progress range.
*/
public void setMaximum(Integer maximum) {
verifyThread();
this.maximum.setDefaultValue(maximum);
}//setMaximum()//
/**
* Sets the component minimum progress value.
* @param minimum The minimum value in the progress range. This must be greater than or equal to zero.
*/
public void setMinimum(Integer minimum) {
verifyThread();
this.minimum.setDefaultValue(minimum);
}//setMinimum()//
/**
* Sets the component progress value.
* @param progress The current progress value. This must be greater than or equal to the minimum and less than or equal to the maximum.
*/
public void setProgress(BigDecimal progress) {
verifyThread();
this.progress.setDefaultValue(progress);
}//setProgress()//
/**
* Sets the association container used to access the maximum value.
* @param container The maximum value association metadata.
*/
public void setMaximumAssociation(SingleAssociationContainer container) {
verifyThread();
this.maximum.setAssociations(container);
}//setMaximumAssociation()//
/**
* Sets the association container used to access the minimum value.
* @param container The minimum value association metadata.
*/
public void setMinimumAssociation(SingleAssociationContainer container) {
verifyThread();
this.minimum.setAssociations(container);
}//setMinimumAssociation()//
/**
* Sets the association container used to access the progress value.
* @param container The progress value association metadata.
*/
public void setProgressAssociation(MultiAssociationContainer container) {
verifyThread();
this.progress.setAssociations(container);
}//setProgressAssociation()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewInitialize()
*/
protected void internalViewInitialize() {
maximum.initialize();
minimum.initialize();
progress.initialize();
super.internalViewInitialize();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRelease()
*/
protected void internalViewRelease() {
super.internalViewRelease();
maximum.release();
minimum.release();
progress.release();
}//internalViewRelease()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRefresh()
*/
protected void internalViewRefresh() {
internalViewRefreshMaximum();
internalViewRefreshMinimum();
super.internalViewRefresh();
}//internalViewRefresh()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalViewRefresh(com.foundation.tcv.swt.server.RowObject)
*/
protected void internalViewRefresh(RowObject rowObject) {
internalViewRefreshProgress(rowObject);
super.internalViewRefresh(rowObject);
}//internalViewRefresh()//
/**
* Refreshes the minimum progress value.
*/
protected void internalViewRefreshMinimum() {
if(minimum.refresh()) {
sendMessage(MESSAGE_SET_MINIMUM, minimum.getValue(), null, 0, 0);
}//if//
}//internalViewRefreshText()//
/**
* Refreshes the maximum progress value.
*/
protected void internalViewRefreshMaximum() {
if(maximum.refresh()) {
sendMessage(MESSAGE_SET_MAXIMUM, maximum.getValue(), null, 0, 0);
}//if//
}//internalViewRefreshText()//
/**
* Refreshes the current progress value.
* @param rowObject The row whose state is being updated.
*/
protected void internalViewRefreshProgress(RowObject rowObject) {
if(progress.refresh(rowObject.value)) {
sendMessage(MESSAGE_SET_PROGRESS, progress.getValue(rowObject.value), null, rowObject.objectId, 0);
}//if//
}//internalViewRefreshSelection()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
*/
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
if(minimum == resourceAssociation) {
internalViewRefreshMinimum();
}//else if//
else if(maximum == resourceAssociation) {
internalViewRefreshMaximum();
}//else if//
else {
super.internalOnValueChanged(resourceAssociation, flags);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object)
*/
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
if(resourceAssociation == progress) {
internalViewRefreshProgress(getCellContainer().getRowObject(alteredItem));
}//if//
else {
super.internalOnValueChanged(resourceAssociation, alteredItem, data, isUpdate);
}//else//
}//internalOnValueChanged()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#processMessage(com.foundation.tcv.view.ViewMessage)
*/
public Object processMessage(ViewMessage viewMessage) {
Object result = null;
switch(viewMessage.getMessageNumber()) {
default: {
result = super.processMessage(viewMessage);
}//default//
}//switch//
return result;
}//processMessage()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#registerRowItem(com.foundation.tcv.swt.server.RowObject)
*/
public void registerRowItem(RowObject rowObject) {
super.registerRowItem(rowObject);
progress.registerItem(rowObject.value, rowObject);
}//registerRowItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#unregisterRowItem(com.foundation.tcv.swt.server.RowObject)
*/
public void unregisterRowItem(RowObject rowObject) {
super.unregisterRowItem(rowObject);
progress.unregisterItem(rowObject.value);
}//unregisterRowItem()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.cell.CellComponent#unregisterRowItems()
*/
public void unregisterRowItems() {
super.unregisterRowItems();
progress.unregisterAllItems();
}//unregisterRowItems()//
/* (non-Javadoc)
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
*/
protected String getClientClassName() {
return "com.foundation.tcv.swt.client.cell.CellProgress";
}//getClientClassName()//
/* (non-Javadoc)
* @see com.foundation.view.IAbstractComponent#getName()
*/
public String getName() {
return "__Progress__";
}//getName()//
}//Progress//