示例#1
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;
 }
示例#2
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;
  }
示例#3
0
  protected void encodeTable(FacesContext facesContext, DataGrid grid, boolean hidden)
      throws IOException {
    ResponseWriter writer = facesContext.getResponseWriter();
    String clientId = grid.getClientId(facesContext);
    int columns = grid.getColumns();
    int rowIndex = grid.getFirst();
    int numberOfRowsToRender =
        (grid.getRows() != 0 ? grid.getRows() : grid.getRowCount()) / columns;

    writer.startElement("table", grid);
    writer.writeAttribute("id", clientId + "_table", "id");
    writer.writeAttribute("class", DataGrid.TABLE_CLASS, null);
    if (hidden) writer.writeAttribute("style", "display:none", null);

    writer.startElement("tbody", null);

    for (int i = 0; i < numberOfRowsToRender; i++) {
      writer.startElement("tr", null);
      writer.writeAttribute("class", DataGrid.TABLE_ROW_CLASS, null);

      for (int j = 0; j < columns; j++) {
        grid.setRowIndex(rowIndex);

        writer.startElement("td", null);
        writer.writeAttribute("class", DataGrid.TABLE_COLUMN_CLASS, null);
        if (grid.isRowAvailable()) {
          renderChildren(facesContext, grid);
          rowIndex++;
        }
        writer.endElement("td");
      }

      writer.endElement("tr");

      if (!grid.isRowAvailable()) break;
    }

    grid.setRowIndex(-1); // cleanup

    writer.endElement("tbody");
    writer.endElement("table");
  }
示例#4
0
  protected void encodeScript(FacesContext facesContext, DataGrid grid) throws IOException {
    ResponseWriter writer = facesContext.getResponseWriter();
    String clientId = grid.getClientId(facesContext);
    String widgetVar = createUniqueWidgetVar(facesContext, grid);

    UIComponent form = ComponentUtils.findParentForm(facesContext, grid);
    if (form == null) {
      throw new FacesException("DataGrid : \"" + clientId + "\" must be inside a form element");
    }

    writer.startElement("script", null);
    writer.writeAttribute("type", "text/javascript", null);

    writer.write(widgetVar + " = new PrimeFaces.widget.DataGrid('" + clientId + "',{");
    writer.write("url:'" + getActionURL(facesContext) + "'");
    writer.write(",formId:'" + form.getClientId(facesContext) + "'");

    if (grid.isPaginator()) {
      writer.write(",paginator:new YAHOO.widget.Paginator({");
      writer.write("rowsPerPage:" + grid.getRows());
      writer.write(",totalRecords:" + grid.getRowCount());
      writer.write(",initialPage:" + grid.getPage());

      if (grid.getPageLinks() != 10) writer.write(",pageLinks:" + grid.getPageLinks());
      if (grid.getPaginatorTemplate() != null)
        writer.write(",template:'" + grid.getPaginatorTemplate() + "'");
      if (grid.getRowsPerPageTemplate() != null)
        writer.write(",rowsPerPageOptions : [" + grid.getRowsPerPageTemplate() + "]");
      if (grid.getFirstPageLinkLabel() != null)
        writer.write(",firstPageLinkLabel:'" + grid.getFirstPageLinkLabel() + "'");
      if (grid.getPreviousPageLinkLabel() != null)
        writer.write(",previousPageLinkLabel:'" + grid.getPreviousPageLinkLabel() + "'");
      if (grid.getNextPageLinkLabel() != null)
        writer.write(",nextPageLinkLabel:'" + grid.getNextPageLinkLabel() + "'");
      if (grid.getLastPageLinkLabel() != null)
        writer.write(",lastPageLinkLabel:'" + grid.getLastPageLinkLabel() + "'");
      if (grid.getCurrentPageReportTemplate() != null)
        writer.write(",pageReportTemplate:'" + grid.getCurrentPageReportTemplate() + "'");
      if (!grid.isPaginatorAlwaysVisible()) writer.write(",alwaysVisible:false");

      String paginatorPosition = grid.getPaginatorPosition();
      String paginatorContainer = null;
      if (paginatorPosition.equals("both"))
        paginatorContainer = clientId + "_paginatorTop','" + clientId + "_paginatorBottom";
      else if (paginatorPosition.equals("top")) paginatorContainer = clientId + "_paginatorTop";
      else if (paginatorPosition.equals("bottom"))
        paginatorContainer = clientId + "_paginatorBottom";

      writer.write(",containers:['" + paginatorContainer + "']");

      writer.write("})");

      if (grid.isEffect()) {
        writer.write(",effect:true");
        writer.write(",effectSpeed:'" + grid.getEffectSpeed() + "'");
      }
    }

    writer.write("});");

    writer.endElement("script");
  }