@Override
  public void messagePosted(final Message event) {
    final Account a = (Account) event.getObject(MessageProperty.ACCOUNT);

    if (account.equals(a)) {
      final SecurityNode node = (SecurityNode) event.getObject(MessageProperty.COMMODITY);

      EventQueue.invokeLater(
          new Runnable() {

            @Override
            public void run() {
              switch (event.getEvent()) {
                case ACCOUNT_REMOVE:
                  MessageBus.getInstance()
                      .unregisterListener(
                          AccountSecurityComboBox.this,
                          MessageChannel.ACCOUNT,
                          MessageChannel.COMMODITY);
                  model.removeAllElements();
                  account = null;
                  break;
                case ACCOUNT_SECURITY_ADD:
                  model.addElement(node);
                  break;
                case SECURITY_REMOVE:
                case ACCOUNT_SECURITY_REMOVE:
                  CommodityNode snode = getSelectedNode();
                  model.removeElement(node);

                  if (snode != null && node != null) {
                    if (snode.equals(node)) {
                      setSelectedItem(null);
                    }
                  }
                  break;
                case SECURITY_MODIFY:
                  updateNode(node);
                  break;
                default:
              }
            }
          });
    }
  }
Esempio n. 2
0
 @Override
 public void messagePosted(final Message event) {
   switch (event.getEvent()) {
     case FILE_CLOSING:
     case CURRENCY_MODIFY:
       simpleInstanceMap.clear();
       fullInstanceMap.clear();
       break;
     default:
       break;
   }
 }
Esempio n. 3
0
 @Override
 public void messagePosted(final Message event) {
   Platform.runLater(
       () -> {
         switch (event.getEvent()) {
           case FILE_LOAD_SUCCESS:
             disabled.setValue(false);
             break;
           case FILE_CLOSING:
             closeAllWindows();
             disabled.setValue(true);
             break;
           default:
             break;
         }
       });
 }
  @Override
  public void messagePosted(final Message event) {

    switch (event.getEvent()) {
      case ACCOUNT_ADD:
      case ACCOUNT_MODIFY:
      case ACCOUNT_REMOVE:
        reload();
        break;
      case TRANSACTION_ADD:
      case TRANSACTION_REMOVE:
        treeTableView
            .refresh(); // TODO implement a better model that listens to account balance changes
        break;
      case FILE_CLOSING:
        Platform.runLater(() -> treeTableView.setRoot(null));
        MessageBus.getInstance()
            .unregisterListener(
                this, MessageChannel.SYSTEM, MessageChannel.ACCOUNT, MessageChannel.TRANSACTION);
        break;
      default:
        break;
    }
  }