예제 #1
0
 /** refresh on all buttons, the selected button will get state pressed */
 private void refreshSelection() {
   // reset all buttons to not set
   for (int i = 0; i < m_aButtons.length; i++) {
     if (m_aButtons[i] != null) {
       XControlModel xModel = (XControlModel) UnoDialog2.getModel(m_aButtons[i]);
       PropertySetHelper aHelper = new PropertySetHelper(xModel);
       if (i == m_nCurrentSelection) {
         final short one = 1;
         aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf(one));
       } else {
         final short zero = 0;
         aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf(zero));
       }
     }
   }
 }
예제 #2
0
  /** implementation of XActionListener will call if a button from the m_aButtonList is pressed. */
  public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) {
    XControlModel xModel = (XControlModel) UnoDialog2.getModel(actionEvent.Source);
    PropertySetHelper aHelper = new PropertySetHelper(xModel);

    int nState = aHelper.getPropertyValueAsInteger(PropertyNames.PROPERTY_STATE, -1);
    if (nState == 0) {
      // this will avoid a wrong state, if already pressed.
      aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf((short) 1));
    }

    // check which Button is pressed.
    String sControlName =
        aHelper.getPropertyValueAsString(PropertyNames.PROPERTY_NAME, PropertyNames.EMPTY_STRING);
    final String sButton = sControlName.substring(7 + m_aControlName.length());
    int nButton = Integer.parseInt(sButton);

    int index = getIndexFor(nButton);
    if (index < listModel.getSize()) {
      setSelected(index);
    }
  }