Beispiel #1
0
 private void addDatePanel() {
   Grid datePanel = new Grid(2, 2);
   datePanel.setText(0, 0, "Departure Date:");
   DateBox departureBox = new DateBox();
   Date departureDate = new Date();
   departureBox.setValue(departureDate);
   datePanel.setWidget(0, 1, departureBox);
   datePanel.setText(1, 0, "Return Date:");
   DateBox returnBox = new DateBox();
   Date returnDate = DateUtils.datePlusWeek(departureDate);
   returnBox.setValue(returnDate);
   datePanel.setWidget(1, 1, returnBox);
   RootPanel.get("date-panel").add(datePanel);
 }
Beispiel #2
0
  private void createTransTable(DealLog[] logs) {
    transGrid = new Grid(logs.length + 1, TRANS_HISTORY_HEADERS.length);

    Util.createGridHeader(transGrid, TRANS_HISTORY_HEADERS, "tableList2");

    NumberFormat fmt = NumberFormat.getFormat("#,##0.00");
    for (int row = 1; row <= logs.length; row++) {
      final DealLog deal = logs[row - 1];
      transGrid.setWidget(row, 0, new Label(deal.getCode()));
      transGrid.getCellFormatter().addStyleName(row, 0, "textCell");
      transGrid.setWidget(row, 1, new Label(deal.getName()));
      transGrid.getCellFormatter().addStyleName(row, 1, "textCell");
      transGrid.setWidget(row, 2, new Label(deal.getBs()));
      transGrid.getCellFormatter().addStyleName(row, 2, "textCell");
      if ("买入".equals(deal.getBs())) {
        transGrid.getCellFormatter().removeStyleName(row, 2, "negativeChange");
        transGrid.getCellFormatter().addStyleName(row, 2, "positiveChange");
      } else {
        transGrid.getCellFormatter().removeStyleName(row, 2, "positiveChange");
        transGrid.getCellFormatter().addStyleName(row, 2, "negativeChange");
      }
      transGrid.setWidget(row, 3, new Label(fmt.format(deal.getPrice())));
      transGrid.getCellFormatter().addStyleName(row, 3, "numericCell");
      transGrid.setWidget(row, 4, new Label(fmt.format(deal.getAmount())));
      transGrid.getCellFormatter().addStyleName(row, 4, "numericCell");
      transGrid.setWidget(row, 5, new Label(fmt.format(deal.getCommission())));
      transGrid.getCellFormatter().addStyleName(row, 5, "numericCell");
      transGrid.setWidget(row, 6, new Label(deal.getCreated()));
      transGrid.getCellFormatter().addStyleName(row, 6, "textCell");
    }
  }
  private Grid buildDoubleList() {
    Grid grid = new Grid(2, 5);

    availableWorkspacesListBox = new ListBox();
    availableWorkspacesListBox.setVisibleItemCount(10);
    availableWorkspacesListBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent arg0) {
            String selectedWorkspaceName =
                availableWorkspacesListBox.getItemText(
                    availableWorkspacesListBox.getSelectedIndex());
            refreshModuleList(selectedWorkspaceName);
          }
        });
    // availableWorkspaces.setWidth( "30%" );

    refreshWorkspaceList();

    try {
      availableModulesListBox.setVisibleItemCount(10);
      selectedModulesListBox.setVisibleItemCount(10);

      Grid btnsPanel = new Grid(2, 1);

      btnsPanel.setWidget(
          0,
          0,
          new Button(
              ">",
              new ClickHandler() {

                public void onClick(ClickEvent sender) {
                  copySelected(availableModulesListBox, selectedModulesListBox);
                }
              }));

      btnsPanel.setWidget(
          1,
          0,
          new Button(
              "&lt;",
              new ClickHandler() {

                public void onClick(ClickEvent sender) {
                  copySelected(selectedModulesListBox, availableModulesListBox);
                }
              }));

      grid.setWidget(0, 0, new SmallLabel(constants.Workspaces()));
      grid.setWidget(0, 2, new SmallLabel("Workspace: Available Modules"));
      grid.setWidget(0, 3, new SmallLabel(""));
      grid.setWidget(0, 4, new SmallLabel("Workspace: Selected Modules"));
      grid.setWidget(1, 0, availableWorkspacesListBox);
      grid.setWidget(1, 2, availableModulesListBox);
      grid.setWidget(1, 3, btnsPanel);
      grid.setWidget(1, 4, selectedModulesListBox);

      grid.getColumnFormatter().setWidth(0, "25%");
      grid.getColumnFormatter().setWidth(1, "10%");
      grid.getColumnFormatter().setWidth(2, "25%");
      grid.getColumnFormatter().setWidth(3, "15%");
      grid.getColumnFormatter().setWidth(4, "25%");
      return grid;
    } finally {
      // sce.setFilteringFacts( filteringFact );
    }
  }
Beispiel #4
0
  private void insertRankTableRow(int row, final AccountInfo info) {
    NumberFormat fmt = NumberFormat.getFormat("#,##0.00");
    rankGrid.setWidget(row, 0, new Label(String.valueOf(row)));
    rankGrid.getCellFormatter().addStyleName(row, 0, "textCell");
    rankGrid.setWidget(row, 1, new Label(info.getDisplayName()));
    rankGrid.getCellFormatter().addStyleName(row, 1, "textCell");
    rankGrid.setWidget(row, 2, new Label(fmt.format(info.getIntialPrincipal())));
    rankGrid.getCellFormatter().addStyleName(row, 2, "numericCell");
    rankGrid.setWidget(row, 3, new Label(fmt.format(info.getLeftCapitical())));
    rankGrid.getCellFormatter().addStyleName(row, 3, "numericCell");
    rankGrid.setWidget(row, 4, new Label(fmt.format(info.getStockValue())));
    rankGrid.getCellFormatter().addStyleName(row, 4, "numericCell");
    rankGrid.setWidget(row, 5, new Label(fmt.format(info.getTotalValue())));
    rankGrid.getCellFormatter().addStyleName(row, 5, "numericCell");
    rankGrid.setWidget(row, 6, new Label(fmt.format(info.getProfit())));
    rankGrid.getCellFormatter().addStyleName(row, 6, "numericCell");
    rankGrid.setWidget(row, 7, new Label(fmt.format(info.getProfitPct()) + "%"));
    rankGrid.getCellFormatter().addStyleName(row, 7, "numericCell");
    if (info.getProfit() > 0) {
      rankGrid.getCellFormatter().removeStyleName(row, 7, "negativeChange");
      rankGrid.getCellFormatter().addStyleName(row, 7, "positiveChange");
      rankGrid.getCellFormatter().removeStyleName(row, 6, "negativeChange");
      rankGrid.getCellFormatter().addStyleName(row, 6, "positiveChange");
    } else if (info.getProfit() < 0) {
      rankGrid.getCellFormatter().removeStyleName(row, 7, "positiveChange");
      rankGrid.getCellFormatter().addStyleName(row, 7, "negativeChange");
      rankGrid.getCellFormatter().removeStyleName(row, 6, "positiveChange");
      rankGrid.getCellFormatter().addStyleName(row, 6, "negativeChange");
    } else {
      rankGrid.getCellFormatter().removeStyleName(row, 7, "positiveChange");
      rankGrid.getCellFormatter().removeStyleName(row, 7, "negativeChange");
      rankGrid.getCellFormatter().removeStyleName(row, 6, "positiveChange");
      rankGrid.getCellFormatter().removeStyleName(row, 6, "negativeChange");
    }

    if (info.getTotalValue() != 0) {
      rankGrid.setWidget(
          row, 8, new Label(fmt.format(100.0 * info.getStockValue() / info.getTotalValue()) + "%"));
    } else {
      rankGrid.setWidget(row, 8, new Label("--"));
    }
    rankGrid.getCellFormatter().addStyleName(row, 8, "numericCell");

    Anchor link = new Anchor("交易记录");
    rankGrid.setWidget(row, 9, link);
    link.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            showTransHistory(info.getUsername(), info.getDisplayName());
          }
        });
    rankGrid.getCellFormatter().addStyleName(row, 9, "textCell");

    Anchor positionBtn = new Anchor("当前持仓");
    rankGrid.setWidget(row, 10, positionBtn);
    positionBtn.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            showPosition(info.getUsername(), info.getDisplayName());
          }
        });
    rankGrid.getCellFormatter().addStyleName(row, 10, "textCell");
  }
  private Grid addWalrusEntry(int row, WalrusInfoWeb walrusInfo) {
    final ArrayList<String> properties = walrusInfo.getProperties();
    int numProperties = properties.size() / 4;
    Grid g = new Grid(1 + numProperties, 2);
    g.setStyleName("euca-table");
    g.setCellPadding(4);

    int i = 0; // row 1
    g.setWidget(i, 0, new Label("Walrus host:"));
    g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    HorizontalPanel p = new HorizontalPanel();
    p.setSpacing(0);
    g.setWidget(i, 1, p);
    final TextBox walrusHost_box = new TextBox();
    walrusHost_box.addChangeListener(new ChangeCallback(this, row));
    walrusHost_box.setVisibleLength(35);
    walrusHost_box.setText(walrusInfo.getHost());
    p.add(walrusHost_box);
    p.add(new EucaButton("Deregister", new DeleteCallback(this, row)));

    for (int propIdx = 0; propIdx < numProperties; ++propIdx) {
      i++; // next row
      if ("KEYVALUE".equals(properties.get(4 * propIdx))) {
        g.setWidget(i, 0, new Label(properties.get(4 * propIdx + 1) + ": "));
        g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
        final TextBox propTextBox = new TextBox();
        propTextBox.addChangeListener(new ChangeCallback(this, row));
        propTextBox.setVisibleLength(30);
        propTextBox.setText(properties.get(4 * propIdx + 2));
        propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage));
        g.setWidget(i, 1, propTextBox);
      } else if ("KEYVALUEHIDDEN".equals(properties.get(4 * propIdx))) {
        g.setWidget(i, 0, new Label(properties.get(4 * propIdx + 1) + ": "));
        g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
        final TextBox propTextBox = new PasswordTextBox();
        propTextBox.addChangeListener(new ChangeCallback(this, row));
        propTextBox.setVisibleLength(30);
        propTextBox.setText(properties.get(4 * propIdx + 2));
        propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage));
        g.setWidget(i, 1, propTextBox);
      } else if ("BOOLEAN".equals(properties.get(4 * propIdx))) {
        final int index = propIdx;
        final CheckBox propCheckbox = new CheckBox();
        g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
        g.setWidget(i, 0, propCheckbox);
        if (Boolean.parseBoolean(properties.get(4 * index + 2))) {
          propCheckbox.setChecked(true);
        } else {
          propCheckbox.setChecked(false);
        }
        propCheckbox.addClickListener(
            new ClickListener() {
              public void onClick(Widget sender) {
                if (((CheckBox) sender).isChecked()) {
                  properties.set(4 * index + 2, String.valueOf(true));
                } else {
                  properties.set(4 * index + 2, String.valueOf(false));
                }
              }
            });
        g.setWidget(i, 1, new Label(properties.get(propIdx * 4 + 1)));
      }
    }
    return g;
  }
  private void initData(SessionDataDto sessionData) {
    Label name = new Label("Session #" + sessionData.getSessionId());
    name.setStyleName(JaggerResources.INSTANCE.css().sessionNameHeader());
    add(name);

    Grid summaryGrid = new Grid(6, 2);
    summaryGrid.getElement().getStyle().setProperty("margin", "40px");

    Label sessionLabel = new Label("Session id");
    sessionLabel.getElement().getStyle().setFontWeight(Style.FontWeight.BOLD);
    summaryGrid.setWidget(0, 0, sessionLabel);
    summaryGrid.setWidget(0, 1, new Label(sessionData.getSessionId()));

    Label startTimeLabel = new Label("Session start time");
    startTimeLabel.getElement().getStyle().setFontWeight(Style.FontWeight.BOLD);
    summaryGrid.setWidget(1, 0, startTimeLabel);
    summaryGrid.setWidget(1, 1, new Label(sessionData.getStartDate()));

    Label endTimeLabel = new Label("Session end time");
    endTimeLabel.getElement().getStyle().setFontWeight(Style.FontWeight.BOLD);
    summaryGrid.setWidget(2, 0, endTimeLabel);
    summaryGrid.setWidget(2, 1, new Label(sessionData.getEndDate()));

    Label numberTasksLabel = new Label("Number of tasks");
    numberTasksLabel.getElement().getStyle().setFontWeight(Style.FontWeight.BOLD);
    summaryGrid.setWidget(3, 0, numberTasksLabel);
    summaryGrid.setWidget(3, 1, new Label(Integer.toString(sessionData.getTasksExecuted())));

    Label failuresLabel = new Label("Number of task failures");
    failuresLabel.getElement().getStyle().setFontWeight(Style.FontWeight.BOLD);
    summaryGrid.setWidget(4, 0, failuresLabel);
    summaryGrid.setWidget(4, 1, new Label(Integer.toString(sessionData.getTasksFailed())));

    Label activeKernels = new Label("Number of active kernels");
    activeKernels.getElement().getStyle().setFontWeight(Style.FontWeight.BOLD);
    summaryGrid.setWidget(5, 0, activeKernels);
    summaryGrid.setWidget(5, 1, new Label(Integer.toString(sessionData.getActiveKernelsCount())));

    add(summaryGrid);

    Label testPanelName = new Label("Tests");
    testPanelName.addStyleName(JaggerResources.INSTANCE.css().testNameHeader());
    add(testPanelName);

    add(testPanel);
  }
  public static FormPanel getLoginPanel() {
    // Create a FormPanel and point it at a service.
    final FormPanel form = new FormPanel();

    form.setAction("/loginFormHandler");
    form.setMethod(FormPanel.METHOD_POST);
    // Create a panel to hold all of the form widgets.
    VerticalPanel panel = new VerticalPanel();
    form.setWidget(panel);
    panel.setSpacing(20);
    final Label emailLabel = new Label("UnityID:");
    final TextBox emailBox = new TextBox();
    final Label passwordLabel = new Label("Password:"******"Log in",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                form.submit();
              }
            });
    panel.add(loginButton);

    Anchor signUpLabel = new Anchor("-- New User: Sign up --");

    signUpLabel.addStyleName("gwt-RegisterAnchor");
    panel.addStyleName("gwt-LoginPanel");
    loginButton.addStyleName("gwt-LoginButton");

    signUpLabel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {

            RootPanel.get("leftnav").clear();
            RootPanel.get("header").clear();
            RootPanel.get("content").clear();

            RootPanel.get("content").add(CustomWidgets.getRegisterForm());
            final Label titleLabel = new Label("Register");
            titleLabel.addStyleName("gwt-Heading");
            RootPanel.get("header").add(titleLabel);
          }
        });
    panel.add(signUpLabel);

    // Add an event handler to the form.
    form.addSubmitHandler(
        new FormPanel.SubmitHandler() {
          public void onSubmit(FormPanel.SubmitEvent event) {
            if (emailBox.getText().length() == 0 || passwordBox.getText().length() == 0) {
              Window.alert("Username and Password must not be empty");
              rootLogger.log(Level.SEVERE, "LOGIN ATTEMPT FAIL");
              event.cancel();
            }
          }
        });
    form.addSubmitCompleteHandler(
        new FormPanel.SubmitCompleteHandler() {
          public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {
            final String userid = emailBox.getText();
            String password = passwordBox.getText();

            loginService.login(
                userid,
                password,
                new AsyncCallback<String>() {
                  public void onFailure(Throwable caught) {
                    rootLogger.log(Level.SEVERE, "LOGIN ATTEMPT FAIL");
                  }

                  public void onSuccess(String result) {
                    if (result.equals("success")) {
                      RootPanel.get("leftnav").clear();
                      RootPanel.get("header").clear();
                      RootPanel.get("content").clear();

                      dbService.readUserData(
                          "ssharm20",
                          new AsyncCallback<HashMap<String, String>>() {
                            public void onFailure(Throwable caught) {
                              rootLogger.log(Level.SEVERE, "Failed reading data from server");
                            }

                            public void onSuccess(HashMap<String, String> result) {
                              RootPanel.get("content").add(CustomWidgets.getHomeDataForm(userid));
                            }
                          });

                      RootPanel.get("leftnav").add(CustomWidgets.getNavBar(userid));
                      final Label titleLabel = new Label("Home");
                      titleLabel.addStyleName("gwt-Heading");
                      RootPanel.get("header").add(titleLabel);
                    } else {
                      Window.alert(result);
                      rootLogger.log(Level.SEVERE, "LOGIN ATTEMPT FAIL");
                    }
                  }
                });
          }
        });
    return form;
  }