/** * Fire an ActionEvent at each registered listener. */ protected void fireActionPerformed(String command) { fireActionEvent(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, command)); }
@Override public void fireFinalEvents() { super.fireFinalEvents(); fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, actionCommand)); if (buttonGroup != null) buttonGroup.fireDelayedFinalEvents(); }
@Override public void fireIntermediateEvents() { super.fireIntermediateEvents(); if (buttonGroup != null) { buttonGroup.fireDelayedIntermediateEvents(); } }
/** * Gets the id of the component. * @return the component id */ public String getLowLevelEventId() { return getComponentId(); }
/** * Sets a button in the selected state. There can be only one button selected at a time. * * @param b the button. * @param selected true if this button is to be selected, otherwise false. */ public void setSelected(SAbstractButton b, boolean selected) { if (selected && b != selection && b != null) { setSelection(b); } // if button should be set to unselected, clear selection if (!selected && b != null && b.equals(selection)) { setSelection(null); } }
buttonGroup.setDelayEvents(true); setSelected(requestSelection); buttonGroup.setDelayEvents(false); } else { setSelected(requestSelection);
/** * Clears the selection such that none of the buttons * in the <code>SButtonGroup</code> are selected. */ public void clearSelection() { if (selection != null) { final SAbstractButton oldSelection = selection; selection = null; if (oldSelection.getGroup() == this) oldSelection.setSelected(false); fireActionPerformed(SELECTION_CHANGED); } }
button.getItemListeners().length > 0 || button.getChangeListeners().length > 0 || (button.getGroup() != null && button.getGroup().getActionListeners().length > 0)) { if (clientProperty == null) { String event = JavaScriptEvent.ON_CHANGE;
/** * removes all buttons from the group. */ public void removeAll() { while (!buttons.isEmpty()) remove(buttons.get(0)); }
/** * Sets the state of the button. * * * @param b true if the button is selected, otherwise false */ @Override public void setSelected(boolean b) { if (isSelected() != b) { if (buttonGroup != null) { buttonGroup.setSelected(this, b); } super.setSelected(b); } }
@Override public String getLowLevelEventId() { if (getGroup() != null && getShowAsFormComponent()) { return getGroup().getComponentId(); } else { return super.getLowLevelEventId(); } // end of if () }
/** * adds a button to the group. * * @param button the button that is to be added */ public void add(SAbstractButton button) { if (buttons != null && !buttons.contains(button)) { buttons.add(button); button.setGroup(this); if (selection == null && button.isSelected()) { setSelection(button); } } }
@Override public void processLowLevelEvent(String action, String... values) { processKeyEvents(values); if (action.endsWith("_keystroke")) return; delayEvents(true); boolean origSelected = isSelected(); if (getGroup() != null) { getGroup().setDelayEvents(true); setSelected(parseSelectionToggle(values[0])); getGroup().setDelayEvents(false); } else { setSelected(parseSelectionToggle(values[0])); } // end of else if (isSelected() != origSelected) { // got an event, that is a select... SForm.addArmedComponent(this); } // end of if () delayEvents(false); }
protected void setSelection(SAbstractButton button) { final SAbstractButton oldSelection = selection; selection = button; if (oldSelection != null && oldSelection.getGroup() == this) oldSelection.setSelected(false); if (selection != null) selection.setSelected(true); fireActionPerformed(selection != null ? selection.getActionCommand() : SELECTION_CHANGED); }
button.getItemListeners().length > 0 || button.getChangeListeners().length > 0 || (button.getGroup() != null && button.getGroup().getActionListeners().length > 0)) { if (clientProperty == null) { String event = JavaScriptEvent.ON_CHANGE;
@Override protected void setParentFrame(SFrame f) { if (f == getParentFrame()) return; if (buttonGroup != null && getSession().getDispatcher() != null) { getSession().getDispatcher().removeLowLevelEventListener(this, buttonGroup.getComponentId()); } // end of if () super.setParentFrame(f); if (buttonGroup != null && f != null && getSession().getDispatcher() != null) { getSession().getDispatcher().addLowLevelEventListener(this, buttonGroup.getComponentId()); } // end of if () }
/** * removes a button from the group. * * @param button the button that is to be removed */ public void remove(SAbstractButton button) { if (button == null || button.getGroup() != this) return; buttons.remove(button); button.setGroup(null); if (button == selection) { setSelection(null); } }
getGroup().setDelayEvents(true); setSelected(parseSelectionToggle(values[0])); getGroup().setDelayEvents(false); } else { setSelected(parseSelectionToggle(values[0]));
@Override public void fireFinalEvents() { fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, actionCommandToFire)); if (getGroup() != null) { getGroup().fireDelayedFinalEvents(); } }
/** * Add this button to a button group. This influences the event-prefix * this button reports to the request dispatcher: it will change to * the button group's prefix. */ protected void setGroup(SButtonGroup g) { if (isDifferent(buttonGroup, g)) { SButtonGroup oldVal = this.buttonGroup; // Do no longer react on events from old button group if (buttonGroup != null && getSession().getDispatcher() != null) { getSession().getDispatcher().removeLowLevelEventListener(this, buttonGroup.getComponentId()); } // end of if () buttonGroup = g; // Button Group changed but button already registered via parent frame? if (buttonGroup != null && getParentFrame() != null && getSession().getDispatcher() != null) { getSession().getDispatcher().addLowLevelEventListener(this, buttonGroup.getComponentId()); } // end of if () reload(); propertyChangeSupport.firePropertyChange("group", oldVal, this.buttonGroup); } }