Example usage for javafx.event EventHandler EventHandler

List of usage examples for javafx.event EventHandler EventHandler

Introduction

In this page you can find the example usage for javafx.event EventHandler EventHandler.

Prototype

EventHandler

Source Link

Usage

From source file:gov.va.isaac.gui.listview.operations.UscrsExportOperation.java

@Override
public void init(ObservableList<SimpleDisplayConcept> conceptList) {
    root.setHgap(10);// w  w  w  . ja va 2s  .  co m
    root.setVgap(10);

    super.init(conceptList);

    String date = new SimpleDateFormat("MM-dd-yyyy HH-mm-ss").format(new Date());
    fileName = "VA_USCRS_Submission_File_" + date;

    //this.chooseFileName(); TODO: Finish the file name system
    fileChooser.setTitle("Save USCRS Concept Request File");
    fileChooser.getExtensionFilters().addAll(new ExtensionFilter("Excel Files .xls .xlsx", "*.xls", "*.xlsx"));
    fileChooser.setInitialFileName(fileName);
    //      outputProperty.set(outputField.textProperty());

    openFileChooser.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent e) {
            file = fileChooser.showSaveDialog(null);
            if (file != null) {
                if (file.getAbsolutePath() != null && file.getAbsolutePath() != "") {
                    outputField.setText(file.getAbsolutePath());
                    filePath = file.getAbsolutePath();
                    logger_.info("File Path Changed: " + filePath);
                }
            }
        }
    });
    outputField.setOnAction( //TODO: So you can manually type in a file path and it validates (break this out)
            new EventHandler<ActionEvent>() {
                @Override
                public void handle(final ActionEvent e) {
                    filePath = outputField.getText();
                    file = new File(filePath);
                }
            });

    allFieldsValid = new ValidBooleanBinding() {
        {
            bind(outputField.textProperty());
            setComputeOnInvalidate(true);
        }

        /* (non-Javadoc)
         * @see javafx.beans.binding.BooleanBinding#computeValue()
         */
        @Override
        protected boolean computeValue() {
            if (outputField.getText() != "" || !outputField.getText().trim().isEmpty()) {
                String fieldOutput = outputField.getText();
                if (filePath != null && !fieldOutput.isEmpty() && file != null) //fieldOutput is repetetive but necessary
                {
                    int lastSeperatorPosition = outputField.getText().lastIndexOf(File.separator);
                    String path = "";
                    if (lastSeperatorPosition > 0) {
                        path = outputField.getText().substring(0, lastSeperatorPosition);
                    } else {
                        path = outputField.getText();
                    }

                    logger_.debug("Output Directory: " + path);
                    File f = new File(path);
                    if (file.isFile()) { //If we want to prevent file overwrite
                        this.setInvalidReason("The file " + filePath + " already exists");
                        return false;
                    } else if (f.isDirectory()) {
                        return true;
                    } else {
                        this.setInvalidReason("Output Path is not a directory");
                        return false;
                    }
                } else {
                    this.setInvalidReason("File Output Directory is not set - output field null!!");
                    return false;
                }
            } else {
                this.setInvalidReason("Output field is empty, output directory is not set");
                return false;
            }
        }
    };

    root.add(openFileChooser, 2, 0);
    GridPane.setHalignment(openFileChooser, HPos.LEFT);

    Label outputLocationLabel = new Label("Output Location");
    root.add(outputLocationLabel, 0, 0);

    GridPane.setHalignment(outputLocationLabel, HPos.LEFT);

    StackPane sp = ErrorMarkerUtils.setupErrorMarker(outputField, null, allFieldsValid);
    root.add(sp, 1, 0);
    GridPane.setHgrow(sp, Priority.ALWAYS);
    GridPane.setHalignment(sp, HPos.LEFT);

    Label datePickerLabel = new Label("Export Date Filter");
    root.add(datePickerLabel, 0, 1);
    GridPane.setHalignment(datePickerLabel, HPos.LEFT);
    root.add(datePicker, 1, 1);

    Label allDatesLabel = new Label("Export All Concepts");
    root.add(allDatesLabel, 0, 2);
    skipFilterCheckbox.setText("Export All Concepts (No Filters)");
    skipFilterCheckbox.setSelected(false);
    root.add(skipFilterCheckbox, 1, 2);

    super.root_ = root;
}

From source file:de.chaosfisch.uploader.gui.GUIUploader.java

private void initApplication(final Stage primaryStage) {

    try {/*w w  w .j av  a2 s  . c  o m*/

        final Parent parent = fxmlLoader
                .load(getClass().getResource("/de/chaosfisch/uploader/view/SimpleJavaYoutubeUploader.fxml"),
                        resources)
                .getRoot();

        final Scene scene = SceneBuilder.create().root(parent).fill(Color.TRANSPARENT).build();

        try (InputStream iconInputStream = getClass()
                .getResourceAsStream("/de/chaosfisch/uploader/resources/images/film.png")) {
            StageBuilder.create().icons(new Image(iconInputStream)).minHeight(MIN_HEIGHT).height(MIN_HEIGHT)
                    .minWidth(MIN_WIDTH).width(MIN_WIDTH).scene(scene).resizable(true)
                    .onCloseRequest(new ApplicationClosePromptDialog()).applyTo(primaryStage);
        }
        parent.setOnMouseDragged(new EventHandler<MouseEvent>() {

            @Override
            public void handle(final MouseEvent me) {
                primaryStage.setX(me.getScreenX() - initX);
                primaryStage.setY(me.getScreenY() - initY);
            }
        });

        parent.setOnMousePressed(new EventHandler<MouseEvent>() {
            @Override
            public void handle(final MouseEvent me) {
                initX = me.getScreenX() - primaryStage.getX();
                initY = me.getScreenY() - primaryStage.getY();
            }
        });

        primaryStage.initStyle(StageStyle.TRANSPARENT);
        primaryStage.show();
    } catch (final IOException e) {
        LOGGER.error("FXML Load error", e);
        throw new RuntimeException(e);
    }
}

From source file:retsys.client.controller.PurchaseOrderController.java

/**
 * Initializes the controller class.//from w w  w.  jav a2 s  .co  m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    po_date.setValue(LocalDate.now());

    loc_of_material.setCellValueFactory(new PropertyValueFactory<POItem, String>("location"));
    material_name.setCellValueFactory(new PropertyValueFactory<POItem, String>("name"));
    brand_name.setCellValueFactory(new PropertyValueFactory<POItem, String>("brand"));
    model_code.setCellValueFactory(new PropertyValueFactory<POItem, String>("model"));
    quantity.setCellValueFactory(new PropertyValueFactory<POItem, Integer>("quantity"));

    poDetail.getColumns().setAll(loc_of_material, material_name, brand_name, model_code, quantity);

    AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(txt_name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() {

                @Override
                public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Item> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("items", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Item>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Item>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Item>() {

                @Override
                public String toString(Item object) {
                    System.out.println("here..." + object);
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Item fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });
    //event handler for setting other item fields with values from selected Item object
    //fires after autocompletion
    bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) {
            Item item = event.getCompletion();
            //fill other item related fields
            txt_brand.setText(item.getBrand());
            txt_location.setUserData(item.getId());
            txt_model.setText(null); // item doesn't have this field. add??
        }
    });

    TextFields.bindAutoCompletion(project,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Project>>() {

                @Override
                public Collection<Project> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Project> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("projects", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Project>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Project>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Project>() {

                @Override
                public String toString(Project object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Project fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });

    TextFields.bindAutoCompletion(vendor,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Vendor>>() {

                @Override
                public Collection<Vendor> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Vendor> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("vendors", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Vendor>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Vendor>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Vendor>() {

                @Override
                public String toString(Vendor object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Vendor fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });
}

From source file:account.management.controller.NewVoucherController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    Platform.runLater(() -> {//ww w  . j a  va 2s . c o m
        onAddNewFieldButtonClick(null);
    });

    account_list = FXCollections.observableArrayList();
    filter_party_rec = FXCollections.observableArrayList();
    filter_party_pay = FXCollections.observableArrayList();

    new AutoCompleteComboBoxListener<>(select_voucher_type);
    select_voucher_type.setOnHiding((e) -> {
        VoucherType a = select_voucher_type.getSelectionModel().getSelectedItem();
        select_voucher_type.setEditable(false);
        select_voucher_type.getSelectionModel().select(a);
    });
    select_voucher_type.setOnShowing((e) -> {
        select_voucher_type.setEditable(true);
    });
    new AutoCompleteComboBoxListener<>(select_location);
    select_location.setOnHiding((e) -> {
        Location a = select_location.getSelectionModel().getSelectedItem();
        select_location.setEditable(false);
        select_location.getSelectionModel().select(a);
    });
    select_location.setOnShowing((e) -> {
        select_location.setEditable(true);
    });

    new AutoCompleteComboBoxListener<>(select_type);
    select_type.setOnHiding((e) -> {
        Project a = select_type.getSelectionModel().getSelectedItem();
        select_type.setEditable(false);
        select_type.getSelectionModel().select(a);
    });
    select_type.setOnShowing((e) -> {
        select_type.setEditable(true);
    });

    new Thread(() -> {
        try {
            Thread.sleep(5000);
            this.button_submit.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() {
                public void handle(final KeyEvent keyEvent) {
                    if (keyEvent.getCode() == KeyCode.ENTER) {
                        System.out.println("attempting to submit new voucher");
                        //Stop letting it do anything else
                        keyEvent.consume();
                        onSubmitButtonClick(null);
                    }
                }
            });
        } catch (InterruptedException ex) {
            Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex);
        }

    }).start();

    /*
    *   voucher type
    */
    new Thread(() -> {
        try {
            HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "get/voucher/type").asJson();
            JSONArray type = res.getBody().getArray();
            for (int i = 0; i < type.length(); i++) {
                JSONObject obj = type.getJSONObject(i);
                int id = Integer.parseInt(obj.get("id").toString());
                String name = obj.get("type_name").toString();
                String note = obj.get("details").toString();
                this.select_voucher_type.getItems().add(new VoucherType(id, name, note));
            }
        } catch (UnirestException ex) {
            Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }).start();

    /*
    *   init locations in select_location combobox
    */
    locations = FXCollections.observableArrayList();
    new Thread(() -> {
        try {
            HttpResponse<JsonNode> response = Unirest.get(MetaData.baseUrl + "get/locations").asJson();
            JSONArray location_array = response.getBody().getArray();
            for (int i = 0; i < location_array.length() - 1; i++) {
                String name = location_array.getJSONObject(i).getString("name");
                String details = location_array.getJSONObject(i).getString("details");
                int id = location_array.getJSONObject(i).getInt("id");
                locations.add(new Location(id, name, details));
            }
            select_location.getItems().addAll(locations);

        } catch (UnirestException ex) {
            System.out.println("exception in UNIREST");
        }
    }).start();

    this.button_submit.setDisable(true);

    field_container.setOnKeyReleased((KeyEvent event) -> {
        validateFields();
    });

    ToggleGroup tg = new ToggleGroup();
    this.project.setToggleGroup(tg);
    this.lc.setToggleGroup(tg);
    this.cnf.setToggleGroup(tg);

    /*
    *   init account name
    */
    new Thread(() -> {
        final ComboBox<Account> a = (ComboBox<Account>) this.field_row.getChildren().get(0);
        try {

            HttpResponse<JsonNode> response = Unirest.get(MetaData.baseUrl + "get/accounts").asJson();
            JSONArray account = response.getBody().getArray();
            for (int i = 1; i < account.length(); i++) {
                JSONObject obj = account.getJSONObject(i);
                int id = Integer.parseInt(obj.get("id").toString());
                String name = obj.get("name").toString();
                String desc = obj.get("description").toString();
                int parent_id = Integer.parseInt(obj.get("parent").toString());

                account_list
                        .add(new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString()));
                if (parent_id == 21) {
                    this.filter_party_rec.add(
                            new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString()));
                }
                if (parent_id == 34) {
                    this.filter_party_pay.add(
                            new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString()));
                }
            }

            a.getItems().addAll(account_list);

        } catch (UnirestException ex) {
            Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            new AutoCompleteComboBoxListener<>(a);
            a.setOnHiding((e) -> {
                Account acc = a.getSelectionModel().getSelectedItem();
                a.setEditable(false);
                a.getSelectionModel().select(acc);
            });
            a.setOnShowing((e) -> {
                a.setEditable(true);
            });

            a.setOnAction((e) -> {
                if (!a.getSelectionModel().isEmpty() && a.getSelectionModel().getSelectedItem().getId() == 21) {
                    a.setPromptText("Select Party");
                    a.getItems().clear();
                    a.getItems().addAll(this.filter_party_rec);
                }
                if (!a.getSelectionModel().isEmpty() && a.getSelectionModel().getSelectedItem().getId() == 34) {
                    a.getItems().clear();
                    a.getItems().addAll(this.filter_party_pay);
                    a.setPromptText("Select Party");
                }
            });

        }
    }).start();

}

From source file:caillou.company.clonemanager.gui.customComponent.location.LocationController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    this.disabledProperty().bind(getModel().disabledProperty());
    final LocationController thisInstance = this;
    this.updatedProperty().addListener(new ChangeListener<Boolean>() {

        @Override//from   w  ww .  j  a  va 2  s.  c  o  m
        public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
            getModel().updateLocation(thisInstance.getPath(), thisInstance.getGroup().getValue());
        }
    });

    this.getModel().getEventBus().register(this);

    LocationsModel locationsModel = mainModel.getLocationsModel();
    groupId.visibleProperty().bind(locationsModel.enableGroupingProperty());
    groupId.managedProperty().bind(locationsModel.enableGroupingProperty());
    groupId.getItems().add(Group.GROUPA);
    groupId.getItems().add(Group.GROUPB);

    path.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            boolean disableExclusion = true;
            if (newValue != null && !newValue.equals("")) {
                File file = new File(newValue);
                if (file.exists() && file.isDirectory()) {
                    disableExclusion = false;
                }
            }
            filterButtonId.setDisable(disableExclusion);
            updated.set(!updated.get());
        }
    });

    groupId.valueProperty().addListener(new ChangeListener<Group>() {
        @Override
        public void changed(ObservableValue<? extends Group> observable, Group oldValue, Group newValue) {
            updated.set(!updated.get());
        }
    });

    disabledProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            path.setDisable(newValue);
            groupId.setDisable(newValue);
            button.setDisable(newValue);
        }

    });

    filterButtonId.setDisable(true);

    /**
     * Due to the bug
     * "https://bitbucket.org/controlsfx/controlsfx/issue/185/nullpointerexception-when-using-popover"
     */
    MainApp.getInstance().getStage().setOnCloseRequest(new EventHandler<WindowEvent>() {
        @Override
        public void handle(WindowEvent event) {
            errorPopOver.hide(Duration.millis(0));
        }
    });
    /**
     * End *
     */

}

From source file:nars.rl.util.ThreeDView.java

private void handleMouse(Scene scene, final Node root) {
    scene.setOnMousePressed(new EventHandler<MouseEvent>() {
        @Override//from   ww  w  .jav a  2s  .c om
        public void handle(MouseEvent me) {
            mousePosX = me.getSceneX();
            mousePosY = me.getSceneY();
            mouseOldX = me.getSceneX();
            mouseOldY = me.getSceneY();
        }
    });
    scene.setOnMouseDragged(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent me) {
            mouseOldX = mousePosX;
            mouseOldY = mousePosY;
            mousePosX = me.getSceneX();
            mousePosY = me.getSceneY();
            mouseDeltaX = (mousePosX - mouseOldX);
            mouseDeltaY = (mousePosY - mouseOldY);

            double modifier = 1.0;
            double modifierFactor = 0.1;

            if (me.isControlDown()) {
                modifier = 0.1;
            }
            if (me.isShiftDown()) {
                modifier = 10.0;
            }
            if (me.isPrimaryButtonDown()) {
                cameraXform.ry
                        .setAngle(cameraXform.ry.getAngle() - mouseDeltaX * modifierFactor * modifier * 2.0); // +
                cameraXform.rx
                        .setAngle(cameraXform.rx.getAngle() + mouseDeltaY * modifierFactor * modifier * 2.0); // -
            } else if (me.isSecondaryButtonDown()) {
                double z = camera.getTranslateZ();
                double newZ = z + mouseDeltaX * modifierFactor * modifier;
                camera.setTranslateZ(newZ);
            } else if (me.isMiddleButtonDown()) {
                cameraXform2.t.setX(cameraXform2.t.getX() + mouseDeltaX * modifierFactor * modifier * 0.3); // -
                cameraXform2.t.setY(cameraXform2.t.getY() + mouseDeltaY * modifierFactor * modifier * 0.3); // -
            }
        }
    });
}

From source file:gov.va.isaac.gui.listview.operations.RefsetValueUtils.java

protected RefsetValueUtils(boolean indent) {
    if (indent) {
        refsetTypeLabel_.setPadding(new Insets(0, 0, 0, 10));
        valueLabel_.setPadding(new Insets(0, 0, 0, 10));
    }//from w  ww  .j av  a2 s .  co  m

    booleanValue_.getItems().add("True");
    booleanValue_.getItems().add("False");
    booleanValue_.getSelectionModel().select(0);

    for (RefsetType rt : RefsetType.values()) {
        refsetType_.getItems().add(rt);
    }

    refsetType_.getSelectionModel().select(0);

    swappable.getChildren().add(booleanValue_);
    booleanValue_.setMaxWidth(Double.MAX_VALUE);
    swappable.getChildren().add(conceptValue_.getNode());
    swappable.getChildren().add(wrappedStringOrIntegerValue_);
    stringOrIntegerValue_.setMaxWidth(Double.MAX_VALUE);

    isValid_ = new UpdateableBooleanBinding() {
        {
            setComputeOnInvalidate(true);
        }

        @Override
        protected boolean computeValue() {
            if (refsetType_.getValue() == RefsetType.rfConcept) {
                return conceptValue_.isValid().get();
            } else if (refsetType_.getValue() == RefsetType.rfInteger
                    || refsetType_.getValue() == RefsetType.rfString) {
                if (StringUtils.isBlank(stringOrIntegerValue_.getText())) {
                    stringOrIntegerErrorMessage_
                            .set(refsetType_.getValue() == RefsetType.rfInteger ? "An integer must be provided"
                                    : "A String must be provided");
                    return false;
                }
                if (refsetType_.getValue() == RefsetType.rfInteger) {
                    try {
                        Integer.parseInt(stringOrIntegerValue_.getText());
                        stringOrIntegerErrorMessage_.set("");
                        return true;
                    } catch (NumberFormatException e) {
                        stringOrIntegerErrorMessage_.set("The value must be an integer");
                        return false;
                    }
                } else if (refsetType_.getValue() == RefsetType.rfString) {
                    stringOrIntegerErrorMessage_.set("");
                    return true;
                } else {
                    LoggerFactory.getLogger(this.getClass()).error("Design error!");
                    return false;
                }
            } else if (refsetType_.getValue() == RefsetType.rfBoolean) {
                return true;
            } else {
                LoggerFactory.getLogger(this.getClass()).error("Design error!");
                return false;
            }
        }
    };

    refsetType_.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            isValid_.clearBindings();
            booleanValue_.setVisible(false);
            conceptValue_.getNode().setVisible(false);
            wrappedStringOrIntegerValue_.setVisible(false);

            if (refsetType_.getValue() == RefsetType.rfString
                    || refsetType_.getValue() == RefsetType.rfInteger) {
                isValid_.addBinding(stringOrIntegerValue_.textProperty());
                valueLabel_.setText(
                        refsetType_.getValue() == RefsetType.rfString ? "String value" : "Integer value");
                wrappedStringOrIntegerValue_.setVisible(true);
            } else if (refsetType_.getValue() == RefsetType.rfConcept) {
                isValid_.addBinding(conceptValue_.isValid());
                valueLabel_.setText("Concept value");
                conceptValue_.getNode().setVisible(true);
            } else if (refsetType_.getValue() == RefsetType.rfBoolean) {
                valueLabel_.setText("Boolean value");
                booleanValue_.setVisible(true);
            } else {
                LoggerFactory.getLogger(this.getClass()).error("Design error!");
            }
            isValid_.invalidate();
        }
    });
    refsetType_.getSelectionModel().select(1);
}

From source file:com.QuarkLabs.BTCeClientJavaFX.PublicTradesController.java

@FXML
void initialize() {
    assert publicTradesTable != null : "fx:id=\"publicTradesTable\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableAmountColumn != null : "fx:id=\"publicTradesTableAmountColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableDateColumn != null : "fx:id=\"publicTradesTableDateColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableItemColumn != null : "fx:id=\"publicTradesTableItemColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTablePriceColumn != null : "fx:id=\"publicTradesTablePriceColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTablePriceCurrencyColumn != null : "fx:id=\"publicTradesTablePriceCurrencyColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableTIDColumn != null : "fx:id=\"publicTradesTableTIDColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableTradeTypeColumn != null : "fx:id=\"publicTradesTableTradeTypeColumn\" was not injected: check your FXML file 'markettrades.fxml'.";

    publicTradesTable.setItems(publicTrades);
    publicTradesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    publicTradesTableAmountColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Double>("amount"));
    publicTradesTableDateColumn.setCellValueFactory(
            new Callback<TableColumn.CellDataFeatures<PublicTrade, String>, ObservableValue<String>>() {
                @Override//from w  w  w  .  ja v a2s  .  com
                public ObservableValue<String> call(
                        TableColumn.CellDataFeatures<PublicTrade, String> publicTradeStringCellDataFeatures) {
                    PublicTrade publicTrade = publicTradeStringCellDataFeatures.getValue();
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTimeInMillis(publicTrade.getDate() * 1000);
                    DateFormat dateFormat = DateFormat.getDateTimeInstance();
                    return new SimpleStringProperty(dateFormat.format(calendar.getTime()));
                }
            });
    publicTradesTableItemColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("item"));
    publicTradesTablePriceColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Double>("price"));
    publicTradesTablePriceCurrencyColumn
            .setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("priceCurrency"));
    publicTradesTableTIDColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Long>("tid"));
    publicTradesTableTradeTypeColumn
            .setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("tradeType"));

    Task<JSONArray> loadPublicTrades = new Task<JSONArray>() {
        @Override
        protected JSONArray call() throws Exception {
            return App.getPublicTrades(pair);
        }
    };
    loadPublicTrades.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
        @Override
        public void handle(WorkerStateEvent workerStateEvent) {
            JSONArray jsonArray = (JSONArray) workerStateEvent.getSource().getValue();
            publicTrades.clear();
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject item = jsonArray.getJSONObject(i);
                PublicTrade publicTrade = new PublicTrade();
                publicTrade.setDate(item.getLong("date"));
                publicTrade.setAmount(item.getDouble("amount"));
                publicTrade.setItem(item.getString("item"));
                publicTrade.setPrice(item.getDouble("price"));
                publicTrade.setPriceCurrency(item.getString("price_currency"));
                publicTrade.setTid(item.getLong("tid"));
                publicTrade.setTradeType(item.getString("trade_type"));
                publicTrades.add(publicTrade);
            }
        }
    });
    Thread thread = new Thread(loadPublicTrades);
    thread.start();
}

From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java

private void openAccountManager() {
    //Window Crap
    Stage accountManagerStage = new Stage();
    accountManagerStage.setTitle("Starbound Server Account Manager");

    GridPane gp = new GridPane();
    gp.setAlignment(Pos.CENTER);// w  w  w . ja va  2s.  co  m
    gp.setVgap(10);
    gp.setHgap(10);
    gp.setPadding(new Insets(25, 25, 25, 25));

    Text title = new Text("Starbound Account Manager");
    title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20));
    gp.add(title, 0, 0, 2, 1);

    ListView<String> user_list = new ListView<String>();
    ObservableList<String> user_list_o = FXCollections.observableArrayList(users);
    user_list.setItems(user_list_o);
    user_list.setPrefHeight(50);

    ListView<String> banned_users_list = new ListView<String>();
    ObservableList<String> banned_users_list_o = FXCollections.observableArrayList(banned_usernames);
    banned_users_list.setItems(banned_users_list_o);
    banned_users_list.setPrefHeight(50);

    ListView<String> banned_ips_list = new ListView<String>();
    ObservableList<String> banned_ips_list_o = FXCollections.observableArrayList(banned_ips);
    banned_ips_list.setItems(banned_ips_list_o);
    banned_ips_list.setPrefHeight(50);

    ListView<String> banned_playernames_list = new ListView<String>();
    ObservableList<String> banned_playernames_list_o = FXCollections.observableArrayList(banned_playernames);
    banned_playernames_list.setItems(banned_playernames_list_o);
    banned_playernames_list.setPrefHeight(50);

    Label user_list_l = new Label("Current Users");
    Label banned_users_list_l = new Label("Banned Users");
    Label banned_ips_list_l = new Label("Banned IP's");
    Label banned_playernames_list_l = new Label("Banned Player Names");

    Button add_user = new Button("Add User");
    Button add_banned_user = new Button("Add Banned User");
    Button add_banned_ip = new Button("Add Banned IP");
    Button add_banned_playername = new Button("Add Banner Playername");

    Button remove_user = new Button("Remove User");
    Button remove_banned_user = new Button("Remove Banned User");
    Button remove_banned_ip = new Button("Remove Banned IP");
    Button remove_banned_playername = new Button("Remove Banner Playername");

    HBox userbox = new HBox();
    userbox.setAlignment(Pos.BOTTOM_LEFT);
    userbox.getChildren().addAll(add_user, remove_user);
    userbox.setSpacing(5);

    HBox b_userbox = new HBox();
    b_userbox.setAlignment(Pos.BOTTOM_LEFT);
    b_userbox.getChildren().addAll(add_banned_user, remove_banned_user);
    b_userbox.setSpacing(5);

    HBox b_ipbox = new HBox();
    b_ipbox.setAlignment(Pos.BOTTOM_LEFT);
    b_ipbox.getChildren().addAll(add_banned_ip, remove_banned_ip);
    b_ipbox.setSpacing(5);

    HBox b_playerbox = new HBox();
    b_playerbox.setAlignment(Pos.BOTTOM_LEFT);
    b_playerbox.getChildren().addAll(add_banned_playername, remove_banned_playername);
    b_playerbox.setSpacing(5);

    Button save = new Button("Save Config");
    save.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            save();
        }

    });

    add_user.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            createAccount(user_list);
        }

    });
    add_banned_user.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            createBannedUser(banned_users_list);
        }

    });
    add_banned_ip.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            createBannedIP(banned_ips_list);
        }

    });
    add_banned_playername.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            createBannedPlayername(banned_playernames_list);
        }

    });

    remove_user.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            users.remove(user_list.getSelectionModel().getSelectedItem());
            user_list.setItems(FXCollections.observableArrayList(users));
        }

    });
    remove_banned_user.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            banned_usernames.remove(banned_users_list.getSelectionModel().getSelectedItem());
            banned_users_list.setItems(FXCollections.observableArrayList(banned_usernames));
        }

    });
    remove_banned_ip.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            banned_ips.remove(banned_ips_list.getSelectionModel().getSelectedItem());
            banned_ips_list.setItems(FXCollections.observableArrayList(banned_ips));
        }

    });
    remove_banned_playername.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            banned_playernames.remove(banned_playernames_list.getSelectionModel().getSelectedItem());
            banned_playernames_list.setItems(FXCollections.observableArrayList(banned_playernames));
        }

    });

    gp.add(user_list_l, 0, 1);
    gp.add(user_list, 0, 2);
    gp.add(userbox, 0, 3);
    gp.add(banned_users_list_l, 0, 4);
    gp.add(banned_users_list, 0, 5);
    gp.add(b_userbox, 0, 6);
    gp.add(banned_ips_list_l, 0, 7);
    gp.add(banned_ips_list, 0, 8);
    gp.add(b_ipbox, 0, 9);
    gp.add(banned_playernames_list_l, 0, 10);
    gp.add(banned_playernames_list, 0, 11);
    gp.add(b_playerbox, 0, 12);
    gp.add(save, 0, 13);

    Scene sc = new Scene(gp, 800 / 2, 600);
    accountManagerStage.setScene(sc);
    accountManagerStage.show();

}

From source file:com.anavationllc.o2jb.ConfigurationApp.java

private EventHandler<KeyEvent> getKeyEventHandler() {
    if (keyEventHandler == null) {
        keyEventHandler = new EventHandler<KeyEvent>() {
            @Override/*from   w ww. j  a v a  2  s.c  o m*/
            public void handle(KeyEvent keyEvent) {
                if (keyEvent.getCode() == KeyCode.ENTER) {
                    if (canSubmit()) {
                        keyEvent.consume();
                        okBtn.fire();
                    }
                } else if (keyEvent.getCode() == KeyCode.ESCAPE) {
                    keyEvent.consume();
                    cancelBtn.fire();
                } else {
                    okBtn.setDisable(!canSubmit());
                }
            }
        };

    }
    return keyEventHandler;
}