Ejemplo n.º 1
0
 @SuppressWarnings("unchecked")
 private void initComponents() {
   pane = new AnchorPane();
   pane.setPrefSize(800, 600);
   pane.setStyle(
       "-fx-background-color: linear-gradient(from 0% 0% to 100% 100%, blue 0%, silver 100%);");
   txPesquisa = new TextField();
   DropShadow ds = new DropShadow();
   ds.setSpread(0.5);
   ds.setColor(Color.web("#FF0000"));
   txPesquisa.setEffect(ds);
   txPesquisa.setPromptText("Digite o item para pesquisa");
   txPesquisa.setPrefWidth(200);
   txPesquisa.setFocusTraversable(false);
   tbVitrine = new TableView<ItensProperty>();
   initItens();
   tbVitrine.setItems(listItens);
   tbVitrine.setPrefSize(780, 550);
   columnProduto = new TableColumn<ItensProperty, String>();
   columnProduto.setCellValueFactory(new PropertyValueFactory<ItensProperty, String>("produto"));
   columnProduto.setText("Produto");
   columnPreco = new TableColumn<ItensProperty, Double>();
   columnPreco.setCellValueFactory(new PropertyValueFactory<ItensProperty, Double>("preco"));
   columnPreco.setText("Preço");
   tbVitrine.getColumns().addAll(columnProduto, columnPreco);
   pane.getChildren().addAll(txPesquisa, tbVitrine);
 }
Ejemplo n.º 2
0
    /**
     * initialize column
     *
     * @param colNameMap <column name, property id>
     */
    public void initColumn(Map<String, String> colNameMap) {

      int numCol = colNameMap.size();
      if (numCol == 0) return;
      getColumns().clear();

      for (Map.Entry<String, String> entry : colNameMap.entrySet()) {
        TableColumn newCol = new TableColumn();
        String colName = entry.getKey();
        newCol.setText(colName);
        newCol.setCellValueFactory(new PropertyValueFactory(entry.getValue()));
        newCol.setMinWidth(COL_UNIT_WIDTH * entry.getKey().length());
        getColumns().add(newCol);
        // set style
        if (colName.equals("Last Price")
            || colName.equals("UnRealized Gain")
            || colName.equals("Realised Gain")
            || colName.equals("Total Gain")) {
          newCol.setCellFactory(
              new Callback<TableColumn, TableCell>() {
                public TableCell call(TableColumn param) {
                  return new TableCell<PortfolioData, Double>() {
                    @Override
                    public void updateItem(Double item, boolean empty) {
                      super.updateItem(item, empty);
                      if (!isEmpty()) {
                        if (item >= 0) this.setTextFill(Color.GREEN);
                        else this.setTextFill(Color.RED);
                        setText(String.valueOf(item));
                      }
                    }
                  };
                }
              });
        } else if (colName.equals("Change Percent")) {
          newCol.setCellFactory(
              new Callback<TableColumn, TableCell>() {
                public TableCell call(TableColumn param) {
                  return new TableCell<PortfolioData, String>() {
                    @Override
                    public void updateItem(String item, boolean empty) {
                      super.updateItem(item, empty);
                      if (!isEmpty()) {
                        if (item.contains("-")) this.setTextFill(Color.RED);
                        else this.setTextFill(Color.GREEN);
                        setText(item);
                      }
                    }
                  };
                }
              });
        }
      }
    }
Ejemplo n.º 3
0
  public void initialize(URL location, ResourceBundle resource) {
    bundle = resource;
    double tableViewWidth = 0.98 * JeproLab.APP_WIDTH;
    double remainingWidth = tableViewWidth - 60;
    jeproLabFeedTableView.setPrefWidth(tableViewWidth);
    jeproLabFeedTableView.setLayoutX(0.01 * JeproLab.APP_WIDTH);

    jeproLabFeedIndexColumn.setText("#");
    jeproLabFeedIndexColumn.setPrefWidth(35);
    jeproLabFeedCheckBoxColumn.setText(bundle.getString("JEPROLAB_LABEL"));
    jeproLabFeedCheckBoxColumn.setPrefWidth(25);
    jeproLabFeedTitleColumn.setText(bundle.getString("JEPROLAB_TITLE_LABEL"));
    jeproLabFeedTitleColumn.setPrefWidth(0.15 * remainingWidth);
    jeproLabFeedAuthorColumn.setText(bundle.getString("JEPROLAB_AUTHOR_LABEL"));
    jeproLabFeedAuthorColumn.setPrefWidth(0.15 * remainingWidth);
    jeproLabFeedDescriptionColumn.setText(bundle.getString("JEPROLAB_DESCRIPTION_LABEL"));
    jeproLabFeedDescriptionColumn.getStyleClass().add("text-left");
    jeproLabFeedDescriptionColumn.setPrefWidth(.6 * remainingWidth);
    jeproLabFeedActionColumn.setText(bundle.getString("JEPROLAB_ACTIONS_LABEL"));
    jeproLabFeedActionColumn.setPrefWidth(0.1 * remainingWidth);
  }
  @FXML
  void initialize() {
    assert claimTasksButton != null
        : "fx:id=\"claimTasksButton\" was not injected: check your FXML file 'WorkflowInbox.fxml'.";
    assert synchronizeButton != null
        : "fx:id=\"synchronizeButton\" was not injected: check your FXML file 'WorkflowInbox.fxml'.";
    assert userName != null
        : "fx:id=\"userName\" was not injected: check your FXML file 'WorkflowInbox.fxml'.";
    assert taskTable != null
        : "fx:id=\"taskTable\" was not injected: check your FXML file 'WorkflowInbox.fxml'.";

    userName.setText(user);

    taskTable.setTableMenuButtonVisible(true);

    // BEGIN Task name
    TableColumn<LocalTask, String> tCol = new TableColumn<>();
    tCol.setText("Task");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getName());
        });
    taskTable.getColumns().add(tCol);
    // END Task name

    // BEGIN Task id
    tCol = new TableColumn<>();
    tCol.setText("id");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getId() + "");
        });
    taskTable.getColumns().add(tCol);
    // END Task id

    // BEGIN Component name
    tCol = new TableColumn<>();
    tCol.setText("Component");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getComponentName());
        });
    taskTable.getColumns().add(tCol);
    // END Component name

    // BEGIN WorkflowAction
    tCol = new TableColumn<>();
    tCol.setText("Action");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getAction().toString());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END WorkflowAction

    // BEGIN TaskActionStatus
    tCol = new TableColumn<>();
    tCol.setText("Action Status");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getActionStatus().name());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END TaskActionStatus

    // BEGIN Owner
    tCol = new TableColumn<>();
    tCol.setText("Owner");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getOwner());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END Owner

    // BEGIN Status
    tCol = new TableColumn<>();
    tCol.setText("Status");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getStatus().name());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END Status

    // BEGIN Component id (hidden)
    tCol = new TableColumn<>();
    tCol.setText("Component Id");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getComponentId());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END Component id (hidden)

    // BEGIN Concept
    TableColumn<LocalTask, SimpleDisplayConcept> conceptCol = new TableColumn<>();
    conceptCol.setText("Concept");
    conceptCol.setCellValueFactory(
        (value) -> {
          if (value.getValue().getComponentId() == null) {
            LOG.error("Component ID for task {} is null", value.getValue().getId());

            return new SimpleObjectProperty<SimpleDisplayConcept>();
          }
          UUID componentUuid = null;
          try {
            componentUuid = UUID.fromString(value.getValue().getComponentId());
          } catch (IllegalArgumentException e) {
            LOG.error("Component ID for task {} is not a valid UUID", value.getValue().getId());

            return new SimpleObjectProperty<SimpleDisplayConcept>();
          }

          ConceptVersionBI containingConcept = null;
          ComponentChronicleBI componentChronicle = WBUtility.getComponentChronicle(componentUuid);
          if (componentChronicle == null) {
            LOG.warn(
                "Component ID for task "
                    + value.getValue().getId()
                    + " retrieved a null componentChronicle");

            containingConcept = WBUtility.getConceptVersion(componentUuid);
            if (containingConcept == null) {
              LOG.error(
                  "Component ID for task "
                      + value.getValue().getId()
                      + " retrieved a null concept");

              return new SimpleObjectProperty<SimpleDisplayConcept>();
            }
          } else {
            try {
              containingConcept =
                  componentChronicle
                      .getEnclosingConcept()
                      .getVersion(WBUtility.getViewCoordinate());
            } catch (Exception e) {
              LOG.error(
                  "Failed getting version from ComponentChronicleBI task "
                      + value.getValue().getId()
                      + ".  Caught "
                      + e.getClass().getName()
                      + " "
                      + e.getLocalizedMessage());
              e.printStackTrace();
            }
            if (containingConcept == null) {
              LOG.error(
                  "ComponentChronicleBI task "
                      + value.getValue().getId()
                      + " contained a null enclosing concept");

              return new SimpleObjectProperty<SimpleDisplayConcept>();
            }
          }

          if (componentChronicle == null) {
            LOG.warn(
                "Component id "
                    + componentUuid
                    + " for task "
                    + value.getValue().getId()
                    + " is a concept, not just a component.");
          }
          SimpleDisplayConcept displayConcept = new SimpleDisplayConcept(containingConcept);
          return new SimpleObjectProperty<SimpleDisplayConcept>(displayConcept);
        });
    taskTable.getColumns().add(conceptCol);
    // END concept

    // BEGIN Concept
    TableColumn<LocalTask, String> conceptIdCol = new TableColumn<>();
    conceptIdCol.setText("Concept Id");
    conceptIdCol.setCellValueFactory(
        (value) -> {
          if (value.getValue().getComponentId() == null) {
            LOG.error("Component ID for task {} is null", value.getValue().getId());

            return new SimpleStringProperty();
          }
          UUID componentUuid = null;
          try {
            componentUuid = UUID.fromString(value.getValue().getComponentId());
          } catch (IllegalArgumentException e) {
            LOG.error("Component ID for task {} is not a valid UUID", value.getValue().getId());

            return new SimpleStringProperty();
          }

          ConceptVersionBI containingConcept = null;
          ComponentChronicleBI componentChronicle = WBUtility.getComponentChronicle(componentUuid);
          if (componentChronicle == null) {
            LOG.warn(
                "Component ID for task "
                    + value.getValue().getId()
                    + " retrieved a null componentChronicle");

            containingConcept = WBUtility.getConceptVersion(componentUuid);
            if (containingConcept == null) {
              LOG.error(
                  "Component ID for task "
                      + value.getValue().getId()
                      + " retrieved a null concept");

              return new SimpleStringProperty();
            }
          } else {
            try {
              containingConcept =
                  componentChronicle
                      .getEnclosingConcept()
                      .getVersion(WBUtility.getViewCoordinate());
            } catch (Exception e) {
              LOG.error(
                  "Failed getting version from ComponentChronicleBI task "
                      + value.getValue().getId()
                      + ".  Caught "
                      + e.getClass().getName()
                      + " "
                      + e.getLocalizedMessage());
              e.printStackTrace();
            }

            if (containingConcept == null) {
              LOG.error(
                  "ComponentChronicleBI task "
                      + value.getValue().getId()
                      + " contained a null enclosing concept");

              return new SimpleStringProperty();
            }
          }

          if (componentChronicle == null) {
            LOG.warn(
                "Component id "
                    + componentUuid
                    + " for task "
                    + value.getValue().getId()
                    + " is a concept, not just a component.");
          }

          UUID uuid = containingConcept.getPrimordialUuid();
          return new SimpleStringProperty(uuid.toString());
        });
    conceptIdCol.setVisible(false);
    taskTable.getColumns().add(conceptIdCol);
    // END concept ID

    float colWidth = 1.0f / taskTable.getColumns().size();
    for (TableColumn<LocalTask, ?> col : taskTable.getColumns()) {
      col.prefWidthProperty().bind(taskTable.widthProperty().multiply(colWidth).subtract(3.0));
      col.setCellFactory(new MyCellFactoryCallback<>());
    }

    claimTasksButton.setOnAction(
        (action) -> {
          claimTasksButton.setDisable(true);
          final BusyPopover claimPopover =
              BusyPopover.createBusyPopover("Claiming new tasks...", claimTasksButton);

          Utility.execute(
              () -> {
                try {
                  wfEngine_.claim(10, user);
                  Platform.runLater(
                      () -> {
                        claimPopover.hide();
                        claimTasksButton.setDisable(false);
                        refreshContent();
                      });
                } catch (Exception e) {
                  logger.error("Unexpected error claiming tasks", e);
                }
              });
        });

    synchronizeButton.setOnAction(
        (action) -> {
          synchronizeButton.setDisable(true);
          final BusyPopover synchronizePopover =
              BusyPopover.createBusyPopover("Synchronizing tasks...", synchronizeButton);

          Utility.execute(
              () -> {
                try {
                  wfEngine_.synchronizeWithRemote();
                  Platform.runLater(
                      () -> {
                        synchronizePopover.hide();
                        synchronizeButton.setDisable(false);
                        refreshContent();
                      });
                } catch (Exception e) {
                  logger.error("Unexpected error synchronizing tasks", e);
                }
              });
        });
  }
Ejemplo n.º 5
0
  private Tuple2<TableView<Offer>, VBox> getOfferTable(Offer.Direction direction) {
    TableView<Offer> tableView = new TableView();

    // price
    TableColumn<Offer, Offer> priceColumn = new TableColumn<>();
    priceColumn.textProperty().bind(priceColumnLabel);
    priceColumn.setMinWidth(120);
    priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    priceColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getPrice()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(priceColumn);

    // amount
    TableColumn<Offer, Offer> amountColumn = new TableColumn<>("Amount (BTC)");
    amountColumn.setText("Amount (BTC)");
    amountColumn.setMinWidth(120);
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatCoin(item.getAmount()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(amountColumn);

    // volume
    TableColumn<Offer, Offer> volumeColumn = new TableColumn<>("Amount (BTC)");
    volumeColumn.setMinWidth(120);
    volumeColumn.textProperty().bind(volumeColumnLabel);
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getOfferVolume()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(volumeColumn);

    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new Label("Currently there are no offers available");
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);

    Label titleLabel =
        new Label(
            direction.equals(Offer.Direction.BUY)
                ? "Offers for buy bitcoin (bid)"
                : "Offers for sell bitcoin (ask)");
    titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 16; -fx-alignment: center");
    UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));

    VBox vBox = new VBox();
    vBox.setSpacing(10);
    vBox.setFillWidth(true);
    vBox.setMinHeight(150);
    vBox.getChildren().addAll(titleLabel, tableView);
    return new Tuple2<>(tableView, vBox);
  }