示例#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;
  }
示例#2
0
  private void setupSessionDataGrid() {
    sessionsDataGrid = new DataGrid<SessionDataDto>();
    sessionsDataGrid.setPageSize(15);
    sessionsDataGrid.setEmptyTableWidget(new Label("No Sessions"));

    // Add a selection model so we can select cells.
    final SelectionModel<SessionDataDto> selectionModel =
        new MultiSelectionModel<SessionDataDto>(
            new ProvidesKey<SessionDataDto>() {
              @Override
              public Object getKey(SessionDataDto item) {
                return item.getSessionId();
              }
            });
    sessionsDataGrid.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<SessionDataDto>createCheckboxManager());

    // Checkbox column. This table will uses a checkbox column for selection.
    // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable mouse selection.
    Column<SessionDataDto, Boolean> checkColumn =
        new Column<SessionDataDto, Boolean>(new CheckboxCell(true, false)) {
          @Override
          public Boolean getValue(SessionDataDto object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
          }
        };
    sessionsDataGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    sessionsDataGrid.setColumnWidth(checkColumn, 40, Style.Unit.PX);

    sessionsDataGrid.addColumn(
        new TextColumn<SessionDataDto>() {
          @Override
          public String getValue(SessionDataDto object) {
            return object.getName();
          }
        },
        "Name");

    sessionsDataGrid.addColumn(
        new TextColumn<SessionDataDto>() {
          @Override
          public String getValue(SessionDataDto object) {
            return object.getStartDate();
          }
        },
        "Start Date");

    sessionsDataGrid.addColumn(
        new TextColumn<SessionDataDto>() {
          @Override
          public String getValue(SessionDataDto object) {
            return object.getEndDate();
          }
        },
        "End Date");

    sessionDataProvider.addDataDisplay(sessionsDataGrid);
  }
示例#3
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();
  }
示例#4
0
 @UiHandler("showCheckedSessionsButton")
 void handleShowCheckedSessionsButtonClick(ClickEvent e) {
   Set<SessionDataDto> sessionDataDtoSet =
       ((MultiSelectionModel<SessionDataDto>) sessionsDataGrid.getSelectionModel())
           .getSelectedSet();
   filterSessions(sessionDataDtoSet);
 }
示例#5
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);
    }
  }
示例#6
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;
 }
示例#7
0
 private void markChange(InputItem rec) {
   if (!changedRecs.containsKey(rec.getId())) {
     changedRecs.put(rec.getId(), rec);
     if (!separator.isVisible()) {
       md.info(
           MDS, "Some data has been changed. Click 'Save' or 'Cancel' when editing is finished.");
       editMode(true);
     }
     dataGrid.redraw();
   }
 }
示例#8
0
  public void updatePlace(TrendsPlace place) {
    if (this.place != null) return;

    this.place = place;
    final TrendsPlace finalPlace = this.place;
    if (place.getSelectedSessionIds().isEmpty()) {

      sessionsDataGrid
          .getSelectionModel()
          .addSelectionChangeHandler(new SessionSelectChangeHandler());

      selectTests = true;
      testDataGrid.getSelectionModel().addSelectionChangeHandler(new TestSelectChangeHandler());

      TaskDataTreeViewModel viewModel = (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel();
      viewModel
          .getSelectionModel()
          .addSelectionChangeHandler(new TaskPlotSelectionChangedHandler());

      metricPanel.addSelectionListener(new MetricsSelectionChangedHandler());

      chooseTab(place.getToken());
      return;
    }

    SessionDataService.Async.getInstance()
        .getBySessionIds(
            0,
            place.getSelectedSessionIds().size(),
            place.getSelectedSessionIds(),
            new AsyncCallback<PagedSessionDataDto>() {
              @Override
              public void onFailure(Throwable caught) {
                caught.printStackTrace();
              }

              @Override
              public void onSuccess(PagedSessionDataDto result) {
                for (SessionDataDto session : result.getSessionDataDtoList()) {
                  sessionsDataGrid.getSelectionModel().setSelected(session, true);
                }
                sessionsDataGrid
                    .getSelectionModel()
                    .addSelectionChangeHandler(new SessionSelectChangeHandler());
                sessionsDataGrid
                    .getSelectionModel()
                    .setSelected(result.getSessionDataDtoList().iterator().next(), true);
                chooseTab(finalPlace.getToken());
              }
            });
    History.newItem(NameTokens.EMPTY);
  }
示例#9
0
  private void createDataGrid() {
    dataGrid = new DataGrid<InputItem>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER);
    selectionModel = new SingleSelectionModel<InputItem>(KEY_PROVIDER);
    dataGrid.setSelectionModel(selectionModel);

    recordStore = new ListDataProvider<InputItem>(KEY_PROVIDER);
    recordStore.addDataDisplay(dataGrid);

    sortHandler = new ColumnSortEvent.ListHandler<InputItem>(recordStore.getList());

    Column<InputItem, InputItem> colId = new IdentityColumn<InputItem>(ID_CELL);
    dataGrid.addColumn(colId, new ResizableHeader<InputItem>("#", dataGrid, colId));
    dataGrid.setColumnWidth(colId, 35, Style.Unit.PX);

    final EditTextCell cellName = new EditTextCell();
    Column<InputItem, String> colName =
        new Column<InputItem, String>(cellName) {
          @Override
          public String getValue(InputItem rec) {
            return rec.getName();
          }
        };
    colName.setFieldUpdater(
        new FieldUpdater<InputItem, String>() {
          @Override
          public void update(int index, InputItem rec, String value) {
            if (!value.equals(rec.getName())) {
              markChange(rec);
              rec.setName(value);
              cellName.clearViewData(rec.getId());
            }
          }
        });
    dataGrid.addColumn(colName, new ResizableHeader<InputItem>("Name", dataGrid, colName));
    dataGrid.setColumnWidth(colName, 128, Style.Unit.PX);

    colName.setSortable(true);
    sortHandler.setComparator(
        colName,
        new Comparator<InputItem>() {
          @Override
          public int compare(InputItem o1, InputItem o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });

    //        final SelectCell<String,Integer> cellActive = new SelectCell<String,Integer>(
    //                ZicoWidgets.<String,Integer>map("NO",0,"YES",1));
    //        Column<InputItem,Integer> colActive = new Column<InputItem, Integer>(cellActive) {
    //            @Override
    //            public Integer getValue(InputItem rec) {
    //                return rec.getActive();
    //            }
    //        };
    //        colActive.setFieldUpdater(new FieldUpdater<InputItem, Integer>() {
    //            @Override
    //            public void update(int index, InputItem rec, Integer value) {
    //                if (rec.getActive() != value) {
    //                    markChange(rec);
    //                    rec.setActive(value);
    //                    cellActive.clearViewData(rec.getId());
    //                }
    //            }
    //        });
    //        dataGrid.addColumn(colActive, new ResizableHeader<InputItem>("Active", dataGrid,
    // colActive));
    //        dataGrid.setColumnWidth(colActive, 128, Style.Unit.PX);

    //        final DatePickerCell cellTstart = new DatePickerCell(ClientUtil.TSTAMP_FORMAT0);
    //        Column<InputItem,Date> colTstart = new Column<InputItem, Date>(cellTstart) {
    //            @Override
    //            public Date getValue(InputItem rec) {
    //                return ClientUtil.unix2date(rec.getTstart());
    //            }
    //        };
    //        colTstart.setFieldUpdater(new FieldUpdater<InputItem, Date>() {
    //            @Override
    //            public void update(int index, InputItem rec, Date value) {
    //                long t = ClientUtil.date2unix(value);
    //                if (t != rec.getTstart()) {
    //                    markChange(rec);
    //                    rec.setTstart(t);
    //                    cellTstart.clearViewData(rec.getId());
    //                }
    //            }
    //        });
    //        colTstart.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    //        dataGrid.addColumn(colTstart, new ResizableHeader<InputItem>("TStart", dataGrid,
    // colTstart));
    //        dataGrid.setColumnWidth(colTstart, 100, Style.Unit.PX);

    //        final DatePickerCell cellTstop = new DatePickerCell(ClientUtil.TSTAMP_FORMAT0);
    //        Column<InputItem,Date> colTstop = new Column<InputItem, Date>(cellTstop) {
    //            @Override
    //            public Date getValue(InputItem rec) {
    //                return ClientUtil.unix2date(rec.getTstop());
    //            }
    //        };
    //        colTstop.setFieldUpdater(new FieldUpdater<InputItem, Date>() {
    //            @Override
    //            public void update(int index, InputItem rec, Date value) {
    //                long t = ClientUtil.date2unix(value);
    //                if (t != rec.getTstop()) {
    //                    markChange(rec);
    //                    rec.setTstop(t);
    //                    cellTstop.clearViewData(rec.getId());
    //                }
    //            }
    //        });
    //        colTstop.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    //        dataGrid.addColumn(colTstop, new ResizableHeader<InputItem>("TStop", dataGrid,
    // colTstop));
    //        dataGrid.setColumnWidth(colTstop, 100, Style.Unit.PX);

    Column<InputItem, Integer> colInput =
        new Column<InputItem, Integer>(cellInput) {
          @Override
          public Integer getValue(InputItem iitem) {
            return iitem.getInputId();
          }
        };
    colInput.setFieldUpdater(
        new FieldUpdater<InputItem, Integer>() {
          @Override
          public void update(int index, InputItem rec, Integer value) {
            if (rec.getInputId() != value) {
              markChange(rec);
              rec.setInputId(value);
              cellInput.clearViewData(rec.getId());
            }
          }
        });
    dataGrid.addColumn(colInput, new ResizableHeader<InputItem>("Input", dataGrid, colInput));
    dataGrid.setColumnWidth(colInput, 128, Style.Unit.PX);

    Column<InputItem, Integer> colTxForm =
        new Column<InputItem, Integer>(cellTxForm) {
          @Override
          public Integer getValue(InputItem rec) {
            return rec.getTxFormid();
          }
        };
    colTxForm.setFieldUpdater(
        new FieldUpdater<InputItem, Integer>() {
          @Override
          public void update(int index, InputItem iitem, Integer value) {
            if (iitem.getTxFormid() != value) {
              markChange(iitem);
              iitem.setTxFormid(value);
              cellTxForm.clearViewData(iitem.getId());
            }
          }
        });
    dataGrid.addColumn(colTxForm, new ResizableHeader<InputItem>("TxForm", dataGrid, colTxForm));
    dataGrid.setColumnWidth(colTxForm, 128, Style.Unit.PX);

    final EditTextCell cellComment = new EditTextCell();
    Column<InputItem, String> colComment =
        new Column<InputItem, String>(cellComment) {
          @Override
          public String getValue(InputItem rec) {
            return rec.getComment();
          }
        };
    colComment.setFieldUpdater(
        new FieldUpdater<InputItem, String>() {
          @Override
          public void update(int index, InputItem rec, String value) {
            if (!value.equals(rec.getComment())) {
              markChange(rec);
              rec.setComment(value);
              cellComment.clearViewData(rec.getId());
            }
          }
        });
    dataGrid.addColumn(colComment, new ResizableHeader<InputItem>("Comment", dataGrid, colComment));

    colComment.setSortable(true);
    sortHandler.setComparator(
        colComment,
        new Comparator<InputItem>() {
          @Override
          public int compare(InputItem o1, InputItem o2) {
            return o1.getComment().compareTo(o2.getComment());
          }
        });

    dataGrid.addCellPreviewHandler(
        new CellPreviewEvent.Handler<InputItem>() {
          @Override
          public void onCellPreview(CellPreviewEvent<InputItem> event) {
            NativeEvent nev = event.getNativeEvent();
            String eventType = nev.getType();
            if (BrowserEvents.CONTEXTMENU.equals(eventType)) {
              selectionModel.setSelected(event.getValue(), true);
              if (event.getValue() != null) {
                contextMenu.setPopupPosition(
                    event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
                contextMenu.show();
              }
            }
          }
        });

    dataGrid.setKeyboardSelectionPolicy(
        HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);
    dataGrid.addDomHandler(
        new DoubleClickHandler() {
          @Override
          public void onDoubleClick(DoubleClickEvent event) {
            event.preventDefault();
          }
        },
        DoubleClickEvent.getType());
    dataGrid.addDomHandler(
        new ContextMenuHandler() {
          @Override
          public void onContextMenu(ContextMenuEvent event) {
            event.preventDefault();
          }
        },
        ContextMenuEvent.getType());
  }
示例#10
0
  @UiHandler("getHyperlink")
  void getHyperlink(ClickEvent event) {
    MultiSelectionModel<SessionDataDto> sessionModel =
        (MultiSelectionModel) sessionsDataGrid.getSelectionModel();
    MultiSelectionModel<TaskDataDto> testModel =
        (MultiSelectionModel) testDataGrid.getSelectionModel();

    Set<SessionDataDto> sessions = sessionModel.getSelectedSet();

    Set<TaskDataDto> tests = testModel.getSelectedSet();

    Set<MetricNameDto> metrics = metricPanel.getSelected();

    TaskDataTreeViewModel taskDataTreeViewModel =
        (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel();
    Set<PlotNameDto> trends = taskDataTreeViewModel.getSelectionModel().getSelectedSet();

    HashSet<String> sessionsIds = new HashSet<String>();
    HashSet<TestsMetrics> testsMetricses = new HashSet<TestsMetrics>(tests.size());
    HashMap<String, TestsMetrics> map = new HashMap<String, TestsMetrics>(tests.size());

    for (SessionDataDto session : sessions) {
      sessionsIds.add(session.getSessionId());
    }

    for (TaskDataDto taskDataDto : tests) {
      TestsMetrics testsMetrics =
          new TestsMetrics(taskDataDto.getTaskName(), new HashSet<String>(), new HashSet<String>());
      testsMetricses.add(testsMetrics);
      map.put(taskDataDto.getTaskName(), testsMetrics);
    }

    for (MetricNameDto metricNameDto : metrics) {
      map.get(metricNameDto.getTests().getTaskName()).getMetrics().add(metricNameDto.getName());
    }

    for (PlotNameDto plotNameDto : trends) {
      map.get(plotNameDto.getTest().getTaskName()).getTrends().add(plotNameDto.getPlotName());
    }

    TrendsPlace newPlace =
        new TrendsPlace(
            mainTabPanel.getSelectedIndex() == 0
                ? NameTokens.SUMMARY
                : mainTabPanel.getSelectedIndex() == 1 ? NameTokens.TRENDS : NameTokens.METRICS);

    newPlace.setSelectedSessionIds(sessionsIds);
    newPlace.setSelectedTestsMetrics(testsMetricses);
    newPlace.setSessionTrends(sessionPlotPanel.getSelected());

    String linkText =
        Window.Location.getHost()
            + Window.Location.getPath()
            + Window.Location.getQueryString()
            + "#"
            + new JaggerPlaceHistoryMapper().getToken(newPlace);
    linkText = URL.encode(linkText);

    // create a dialog for copy link
    final DialogBox dialog = new DialogBox(false, true);
    dialog.setText("Share link");
    dialog.setModal(true);
    dialog.setAutoHideEnabled(true);
    dialog.setPopupPosition(event.getClientX(), event.getClientY());

    final TextArea textArea = new TextArea();
    textArea.setText(linkText);
    textArea.setWidth("300px");
    textArea.setHeight("40px");
    // select text
    Scheduler.get()
        .scheduleDeferred(
            new Scheduler.ScheduledCommand() {
              @Override
              public void execute() {
                textArea.setVisible(true);
                textArea.setFocus(true);
                textArea.selectAll();
              }
            });

    dialog.add(textArea);

    dialog.show();
  }
示例#11
0
 @UiHandler("uncheckSessionsButton")
 void handleUncheckSessionsButtonClick(ClickEvent e) {
   MultiSelectionModel model = (MultiSelectionModel<?>) sessionsDataGrid.getSelectionModel();
   model.clear();
 }