List of usage examples for javafx.scene.control Label Label
public Label(String text)
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void addMessage() { if (message != null) { messageLabel = new Label(truncatedMessage); messageLabel.setMouseTransparent(true); messageLabel.setWrapText(true);/*from ww w .j a va 2s. c om*/ GridPane.setHalignment(messageLabel, HPos.LEFT); GridPane.setHgrow(messageLabel, Priority.ALWAYS); GridPane.setMargin(messageLabel, new Insets(3, 0, 0, 0)); GridPane.setRowIndex(messageLabel, ++rowIndex); GridPane.setColumnIndex(messageLabel, 0); GridPane.setColumnSpan(messageLabel, 2); gridPane.getChildren().add(messageLabel); } }
From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java
private void fillTableViewWithDatasetRows(TableView<DatasetRow> tableView) { // We need to precalculate. ObservableList<DatasetRow> rows = dataset.rowsProperty(); // Setup table. tableView.editableProperty().set(false); ObservableList<TableColumn<DatasetRow, ?>> cols = tableView.getColumns(); cols.clear();//from w w w . ja v a 2 s .co m // Set up columns. TableColumn<DatasetRow, String> colRowName = new TableColumn<>("Name"); colRowName.setCellValueFactory((TableColumn.CellDataFeatures<DatasetRow, String> features) -> { DatasetRow row = features.getValue(); Set<Name> names = dataset.getNamesInRow(row); if (names.isEmpty()) { return new ReadOnlyStringWrapper("(None)"); } else { return new ReadOnlyStringWrapper( names.stream().map(n -> n.getFullName()).collect(Collectors.joining("; "))); } }); colRowName.setPrefWidth(100.0); cols.add(colRowName); // Create a column for every column here. dataset.getColumns().forEach((DatasetColumn col) -> { String colName = col.getName(); TableColumn<DatasetRow, String> colColumn = new TableColumn<>(colName); colColumn.setCellValueFactory((TableColumn.CellDataFeatures<DatasetRow, String> features) -> { DatasetRow row = features.getValue(); String val = row.get(colName); return new ReadOnlyStringWrapper(val == null ? "" : val); }); colColumn.setPrefWidth(100.0); cols.add(colColumn); }); // Set table items. tableView.itemsProperty().set(rows); // What if it's empty? tableView.setPlaceholder(new Label("No data contained in this dataset.")); }
From source file:mesclasses.view.JourneeController.java
/** * dessine la grid sanctions/*from w w w .j av a 2 s .c om*/ * @param eleve * @param rowIndex */ private void drawSanctions(Eleve eleve, int rowIndex) { EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve); drawEleveName(sanctionsGrid, eleve, rowIndex); if (!eleve.isInClasse(currentDate.getValue())) { return; } HBox punitionsBox = new HBox(); punitionsBox.setAlignment(Pos.CENTER_LEFT); TextFlow nbPunitions = new TextFlow(); Label nbPunitionLabel = new Label( "" + eleve.getPunitions().stream().filter(p -> p.getSeance() == seanceSelect.getValue()).count()); nbPunitionLabel.setPrefHeight(20); nbPunitions.getChildren().add(new Label(" (")); nbPunitions.getChildren().add(nbPunitionLabel); nbPunitions.getChildren().add(new Label(")")); nbPunitions.visibleProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0")); nbPunitions.managedProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0")); Button punitionBtn = Btns.punitionBtn(); punitionBtn.setOnAction((event) -> { if (openPunitionDialog(eleve)) { int nbPunition = Integer.parseInt(nbPunitionLabel.getText()); nbPunitionLabel.setText("" + (nbPunition + 1)); } }); punitionsBox.getChildren().add(punitionBtn); punitionsBox.getChildren().add(nbPunitions); sanctionsGrid.add(punitionsBox, 3, rowIndex, HPos.LEFT); CheckBox motCarnet = new CheckBox(); Label cumulMot = new Label(); motCarnet.setSelected(model.getMotForSeance(eleve, seanceSelect.getValue()) != null); motCarnet.selectedProperty().addListener((ob, o, checked) -> { Mot mot = model.getMotForSeance(eleve, seanceSelect.getValue()); if (checked && mot == null) { model.createMot(eleve, seanceSelect.getValue()); } else if (mot != null) { model.delete(mot); } writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3); }); sanctionsGrid.add(motCarnet, 4, rowIndex, null); writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3); sanctionsGrid.add(cumulMot, 5, rowIndex, null); CheckBox exclus = new CheckBox(); TextField motif = new TextField(); Bindings.bindBidirectional(exclus.selectedProperty(), eleveData.exclusProperty()); sanctionsGrid.add(exclus, 6, rowIndex, null); exclus.selectedProperty().addListener((o, oldV, newV) -> { if (!newV && StringUtils.isNotBlank(motif.getText()) && ModalUtil.confirm("Effacer le motif ?", "Effacer le motif ?")) { motif.clear(); } }); Bindings.bindBidirectional(motif.textProperty(), eleveData.MotifProperty()); motif.textProperty().addListener((o, oldV, newV) -> { if (StringUtils.isNotBlank(newV)) { exclus.setSelected(true); } }); GridPane.setMargin(motif, new Insets(0, 10, 0, 0)); sanctionsGrid.add(motif, 7, rowIndex, HPos.LEFT); }
From source file:com.chart.SwingChart.java
/** * Series edition/*from ww w .ja v a 2 s.co m*/ * @param series Series to edit */ void editSeries(final Series series) { String[] style = series.getStyle().split(";"); String strColor = "black"; final TextField editWidth = new TextField(); String tempS = "null"; for (String e : style) { if (e.contains("color: ")) { strColor = e.replace("color: ", ""); } else if (e.contains("width: ")) { editWidth.setText(e.replace("width: ", "")); } else if (e.contains("shape: ")) { tempS = e.replace("shape: ", ""); } } final String symbol = tempS; final List<SeriesShape> symbolList = new ArrayList<>(); final ObservableList<SeriesShape> symbolListModel; final ListView<SeriesShape> comboSymbol = new ListView(); symbolList.add(new SeriesShape("null", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("circle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("crux", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(strColor))); symbolListModel = FXCollections.observableList(symbolList); comboSymbol.setItems(symbolListModel); comboSymbol.setCellFactory(new Callback<ListView<SeriesShape>, ListCell<SeriesShape>>() { @Override public ListCell<SeriesShape> call(ListView<SeriesShape> p) { ListCell<SeriesShape> cell = new ListCell<SeriesShape>() { @Override protected void updateItem(SeriesShape t, boolean bln) { super.updateItem(t, bln); if (t != null) { setText(""); setGraphic(t.getShapeGraphic()); } } }; return cell; } }); for (SeriesShape smb : symbolListModel) { if (smb.getName().equals(symbol)) { comboSymbol.getSelectionModel().select(smb); } } final ColorPicker colorPicker = new ColorPicker(javafx.scene.paint.Color.web(strColor)); colorPicker.setOnAction((ActionEvent t) -> { String sc = colorPicker.getValue().toString(); symbolListModel.clear(); symbolListModel.add(new SeriesShape("null", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("circle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("crux", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(sc))); comboSymbol.setItems(symbolListModel); for (SeriesShape smb : symbolListModel) { if (smb.getName().equals(symbol)) { comboSymbol.getSelectionModel().select(smb); } } }); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); grid.add(new Label("Series"), 0, 0); grid.add(new Label(series.getKey().toString()), 1, 0); grid.add(new Label("Color"), 0, 1); grid.add(colorPicker, 1, 1); grid.add(new Label("Width"), 0, 2); grid.add(editWidth, 1, 2); grid.add(new Label("Shape"), 0, 3); grid.add(comboSymbol, 1, 3); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { String strColor = colorPicker.getValue().toString(); String strWidth = editWidth.getText(); double dWidth = Double.valueOf(strWidth); String strSimbolo = "null"; SeriesShape simb = new SeriesShape(comboSymbol.getSelectionModel().getSelectedItem().toString(), javafx.scene.paint.Color.web(strColor)); XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer(series.getAxisIndex()); renderer.setSeriesPaint(series.getSeriesIndex(), scene2awtColor(colorPicker.getValue())); try { if (Double.valueOf(strWidth) > 0) { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(series.getSeriesIndex(), true); renderer.setSeriesStroke(series.getSeriesIndex(), new BasicStroke(Integer.valueOf(strWidth))); } else { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(series.getSeriesIndex(), false); } } catch (NumberFormatException ex) { } if (simb.getName().contains("null")) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(series.getSeriesIndex(), false); renderer.setSeriesShape(series.getSeriesIndex(), null); } else { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(series.getSeriesIndex(), true); renderer.setSeriesShape(series.getSeriesIndex(), simb.getShapeAWT()); if (simb.getName().contains("empty")) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(series.getSeriesIndex(), false); } else { ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(series.getSeriesIndex(), true); } } series.setStyle( "color: " + strColor + ";width: " + editWidth.getText() + ";shape: " + strSimbolo + ";"); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { if (((Label) nn).getText().equals(series.getKey().toString())) { ((Label) nn).setGraphic(simb.getShapeGraphic()); } } } } } return true; } }.show(); }
From source file:acmi.l2.clientmod.xdat.Controller.java
@FXML private void about() { Dialogs.show(Alert.AlertType.INFORMATION, "About", null, new Label("XDAT Editor\n" + "Version: " + editor.getApplicationVersion())); }
From source file:com.chart.SwingChart.java
/** * Background edition/*from w w w . ja v a 2 s. c o m*/ */ final public void backgroundEdition() { final ColorPicker colorPickerChartBackground = new ColorPicker( javafx.scene.paint.Color.web(strChartBackgroundColor)); colorPickerChartBackground.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerGridline = new ColorPicker(javafx.scene.paint.Color.web(strGridlineColor)); colorPickerGridline.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerBackground = new ColorPicker(javafx.scene.paint.Color.web(strBackgroundColor)); colorPickerBackground.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerTick = new ColorPicker(javafx.scene.paint.Color.web(strTickColor)); colorPickerTick.setMaxWidth(Double.MAX_VALUE); final TextField tfFontSize = new TextField(); tfFontSize.setMaxWidth(Double.MAX_VALUE); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); grid.add(new Label("Background color"), 0, 0); grid.add(colorPickerChartBackground, 1, 0); grid.add(new Label("Gridline color"), 0, 1); grid.add(colorPickerGridline, 1, 1); grid.add(new Label("Frame color"), 0, 2); grid.add(colorPickerBackground, 1, 2); grid.add(new Label("Tick color"), 0, 3); grid.add(colorPickerTick, 1, 3); grid.add(new Label("Font size"), 0, 4); grid.add(tfFontSize, 1, 4); tfFontSize.setText(String.valueOf(fontSize)); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { fontSize = Float.valueOf(tfFontSize.getText().replace(",", ".")); strBackgroundColor = colorPickerBackground.getValue().toString().replace("0x", "#"); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; } } chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder( scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))))); chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); legendFrame.setStyle("marco: " + colorPickerBackground.getValue().toString().replace("0x", "#") + ";-fx-background-color: marco;"); strChartBackgroundColor = colorPickerChartBackground.getValue().toString().replace("0x", "#"); plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor))); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { ((Label) nn).setStyle("fondo: " + colorPickerChartBackground.getValue().toString().replace("0x", "#") + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: " + String.valueOf(fontSize) + "px"); } } } } strGridlineColor = colorPickerGridline.getValue().toString().replace("0x", "#"); plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); strTickColor = colorPickerTick.getValue().toString().replace("0x", "#"); abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); abcissaAxis.setTickLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); for (NumberAxis ejeOrdenada : AxesList) { ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); ejeOrdenada.setTickLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); } return true; } }.show(); }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private Pane createSidePane() { BorderPane pane = new BorderPane(); TabPane tabPane = new TabPane(); kmDisplay = new KaplanMeierDisplay(null, null, null, null); BorderPane paneKaplanMeier = new BorderPane(); paneKaplanMeier.setCenter(kmDisplay.getView()); paneKaplanMeier.setPadding(new Insets(10, 10, 10, 10)); // comboMainMeasurement.prefWidthProperty().bind(paneKaplanMeier.widthProperty()); comboMainMeasurement.setMaxWidth(Double.MAX_VALUE); comboMainMeasurement.setTooltip(new Tooltip("Measurement thresholded to create survival curves etc.")); GridPane kmTop = new GridPane(); kmTop.add(new Label("Score"), 0, 0); kmTop.add(comboMainMeasurement, 1, 0); kmTop.add(new Label("Survival type"), 0, 1); kmTop.add(comboSurvival, 1, 1);// w w w. ja v a2 s . co m comboSurvival.setTooltip(new Tooltip("Specify overall or recurrence-free survival (if applicable)")); comboSurvival.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(comboMainMeasurement, Priority.ALWAYS); GridPane.setHgrow(comboSurvival, Priority.ALWAYS); kmTop.setHgap(5); paneKaplanMeier.setTop(kmTop); // kmDisplay.setOrientation(Orientation.VERTICAL); histogramDisplay = new HistogramDisplay(model, false); comboMainMeasurement.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshCombo(); histogramDisplay.showHistogram(n); updateSurvivalCurves(); }); comboMeasurementMethod.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshHistogram(); scatterPane.updateChart(); updateSurvivalCurves(); }); comboSurvival.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { updateSurvivalCurves(); }); // Create a Tab for showing images BorderPane paneImages = new BorderPane(); CheckBox cbShowOverlay = new CheckBox("Show overlay"); imageAvailability.addListener((c, v, n) -> { if (n == ImageAvailability.OVERLAY_ONLY) cbShowOverlay.setSelected(true); else if (n == ImageAvailability.IMAGE_ONLY) cbShowOverlay.setSelected(false); cbShowOverlay.setDisable(n != ImageAvailability.BOTH); }); ListView<TMAEntry> listImages = new ListView<>(); listImages.setCellFactory(v -> new ImageListCell(cbShowOverlay.selectedProperty(), imageCache)); listImages.widthProperty().addListener((v, o, n) -> listImages.refresh()); listImages.setStyle("-fx-control-inner-background-alt: -fx-control-inner-background ;"); table.getSelectionModel().getSelectedItems().addListener((Change<? extends TreeItem<TMAEntry>> e) -> { List<TMAEntry> entries = new ArrayList<>(); for (TreeItem<TMAEntry> item : e.getList()) { if (item.getChildren().isEmpty()) { if (item.getValue().hasImage() || item.getValue().hasOverlay()) entries.add(item.getValue()); } else { for (TreeItem<TMAEntry> item2 : item.getChildren()) { if (item2.getValue().hasImage() || item2.getValue().hasOverlay()) entries.add(item2.getValue()); } } listImages.getItems().setAll(entries); } }); cbShowOverlay.setAlignment(Pos.CENTER); cbShowOverlay.setMaxWidth(Double.MAX_VALUE); cbShowOverlay.setPadding(new Insets(5, 5, 5, 5)); cbShowOverlay.selectedProperty().addListener((v, o, n) -> listImages.refresh()); paneImages.setCenter(listImages); paneImages.setTop(cbShowOverlay); // Determine visibility based upon whether there are any images to show // Tab tabImages = new Tab("Images", paneImages); ScrollPane scrollPane = new ScrollPane(paneKaplanMeier); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED); Tab tabSurvival = new Tab("Survival", scrollPane); tabPane.getTabs().addAll(new Tab("Table", getCustomizeTablePane()), // tabImages, new Tab("Histogram", histogramDisplay.getPane()), new Tab("Scatterplot", scatterPane.getPane()), tabSurvival); tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); // if (imageAvailability.get() != ImageAvailability.NONE) // tabPane.getTabs().add(1, tabImages); // // imageAvailability.addListener((c, v, n) -> { // if (n == ImageAvailability.NONE) // tabPane.getTabs().remove(tabImages); // else if (!tabPane.getTabs().contains(tabImages)) // tabPane.getTabs().add(1, tabImages); // }); // tabSurvival.visibleProperty().bind( // Bindings.createBooleanBinding(() -> !survivalColumns.isEmpty(), survivalColumns) // ); pane.setCenter(tabPane); pane.setMinWidth(350); return pane; }
From source file:com.chart.SwingChart.java
/** * Set lower and upper limits for an ordinate * @param axis Axis to configure//from w w w . j a v a2 s. co m */ void setOrdinateRange(final NumberAxis axis) { axis.setAutoRange(false); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); final TextField tfMax; final TextField tfMin; final TextField tfTick; final TextField tfFuente; grid.add(new Label("Axis"), 0, 0); grid.add(new Label(axis.getLabel()), 1, 0); grid.add(new Label("Lower"), 0, 1); grid.add(tfMin = new TextField(), 1, 1); grid.add(new Label("Upper"), 0, 2); grid.add(tfMax = new TextField(), 1, 2); grid.add(new Label("Space"), 0, 3); grid.add(tfTick = new TextField(), 1, 3); tfMin.setText(String.valueOf(axis.getLowerBound())); tfMax.setText(String.valueOf(axis.getUpperBound())); tfTick.setText(String.valueOf(axis.getTickUnit().getSize())); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { axis.setLowerBound(Double.valueOf(tfMin.getText())); axis.setUpperBound(Double.valueOf(tfMax.getText())); axis.setTickUnit(new NumberTickUnit(Double.valueOf(tfTick.getText()))); return true; } }.show(); }
From source file:ui.main.MainViewController.java
private synchronized void paintDate(Chat chat, String day) { //this method draws the recievied text message Task<HBox> recievedMessages = new Task<HBox>() { @Override// ww w.ja v a 2s .c o m protected HBox call() throws Exception { VBox vbox = new VBox(); //to add text //chat message Label l = new Label(day); l.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, null, null))); HBox hbox = new HBox(); hbox.setAlignment(Pos.CENTER); hbox.getChildren().addAll(l); return hbox; } }; recievedMessages.setOnSucceeded(event -> { chatList.getChildren().add(recievedMessages.getValue()); }); if (chat.getParticipant().contains(currentChat.getParticipant())) { Thread t = new Thread(recievedMessages); try { t.join(); } catch (InterruptedException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } //t.setDaemon(true); t.start(); scrollPane.setVvalue(scrollPane.getHmax()); } }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
private boolean validateSign() { if (logger.isDebugEnabled()) { logger.debug("[VALIDATE]"); }//from w w w . ja v a 2 s . c o m boolean isValid = true; // // Validate the Source JAR field // if (StringUtils.isBlank(activeProfile.getSourceFileFileName())) { if (!tfSourceFile.getStyleClass().contains("tf-validation-error")) { tfSourceFile.getStyleClass().add("tf-validation-error"); } isValid = false; } else { if (!new File(activeProfile.getSourceFileFileName()).exists()) { if (!tfSourceFile.getStyleClass().contains("tf-validation-error")) { tfSourceFile.getStyleClass().add("tf-validation-error"); } Alert alert = new Alert(Alert.AlertType.ERROR, "Specified Source " + activeProfile.getArgsType() + " does not exist"); alert.showAndWait(); isValid = false; } } // // Validate the TargetJAR field // if (StringUtils.isBlank(activeProfile.getTargetFileFileName())) { if (!tfTargetFile.getStyleClass().contains("tf-validation-error")) { tfTargetFile.getStyleClass().add("tf-validation-error"); } isValid = false; } if (activeProfile.getArgsType() == SigningArgumentsType.FOLDER) { if (StringUtils.equalsIgnoreCase(activeProfile.getSourceFileFileName(), activeProfile.getTargetFileFileName())) { if (!tfTargetFile.getStyleClass().contains("tf-validation-error")) { tfTargetFile.getStyleClass().add("tf-validation-error"); } Alert alert = new Alert(Alert.AlertType.ERROR, "Source folder and target folder cannot be the same"); alert.showAndWait(); isValid = false; } } // // #13 Validate the Jarsigner Config form // String jarsignerConfigField = ""; String jarsignerConfigMessage = ""; if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigKeystore())) { jarsignerConfigField = "Keystore"; jarsignerConfigMessage = "A keystore must be specified"; } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigStorepass())) { jarsignerConfigField = "Storepass"; jarsignerConfigMessage = "A password for the keystore must be specified"; } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigAlias())) { jarsignerConfigField = "Alias"; jarsignerConfigMessage = "An alias for the key must be specified"; } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigKeypass())) { jarsignerConfigField = "Keypass"; jarsignerConfigMessage = "A password for the key must be specified"; } if (StringUtils.isNotEmpty(jarsignerConfigMessage)) { if (logger.isDebugEnabled()) { logger.debug("[VALIDATE] jarsigner config not valid {}", jarsignerConfigMessage); } Alert alert = new Alert(Alert.AlertType.ERROR, "Set " + jarsignerConfigField + " in Configure"); alert.setHeaderText(jarsignerConfigMessage); FlowPane fp = new FlowPane(); Label lbl = new Label("Set " + jarsignerConfigField + " in "); Hyperlink link = new Hyperlink("Configure"); fp.getChildren().addAll(lbl, link); link.setOnAction((evt) -> { alert.close(); openJarsignerConfig(); }); alert.getDialogPane().contentProperty().set(fp); alert.showAndWait(); isValid = false; } // // #38 check keystore prior to running // KeytoolCommand keytoolCommand = keytoolCommandProvider.get(); Task<Boolean> keytoolTask = new Task<Boolean>() { @Override protected Boolean call() throws Exception { final List<String> aliases = keytoolCommand.findAliases( activeConfiguration.getKeytoolCommand().toString(), activeProfile.getJarsignerConfigKeystore(), activeProfile.getJarsignerConfigStorepass()); if (logger.isDebugEnabled()) { logger.debug("[KEYTOOL] # aliases=" + CollectionUtils.size(aliases)); } return true; } }; new Thread(keytoolTask).start(); try { if (!keytoolTask.get()) { if (logger.isDebugEnabled()) { logger.debug("[KEYTOOL] keystore or configuration not valid"); } isValid = false; } } catch (InterruptedException | ExecutionException e) { isValid = false; logger.error("error accessing keystore", e); Alert alert = new Alert(Alert.AlertType.ERROR, e.getMessage() // contains formatted string ); alert.showAndWait(); } return isValid; }