AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
invocationChange (InvocationEvent event) yoix.event
 
The invocationChange event handler is a special user-defined Function that can be added to a JTable when it is created and that will be called automatically with a single InvocationEvent argument whenever a JTable columns are reordered or resized. An invocationChange event handler can only be added via addEventHandler after a component is created, but an existing invocationChange event handler can be assigned new values. Assigning NULL to invocationChange disables its functionality until a non-NULL value is assigned to it.

The InvocationEvent received by this handler will have the following fields:
change A String that indicates what sort of change caused the event to occur. Possible values are:
add signals that a column has been added to the table. The event will also contain viewColumn and valuesColumn elements.
drag signals that a column has been moved within the table. The event will also contain fromViewColumn, toViewColumn, and valuesColumn elements.
remove signals that a column has been removed from the table. The event will also contain viewColumn and valuesColumn elements.
resize signals that a column has been resized in the table. The event will also contain viewColumn, valuesColumn, and width elements.
The value text of this element will be entirely in lower case as indicated above.
fromViewColumn When change is drag, then this int element is included in the event and gives the most recent location of the column being moved in terms of the current table view. Note that when a column is being dragged across several columns an event of this type will be generated each time the moving column finds a potential resting place, which is indicated by toViewColumn. Thus this value is not necessarily the original starting position of the column, but only the previous potential stopping point in the course of the drag.
id An Object that must be an int or String, that identifies the type of this event. A value that is a String must be the name of an event handler that can process this event. A value that is an int must be a number that the yoix.event.HandlerID dictionary associates with an event handler that can process this event.

In practice, id is only used when you build an event that gets handed to postEvent, and in that case the value assigned to id is almost always a String.

toViewColumn When change is drag, then this int element is included in the event and gives the current location of the column being moved in terms of the current table view. Note that when a column is being dragged across several columns an event of this type will be generated each time the moving column finds a potential resting place, which is indicated by this value.
valuesColumn This int element is always present in the event regardless of the value of change. It provides the index in the data matrix of the column being added, dragged, removed or resized.
viewColumn This int element is present in the event whenever the value of change is add, remove or resize. It provides the index in the current table view of the column being added, removed or resized.
width This double element is present in the event whenever the value of change is resize. It indicates the current with of the column being resized. As with other Yoix measures, this value is in screen units of 72 per inch.
 
 Example:   The program,
import yoix.*.*;

JFrame screen = {
 Dimension size = NULL;
 int    visible = TRUE;

 Array layout = {
  new JTable {
   String tag = "$_table";
   int reorder = TRUE;
   int resize = TRUE;
   int scroll = AS_NEEDED;
   int edit = 0;
   Array headers = { "Region", "Median", "% of US", "Selected" };
   Array types = { STRING_TYPE, MONEY_TYPE, PERCENT_TYPE, BOOLEAN_TYPE };
   String values = "US|44473|1|1\nNH|57352|1.28959|0\n"
    + "MI|44476|1.00007|0\nWV|32589|0.73278|0\n";
   int resizemode = AUTO_RESIZE_OFF;
   Color background = Color.white;


   invocationChange(e) {
    switch(e.change) {
    case "resize":
     if (e.viewColumn >= 0) {
      root.SyncSizes(this, root.components.$_filter);
     }
     break;
    case "drag":
     root.components.$_filter.action(MOVE_COLUMN, e.fromViewColumn, e.toViewColumn);
     break;
    }
   }

   int adjusting = FALSE;
   adjustmentValueChanged(e) {

    if (e.orientation == HORIZONTAL) {
     adjusting = TRUE;

     if (!root.components.$_filter.adjusting)
      root.components.$_filter.origin = new Point { double x = origin.x; int y = 0; };
     adjusting = FALSE;
    }
   }
  },
  CENTER,
  new JTable {
   String tag = "$_filter";
   int reorder = 0;
   int rows = 1;
   int resize = 0;
   int scrollinit = NONE;
   int scrollvert = HORIZONTAL_NEVER|VERTICAL_ALWAYS;
   int scrollmode = scrollinit;
   int scroll = scrollmode;
   int resizemode = AUTO_RESIZE_OFF;
   int rowheightadjustment = -1;
   int edit = TRUE;
   Color background = Color.white;
   Color selectionbackground = Color.white;

   String outputfilter = "\t";

   Array types = {
    STRING_TYPE, STRING_TYPE, STRING_TYPE, STRING_TYPE,
   };
   String text = "A|B|C|D";

   int adjusting = FALSE;
   adjustmentValueChanged(e) {

    if (e.orientation == HORIZONTAL) {
     adjusting = TRUE;

     if (!root.components.$_table.adjusting)
      root.components.$_table.origin = new Point { double x = origin.x; int y = 0; };
     adjusting = FALSE;
    }
   }
  },
  SOUTH,
 };

 SyncSizes(JTable master, JTable slave) {
  if (master.size.height > master.viewport.height) {
   if (slave.scrollmode == slave.scrollinit) {
    slave.scrollmode = slave.scrollvert;
    slave.scroll = slave.scrollvert;
   }
  } else {
   if (slave.scrollmode == slave.scrollvert) {
    slave.scrollmode = slave.scrollinit;
    slave.scroll = slave.scrollinit;
   }
  }
  for(n = 0; n < master.width; n++) {
   w = master.action(GET_COLUMN_FIELD, n, "width");
	 v = master.action(GET_COLUMN_VIEW_INDEX, n);
	 m = slave.action(GET_COLUMN_DATA_INDEX, v);
	 slave.action(SET_COLUMN_FIELD, m, "width", w);
  }
 }
};
shows how the columns of two tables can be kept in sync. In this case, the bottom table tracks drag and resize changes made to columns in the top table.
 
 Return:   none
 
 See Also:   actionPerformed, addEventHandler, adjustmentValueChanged, caretUpdate, componentHidden, componentMoved, componentResized, componentShown, dragDropEnd, dragEnter, dragExit, dragGestureRecognized, dragMouseMoved, dragOver, drop, dropActionChanged, Event, focusGained, focusLost, hyperlinkActivated, hyperlinkEntered, hyperlinkExited, invocationAction, invocationBrowse, invocationEdit, invocationEditKey, InvocationEvent, invocationRun, invocationSelection, itemStateChanged, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, removeEventHandler, stateChanged, textValueChanged, valueChanged, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened

 

Yoix is a registered trademark of AT&T Intellectual Property.