/** * Creates and returns the default <code>Action</code> for toggling the * horizontal scrollBar. */ private Action createHorizontalScrollAction() { BoundAction action = new BoundAction(null, HORIZONTALSCROLL_ACTION_COMMAND); action.setStateAction(); action.registerCallback(this, "setHorizontalScrollEnabled"); action.setSelected(isHorizontalScrollEnabled()); return action; }
/** * Creates and returns the default <code>Action</code> for packing the * selected column. */ private Action createPackSelectedAction() { BoundAction action = new BoundAction(null, PACKSELECTED_ACTION_COMMAND); action.registerCallback(this, "packSelected"); action.setEnabled(getSelectedColumnCount() > 0); return action; }
/** * Add an item listener which will be invoked for toggle actions. */ public void addItemListener(ItemListener listener) { addListener(ItemListener.class, listener); }
/** * Creates and returns the default <b>Action </b> for packing all columns. */ private Action createPackAllAction() { BoundAction action = new BoundAction(null, PACKALL_ACTION_COMMAND); action.registerCallback(this, "packAll"); return action; }
/** * Callback for toggle actions. */ public void itemStateChanged(ItemEvent evt) { // Update all objects that share this item boolean newValue; boolean oldValue = isSelected(); newValue = evt.getStateChange() == ItemEvent.SELECTED; if (oldValue != newValue) { setSelected(newValue); // Forward the event to the delgate for handling. ItemListener[] ilist = getItemListeners(); if (ilist != null) { for (int i = 0; i < ilist.length; i++) { ilist[i].itemStateChanged(evt); } } } }
/** * Registers a callback method when the Action corresponding to * the action id is invoked. When a Component that was constructed from the * Action identified by the action id invokes actionPerformed then the method * named will be invoked on the handler Object. * <p> * If the Action represented by the action id is a StateChangeAction, then * the method passed should take an int as an argument. The value of * getStateChange() on the ItemEvent object will be passed as the parameter. * * @param handler the object which will be perform the action * @param method the name of the method on the handler which will be called. */ public void registerCallback(Object handler, String method) { if (isStateAction()) { // Create a handler for toggle type actions. addItemListener(new BooleanInvocationHandler(handler, method)); } else { // Create a new ActionListener using the dynamic proxy API. addActionListener(EventHandler.create(ActionListener.class, handler, method)); } }
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); Object typeOrNull; while (null != (typeOrNull = s.readObject())) { if ("callback".equals(typeOrNull)) { Object handler = s.readObject(); String method = (String) s.readObject(); addActionListener(EventHandler.create(ActionListener.class, handler, method)); } else if (BooleanInvocationHandler.class.getName().equals(typeOrNull)) { Object handler = s.readObject(); String method = (String) s.readObject(); addItemListener(new BooleanInvocationHandler(handler, method)); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); EventListener l = (EventListener) s.readObject(); addListener((Class<EventListener>)Class.forName((String)typeOrNull, true, cl), l); } } } }
/** * Convenience method to register a callback method on a <code>BoundAction</code> * * @see BoundAction#registerCallback * @param id value of the action id - which is the value of the ACTION_COMMAND_KEY * @param handler the object which will be perform the action * @param method the name of the method on the handler which will be called. */ public void registerCallback(Object id, Object handler, String method) { BoundAction action = getBoundAction(id); if (action != null) { action.registerCallback(handler, method); } }
/** * Synchs selected state of horizontal scrolling <code>Action</code> to * enablement of enhanced auto-resize behaviour. */ protected void updateHorizontalAction() { Action showHorizontal = getActionMap().get( HORIZONTALSCROLL_ACTION_COMMAND); if (showHorizontal instanceof BoundAction) { ((BoundAction) showHorizontal) .setSelected(isHorizontalScrollEnabled()); } }
public static BoundAction createBoundAction(String id, String name, String mnemonic, boolean toggle, String group) { return (BoundAction)configureAction(new BoundAction(name, id), mnemonic, toggle, group); }
/** * Callback for command actions. */ @Override public void actionPerformed(ActionEvent evt) { ActionListener[] alist = getActionListeners(); if (alist != null) { for (int i = 0 ; i < alist.length; i++) { alist[i].actionPerformed(evt); } } }
/** * Creates and returns the default <b>Action </b> for packing all columns. */ private Action createPackAllAction() { BoundAction action = new BoundAction(null, PACKALL_ACTION_COMMAND); action.registerCallback(this, "packAll"); return action; }
/** * Callback for toggle actions. */ @Override public void itemStateChanged(ItemEvent evt) { // Update all objects that share this item boolean newValue; boolean oldValue = isSelected(); newValue = evt.getStateChange() == ItemEvent.SELECTED; if (oldValue != newValue) { setSelected(newValue); // Forward the event to the delgate for handling. ItemListener[] ilist = getItemListeners(); if (ilist != null) { for (int i = 0; i < ilist.length; i++) { ilist[i].itemStateChanged(evt); } } } }
/** * Registers a callback method when the Action corresponding to * the action id is invoked. When a Component that was constructed from the * Action identified by the action id invokes actionPerformed then the method * named will be invoked on the handler Object. * <p> * If the Action represented by the action id is a StateChangeAction, then * the method passed should take an int as an argument. The value of * getStateChange() on the ItemEvent object will be passed as the parameter. * * @param handler the object which will be perform the action * @param method the name of the method on the handler which will be called. */ public void registerCallback(Object handler, String method) { if (isStateAction()) { // Create a handler for toogle type actions. addItemListener(new BooleanInvocationHandler(handler, method)); } else { // Create a new ActionListener using the dynamic proxy api. addActionListener((ActionListener)EventHandler.create(ActionListener.class, handler, method)); } }
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); Object typeOrNull; while (null != (typeOrNull = s.readObject())) { if ("callback".equals(typeOrNull)) { Object handler = s.readObject(); String method = (String) s.readObject(); addActionListener(EventHandler.create(ActionListener.class, handler, method)); } else if (BooleanInvocationHandler.class.getName().equals(typeOrNull)) { Object handler = s.readObject(); String method = (String) s.readObject(); addItemListener(new BooleanInvocationHandler(handler, method)); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); EventListener l = (EventListener) s.readObject(); addListener((Class<EventListener>)Class.forName((String)typeOrNull, true, cl), l); } } } }
/** * Convenience method to register a callback method on a <code>BoundAction</code> * * @see BoundAction#registerCallback * @param id value of the action id - which is the value of the ACTION_COMMAND_KEY * @param handler the object which will be perform the action * @param method the name of the method on the handler which will be called. */ public void registerCallback(Object id, Object handler, String method) { BoundAction action = getBoundAction(id); if (action != null) { action.registerCallback(handler, method); } }
/** * Synchs selected state of horizontal scrolling <code>Action</code> to * enablement of enhanced auto-resize behaviour. */ protected void updateHorizontalAction() { Action showHorizontal = getActionMap().get( HORIZONTALSCROLL_ACTION_COMMAND); if (showHorizontal instanceof BoundAction) { ((BoundAction) showHorizontal) .setSelected(isHorizontalScrollEnabled()); } }
public static BoundAction createBoundAction(String id, String name, String mnemonic, boolean toggle, String group) { return (BoundAction)configureAction(new BoundAction(name, id), mnemonic, toggle, group); }
/** * Callback for command actions. */ public void actionPerformed(ActionEvent evt) { ActionListener[] alist = getActionListeners(); if (alist != null) { for (int i = 0 ; i < alist.length; i++) { alist[i].actionPerformed(evt); } } }
/** * Creates and returns the default <code>Action</code> for toggling the * horizontal scrollBar. */ private Action createHorizontalScrollAction() { BoundAction action = new BoundAction(null, HORIZONTALSCROLL_ACTION_COMMAND); action.setStateAction(); action.registerCallback(this, "setHorizontalScrollEnabled"); action.setSelected(isHorizontalScrollEnabled()); return action; }