Esempio n. 1
0
  /* ------------------------------------------------------------------ */
  public void propertyChange(PropertyChangeEvent aEvent) throws com.sun.star.uno.RuntimeException {
    try {
      // did it come from a radio button or checkbox?
      if (aEvent.PropertyName.equals("State")) { // yep
        Short aNewState = (Short) aEvent.NewValue;

        XPropertySet xModel = UNO.queryPropertySet(aEvent.Source);
        String sName = (String) xModel.getPropertyValue("Name");

        Short aClassId = (Short) xModel.getPropertyValue("ClassId");
        if (FormComponentType.RADIOBUTTON == aClassId.shortValue()) {
          String sRefValue = (String) xModel.getPropertyValue("RefValue");

          short nNewValue = ((Short) aEvent.NewValue).shortValue();
          if (sName.equals("KeyGen")) {
            // it's one of the options for key generation
            if (sRefValue.equals("none")) { // no automatic generation at all
              m_aSalesmanKeyGenerator.stopGenerator();
              m_aSalesKeyGenerator.stopGenerator();
            } else {
              boolean bGenerateOnReset = true;
              if (sRefValue.equals("update")) { // generate on update
                bGenerateOnReset = (0 == nNewValue);
              } else if (sRefValue.equals("reset")) { // generate on reset
                bGenerateOnReset = (0 != nNewValue);
              }
              m_aSalesmanKeyGenerator.activateKeyGenerator(bGenerateOnReset);
              m_aSalesKeyGenerator.activateKeyGenerator(bGenerateOnReset);
            }
          }
        } else if (FormComponentType.CHECKBOX == aClassId.shortValue()) {
          boolean bEnabled = (0 != aNewState.shortValue());
          if (sName.equals("defaultdate")) {
            m_bDefaultSalesDate = bEnabled;
          } else if (sName.equals("protectkeys")) {
            m_bProtectKeyFields = bEnabled;
            m_aSalesmenLocker.enableLock(m_bProtectKeyFields);
            m_aSalesLocker.enableLock(m_bProtectKeyFields);
          } else if (sName.equals("emptysales")) {
            m_bAllowEmptySales = bEnabled;
            m_aSalesNameValidator.enableColumnWatch(m_bAllowEmptySales);
          }
        }
      }
    } catch (com.sun.star.uno.Exception e) {
      System.out.println(e);
      e.printStackTrace();
    }
  }
Esempio n. 2
0
  /** performs any cleanup before exiting the program */
  @Override
  protected void cleanUp() throws java.lang.Exception {
    // remove the listeners at the buttons
    RevokeButtons aRevoke = new RevokeButtons(m_aOperator);
    aRevoke.handle(m_document.getFormComponentTreeRoot());

    // remove the key generator listeners from the form
    m_aSalesmanKeyGenerator.stopGenerator();
    m_aSalesKeyGenerator.stopGenerator();

    // and the control lockers
    m_aSalesmenLocker.enableLock(false);
    m_aSalesLocker.enableLock(false);

    // the validator for the grid column
    m_aSalesNameValidator.enableColumnWatch(false);

    // remove our own reset listener from the form
    XNameAccess xMasterAsNames = UnoRuntime.queryInterface(XNameAccess.class, m_xMasterForm);
    XReset xFormReset = UNO.queryReset(xMasterAsNames.getByName("Sales"));
    xFormReset.removeResetListener(this);

    super.cleanUp();
  }