Java Code Examples for javafx.util.StringConverter

The following examples show how to use javafx.util.StringConverter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FxDock   Source File: Converters.java    License: Apache License 2.0 6 votes vote down vote up
public static StringConverter<Object> OBJECT()
{
	if(objectConverter == null)
	{
		objectConverter = new StringConverter<Object>()
		{
			public String toString(Object x)
			{
				return x == null ? null : x.toString();
			}

			public Object fromString(String s)
			{
				return s;
			}
		};
	}
	return objectConverter;
}
 
Example 2
Source Project: ARMStrong   Source File: CellUtils.java    License: Mozilla Public License 2.0 6 votes vote down vote up
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    if (textField != null) {
        textField.setText(getItemText(cell, converter));
    }
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
Example 3
Source Project: AsciidocFX   Source File: CellUtils.java    License: Apache License 2.0 6 votes vote down vote up
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    if (textField != null) {
        textField.setText(getItemText(cell, converter));
    }
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
Example 4
private void initComboBox() {
    interfacesComboBox.setItems(FXCollections.observableList(new ArrayList<>(interfacesInfo.values())));
    interfacesComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        propertiesTableView.setItems(FXCollections.observableList(new ArrayList<>(newValue.getProperties().entrySet())));
    });

    interfacesComboBox.setConverter(new StringConverter<InterfaceInfo>() {
        @Override
        public String toString(InterfaceInfo object) {
            return object.Slot_str;
        }

        @Override
        public InterfaceInfo fromString(String string) {
            return null;
        }
    });
    interfacesComboBox.getSelectionModel().select(0);
}
 
Example 5
Source Project: ARMStrong   Source File: CellUtils.java    License: Mozilla Public License 2.0 6 votes vote down vote up
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
    final TextField textField = new TextField(getItemText(cell, converter));

    // Use onAction here rather than onKeyReleased (with check for Enter),
    // as otherwise we encounter RT-34685
    textField.setOnAction(event -> {
        if (converter == null) {
            throw new IllegalStateException(
                    "Attempting to convert text input into Object, but provided "
                            + "StringConverter is null. Be sure to set a StringConverter "
                            + "in your cell factory.");
        }
        cell.commitEdit(converter.fromString(textField.getText()));
        event.consume();
    });
    textField.setOnKeyReleased(t -> {
        if (t.getCode() == KeyCode.ESCAPE) {
            cell.cancelEdit();
            t.consume();
        }
    });
    return textField;
}
 
Example 6
Source Project: cute-proxy   Source File: SimpleButton.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void init() {
    Bindings.bindBidirectional(tooltipText, tooltipProperty(), new StringConverter<Tooltip>() {
        @Override
        public String toString(Tooltip tooltip) {
            if (tooltip == null) {
                return null;
            }
            return tooltip.getText();
        }

        @Override
        public Tooltip fromString(String string) {
            if (string == null) {
                return null;
            }
            return new Tooltip(string);
        }
    });
    iconPath.addListener((observable, oldValue, newValue) ->
            graphicProperty().set(new ImageView(new Image(getClass().getResourceAsStream(newValue)))));
}
 
Example 7
Source Project: bisq   Source File: DebugView.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private void addGroup(String title, ObservableList<Class<? extends Task>> list) {
    final Tuple2<Label, ComboBox<Class<? extends Task>>> selectTaskToIntercept =
            addTopLabelComboBox(root, ++rowIndex, title, "Select task to intercept", 15);
    ComboBox<Class<? extends Task>> comboBox = selectTaskToIntercept.second;
    comboBox.setVisibleRowCount(list.size());
    comboBox.setItems(list);
    comboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(Class<? extends Task> item) {
            return item.getSimpleName();
        }

        @Override
        public Class<? extends Task> fromString(String s) {
            return null;
        }
    });
    comboBox.setOnAction(event -> Task.taskToIntercept = comboBox.getSelectionModel().getSelectedItem());
}
 
Example 8
Source Project: oim-fx   Source File: ItemRemoveListCell.java    License: MIT License 6 votes vote down vote up
@Override
    public void updateItem(T item, boolean empty) {
        super.updateItem(item, empty);
        if (!empty) {
//        	removeButton.setOnAction(new EventHandler<ActionEvent>() {
//                @Override
//                public void handle(ActionEvent event) {
//                    if (null != removeValueAction) {
//                    	removeValueAction.value(getItem());;
//                    }
//                }
//            });
        	Button b=new Button("(x)");
        	b.setOnAction(a->{
        		System.out.println(888);
        	});
            StringConverter<T> c = getConverter();
            //setGraphic(b);
            setText(c != null ? c.toString(item) : (item == null ? "" : item.toString()));
        } else {
            //setGraphic(null);
            setText(null);
        }
    }
 
Example 9
Source Project: oim-fx   Source File: ItemListCell.java    License: MIT License 6 votes vote down vote up
public ItemListCell(ExecuteAction executeAction, final StringConverter<T> converter) {
    setConverter(converter);
    this.executeAction = executeAction;
    this.button = new Button();
    button.getStyleClass().clear();
    button.setMinHeight(20);
    button.setMinWidth(20);

    //Image image = ImageBox.getImageClassPath("/resources/common/imagse/close/1_cancel_button_hover.png");
    //button.setGraphic(new ImageView(image));
    
    button.setText("X");
    setAlignment(Pos.CENTER_LEFT);
    setContentDisplay(ContentDisplay.LEFT);
    setGraphic(null);
}
 
Example 10
void initializeIntervalChartAxes() {
    final NumberAxis xAxis = (NumberAxis) intervalChart.getXAxis();
    xAxis.setForceZeroInRange(false);

    // Bind X Tick label formatter to choice-box
    intervalXTickLabel.getItems().addAll(IntervalTickFormatter.values());
    intervalXTickLabel.getSelectionModel().select(0);
    ObjectBinding<StringConverter<Number>> intervalXLabelConverter = Bindings.createObjectBinding(
            () -> intervalXTickLabel.getSelectionModel().getSelectedItem().getConverter(),
            intervalXTickLabel.getSelectionModel().selectedItemProperty()
    );
    xAxis.tickLabelFormatterProperty().bind(intervalXLabelConverter);

}
 
Example 11
private Node buildDynamicSelectComponent(ConfigNode node, String settingName, Serializable value) {
    try {
        DynamicSelection sel = (DynamicSelection) node.subject.getClass().getField(settingName).get(node.subject);
        ChoiceBox widget = new ChoiceBox(FXCollections.observableList(new ArrayList(sel.getSelections().keySet())));
        widget.setMinWidth(175.0);
        widget.setConverter(new StringConverter() {
            @Override
            public String toString(Object object) {
                return (String) sel.getSelections().get(object);
            }
            
            @Override
            public Object fromString(String string) {
                return sel.findValueByMatch(string);
            }
        });
        Object selected = value == null ? null : widget.getConverter().fromString(String.valueOf(value));
        if (selected == null) {
            widget.getSelectionModel().selectFirst();
        } else {
            widget.setValue(selected);
        }
        widget.valueProperty().addListener((Observable e) -> {
            node.setFieldValue(settingName, widget.getConverter().toString(widget.getValue()));
        });
        return widget;
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
        Logger.getLogger(ConfigurationUIController.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
Example 12
Source Project: ARMStrong   Source File: CellUtils.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/***************************************************************************
 *                                                                         *
 * General convenience                                                     *
 *                                                                         *
 **************************************************************************/

/*
 * Simple method to provide a StringConverter implementation in various cell
 * implementations.
 */
@SuppressWarnings("unchecked")
static <T> StringConverter<T> defaultStringConverter() {
    return (StringConverter<T>) defaultStringConverter;
}
 
Example 13
Source Project: constellation   Source File: DateTimeRangeInputPane.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Build a single datetime picker.
 *
 * @param label
 * @param ld
 * @param h
 * @param m
 * @param s
 * @param listener
 * @return
 */
private Pane createPicker(final String label, final ChangeListener<String> changed) {
    final Label dpLabel = new Label(label);
    final DatePicker dp = new DatePicker();
    dp.setConverter(new StringConverter<LocalDate>() {
        @Override
        public String toString(final LocalDate date) {
            return date != null ? DATE_FORMATTER.format(date) : "";
        }

        @Override
        public LocalDate fromString(final String s) {
            return s != null && !s.isEmpty() ? LocalDate.parse(s, DATE_FORMATTER) : null;
        }
    });
    dpLabel.setLabelFor(dp);
    final HBox dpBox = new HBox(dpLabel, dp);
    final HBox spinnerBox = new HBox(CONTROLPANE_SPACING / 2);
    dp.maxWidthProperty().bind(spinnerBox.widthProperty().multiply(2.0 / 3.0));
    spinnerBox.getChildren().addAll(createSpinner("Hour", 0, 23, changed), createSpinner("Minute", 0, 59, changed), createSpinner("Second", 0, 59, changed));
    final VBox picker = new VBox(dpBox, spinnerBox);
    picker.setStyle("-fx-padding:4; -fx-border-radius:4; -fx-border-color: grey;");

    dp.getEditor().textProperty().addListener(changed);

    // The DatePicker has the horrible problem that you can type in the text field, but the value won't change,
    // so if you type a new date and click Go, the old date will be used, not the new date that you can see.
    // The simplest way to avoid this is to disable the text field. :-(
    dp.getEditor().setDisable(true);

    datePickers.add(dp);

    return picker;
}
 
Example 14
Source Project: Open-Lowcode   Source File: LargeTextTableCell.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * creates a large text table cell with no restriction for data entry and
 * aligned on left
 * 
 * @param converter    converter to generate the object from string entered
 * @param largedisplay true if several lines (large display)
 * @param lineheight   line height in pixel
 */
public LargeTextTableCell(StringConverter<T> converter, boolean largedisplay, double lineheight) {
	this.lineheightfortable = lineheight;
	setConverter(converter);
	this.alignonright = false;
	this.largedisplay = largedisplay;
	if (this.largedisplay) {
		this.getStyleClass().add("text-area-table-cell");
	} else {
		this.getStyleClass().add("text-field-table-cell");
	}
}
 
Example 15
Source Project: phoebus   Source File: CellUtiles.java    License: Eclipse Public License 1.0 5 votes vote down vote up
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final ComboBox<T> comboBox) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (comboBox != null) {
                comboBox.getSelectionModel().select(cell.getItem());
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, comboBox);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(comboBox);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
Example 16
Source Project: ARMStrong   Source File: CellUtils.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/***************************************************************************
 *                                                                         *
 * ChoiceBox convenience                                                   *
 *                                                                         *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final ChoiceBox<T> choiceBox) {
    updateItem(cell, converter, null, null, choiceBox);
}
 
Example 17
Source Project: marathonv5   Source File: JavaFXChoiceBoxCellElement.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public String _getValue() {
    StringConverter converter = getConverter();
    Object item = ((Cell) node).getItem();
    if (converter != null) {
        return converter.toString(item);
    }
    return item.toString();
}
 
Example 18
Source Project: phoebus   Source File: CellUtiles.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/***************************************************************************
 *                                                                         *
 * TextField convenience                                                   *
 *                                                                         *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final TextField textField) {
    updateItem(cell, converter, null, null, textField);
}
 
Example 19
/**
 * creates a large text table cell with no restriction for data entry and
 * aligned on left
 * 
 * @param converter    converter to generate the object from string entered
 * @param largedisplay true if several lines (large display)
 * @param lineheight   line height in pixel
 */
public LargeTextTreeTableCell(StringConverter<T> converter, boolean largedisplay, double lineheight) {
	this.lineheightfortable = lineheight;
	setConverter(converter);
	this.alignonright = false;
	this.largedisplay = largedisplay;
	if (this.largedisplay) {
		this.getStyleClass().add("text-area-table-cell");
	} else {
		this.getStyleClass().add("text-field-table-cell");
	}
}
 
Example 20
Source Project: Game2048FX   Source File: SettingsPresenter.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void initialize() {
    settings.showingProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue) {
            AppBar appBar = getApp().getAppBar();
            appBar.setNavIcon(MaterialDesignIcon.ARROW_BACK.button(e -> getApp().goHome()));
            appBar.setTitleText("Game Settings");
            appBar.getActionItems().add(MaterialDesignIcon.CLOSE.button(e -> getApp().goHome()));
            gameMode.set(gameModel.getGameMode());
        }
    });

    gameMode.addListener((obs, ov, nv) -> {
        if (nv != gameModel.getGameMode()) {
            showAlertDialog(nv);
        }
    });
    final DefaultOption<ObjectProperty<GameMode>> gameModeOption = new DefaultOption<>(MaterialDesignIcon.APPS.graphic(),
            "Game Mode", "Choose the Game Mode", "Mode", gameMode, true);
    gameModeOption.setExtendedDescription("Select between: \n\n"
            + "\u2022 Easy: Save and restore are allowed at any time\n\n\n"
            + "\u2022 Advanced: Save allowed only after a 2048 tile, you can restore at any time\n\n\n"
            + "\u2022 Expert: Save and restore are not allowed.");
    gameModeOption.setStringConverter(new StringConverter() {
        @Override
        public String toString(Object object) {
            return ((GameMode) object).getText();
        }

        @Override
        public Object fromString(String string) {
            return GameMode.valueOf(string);
        }
    });
    
    final DefaultOption<BooleanProperty> vibrateOption = new DefaultOption<>(MaterialDesignIcon.VIBRATION.graphic(),
            "Vibrate", "Vibrate every 2048 tile", "Options", gameModel.vibrateModeOnProperty(), true);
    
    settingsPane.getOptions().addAll(gameModeOption, vibrateOption);
    
}
 
Example 21
Source Project: bisq   Source File: GUIUtil.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static StringConverter<TradeCurrency> getTradeCurrencyConverter(String postFixSingle,
                                                                       String postFixMulti,
                                                                       Map<String, Integer> offerCounts) {
    return new StringConverter<>() {
        @Override
        public String toString(TradeCurrency tradeCurrency) {
            String code = tradeCurrency.getCode();
            Optional<Integer> offerCountOptional = Optional.ofNullable(offerCounts.get(code));
            final String displayString;
            displayString = offerCountOptional
                    .map(offerCount -> CurrencyUtil.getNameAndCode(code)
                            + " - " + offerCount + " " + (offerCount == 1 ? postFixSingle : postFixMulti))
                    .orElseGet(() -> CurrencyUtil.getNameAndCode(code));
            // http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
            if (code.equals(GUIUtil.SHOW_ALL_FLAG))
                return "▶ " + Res.get("list.currency.showAll");
            else if (code.equals(GUIUtil.EDIT_FLAG))
                return "▼ " + Res.get("list.currency.editList");
            return tradeCurrency.getDisplayPrefix() + displayString;
        }

        @Override
        public TradeCurrency fromString(String s) {
            return null;
        }
    };
}
 
Example 22
Source Project: ARMStrong   Source File: CellUtils.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/***************************************************************************
 *                                                                         *
 * TextField convenience                                                   *
 *                                                                         *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final TextField textField) {
    updateItem(cell, converter, null, null, textField);
}
 
Example 23
Source Project: bisq   Source File: AssetFeeView.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void initialize() {
    addTitledGroupBg(root, gridRow, 3, Res.get("dao.burnBsq.header"));

    assetComboBox = FormBuilder.addComboBox(root, gridRow,
            Res.get("dao.burnBsq.selectAsset"), Layout.FIRST_ROW_DISTANCE);
    assetComboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(StatefulAsset statefulAsset) {
            return CurrencyUtil.getNameAndCode(statefulAsset.getAsset().getTickerSymbol());
        }

        @Override
        public StatefulAsset fromString(String string) {
            return null;
        }
    });

    feeAmountInputTextField = addInputTextField(root, ++gridRow, Res.get("dao.burnBsq.fee"));
    feeAmountInputTextField.setValidator(bsqValidator);

    trialPeriodTextField = FormBuilder.addTopLabelTextField(root, ++gridRow, Res.get("dao.burnBsq.trialPeriod")).second;

    payFeeButton = addButtonAfterGroup(root, ++gridRow, Res.get("dao.burnBsq.payFee"));

    tableView = FormBuilder.addTableViewWithHeader(root, ++gridRow, Res.get("dao.burnBsq.allAssets"), 20, "last");
    createColumns();
    tableView.setItems(sortedList);

    createListeners();
}
 
Example 24
private void commitEditorText() {
  if (!isEditable())
    return;
  String text = getEditor().getText();
  SpinnerValueFactory<T> valueFactory = getValueFactory();
  if (valueFactory != null) {
    StringConverter<T> converter = valueFactory.getConverter();
    if (converter != null) {
      T value = converter.fromString(text);
      valueFactory.setValue(value);
    }
  }
}
 
Example 25
Source Project: pmd-designer   Source File: DesignerUtil.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static <T> StringConverter<T> stringConverter(Function<T, String> toString, Function<String, T> fromString) {
    return new StringConverter<T>() {
        @Override
        public String toString(T object) {
            return toString.apply(object);
        }


        @Override
        public T fromString(String string) {
            return fromString.apply(string);
        }
    };
}
 
Example 26
public LanguageVersionRangeSlider() {

        setMin(NO_MIN);
        setBlockIncrement(1);
        setMajorTickUnit(1);
        setMinorTickCount(0);
        setSnapToTicks(true);

        currentLanguage.values().distinct().subscribe(this::initLanguage);

        StringConverter<Number> converter = DesignerUtil.stringConverter(
            num -> {
                int n = num.intValue();
                if (n < 0) {
                    return NO_MIN_STR;
                } else if (n >= curVersions.size()) {
                    return NO_MAX_STR;
                } else {
                    return curVersions.get(n).getShortName();
                }
            },
            ver -> {
                switch (ver) {
                case NO_MIN_STR:
                    return -1;
                case NO_MAX_STR:
                    return curVersions.size();
                default:
                    LanguageVersion withName = curVersions.stream().filter(lv -> lv.getShortName().equals(ver)).findFirst().get();
                    return curVersions.indexOf(withName);
                }
            }
        );

        setLabelFormatter(converter);


    }
 
Example 27
Source Project: ARMStrong   Source File: CellUtils.java    License: Mozilla Public License 2.0 5 votes vote down vote up
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final ComboBox<T> comboBox) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (comboBox != null) {
                comboBox.getSelectionModel().select(cell.getItem());
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, comboBox);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(comboBox);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
Example 28
Source Project: milkman   Source File: CreateWorkspaceDialog.java    License: MIT License 5 votes vote down vote up
public void showAndWait(List<WorkspaceSynchronizer> synchronizers, Toaster toaster) {
	this.toaster = toaster;
	JFXDialogLayout content = new CreateWorkspaceDialogFxml(this);
	synchronizers.forEach(i -> syncSelector.getItems().add(i.getDetailFactory()));
	
	//default to first item
	if (syncSelector.getItems().size() > 0) {
		SynchronizationDetailFactory defaultSync = syncSelector.getItems().get(0);
		syncSelector.setValue(defaultSync);
		syncDetailsArea.getChildren().add(defaultSync.getSyncDetailsControls());
		selectedSynchronizer = defaultSync;
	}
	
	syncSelector.setConverter(new StringConverter<SynchronizationDetailFactory>() {
		
		@Override
		public String toString(SynchronizationDetailFactory object) {
			return object.getName();
		}
		
		@Override
		public SynchronizationDetailFactory fromString(String string) {
			return null;
		}
	});
	syncSelector.getSelectionModel().selectedItemProperty().addListener((obs, o, v) -> {
		if (o != v && v != null) {
			selectedSynchronizer = v;
			syncDetailsArea.getChildren().clear();
			syncDetailsArea.getChildren().add(v.getSyncDetailsControls());
		} 
	});
	dialog = FxmlUtil.createDialog(content);
	dialog.showAndWait();
}
 
Example 29
Source Project: milkman   Source File: ExportDialog.java    License: MIT License 5 votes vote down vote up
public void showAndWait(List<Exporter<T>> exporters, Templater templater, Toaster toaster, T objToExport) {
	this.templater = templater;
	this.toaster = toaster;
	this.objToExport = objToExport;
	JFXDialogLayout content = new ExportDialogFxml(this);
	exportSelector.setPromptText("Select Exporter");
	exporters.forEach(exportSelector.getItems()::add);
	exportSelector.setConverter(new StringConverter<Exporter<T>>() {
		
		@Override
		public String toString(Exporter<T> object) {
			return object.getName();
		}
		
		@Override
		public Exporter<T> fromString(String string) {
			return null;
		}
	});
	exportSelector.getSelectionModel().selectedItemProperty().addListener((obs, o, v) -> {
		if (o != v && v != null) {
			selectedExporter = v;
			exportArea.getChildren().clear();
			exportArea.getChildren().add(v.getRoot(objToExport, templater));
			exportBtn.setDisable(v.isAdhocExporter());
		} 
	});
	dialog = FxmlUtil.createDialog(content);
	dialog.showAndWait();
}
 
Example 30
Source Project: JFoenix   Source File: JFXComboBox.java    License: Apache License 2.0 5 votes vote down vote up
private boolean updateDisplayText(ListCell<T> cell, T item, boolean empty) {
    if (empty) {
        // create empty cell
        if (cell == null) {
            return true;
        }
        cell.setGraphic(null);
        cell.setText(null);
        return true;
    } else if (item instanceof Node) {
        Node currentNode = cell.getGraphic();
        Node newNode = (Node) item;
        //  create a node from the selected node of the listview
        //  using JFXComboBox {@link #nodeConverterProperty() NodeConverter})
        NodeConverter<T> nc = this.getNodeConverter();
        Node node = nc == null ? null : nc.toNode(item);
        if (currentNode == null || !currentNode.equals(newNode)) {
            cell.setText(null);
            cell.setGraphic(node == null ? newNode : node);
        }
        return node == null;
    } else {
        // run item through StringConverter if it isn't null
        StringConverter<T> c = this.getConverter();
        String s = item == null ? this.getPromptText() : (c == null ? item.toString() : c.toString(item));
        cell.setText(s);
        cell.setGraphic(null);
        return s == null || s.isEmpty();
    }
}