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,210 @@
/*
* Copyright (c) 2007,2009 Declarative Engineering LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Declarative Engineering LLC
* verson 1 which accompanies this distribution, and is available at
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
*/
package com.foundation.tcv.swt.client;
import org.eclipse.swt.widgets.Composite;
import com.common.debug.Debug;
import com.common.util.IHashSet;
import com.common.util.IIterator;
import com.foundation.tcv.client.controller.SessionViewController;
import com.foundation.tcv.client.view.IAbstractClientViewComponent;
import com.foundation.tcv.swt.ILayout;
import com.foundation.tcv.view.ViewMessage;
import com.foundation.view.AbstractMultiResourceHolder;
import com.foundation.view.AbstractResourceHolder;
import com.foundation.view.resource.AbstractResourceService;
public abstract class Layout implements ILayout, IAbstractClientViewComponent {
/** The container that uses this layout. Only one of the container or cellContainer will be provided. */
private IAbstractSwtContainer container = null;
/** The cell container that uses this layout. */
private ICellContainer cellContainer = null;
/** The controller for this view session. */
private SessionViewController sessionViewController = null;
/** The component number assigned to this instance. */
private int number = -1;
/**
* A handler that is called to apply a set of changes to one or more layout.
*/
public interface IChangeHandler {
/**
* Applies the changes to the layout.
* @param layout The layout to apply the changes to.
*/
public void applyChanges(org.eclipse.swt.widgets.Layout layout);
}//IChangeHandler//
/**
* Layout constructor.
*/
public Layout() {
}//Layout()//
/**
* Initializes the layout.
*/
public abstract void initialize();
/**
* Synchronizes the layout by transfering data from the view to the model.
*/
public abstract void synchronize();
/**
* Releases the layout.
*/
public abstract void release();
/**
* Creates a layout that is used by an SWT control.
* @param rowObject The optional row object that the layout is associated with. This should be provided if the cellComponent is specified, otherwise it should be null.
* @return The SWT layout.
*/
public abstract org.eclipse.swt.widgets.Layout createLayout(Object rowObject);
/**
* Calls layout on the container.
* @param rowObject The optional row object with which the container is associated.
* @param changed If the container's cache should be flushed.
* @param all If all the children also require laying out.
*/
protected void layoutContainer(RowObject rowObject, boolean changed, boolean all) {
if(getCellContainer() != null) {
if(rowObject != null) {
getCellContainer().getSwtComposite(rowObject).layout(changed, all);
}//if//
else {
IIterator iterator = getCellContainer().getSwtComposites();
while(iterator.hasNext()) {
((Composite) iterator.next()).layout(changed, all);
}//while//
}//else//
}//if//
else {
getContainer().getSwtComposite().layout(changed, all);
}//else//
}//layoutContainer()//
/**
* Applies changes to the layout in the container.
* @param rowObject The optional row object with which the container is associated.
* @param handler The handler called to make the actual changes.
*/
protected void applyChanges(RowObject rowObject, IChangeHandler handler) {
if(getCellContainer() != null) {
if(rowObject != null) {
handler.applyChanges(getCellContainer().getSwtComposite(rowObject).getLayout());
}//if//
else {
IIterator iterator = getCellContainer().getSwtComposites();
while(iterator.hasNext()) {
handler.applyChanges(((Composite) iterator.next()).getLayout());
}//while//
}//else//
}//if//
else {
if(getContainer().getSwtComposite() != null && !getContainer().getSwtComposite().isDisposed()) {
handler.applyChanges(getContainer().getSwtComposite().getLayout());
}//if//
}//else//
}//applyChanges()//
/* (non-Javadoc)
* @see com.foundation.tcv.client.view.IAbstractClientViewComponent#getSessionViewController()
*/
public SessionViewController getSessionViewController() {
return sessionViewController;
}//getSessionViewController()//
/**
* Gets the component in the same 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()//
/**
* 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()//
/**
* Gets the container using this layout.
* @return The container that this layout supports.
*/
protected IAbstractSwtContainer getContainer() {
return container;
}//getContainer()//
/**
* Gets the cell container using this layout.
* @return The cell container that this layout supports.
*/
protected ICellContainer getCellContainer() {
return cellContainer;
}//getCellContainer()//
/**
* Sets the container using this layout.
* @param container The container that this layout supports.
*/
protected void setContainer(AbstractComponent container) {
if(container instanceof IAbstractSwtContainer) {
this.container = (IAbstractSwtContainer) container;
this.container.setLayout(this);
}//if//
else {
this.cellContainer = (ICellContainer) container;
this.cellContainer.setLayout(this);
}//else//
}//setContainer()//
/* (non-Javadoc)
* @see com.foundation.tcv.client.view.IAbstractClientViewComponent#initialize(int, com.foundation.tcv.client.controller.SessionViewController)
*/
public void initialize(int number, SessionViewController sessionViewController) {
this.number = number;
this.sessionViewController = sessionViewController;
}//initialize()//
/* (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.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.view.IResourceHolderComponent#getResourceService()
*/
public final AbstractResourceService getResourceService() {
return null;
}//getResourceService()//
/* (non-Javadoc)
* @see com.foundation.view.IResourceHolderComponent#resourceHolderChanged(com.foundation.view.AbstractMultiResourceHolder, com.common.util.IHashSet, java.lang.Object, java.lang.Object)
*/
public final void resourceHolderChanged(AbstractMultiResourceHolder resourceHolder, IHashSet rows, Object oldValue, Object newValue) {
}//resourceHolderChanged()//
/* (non-Javadoc)
* @see com.foundation.view.IResourceHolderComponent#resourceHolderChanged(com.foundation.view.AbstractMultiResourceHolder, java.lang.Object, java.lang.Object, java.lang.Object)
*/
public final void resourceHolderChanged(AbstractMultiResourceHolder resourceHolder, Object row, Object oldValue, Object newValue) {
}//resourceHolderChanged()//
/* (non-Javadoc)
* @see com.foundation.view.IResourceHolderComponent#resourceHolderChanged(com.foundation.view.AbstractResourceHolder, java.lang.Object, java.lang.Object)
*/
public final void resourceHolderChanged(AbstractResourceHolder resourceHolder, Object oldValue, Object newValue, int flags) {
}//resourceHolderChanged()//
}//Layout//