846 lines
30 KiB
Java
846 lines
30 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.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//
|