1481 lines
56 KiB
Java
1481 lines
56 KiB
Java
|
|
/*
|
||
|
|
* 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.view.swt;
|
||
|
|
|
||
|
|
import org.eclipse.swt.widgets.Composite;
|
||
|
|
import org.eclipse.swt.widgets.Shell;
|
||
|
|
|
||
|
|
import com.common.thread.IRunnable;
|
||
|
|
import com.common.util.*;
|
||
|
|
import com.common.comparison.Comparator;
|
||
|
|
import com.common.debug.*;
|
||
|
|
import com.foundation.controller.AbstractViewController;
|
||
|
|
import com.foundation.controller.IDecorationMultiListener;
|
||
|
|
import com.foundation.event.*;
|
||
|
|
import com.foundation.metadata.Attribute;
|
||
|
|
import com.foundation.view.*;
|
||
|
|
import com.foundation.view.swt.cell.CellComponent;
|
||
|
|
import com.foundation.util.*;
|
||
|
|
|
||
|
|
/*
|
||
|
|
* This class tries to abstract as much as possible of collection type components.
|
||
|
|
* There are several different types of collection components, but they all have a concept of rows in common.
|
||
|
|
* Each 'row' is an object from which the display data is derived.
|
||
|
|
* Some subclasses add the concept of columns and parent child relationships between rows.
|
||
|
|
*/
|
||
|
|
public abstract class CollectionComponent extends ScrollableComponent implements IAbstractContainer, ICellContainer, IDecorationMultiListener {
|
||
|
|
/** Used by the hidden data to identify when the previous value has not yet been assigned a value. */
|
||
|
|
protected static final Object UNSET_VALUE = new Object();
|
||
|
|
/** A multi-selection option that tells the hidden data linkage to always pass the default value when there are multiple selections. */
|
||
|
|
public static final int MULTI_SELECTION_OPTION_DEFAULT = 0;
|
||
|
|
/** A multi-selection option that tells the hidden data linkage to pass the selection's value if all selections resolve to the same value, otherwise pass the default value. */
|
||
|
|
public static final int MULTI_SELECTION_OPTION_COMMON = 1;
|
||
|
|
/** This multi-selection option is only usable for boolean hidden data. It performs a logical AND operation to receive a value. */
|
||
|
|
public static final int MULTI_SELECTION_OPTION_AND = 2;
|
||
|
|
/** This multi-selection option is only usable for boolean hidden data. It performs a logical OR operation to receive a value. */
|
||
|
|
public static final int MULTI_SELECTION_OPTION_OR = 3;
|
||
|
|
|
||
|
|
/** 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 SingleResourceAssociation selection = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_OBJECT, true, null);
|
||
|
|
/** Called when the user double clicks on a collection item. */
|
||
|
|
private IMethodAssociation doubleClickMethod = null;
|
||
|
|
/** A listener support for receiving collection change events. */
|
||
|
|
private EventSupport eventSupport = new EventSupport(null);
|
||
|
|
/** Whether the collection should use logical comparison instead of identitity comparison (default) on the collection items. */
|
||
|
|
private boolean useLogicalComparison = false;
|
||
|
|
/** 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 user is allowed to make multiple selections. */
|
||
|
|
private boolean allowMultiSelection;
|
||
|
|
/** 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 = 0;
|
||
|
|
/** The task that auto synchronizes the selection after a short delay. */
|
||
|
|
protected Task autoSynchronizeSelectionTask = null;
|
||
|
|
/** Whether the validation code in the view controller should be executed after synchronizing the value. */
|
||
|
|
private boolean autoValidate = false;
|
||
|
|
/** A reference to the last item collection known to this component. */
|
||
|
|
private ICollection currentCollection = null;
|
||
|
|
/** A reference to the last selection collection known to this component. */
|
||
|
|
private ICollection currentSelections = null;
|
||
|
|
/** A handler that will redirect collection events to this collection component. */
|
||
|
|
private final CollectionHandler collectionHandler = new CollectionHandler();
|
||
|
|
/** A handler that will redirect selection events to this collection component. */
|
||
|
|
private final SelectionHandler selectionHandler = new SelectionHandler();
|
||
|
|
/** 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;
|
||
|
|
/** The collection of HiddenData instances, one for each hidden data holder. */
|
||
|
|
private IList hiddenDataSets = new LiteList(10, 20);
|
||
|
|
/** The linkage for the selection related value. */
|
||
|
|
private Linkage selectionLinkage = new Linkage();
|
||
|
|
/** The collection of cell components. */
|
||
|
|
private LiteList cellComponents = null;
|
||
|
|
/** Whether the items in the collection decorate the rows in the list. */
|
||
|
|
private boolean decorateItems = false;
|
||
|
|
/** The count of calls to preChangeCollection(). Incremented for each call to preChangeCollection(), decremented for each call to postChangeCollection(). This counter determines when to call internalPostChangeCollection(). */
|
||
|
|
private int preChangeCollectionCounter = 0;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Encapsulates the value and related data for a 'row' in the component.
|
||
|
|
* A row can exist in multiple places in the component and thus has a reference counter.
|
||
|
|
* The object id may be used by some components to tie the row to the control.
|
||
|
|
*/
|
||
|
|
protected static class RowObject {
|
||
|
|
public Object value = null;
|
||
|
|
public int referenceCount = 1;
|
||
|
|
|
||
|
|
public RowObject(Object value) {
|
||
|
|
this.value = value;
|
||
|
|
}//RowObject()//
|
||
|
|
/**
|
||
|
|
* Gets the value represented by this row object instance.
|
||
|
|
* @return The value this row describes.
|
||
|
|
*/
|
||
|
|
public Object getValue() {
|
||
|
|
return value;
|
||
|
|
}//getValue()//
|
||
|
|
/**
|
||
|
|
* Releases any resources held by the row object.
|
||
|
|
*/
|
||
|
|
public void dispose() {
|
||
|
|
//Does nothing.//
|
||
|
|
}//dispose()//
|
||
|
|
}//RowObject//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The public interface for the hidden data, allowing the view code access to the public methods.
|
||
|
|
*/
|
||
|
|
public interface IHiddenData extends IAbstractComponent {
|
||
|
|
/**
|
||
|
|
* Sets the associations used to get the data value for the row.
|
||
|
|
* @param container The associations for the hidden data's value.
|
||
|
|
*/
|
||
|
|
public void setDataAssociation(MultiAssociationContainer container);
|
||
|
|
/**
|
||
|
|
* Adds a link associated with the collection's selection's hidden data value.
|
||
|
|
* @param link The local linkage for the selection related data.
|
||
|
|
*/
|
||
|
|
public void addSelectionLink(LinkData link);
|
||
|
|
}//IHiddenData//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The base class for the different types of hidden data.
|
||
|
|
* Hidden data is used by the collection to activate linkages without going through the controllers or models.
|
||
|
|
* Each object in the collection will then be assigned a value for each hidden data and the selection determines the value assigned to the linkages.
|
||
|
|
*/
|
||
|
|
protected abstract class HiddenData extends AbstractComponent implements IHiddenData {
|
||
|
|
/** The association containing the hidden data. */
|
||
|
|
private MultiResourceAssociation data;
|
||
|
|
/** The zero based index of the hidden data. This identifies the hidden data that generates events. */
|
||
|
|
private int hiddenDataIndex;
|
||
|
|
/** The previous selection related value for this hidden data. This allows linkages to be activated only when the value is altered. */
|
||
|
|
private Object previousValue = UNSET_VALUE;
|
||
|
|
/** The linkage for the selection related value. */
|
||
|
|
private Linkage selectionLinkage = new Linkage();
|
||
|
|
/** The multi-selection options for the hidden data. */
|
||
|
|
private int multiSelectionOption = MULTI_SELECTION_OPTION_DEFAULT;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* HiddenData constructor.
|
||
|
|
* @param hiddenDataIndex The index in the hidden data set.
|
||
|
|
* @param type The type of resource association required. This should be one of the ResourceAssociation.TYPE_xxx identifiers.
|
||
|
|
*/
|
||
|
|
protected HiddenData(int hiddenDataIndex, int type) {
|
||
|
|
super(CollectionComponent.this, 0);
|
||
|
|
this.hiddenDataIndex = hiddenDataIndex;
|
||
|
|
this.data = new MultiResourceAssociation(this, this, getViewContext(), type, false, null);
|
||
|
|
}//HiddenData()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IAbstractComponent#getName()
|
||
|
|
*/
|
||
|
|
public String getName() {
|
||
|
|
return "__HiddenData__";
|
||
|
|
}//getName()//
|
||
|
|
/**
|
||
|
|
* Sets the option used for handling multiple selections when determining the link related value.
|
||
|
|
* @param multiSelectionOption One of the MULTI_SELECTION_OPTION_xxx values defined by CollectionComponent.
|
||
|
|
*/
|
||
|
|
public void setMultiSelectionOption(int multiSelectionOption) {
|
||
|
|
this.multiSelectionOption = multiSelectionOption;
|
||
|
|
}//setMultiSelectionOption()//
|
||
|
|
/**
|
||
|
|
* Initializes the hidden data resources.
|
||
|
|
*/
|
||
|
|
public void initialize() {
|
||
|
|
data.initialize();
|
||
|
|
isInitialized(true);
|
||
|
|
}//initialize()//
|
||
|
|
/**
|
||
|
|
* Releases the hidden data resources.
|
||
|
|
*/
|
||
|
|
public void release() {
|
||
|
|
data.release();
|
||
|
|
}//release()//
|
||
|
|
/**
|
||
|
|
* Registers a collection item with the hidden data.
|
||
|
|
* @param value The value to be registered with the bindings.
|
||
|
|
* @deprecated Call registerItem(Object, Object) instead.
|
||
|
|
*/
|
||
|
|
public void registerItem(Object value) {
|
||
|
|
data.registerItem(value, null);
|
||
|
|
}//registerItem()//
|
||
|
|
/**
|
||
|
|
* Registers a collection item with the hidden data.
|
||
|
|
* @param value The value to be registered with the bindings.
|
||
|
|
* @param data The data associated with this registration.
|
||
|
|
*/
|
||
|
|
public void registerItem(Object value, Object data) {
|
||
|
|
this.data.registerItem(value, data);
|
||
|
|
}//registerItem()//
|
||
|
|
/**
|
||
|
|
* Unregisters a collection item from the hidden data.
|
||
|
|
* @param value The value to be unregistered with the bindings.
|
||
|
|
*/
|
||
|
|
public void unregisterItem(Object value) {
|
||
|
|
data.unregisterItem(value);
|
||
|
|
}//unregisterItem()//
|
||
|
|
/**
|
||
|
|
* Unregisters all collection items from the hidden data.
|
||
|
|
*/
|
||
|
|
public void unregisterItems() {
|
||
|
|
data.unregisterAllItems();
|
||
|
|
}//unregisterItems()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.CollectionComponent.IHiddenData#setDataAssociation(com.foundation.view.MultiAssociationContainer)
|
||
|
|
*/
|
||
|
|
public void setDataAssociation(MultiAssociationContainer association) {
|
||
|
|
verifyThread();
|
||
|
|
this.data.setAssociations(association);
|
||
|
|
}//addDataAssociation()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.CollectionComponent.IHiddenData#addSelectionLink(com.foundation.view.LinkData)
|
||
|
|
*/
|
||
|
|
public void addSelectionLink(LinkData link) {
|
||
|
|
selectionLinkage.add(link);
|
||
|
|
}//addSelectionLink()//
|
||
|
|
/**
|
||
|
|
* Gets the data association that controls access to the hidden data value.
|
||
|
|
* @return The association through which the latest hidden data value can be accessed.
|
||
|
|
*/
|
||
|
|
public MultiResourceAssociation getDataAssociation() {
|
||
|
|
return data;
|
||
|
|
}//getDataAssociation()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.IInternalAbstractComponent#getShell()
|
||
|
|
*/
|
||
|
|
public Shell getShell() {
|
||
|
|
return CollectionComponent.this.getShell();
|
||
|
|
}//getShell()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.AbstractComponent#initializeControl(int)
|
||
|
|
*/
|
||
|
|
protected void initializeControl(int style, Object data) {
|
||
|
|
}//initializeControl()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.AbstractComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object, java.lang.Object, boolean)
|
||
|
|
*/
|
||
|
|
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isUpdate) {
|
||
|
|
if(resourceAssociation == this.data) {
|
||
|
|
if(isInitialized()) {
|
||
|
|
//This should never be false I think.//
|
||
|
|
if(alteredItem != null) {
|
||
|
|
//Verify that the item cell data has actually been altered.//
|
||
|
|
if(this.data.refresh(alteredItem)) {
|
||
|
|
updateHiddenData(alteredItem, hiddenDataIndex, this.data.getValue(alteredItem));
|
||
|
|
}//if//
|
||
|
|
}//if//
|
||
|
|
}//if//
|
||
|
|
}//if//
|
||
|
|
else {
|
||
|
|
super.internalOnValueChanged(resourceAssociation, alteredItem, data, isUpdate);
|
||
|
|
}//else//
|
||
|
|
}//internalOnValueChanged()//
|
||
|
|
/**
|
||
|
|
* Invokes the linkage with the given value.
|
||
|
|
* @param value The last value for the selection and this hidden data.
|
||
|
|
*/
|
||
|
|
public void invokeLinkage(Object[] selections) {
|
||
|
|
Object value = null;
|
||
|
|
|
||
|
|
if((selections == null) || (selections.length == 0) || (multiSelectionOption == MULTI_SELECTION_OPTION_DEFAULT)) {
|
||
|
|
value = getDataAssociation().getDefaultValue();
|
||
|
|
}//if//
|
||
|
|
else {
|
||
|
|
getDataAssociation().refresh(selections[0]);
|
||
|
|
value = getDataAssociation().getValue(selections[0]);
|
||
|
|
|
||
|
|
for(int index = 1; index < selections.length; index++) {
|
||
|
|
Object next;
|
||
|
|
|
||
|
|
getDataAssociation().refresh(selections[index]);
|
||
|
|
next = getDataAssociation().getValue(selections[index]);
|
||
|
|
|
||
|
|
switch(multiSelectionOption) {
|
||
|
|
case MULTI_SELECTION_OPTION_COMMON: {
|
||
|
|
//If the values are not comparable then use the default value for the linkage and exit the loop.//
|
||
|
|
if(!Comparator.equals(next, value)) {
|
||
|
|
value = getDataAssociation().getDefaultValue();
|
||
|
|
index = selections.length;
|
||
|
|
}//if//
|
||
|
|
break;
|
||
|
|
}//case//
|
||
|
|
case MULTI_SELECTION_OPTION_AND: {
|
||
|
|
if((next instanceof Boolean) && (value instanceof Boolean)) {
|
||
|
|
value = ((Boolean) next).booleanValue() && ((Boolean) value).booleanValue() ? Boolean.TRUE : Boolean.FALSE;
|
||
|
|
}//if//
|
||
|
|
//TODO: What should we do if they are not booleans? For now we will ignore this since a view building tool would prevent the possibility.
|
||
|
|
break;
|
||
|
|
}//case//
|
||
|
|
case MULTI_SELECTION_OPTION_OR: {
|
||
|
|
if((next instanceof Boolean) && (value instanceof Boolean)) {
|
||
|
|
value = ((Boolean) next).booleanValue() || ((Boolean) value).booleanValue() ? Boolean.TRUE : Boolean.FALSE;
|
||
|
|
}//if//
|
||
|
|
//TODO: What should we do if they are not booleans? For now we will ignore this since a view building tool would prevent the possibility.
|
||
|
|
break;
|
||
|
|
}//case//
|
||
|
|
}//switch//
|
||
|
|
}//for//
|
||
|
|
}//else//
|
||
|
|
|
||
|
|
if(!Comparator.equals(value, previousValue)) {
|
||
|
|
previousValue = value;
|
||
|
|
selectionLinkage.invoke(value);
|
||
|
|
}//if//
|
||
|
|
}//invokeLinkage()//
|
||
|
|
/**
|
||
|
|
* Invokes the linkage with the given value.
|
||
|
|
* @param value The last value for the selection and this hidden data.
|
||
|
|
*/
|
||
|
|
public void invokeLinkage(Object selection) {
|
||
|
|
Object value;
|
||
|
|
|
||
|
|
getDataAssociation().refresh(selection);
|
||
|
|
value = getDataAssociation().getValue(selection);
|
||
|
|
|
||
|
|
if(!Comparator.equals(value, previousValue)) {
|
||
|
|
previousValue = value;
|
||
|
|
selectionLinkage.invoke(value);
|
||
|
|
}//if//
|
||
|
|
}//invokeLinkage()//
|
||
|
|
}//HiddenData//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The public interface for the hidden boolean data, allowing the view code access to the public methods.
|
||
|
|
*/
|
||
|
|
public interface IHiddenBoolean extends IHiddenData {
|
||
|
|
/**
|
||
|
|
* Sets the data to be used if the associations result in a null value.
|
||
|
|
* @param data The default value to be used.
|
||
|
|
*/
|
||
|
|
public void setData(Boolean data);
|
||
|
|
}//IHiddenBoolean//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The public interface for the hidden integer data, allowing the view code access to the public methods.
|
||
|
|
*/
|
||
|
|
public interface IHiddenInteger extends IHiddenData {
|
||
|
|
/**
|
||
|
|
* Sets the data to be used if the associations result in a null value.
|
||
|
|
* @param data The default value to be used.
|
||
|
|
*/
|
||
|
|
public void setData(Integer data);
|
||
|
|
}//IHiddenInteger//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The public interface for the hidden string data, allowing the view code access to the public methods.
|
||
|
|
*/
|
||
|
|
public interface IHiddenString extends IHiddenData {
|
||
|
|
/**
|
||
|
|
* Sets the data to be used if the associations result in a null value.
|
||
|
|
* @param data The default value to be used.
|
||
|
|
*/
|
||
|
|
public void setData(String data);
|
||
|
|
}//IHiddenString//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The public interface for the hidden color data, allowing the view code access to the public methods.
|
||
|
|
*/
|
||
|
|
public interface IHiddenColor extends IHiddenData {
|
||
|
|
/**
|
||
|
|
* Sets the data to be used if the associations result in a null value.
|
||
|
|
* @param data The default value to be used.
|
||
|
|
*/
|
||
|
|
public void setData(JefColor data);
|
||
|
|
}//IHiddenColor//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The public interface for the hidden font data, allowing the view code access to the public methods.
|
||
|
|
*/
|
||
|
|
public interface IHiddenFont extends IHiddenData {
|
||
|
|
/**
|
||
|
|
* Sets the data to be used if the associations result in a null value.
|
||
|
|
* @param data The default value to be used.
|
||
|
|
*/
|
||
|
|
public void setData(JefFont data);
|
||
|
|
}//IHiddenFont//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* An implementation of hidden data for boolean values.
|
||
|
|
*/
|
||
|
|
public class HiddenBoolean extends HiddenData implements IHiddenBoolean {
|
||
|
|
/**
|
||
|
|
* HiddenBoolean constructor.
|
||
|
|
* @param hiddenDataIndex The index in the hidden data set.
|
||
|
|
*/
|
||
|
|
public HiddenBoolean(int hiddenDataIndex) {
|
||
|
|
super(hiddenDataIndex, ResourceAssociation.TYPE_BOOLEAN);
|
||
|
|
}//HiddenBoolean()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.CollectionComponent.IHiddenBoolean#setData(java.lang.Boolean)
|
||
|
|
*/
|
||
|
|
public void setData(Boolean data) {
|
||
|
|
verifyThread();
|
||
|
|
getDataAssociation().setDefaultValue(data);
|
||
|
|
}//setData()//
|
||
|
|
}//HiddenBoolean//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* An implementation of hidden data for integer values.
|
||
|
|
*/
|
||
|
|
public class HiddenInteger extends HiddenData implements IHiddenInteger {
|
||
|
|
/**
|
||
|
|
* HiddenInteger constructor.
|
||
|
|
* @param hiddenDataIndex The index in the hidden data set.
|
||
|
|
*/
|
||
|
|
public HiddenInteger(int hiddenDataIndex) {
|
||
|
|
super(hiddenDataIndex, ResourceAssociation.TYPE_INTEGER);
|
||
|
|
}//HiddenInteger()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.CollectionComponent.IHiddenBoolean#setData(java.lang.Boolean)
|
||
|
|
*/
|
||
|
|
public void setData(Integer data) {
|
||
|
|
verifyThread();
|
||
|
|
getDataAssociation().setDefaultValue(data);
|
||
|
|
}//setData()//
|
||
|
|
}//HiddenInteger//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* An implementation of hidden data for string values.
|
||
|
|
*/
|
||
|
|
public class HiddenString extends HiddenData implements IHiddenString {
|
||
|
|
/**
|
||
|
|
* HiddenString constructor.
|
||
|
|
* @param hiddenDataIndex The index in the hidden data set.
|
||
|
|
*/
|
||
|
|
public HiddenString(int hiddenDataIndex) {
|
||
|
|
super(hiddenDataIndex, ResourceAssociation.TYPE_TEXT);
|
||
|
|
}//HiddenString()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.CollectionComponent.IHiddenBoolean#setData(java.lang.Boolean)
|
||
|
|
*/
|
||
|
|
public void setData(String data) {
|
||
|
|
verifyThread();
|
||
|
|
getDataAssociation().setDefaultValue(data);
|
||
|
|
}//setData()//
|
||
|
|
}//HiddenString//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* An implementation of hidden data for font values.
|
||
|
|
*/
|
||
|
|
public class HiddenFont extends HiddenData implements IHiddenFont {
|
||
|
|
/**
|
||
|
|
* HiddenFont constructor.
|
||
|
|
* @param hiddenDataIndex The index in the hidden data set.
|
||
|
|
*/
|
||
|
|
public HiddenFont(int hiddenDataIndex) {
|
||
|
|
super(hiddenDataIndex, ResourceAssociation.TYPE_FONT);
|
||
|
|
}//HiddenFont()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.CollectionComponent.IHiddenBoolean#setData(java.lang.Boolean)
|
||
|
|
*/
|
||
|
|
public void setData(JefFont data) {
|
||
|
|
verifyThread();
|
||
|
|
getDataAssociation().setDefaultValue(data);
|
||
|
|
}//setData()//
|
||
|
|
}//HiddenFont//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* An implementation of hidden data for color values.
|
||
|
|
*/
|
||
|
|
public class HiddenColor extends HiddenData implements IHiddenColor {
|
||
|
|
/**
|
||
|
|
* HiddenColor constructor.
|
||
|
|
* @param hiddenDataIndex The index in the hidden data set.
|
||
|
|
*/
|
||
|
|
public HiddenColor(int hiddenDataIndex) {
|
||
|
|
super(hiddenDataIndex, ResourceAssociation.TYPE_COLOR);
|
||
|
|
}//HiddenColor()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.CollectionComponent.IHiddenBoolean#setData(java.lang.Boolean)
|
||
|
|
*/
|
||
|
|
public void setData(JefColor data) {
|
||
|
|
verifyThread();
|
||
|
|
getDataAssociation().setDefaultValue(data);
|
||
|
|
}//setData()//
|
||
|
|
}//HiddenColor//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 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.IInlineIndexedCollectionObserver#allRemoved()
|
||
|
|
*/
|
||
|
|
public void removingAll() {
|
||
|
|
if(!suspendCollectionHooks) {
|
||
|
|
//Allow the collection to suspend activites that would adversly affect performance while the collection make large scale changes.//
|
||
|
|
preChangeCollection();
|
||
|
|
itemAllRemoved();
|
||
|
|
postChangeCollection();
|
||
|
|
}//if//
|
||
|
|
}//removingAll()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineIndexedCollectionObserver#valuesSorted(int[])
|
||
|
|
*/
|
||
|
|
public void valuesSorted(int[] mapping) {
|
||
|
|
if(!suspendCollectionHooks) {
|
||
|
|
preChangeCollection();
|
||
|
|
itemSorted(mapping);
|
||
|
|
postChangeCollection();
|
||
|
|
}//if//
|
||
|
|
}//valuesSorted()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineCollectionObserver#startChanges(int)
|
||
|
|
*/
|
||
|
|
public void startChanges(int changeCount) {
|
||
|
|
//Allow the collection to suspend activites that would adversly affect performance while the collection make large scale changes.//
|
||
|
|
preChangeCollection();
|
||
|
|
}//startChanges()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineCollectionObserver#stopChanges()
|
||
|
|
*/
|
||
|
|
public void stopChanges() {
|
||
|
|
postChangeCollection();
|
||
|
|
}//stopChanges()//
|
||
|
|
}//CollectionHandler//
|
||
|
|
/**
|
||
|
|
* Captures and directs selection collection changes.
|
||
|
|
*/
|
||
|
|
private final class SelectionHandler implements IInlineCollectionObserver, IInlineIndexedCollectionObserver {
|
||
|
|
/**
|
||
|
|
* SelectionHandler constructor.
|
||
|
|
*/
|
||
|
|
private SelectionHandler() {
|
||
|
|
}//SelectionHandler()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueAdded(java.lang.Object, int)
|
||
|
|
*/
|
||
|
|
public void valueAdded(Object value, int index) {
|
||
|
|
if(!suspendSelectionHooks) {
|
||
|
|
selectionAdded(value);
|
||
|
|
}//if//
|
||
|
|
}//valueAdded()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineCollectionObserver#valueAdded(java.lang.Object)
|
||
|
|
*/
|
||
|
|
public void valueAdded(Object value) {
|
||
|
|
if(!suspendSelectionHooks) {
|
||
|
|
selectionAdded(value);
|
||
|
|
}//if//
|
||
|
|
}//valueAdded()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineIndexedCollectionObserver#valueRemoved(java.lang.Object, int)
|
||
|
|
*/
|
||
|
|
public void valueRemoved(Object value, int index) {
|
||
|
|
if(!suspendSelectionHooks) {
|
||
|
|
selectionRemoved(value);
|
||
|
|
}//if//
|
||
|
|
}//valueRemoved()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineCollectionObserver#valueRemoved(java.lang.Object)
|
||
|
|
*/
|
||
|
|
public void valueRemoved(Object value) {
|
||
|
|
if(!suspendSelectionHooks) {
|
||
|
|
selectionRemoved(value);
|
||
|
|
}//if//
|
||
|
|
}//valueRemoved()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineIndexedCollectionObserver#removingAll()
|
||
|
|
*/
|
||
|
|
public void removingAll() {
|
||
|
|
if(!suspendSelectionHooks) {
|
||
|
|
selectionAllRemoved();
|
||
|
|
}//if//
|
||
|
|
}//removingAll()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineIndexedCollectionObserver#valuesSorted(int[])
|
||
|
|
*/
|
||
|
|
public void valuesSorted(int[] mapping) {
|
||
|
|
}//valuesSorted()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineCollectionObserver#startChanges(int)
|
||
|
|
*/
|
||
|
|
public void startChanges(int changeCount) {
|
||
|
|
}//startChanges()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.util.IInlineCollectionObserver#stopChanges()
|
||
|
|
*/
|
||
|
|
public void stopChanges() {
|
||
|
|
}//stopChanges()//
|
||
|
|
}//SelectionHandler//
|
||
|
|
/**
|
||
|
|
* CollectionComponent constructor.
|
||
|
|
* @param parent The parent container.
|
||
|
|
* @param name The name of the component.
|
||
|
|
* @param style The style for the control.
|
||
|
|
*/
|
||
|
|
public CollectionComponent(Container parent, String name, int style) {
|
||
|
|
super(parent, name, style);
|
||
|
|
}//CollectionComponent()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#setController(com.foundation.controller.AbstractViewController)
|
||
|
|
*/
|
||
|
|
public void setController(AbstractViewController controller) {
|
||
|
|
getContainer().setController(controller);
|
||
|
|
}//setController()//
|
||
|
|
/**
|
||
|
|
* Gets the number of selections in the component.
|
||
|
|
* @return The count of selections.
|
||
|
|
*/
|
||
|
|
protected abstract int controlGetSelectionCount();
|
||
|
|
/**
|
||
|
|
* Updates selection linkages associated with the hidden data 'columns' based on the current selection settings.
|
||
|
|
*/
|
||
|
|
protected void updateSelectionLinks() {
|
||
|
|
selectionLinkage.invoke(controlGetSelectionCount() > 0 ? Boolean.TRUE : Boolean.FALSE);
|
||
|
|
}//updateSelectionLinks()//
|
||
|
|
/**
|
||
|
|
* 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(SingleAssociationContainer container) {
|
||
|
|
verifyThread();
|
||
|
|
this.selection.setAssociations(container);
|
||
|
|
}//setSelectionAssociation()//
|
||
|
|
/**
|
||
|
|
* Adds a hidden boolean holder to the collection component.
|
||
|
|
* @return The hidden boolean holder which may be modified to collect boolean values for each object in the collection component.
|
||
|
|
*/
|
||
|
|
public IHiddenBoolean addHiddenBoolean() {
|
||
|
|
HiddenBoolean result = new HiddenBoolean(hiddenDataSets.getSize());
|
||
|
|
|
||
|
|
if(isInitialized()) {
|
||
|
|
throw new RuntimeException("Cannot created hidden data structures after initializing the view component.");
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
hiddenDataSets.add(result);
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}//addHiddenBoolean()//
|
||
|
|
/**
|
||
|
|
* Adds a hidden integer holder to the collection component.
|
||
|
|
* @return The hidden integer holder which may be modified to collect integer values for each object in the collection component.
|
||
|
|
*/
|
||
|
|
public IHiddenInteger addHiddenInteger() {
|
||
|
|
HiddenInteger result = new HiddenInteger(hiddenDataSets.getSize());
|
||
|
|
|
||
|
|
if(isInitialized()) {
|
||
|
|
throw new RuntimeException("Cannot created hidden data structures after initializing the view component.");
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
hiddenDataSets.add(result);
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}//addHiddenInteger()//
|
||
|
|
/**
|
||
|
|
* Adds a hidden string holder to the collection component.
|
||
|
|
* @return The hidden string holder which may be modified to collect string values for each object in the collection component.
|
||
|
|
*/
|
||
|
|
public IHiddenString addHiddenString() {
|
||
|
|
HiddenString result = new HiddenString(hiddenDataSets.getSize());
|
||
|
|
|
||
|
|
if(isInitialized()) {
|
||
|
|
throw new RuntimeException("Cannot created hidden data structures after initializing the view component.");
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
hiddenDataSets.add(result);
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}//addHiddenString()//
|
||
|
|
/**
|
||
|
|
* Adds a hidden font holder to the collection component.
|
||
|
|
* @return The hidden font holder which may be modified to collect font values for each object in the collection component.
|
||
|
|
*/
|
||
|
|
public IHiddenFont addHiddenFont() {
|
||
|
|
HiddenFont result = new HiddenFont(hiddenDataSets.getSize());
|
||
|
|
|
||
|
|
if(isInitialized()) {
|
||
|
|
throw new RuntimeException("Cannot created hidden data structures after initializing the view component.");
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
hiddenDataSets.add(result);
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}//addHiddenFont()//
|
||
|
|
/**
|
||
|
|
* Adds a hidden color holder to the collection component.
|
||
|
|
* @return The hidden color holder which may be modified to collect color values for each object in the collection component.
|
||
|
|
*/
|
||
|
|
public IHiddenColor addHiddenColor() {
|
||
|
|
HiddenColor result = new HiddenColor(hiddenDataSets.getSize());
|
||
|
|
|
||
|
|
if(isInitialized()) {
|
||
|
|
throw new RuntimeException("Cannot created hidden data structures after initializing the view component.");
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
hiddenDataSets.add(result);
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}//addHiddenColor()//
|
||
|
|
/**
|
||
|
|
* Adds a link invoked when the selection state for the component changes.
|
||
|
|
* @param link The invoked when the collection selection changes from no selection to any selection or visa versa.
|
||
|
|
*/
|
||
|
|
public void addSelectionLink(LinkData link) {
|
||
|
|
selectionLinkage.add(link);
|
||
|
|
}//addSelectionLink()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IAbstractContainer#addComponent(com.foundation.view.IAbstractComponent)
|
||
|
|
*/
|
||
|
|
public void addComponent(IAbstractComponent component) {
|
||
|
|
//Never called.//
|
||
|
|
}//addComponent()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IAbstractContainer#removeComponent(com.foundation.view.IAbstractComponent)
|
||
|
|
*/
|
||
|
|
public void removeComponent(IAbstractComponent component) {
|
||
|
|
//Never called.//
|
||
|
|
}//removeComponent()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.ICellContainer#addCellComponent(com.foundation.view.swt.cell.CellComponent)
|
||
|
|
*/
|
||
|
|
public void addCellComponent(CellComponent component) {
|
||
|
|
if(cellComponents == null) {
|
||
|
|
cellComponents = new LiteList(10, 20);
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
cellComponents.add(component);
|
||
|
|
|
||
|
|
if(isInitialized()) {
|
||
|
|
((AbstractComponent) component).internalViewInitializeAll();
|
||
|
|
}//if//
|
||
|
|
}//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.view.swt.ICellContainer#getSwtComposite(java.lang.Object)
|
||
|
|
*/
|
||
|
|
public Composite getSwtComposite(Object rowObject) {
|
||
|
|
return (Composite) getSwtControl();
|
||
|
|
}//getSwtComposite()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.ICellContainer#getSwtComposites()
|
||
|
|
*/
|
||
|
|
public IIterator getSwtComposites() {
|
||
|
|
return LiteList.EMPTY_LIST.iterator();
|
||
|
|
}//getSwtComposites()//
|
||
|
|
/**
|
||
|
|
* Gets the method called to handle a double click.
|
||
|
|
* @return The method called when a list item 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 list item is double clicked.
|
||
|
|
*/
|
||
|
|
public void setDoubleClickMethod(IMethodAssociation doubleClickMethod) {
|
||
|
|
verifyThread();
|
||
|
|
this.doubleClickMethod = doubleClickMethod;
|
||
|
|
}//setDoubleClickMethod()//
|
||
|
|
/**
|
||
|
|
* 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();
|
||
|
|
this.autoSynchronizeSelection = autoSynchronizeSelection;
|
||
|
|
}//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//
|
||
|
|
|
||
|
|
this.autoSynchronizeSelectionDelay = autoSynchronizeSelectionDelay;
|
||
|
|
}//setAutoSynchronizeSelectionDelay()//
|
||
|
|
/**
|
||
|
|
* Gets whether validate routine is called after a synchronize.
|
||
|
|
* @return autoValidate Whether the validation code in the view controller will be called after synchronizing the selection.
|
||
|
|
*/
|
||
|
|
public boolean getAutoValidate() {
|
||
|
|
return autoValidate;
|
||
|
|
}//getAutoValidate()//
|
||
|
|
/**
|
||
|
|
* 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 selection.
|
||
|
|
*/
|
||
|
|
public void setAutoValidate(boolean autoValidate) {
|
||
|
|
this.autoValidate = autoValidate;
|
||
|
|
}//setAutoValidate()//
|
||
|
|
/**
|
||
|
|
* Registers the collection item with any and all listeners and associations.
|
||
|
|
* <p>This method provides the control an opportunity to register the item with any MultiResourceAssociations that are a part of the main control, and/or with any columns for those controls with them.</p>
|
||
|
|
* @param item The item in the collection being displayed.
|
||
|
|
*/
|
||
|
|
protected abstract void registerItem(Object item);
|
||
|
|
/**
|
||
|
|
* Unregisters the collection item with any and all listeners and associations.
|
||
|
|
* <p>This method provides the control an opportunity to unregister the item with any MultiResourceAssociations that are a part of the main control, and/or with any columns for those controls with them.</p>
|
||
|
|
* @param item The item no longer in the collection being displayed.
|
||
|
|
*/
|
||
|
|
protected abstract void unregisterItem(Object item);
|
||
|
|
/**
|
||
|
|
* Unregisters all the collection items with any and all listeners and associations.
|
||
|
|
* <p>This method provides the control an opportunity to unregister all items with any MultiResourceAssociations that are a part of the main control, and/or with any columns for those controls with them.</p>
|
||
|
|
*/
|
||
|
|
protected abstract void unregisterItems();
|
||
|
|
/**
|
||
|
|
* Gets the collection of items in the model.
|
||
|
|
* @return The model's collection of items.
|
||
|
|
*/
|
||
|
|
protected final ICollection getModelItems() {
|
||
|
|
Object items = collection.getValue();
|
||
|
|
|
||
|
|
return items instanceof ICollection ? (ICollection) items : null;
|
||
|
|
}//getModelItems()//
|
||
|
|
/**
|
||
|
|
* Gets the collection of selected items in the model.
|
||
|
|
* @return The model's collection of selected items.
|
||
|
|
*/
|
||
|
|
protected final ICollection getModelSelections() {
|
||
|
|
Object selections = selection.getValue();
|
||
|
|
|
||
|
|
return selections instanceof ICollection ? (ICollection) selections : null;
|
||
|
|
}//getModelSelections()//
|
||
|
|
/**
|
||
|
|
* Gets the selected item in the model.
|
||
|
|
* @return The item to selected in the model.
|
||
|
|
*/
|
||
|
|
protected final Object getModelSelection() {
|
||
|
|
return this.selection.getValue();
|
||
|
|
}//getModelSelection()//
|
||
|
|
/**
|
||
|
|
* Sets the selected item in the model.
|
||
|
|
* @param selection The item to be selected in the model.
|
||
|
|
*/
|
||
|
|
protected final void setModelSelection(Object selection) {
|
||
|
|
this.selection.setValue(selection);
|
||
|
|
}//setModelSelection()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.AbstractComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
|
||
|
|
*/
|
||
|
|
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
|
||
|
|
if(resourceAssociation == collection) {
|
||
|
|
internalViewRefreshCollection();
|
||
|
|
}//if//
|
||
|
|
else if(resourceAssociation == selection) {
|
||
|
|
internalViewRefreshSelection();
|
||
|
|
}//else if//
|
||
|
|
else {
|
||
|
|
super.internalOnValueChanged(resourceAssociation, flags);
|
||
|
|
}//else//
|
||
|
|
}//internalOnValueChanged()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.AbstractComponent#internalViewInitializeAll()
|
||
|
|
*/
|
||
|
|
public void internalViewInitializeAll() {
|
||
|
|
super.internalViewInitializeAll();
|
||
|
|
|
||
|
|
if(cellComponents != null) {
|
||
|
|
for(int index = 0; index < cellComponents.getSize(); index++) {
|
||
|
|
((AbstractComponent) cellComponents.get(index)).internalViewInitializeAll();
|
||
|
|
}//for//
|
||
|
|
}//if//
|
||
|
|
}//internalViewInitializeAll()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.AbstractComponent#internalViewReleaseAll()
|
||
|
|
*/
|
||
|
|
public void internalViewReleaseAll() {
|
||
|
|
super.internalViewReleaseAll();
|
||
|
|
|
||
|
|
if(cellComponents != null) {
|
||
|
|
for(int index = 0; index < cellComponents.getSize(); index++) {
|
||
|
|
((AbstractComponent) cellComponents.get(index)).internalViewReleaseAll();
|
||
|
|
}//for//
|
||
|
|
}//if//
|
||
|
|
}//internalViewReleaseAll()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.Component#internalViewRefreshAll()
|
||
|
|
*/
|
||
|
|
public void internalViewRefreshAll() {
|
||
|
|
super.internalViewRefreshAll();
|
||
|
|
|
||
|
|
if(cellComponents != null) {
|
||
|
|
for(int index = 0; index < cellComponents.getSize(); index++) {
|
||
|
|
((AbstractComponent) cellComponents.get(index)).internalViewRefreshAll();
|
||
|
|
}//for//
|
||
|
|
}//if//
|
||
|
|
}//internalViewRefreshAll()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.Component#internalViewSynchronizeAll()
|
||
|
|
*/
|
||
|
|
public void internalViewSynchronizeAll() {
|
||
|
|
super.internalViewSynchronizeAll();
|
||
|
|
|
||
|
|
if(cellComponents != null) {
|
||
|
|
for(int index = 0; index < cellComponents.getSize(); index++) {
|
||
|
|
((AbstractComponent) cellComponents.get(index)).internalViewSynchronizeAll();
|
||
|
|
}//for//
|
||
|
|
}//if//
|
||
|
|
}//internalViewSynchronizeAll()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.AbstractComponent#internalViewInitialize()
|
||
|
|
*/
|
||
|
|
protected void internalViewInitialize() {
|
||
|
|
for(int index = 0; index < hiddenDataSets.getSize(); index++) {
|
||
|
|
((HiddenData) hiddenDataSets.get(index)).initialize();
|
||
|
|
}//for//
|
||
|
|
|
||
|
|
if(canDecorate() && getDecorateItems()) {
|
||
|
|
getDecorationManager().registerDecorationListener(this);
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
collection.initialize(true);
|
||
|
|
selection.initialize(true);
|
||
|
|
super.internalViewInitialize();
|
||
|
|
}//internalViewInitialize()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.AbstractComponent#internalViewRelease()
|
||
|
|
*/
|
||
|
|
protected void internalViewRelease() {
|
||
|
|
//Release the hooks into the collections.//
|
||
|
|
unregisterCollectionHooks(currentCollection, collectionHandler);
|
||
|
|
unregisterCollectionHooks(currentSelections, selectionHandler);
|
||
|
|
|
||
|
|
synchronized(this) {
|
||
|
|
if(autoSynchronizeSelectionTask != null) {
|
||
|
|
removeTask(autoSynchronizeSelectionTask);
|
||
|
|
autoSynchronizeSelectionTask = null;
|
||
|
|
}//if//
|
||
|
|
}//synchronized//
|
||
|
|
|
||
|
|
if(decorateItems && getDecorationManager() != null) {
|
||
|
|
getDecorationManager().unregisterDecorationListener(this);
|
||
|
|
decorateItems = false;
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
super.internalViewRelease();
|
||
|
|
collection.release();
|
||
|
|
selection.release();
|
||
|
|
|
||
|
|
for(int index = 0; index < hiddenDataSets.getSize(); index++) {
|
||
|
|
((HiddenData) hiddenDataSets.get(index)).release();
|
||
|
|
}//for//
|
||
|
|
|
||
|
|
eventSupport.unregisterAll();
|
||
|
|
}//internalViewRelease()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.AbstractComponent#internalViewRefresh()
|
||
|
|
*/
|
||
|
|
protected void internalViewRefresh() {
|
||
|
|
super.internalViewRefresh();
|
||
|
|
internalViewRefreshCollection();
|
||
|
|
internalViewRefreshSelection();
|
||
|
|
}//internalViewRefresh()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.swt.AbstractComponent#internalViewSynchronize()
|
||
|
|
*/
|
||
|
|
protected void internalViewSynchronize() {
|
||
|
|
super.internalViewSynchronize();
|
||
|
|
internalViewSynchronizeSelection();
|
||
|
|
}//internalViewSynchronize()//
|
||
|
|
/**
|
||
|
|
* Synchronizes the selection when the view synchronizes.
|
||
|
|
*/
|
||
|
|
protected void internalViewSynchronizeSelection() {
|
||
|
|
if(!getAutoSynchronizeSelection()) {
|
||
|
|
synchronizeSelection();
|
||
|
|
}//if//
|
||
|
|
else {
|
||
|
|
synchronized(this) {
|
||
|
|
if(autoSynchronizeSelectionTask != null) {
|
||
|
|
removeTask(autoSynchronizeSelectionTask);
|
||
|
|
autoSynchronizeSelectionTask.execute();
|
||
|
|
}//if//
|
||
|
|
}//synchronized//
|
||
|
|
}//else//
|
||
|
|
}//internalViewSynchronize()//
|
||
|
|
/**
|
||
|
|
* Synchronizes the selection when the user interacts with the collection.
|
||
|
|
*/
|
||
|
|
protected abstract void synchronizeSelection();
|
||
|
|
/**
|
||
|
|
* Refreshes the collection.
|
||
|
|
*/
|
||
|
|
protected final void internalViewRefreshCollection() {
|
||
|
|
if(collection.refresh()) {
|
||
|
|
ICollection oldCollection = currentCollection;
|
||
|
|
|
||
|
|
//Allow the collection to suspend activites that would adversly affect performance while the collection make large scale changes.//
|
||
|
|
preChangeCollection();
|
||
|
|
|
||
|
|
try {
|
||
|
|
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) {
|
||
|
|
unregisterItems();
|
||
|
|
unregisterCollectionHooks(oldCollection, collectionHandler);
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
if(currentCollection != null) {
|
||
|
|
IIterator iterator = currentCollection.iterator();
|
||
|
|
|
||
|
|
suspendCollectionHooks = true;
|
||
|
|
registerCollectionHooks(currentCollection, collectionHandler);
|
||
|
|
suspendCollectionHooks = false;
|
||
|
|
|
||
|
|
while(iterator.hasNext()) {
|
||
|
|
Object next = iterator.next();
|
||
|
|
|
||
|
|
registerItem(next);
|
||
|
|
}//while//
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
internalViewRefreshCollection(currentCollection, oldCollection);
|
||
|
|
//Force the selection to be updated.//
|
||
|
|
internalViewRefreshSelection(true);
|
||
|
|
}//try//
|
||
|
|
finally {
|
||
|
|
//Allow the collection to resume activites that were suspended while the collection was changing.//
|
||
|
|
postChangeCollection();
|
||
|
|
}//finally//
|
||
|
|
}//if//
|
||
|
|
}//internalViewRefreshCollection()//
|
||
|
|
/**
|
||
|
|
* Refreshes the collection.
|
||
|
|
* @param newCollection The new collection of items in the component.
|
||
|
|
* @param oldCollection The old collection of items in the component.
|
||
|
|
*/
|
||
|
|
protected abstract void internalViewRefreshCollection(ICollection newCollection, ICollection oldCollection);
|
||
|
|
/**
|
||
|
|
* Refreshes the selection.
|
||
|
|
*/
|
||
|
|
protected final void internalViewRefreshSelection() {
|
||
|
|
internalViewRefreshSelection(false);
|
||
|
|
}//internalViewRefreshSelection()//
|
||
|
|
/**
|
||
|
|
* Refreshes the selection.
|
||
|
|
* @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) {
|
||
|
|
if(selection.refresh() || force) {
|
||
|
|
if(getAllowMultiSelection()) {
|
||
|
|
ICollection oldSelections = currentSelections;
|
||
|
|
|
||
|
|
if(selection.getValue() instanceof ICollection) {
|
||
|
|
currentSelections = (ICollection) selection.getValue();
|
||
|
|
}//if//
|
||
|
|
else {
|
||
|
|
currentSelections = null;
|
||
|
|
|
||
|
|
if(selection.getValue() != null) {
|
||
|
|
Debug.log("Error: The selection value is not a collection as expected!");
|
||
|
|
}//if//
|
||
|
|
}//else//
|
||
|
|
|
||
|
|
if(oldSelections != null) {
|
||
|
|
unregisterCollectionHooks(oldSelections, selectionHandler);
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
if(currentSelections != null) {
|
||
|
|
suspendSelectionHooks = true;
|
||
|
|
registerCollectionHooks(currentSelections, selectionHandler);
|
||
|
|
suspendSelectionHooks = false;
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
internalViewRefreshSelections(currentSelections, oldSelections);
|
||
|
|
}//if//
|
||
|
|
else {
|
||
|
|
Object selectedItem = selection.getValue();
|
||
|
|
|
||
|
|
internalViewRefreshSelection(selectedItem);
|
||
|
|
}//else//
|
||
|
|
|
||
|
|
//Update the linkages that connect to the selection.//
|
||
|
|
updateSelectionLinks();
|
||
|
|
}//if//
|
||
|
|
}//internalViewRefreshSelection()//
|
||
|
|
/**
|
||
|
|
* Refreshes the selection.
|
||
|
|
* @param selectedItem The new selected item.
|
||
|
|
*/
|
||
|
|
protected abstract void internalViewRefreshSelection(Object selectedItem);
|
||
|
|
/**
|
||
|
|
* Refreshes the selections.
|
||
|
|
* @param newSelections The new collection of selections.
|
||
|
|
* @param oldSelections The old collection of selections.
|
||
|
|
*/
|
||
|
|
protected abstract void internalViewRefreshSelections(ICollection newSelections, ICollection oldSelections);
|
||
|
|
/**
|
||
|
|
* 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()//
|
||
|
|
/**
|
||
|
|
* Called when an item is being added to the displayed collection.
|
||
|
|
* This is separated from the itemAdded(..) method since this code is run when any item is added anywhere in the displayed collection.
|
||
|
|
* @param item The item that is being added.
|
||
|
|
*/
|
||
|
|
protected void internalItemAdded(Object item) {
|
||
|
|
for(int index = 0; index < getHiddenDataCount(); index++) {
|
||
|
|
getHiddenData(index).registerItem(item);
|
||
|
|
}//for//
|
||
|
|
}//internalItemAdded()//
|
||
|
|
/**
|
||
|
|
* Called when an item is being removed from the displayed collection.
|
||
|
|
* This is separated from the itemRemoved(..) method since this code is run when any item is removed anywhere in the displayed collection.
|
||
|
|
* @param item The item that is being removed.
|
||
|
|
*/
|
||
|
|
protected void internalItemRemoved(Object item) {
|
||
|
|
for(int index = 0; index < getHiddenDataCount(); index++) {
|
||
|
|
getHiddenData(index).unregisterItem(item);
|
||
|
|
}//for//
|
||
|
|
}//internalItemRemoved()//
|
||
|
|
/**
|
||
|
|
* Called when all items are being removed from the displayed collection.
|
||
|
|
* This is separated from the itemsRemoved(..) method since this code is run when any item is removed anywhere in the displayed collection.
|
||
|
|
*/
|
||
|
|
protected void internalItemsRemoved() {
|
||
|
|
for(int index = 0; index < getHiddenDataCount(); index++) {
|
||
|
|
getHiddenData(index).unregisterItems();
|
||
|
|
}//for//
|
||
|
|
}//internalItemsRemoved()//
|
||
|
|
/**
|
||
|
|
* Called when an item is added to the primary collection.
|
||
|
|
* @param item The item added.
|
||
|
|
* @param index The index of the item if available, otherwise -1.
|
||
|
|
*/
|
||
|
|
protected abstract void itemAdded(Object item, int index);
|
||
|
|
/**
|
||
|
|
* Called when an item is removed from the primary collection.
|
||
|
|
* @param item The item removed.
|
||
|
|
* @param index The index of the item if available, otherwise -1.
|
||
|
|
*/
|
||
|
|
protected abstract void itemRemoved(Object item, int index);
|
||
|
|
/**
|
||
|
|
* Called when all the items are removed from the primary collection.
|
||
|
|
*/
|
||
|
|
protected abstract void itemAllRemoved();
|
||
|
|
/**
|
||
|
|
* Called when the items in the primary collection 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 abstract void itemSorted(int[] mapping);
|
||
|
|
/**
|
||
|
|
* Called when a selected object is added to the collection of selections.
|
||
|
|
* @param value The value added to the collection of selections.
|
||
|
|
*/
|
||
|
|
protected abstract void selectionAdded(Object value);
|
||
|
|
/**
|
||
|
|
* Called when a selected object is removed from the collection of selections.
|
||
|
|
* @param value The value removed from the collection of selections.
|
||
|
|
*/
|
||
|
|
protected abstract void selectionRemoved(Object value);
|
||
|
|
/**
|
||
|
|
* Called when all selections are removed from the collection of selections.
|
||
|
|
*/
|
||
|
|
protected abstract void selectionAllRemoved();
|
||
|
|
/**
|
||
|
|
* Updates the hidden data for the hidden data holder at the given index (zero based).
|
||
|
|
* @param item The collection item for which the data is being updated.
|
||
|
|
* @param hiddenDataIndex The zero based index of the hidden data object which can be used to maintain the data.
|
||
|
|
* @param value The new value for the collection item and hidden data holder.
|
||
|
|
*/
|
||
|
|
protected abstract void updateHiddenData(Object item, int hiddenDataIndex, Object value);
|
||
|
|
/**
|
||
|
|
* Called before the collection of displayed values is modified.
|
||
|
|
* This method, in combination with postChangeCollection(), allows the control to be more efficient about its adding of items.
|
||
|
|
*/
|
||
|
|
protected final void preChangeCollection() {
|
||
|
|
if(preChangeCollectionCounter++ == 0) {
|
||
|
|
internalPreChangeCollection();
|
||
|
|
}//if//
|
||
|
|
}//preChangeCollection()//
|
||
|
|
/**
|
||
|
|
* Called after the collection of displayed values is modified.
|
||
|
|
*/
|
||
|
|
protected final void postChangeCollection() {
|
||
|
|
if(--preChangeCollectionCounter == 0) {
|
||
|
|
internalPostChangeCollection();
|
||
|
|
}//if//
|
||
|
|
}//postChangeCollection()//
|
||
|
|
/**
|
||
|
|
* Called before the collection of displayed values is modified.
|
||
|
|
* This method, in combination with postChangeCollection(), allows the control to be more efficient about its adding of items.
|
||
|
|
*/
|
||
|
|
protected void internalPreChangeCollection() {
|
||
|
|
//Subclasses should override as required.//
|
||
|
|
}//preChangeCollection()//
|
||
|
|
/**
|
||
|
|
* Called after the collection of displayed values is modified.
|
||
|
|
*/
|
||
|
|
protected void internalPostChangeCollection() {
|
||
|
|
//Subclasses should override as required.//
|
||
|
|
}//postChangeCollection()//
|
||
|
|
/**
|
||
|
|
* Gets the hidden data set for the given index.
|
||
|
|
* @param hiddenDataIndex The zero based index for the desired hidden data metadata.
|
||
|
|
* @return The metadata describing the hidden data and providing access to the current value for any collection item.
|
||
|
|
*/
|
||
|
|
protected HiddenData getHiddenData(int hiddenDataIndex) {
|
||
|
|
return (HiddenData) hiddenDataSets.get(hiddenDataIndex);
|
||
|
|
}//getHiddenData()//
|
||
|
|
/**
|
||
|
|
* Gets the number of hidden data sets used by the collection component.
|
||
|
|
* @return The count of hidden data 'columns'.
|
||
|
|
*/
|
||
|
|
protected int getHiddenDataCount() {
|
||
|
|
return hiddenDataSets.getSize();
|
||
|
|
}//getHiddenDataCount()//
|
||
|
|
/**
|
||
|
|
* Determines whether the control allows the user to make multiple selections at one time.
|
||
|
|
* @return Whether more than one value can be selected at a time.
|
||
|
|
*/
|
||
|
|
protected boolean getAllowMultiSelection() {
|
||
|
|
return allowMultiSelection;
|
||
|
|
}//getAllowMultiSelection()//
|
||
|
|
/**
|
||
|
|
* Determines whether the control allows the user to make multiple selections at one time.
|
||
|
|
* @param allowMultiSelection Whether more than one value can be selected at a time.
|
||
|
|
*/
|
||
|
|
protected void setAllowMultiSelection(boolean allowMultiSelection) {
|
||
|
|
this.allowMultiSelection = allowMultiSelection;
|
||
|
|
}//setAllowMultiSelection()//
|
||
|
|
/**
|
||
|
|
* 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()//
|
||
|
|
/**
|
||
|
|
* Gets whether the collection items should be compared using logical equality instead of the default identitiy equality.
|
||
|
|
* @return Whether a logical compare should be used on collection items.
|
||
|
|
*/
|
||
|
|
public boolean getUseLogicalComparison() {
|
||
|
|
return useLogicalComparison;
|
||
|
|
}//getUseLogicalComparison()//
|
||
|
|
/**
|
||
|
|
* Sets whether the collection items should be compared using logical equality instead of the default identitiy equality.
|
||
|
|
* @param useLogicalComparison Whether a logical compare should be used on collection items.
|
||
|
|
*/
|
||
|
|
public void setUseLogicalComparison(boolean useLogicalComparison) {
|
||
|
|
this.useLogicalComparison = useLogicalComparison;
|
||
|
|
}//setUseLogicalComparison()//
|
||
|
|
/**
|
||
|
|
* Determines whether the two texts require swapping.
|
||
|
|
* This is used by the sorting code to determine whether rows should be swapped.
|
||
|
|
* @param text1 The first text.
|
||
|
|
* @param text2 The second text (following the first text).
|
||
|
|
* @param reverse Whether the logic should be reversed.
|
||
|
|
* @return Whether text1 and text2 require swapping.
|
||
|
|
*/
|
||
|
|
protected boolean requiresSwap(String text1, String text2, boolean reverse) {
|
||
|
|
int compare = Comparator.getNumericStringComparator().compare(text1, text2);
|
||
|
|
|
||
|
|
return reverse ? compare > 0 : compare < 0;
|
||
|
|
}//requiresSwap()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IAbstractContainer#getComponents()
|
||
|
|
*/
|
||
|
|
public IList getComponents() {
|
||
|
|
return LiteList.EMPTY_LIST;
|
||
|
|
}//getComponents()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#center()
|
||
|
|
*/
|
||
|
|
public void center() {
|
||
|
|
getContainer().center();
|
||
|
|
}//center()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#center(com.foundation.view.IView)
|
||
|
|
*/
|
||
|
|
public void center(IView centerOnView) {
|
||
|
|
getContainer().center(centerOnView);
|
||
|
|
}//center()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#execute(com.common.thread.IRunnable)
|
||
|
|
*/
|
||
|
|
public Object execute(IRunnable runnable) {
|
||
|
|
return getContainer().execute(runnable);
|
||
|
|
}//execute()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#executeAsynch(com.common.thread.IRunnable)
|
||
|
|
*/
|
||
|
|
public void executeAsync(IRunnable runnable) {
|
||
|
|
getContainer().executeAsync(runnable);
|
||
|
|
}//executeAsynch()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#getRequestHandler()
|
||
|
|
*/
|
||
|
|
public IRequestHandler getRequestHandler() {
|
||
|
|
return getContainer().getRequestHandler();
|
||
|
|
}//getRequestHandler()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#maximize()
|
||
|
|
*/
|
||
|
|
public void maximize() {
|
||
|
|
getContainer().maximize();
|
||
|
|
}//maximize()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#minimize()
|
||
|
|
*/
|
||
|
|
public void minimize() {
|
||
|
|
getContainer().minimize();
|
||
|
|
}//minimize()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#pack()
|
||
|
|
*/
|
||
|
|
public final void pack() {
|
||
|
|
getContainer().pack();
|
||
|
|
}//pack()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#layout()
|
||
|
|
*/
|
||
|
|
public final void layout() {
|
||
|
|
getContainer().layout();
|
||
|
|
}//layout()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.IView#show()
|
||
|
|
*/
|
||
|
|
public void show() {
|
||
|
|
getContainer().show();
|
||
|
|
}//show()//
|
||
|
|
/**
|
||
|
|
* Determines whether the control is capable of processing collection item decorations.
|
||
|
|
* @return Whether the control can handle collection item decorations.
|
||
|
|
*/
|
||
|
|
protected boolean canDecorate() {
|
||
|
|
return false;
|
||
|
|
}//canDecorate()//
|
||
|
|
/**
|
||
|
|
* Gets whether the items in the collection decorate the rows in the display.
|
||
|
|
* @return Whether the markup for the objects in the collection will decorate the rows in the collection control.
|
||
|
|
*/
|
||
|
|
public boolean getDecorateItems() {
|
||
|
|
return decorateItems;
|
||
|
|
}//getDecorateItems()//
|
||
|
|
/**
|
||
|
|
* Sets whether the items in the collection decorate the rows in the display.
|
||
|
|
* @param decorateItems Whether the markup for the objects in the collection will decorate the rows in the collection control.
|
||
|
|
*/
|
||
|
|
public void setDecorateItems(boolean decorateItems) {
|
||
|
|
if(!isInitialized() && this.decorateItems != decorateItems) {
|
||
|
|
this.decorateItems = decorateItems;
|
||
|
|
}//if//
|
||
|
|
}//setDecorateItems()//
|
||
|
|
/* (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) {
|
||
|
|
boolean result = false;
|
||
|
|
|
||
|
|
//Note: This method should be overloaded to test the decoration type also. This is left up to subclasses since only they know what types of decorations are supported.//
|
||
|
|
if(currentCollection != null && attribute == null) {
|
||
|
|
//TODO: For very large collections we should really use a hash set here otherwise we could end up with really bad performance. We could create on on the fly if we knew what size of collection starts to degrade performance.
|
||
|
|
result = currentCollection.containsValue(object);
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}//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) {
|
||
|
|
//Override in subclasses.//
|
||
|
|
}//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) {
|
||
|
|
//Override in subclasses.//
|
||
|
|
}//removeDecoration()//
|
||
|
|
}//CollectionComponent//
|