Exemplo n.º 1
0
  private boolean initializeOutstanding2(
      DataGrid grid,
      boolean ascend,
      boolean caseOn,
      BuySellType buySellType,
      BuySellType editOutstandingOrderBuySellType,
      IOpenCloseRelationSite openCloseRelationSite,
      Order mapOrder) {
    Boolean isSpot =
        openCloseRelationSite.getOrderType() == null
            ? null
            : openCloseRelationSite.getOrderType().isSpot();
    this.setOutstandingOrders(
        buySellType,
        mapOrder,
        isSpot,
        openCloseRelationSite.isMakeLimitOrder(),
        openCloseRelationSite.isDelivery());
    HashMap<Guid, RelationOrder> editOutstandingOrders =
        this.getEditOutstandingOrders(editOutstandingOrderBuySellType, mapOrder);
    boolean hasChange = this.hasChange(grid, editOutstandingOrders);

    if (hasChange) {
      this.unbindOutstanding();
      this._outstandingKey = Guid.newGuid().toString();
      this._bindingSourceForOutstanding = new tradingConsole.ui.grid.BindingSource();

      boolean isMakeOrder2 =
          this._settingsManager.get_Customer().get_SingleAccountOrderType() == 2
              || this._settingsManager.get_Customer().get_MultiAccountsOrderType() == 2;

      RelationOrder.initialize(
          isMakeOrder2,
          grid,
          this._outstandingKey,
          editOutstandingOrders.values(),
          this._bindingSourceForOutstanding,
          openCloseRelationSite,
          editOutstandingOrderBuySellType);

      int column = this._bindingSourceForOutstanding.getColumnByName(OutstandingOrderColKey.IsBuy);
      if (column != -1) {
        grid.sortColumn(column, false, ascend);
        TableColumnChooser.hideColumn(grid, column);
      }
    } else {
      this._outstandingKey = grid.get_BindingSource().get_DataSourceKey();
      this._outstandingOrders.clear();
      for (int row = 0; row < grid.getRowCount(); row++) {
        RelationOrder relationOrder = (RelationOrder) (grid.getObject(row));
        this._outstandingOrders.put(relationOrder.get_OpenOrderId(), relationOrder);
      }
    }

    return hasChange;
  }
Exemplo n.º 2
0
  public static void initialize(DataGrid grid) {
    // grid.setRedraw(false);
    // grid.reset();
    grid.setShowVerticalLines(false);
    grid.setBackground(GridFixedBackColor.account);
    grid.setForeground(GridBackColor.account);
    // grid.setBorderStyle(BorderStyle.account);
    // grid.setRowLabelWidth(RowLabelWidth.account);
    // grid.setSelectionBackground(SelectionBackground.account);
    // grid.setCurrentCellColor(CurrentCellColor.account);
    // grid.setCurrentCellBorder(CurrentCellBorder.account);

    // grid.setRedraw(true);
    // grid.doLayout();
  }
Exemplo n.º 3
0
  public static void initialize(
      DataGrid grid,
      String dataSourceKey,
      Collection dataSource,
      tradingConsole.ui.grid.BindingSource bindingSource,
      boolean isAllowEditIsBuy,
      int dQMaxMove,
      int stepSize) {
    grid.setShowVerticalLines(false);
    grid.setBackground(GridFixedBackColor.account);
    grid.setForeground(GridBackColor.account);
    // grid.setSelectionBackground(SelectionBackground.account);

    TradingConsole.bindingManager.bind(
        dataSourceKey,
        dataSource,
        bindingSource,
        MakeOrderAccount.getPropertyDescriptors(isAllowEditIsBuy, dQMaxMove, stepSize));
    grid.setModel(bindingSource);
    TradingConsole.bindingManager.setHeader(
        dataSourceKey,
        SwingConstants.CENTER,
        25,
        GridFixedForeColor.account,
        Color.white,
        HeaderFont.account);
    TradingConsole.bindingManager.setGrid(
        dataSourceKey,
        18,
        Color.black,
        Color.lightGray,
        Color.blue,
        true,
        true,
        GridFont.account,
        false,
        true,
        true);

    if (isAllowEditIsBuy) {
      String[] listStrings = new String[] {Language.Buy, Language.Sell};
      ListComboBoxCellEditor listComboBoxCellEditor = new ListComboBoxCellEditor(listStrings);
      int column = bindingSource.getColumnByName(MakeOrderAccountGridColKey.IsBuyForCombo);
      grid.getColumnModel().getColumn(column).setCellEditor(listComboBoxCellEditor);
    }
  }
Exemplo n.º 4
0
 private boolean hasChange(DataGrid grid, HashMap<Guid, RelationOrder> relationOrders) {
   if (grid.get_BindingSource() == null || grid.getRowCount() != relationOrders.size()) {
     return true;
   } else {
     int openOrderSummaryColumn = -1;
     for (int column = 0; column < grid.getColumnModel().getColumnCount(); column++) {
       if (grid.getColumnModel()
           .getColumn(column)
           .getIdentifier()
           .equals(OutstandingOrderColKey.OpenOrderSummary)) {
         openOrderSummaryColumn = column;
         break;
       }
     }
     for (int row = 0; row < grid.getRowCount(); row++) {
       RelationOrder realtionOrder = (RelationOrder) grid.getObject(row);
       Guid openOrderId = realtionOrder.get_OpenOrderId();
       RelationOrder realtionOrder2 = relationOrders.get(openOrderId);
       if (realtionOrder2 == null
           || realtionOrder2.getAvailableCloseLot().compareTo(realtionOrder.getAvailableCloseLot())
               != 0
           || (openOrderSummaryColumn > -1
               && !realtionOrder2
                   .get_OpenOrderSummary()
                   .equals(grid.getValueAt(row, openOrderSummaryColumn).toString()))) {
         return true;
       }
     }
   }
   return false;
 }