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