Java Code Examples for javafx.beans.property.ReadOnlyStringWrapper

The following examples show how to use javafx.beans.property.ReadOnlyStringWrapper. 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: tcMenu   Source File: GenerateCodeDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void buildTable() {
    propsTable = new TableView<>();
    defineCol = new TableColumn<>("Parameter");
    typeCol = new TableColumn<>("SubSystem");
    valueCol = new TableColumn<>("Value");
    descriptionCol = new TableColumn<>("Description");
    descriptionCol.setPrefWidth(400);
    propsTable.getColumns().addAll(defineCol, typeCol, valueCol, descriptionCol);
    propsTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    propsTable.setMaxHeight(2000);

    defineCol.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getName()));
    typeCol.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getSubsystem().toString()));
    valueCol.setCellValueFactory(param -> param.getValue().getProperty());
    valueCol.setPrefWidth(130);
    descriptionCol.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getDescription()));

    propsTable.setEditable(true);
    valueCol.setEditable(true);

    valueCol.setCellFactory(editCol -> new CreatorEditingTableCell(editorUI));

    changeProperties();
}
 
Example 2
Source Project: PreferencesFX   Source File: HistoryTable.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes a new table, showing the {@code changes}.
 *
 * @param changes to be shown in the table
 */
public HistoryTable(ObservableList<Change> changes) {
  this.changes = changes;

  TableColumn<Change, String> timestamp = new TableColumn<>("Time");
  timestamp.setCellValueFactory(
      change -> new ReadOnlyStringWrapper(change.getValue().getTimestamp())
  );

  TableColumn<Change, String> breadcrumb = new TableColumn<>("Setting");
  breadcrumb.setCellValueFactory(
      change -> new ReadOnlyStringWrapper(change.getValue().getSetting().toString())
  );

  TableColumn<Change, Object> oldValue = new TableColumn<>("Old Value");
  oldValue.setCellValueFactory(change -> change.getValue().oldListProperty());

  TableColumn<Change, Object> newValue = new TableColumn<>("New Value");
  newValue.setCellValueFactory(change -> change.getValue().newListProperty());

  setItems(this.changes);
  getColumns().addAll(timestamp, breadcrumb, oldValue, newValue);
}
 
Example 3
Source Project: phoebus   Source File: WidgetInfoDialog.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private Tab createMacros(final Macros orig_macros)
{
    final Macros macros = (orig_macros == null) ? new Macros() : orig_macros;
    // Use text field to allow copying the name and value
    // Table uses list of macro names as input
    // Name column just displays the macro name,..
    final TableColumn<String, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
    name.setCellFactory(col -> new ReadOnlyTextCell<>());
    name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue()));

    // .. value column fetches the macro value
    final TableColumn<String, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
    value.setCellFactory(col -> new ReadOnlyTextCell<>());
    value.setCellValueFactory(param -> new ReadOnlyStringWrapper(macros.getValue(param.getValue())));

    final TableView<String> table =
        new TableView<>(FXCollections.observableArrayList(macros.getNames()));
    table.getColumns().add(name);
    table.getColumns().add(value);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    return new Tab(Messages.WidgetInfoDialog_TabMacros, table);
}
 
Example 4
Source Project: phoebus   Source File: ChannelTreeController.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@FXML
public void initialize() {
    dispose();

    node.setCellValueFactory(cellValue -> new ReadOnlyStringWrapper(cellValue.getValue().getValue().getDisplayName()));
    value.setCellValueFactory(cellValue -> new ReadOnlyStringWrapper(cellValue.getValue().getValue().getDisplayValue()));

    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    treeTableView.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
        if (newSelection != null) {
            final List<Channel> selectedChannels = new ArrayList<Channel>();
            treeTableView.getSelectionModel().getSelectedItems().stream().forEach(item -> {
                selectedChannels.addAll(item.getValue().getNodeChannels());
            });
            SelectionService.getInstance().setSelection(treeTableView, selectedChannels);
        }
    });
}
 
Example 5
Source Project: curly   Source File: BatchRunnerResult.java    License: Apache License 2.0 6 votes vote down vote up
public BatchRunnerResult() {
    reportRow().add(new ReadOnlyStringWrapper("Batch run"));
    
    StringBinding successOrNot = Bindings.when(completelySuccessful())
            .then(ApplicationState.getMessage(COMPLETED_SUCCESSFUL))
            .otherwise(ApplicationState.getMessage(COMPLETED_UNSUCCESSFUL));
    StringBinding successMessageBinding = Bindings.when(completed())
            .then(successOrNot).otherwise(ApplicationState.getMessage(INCOMPLETE));
    reportRow().add(successMessageBinding);

    reportRow().add(percentCompleteString().concat(" complete"));
    reportRow().add(percentSuccessString().concat(" success"));
    reportRow().add(getDuration());
    allBindings.add(successOrNot);
    allBindings.add(successMessageBinding);
}
 
Example 6
Source Project: curly   Source File: ActionGroupRunnerResult.java    License: Apache License 2.0 6 votes vote down vote up
private void buildRow(Map<String, String> variables, Set<String> reportColumns) {
    successOrNot = Bindings.when(completelySuccessful())
            .then(ApplicationState.getMessage(COMPLETED_SUCCESSFUL))
            .otherwise(ApplicationState.getMessage(COMPLETED_UNSUCCESSFUL));
    completeStatus = Bindings.when(Bindings.greaterThanOrEqual(percentComplete(), 1))
            .then(successOrNot)
            .otherwise(ApplicationState.getMessage(INCOMPLETE));
    
    reportRow().add(new ReadOnlyStringWrapper(task));
    reportRow().add(completeStatus);
    reportRow().add(percentCompleteString().concat(" complete"));
    reportRow().add(percentSuccessString().concat(" success"));
    reportRow().add(getDuration());
    reportColumns.forEach((colName) -> reportRow().add(new SimpleStringProperty(variables.get(colName))));
    allBindings.add(successOrNot);
    allBindings.add(completeStatus);
}
 
Example 7
Source Project: curly   Source File: ConnectionManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void getAuthenticatedConnection() throws IOException {
    webserver.requireLogin = true;
    AuthHandler handler = new AuthHandler(
            new ReadOnlyStringWrapper("localhost:"+webserver.port), 
            new ReadOnlyBooleanWrapper(false), 
            new ReadOnlyStringWrapper(TEST_USER), 
            new ReadOnlyStringWrapper(TEST_PASSWORD)
    );
    CloseableHttpClient client = handler.getAuthenticatedClient();
    assertNotNull(client);
    HttpUriRequest request = new HttpGet("http://localhost:"+webserver.port+"/testUri");
    client.execute(request);
    Header authHeader = webserver.lastRequest.getFirstHeader("Authorization");
    assertNotNull(authHeader);
    String compareToken = "Basic "+Base64.getEncoder().encodeToString((TEST_USER + ":" + TEST_PASSWORD).getBytes());
    assertEquals("Auth token should be expected format", authHeader.getValue(), compareToken);
}
 
Example 8
Source Project: latexdraw   Source File: BadaboomController.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void initialize(final URL location, final ResourceBundle resources) {
	final ObservableList<TableColumn<Throwable, ?>> cols = table.getColumns();
	((TableColumn<Throwable, String>) cols.get(0)).setCellValueFactory(cell -> new ReadOnlyStringWrapper(cell.getValue().toString()));
	((TableColumn<Throwable, String>) cols.get(1)).setCellValueFactory(cell -> new ReadOnlyStringWrapper(cell.getValue().getMessage()));
	((TableColumn<Throwable, String>) cols.get(2)).setCellValueFactory(cell -> {
		final StackTraceElement[] stackTrace = cell.getValue().getStackTrace();
		final String msg = stackTrace.length > 0 ? stackTrace[0].toString() : "";
		return new ReadOnlyStringWrapper(msg);
	});
	cols.forEach(col -> col.prefWidthProperty().bind(table.widthProperty().divide(3)));
	table.itemsProperty().bind(BadaboomCollector.INSTANCE.errorsProperty());
	table.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

	final Callable<String> converter = () -> {
		final Throwable ex = table.getSelectionModel().getSelectedItem();
		if(ex == null) {
			return "";
		}
		return Arrays.stream(ex.getStackTrace()).map(Object::toString).collect(Collectors.joining("\n\tat ", ex.toString() + "\n\tat ", "")); //NON-NLS
	};
	stack.textProperty().bind(Bindings.createStringBinding(converter, table.getSelectionModel().selectedItemProperty()));
}
 
Example 9
Source Project: kafka-message-tool   Source File: TopicConfigView.java    License: MIT License 5 votes vote down vote up
private StringExpression composeBrokerConfigWindowTitle() {
    return new ReadOnlyStringWrapper("Topic configuration")
            .concat(" '").concat(config.nameProperty()).concat("' (")
            .concat("topic:")
            .concat(config.topicNameProperty())
            .concat(")");
}
 
Example 10
Source Project: kafka-message-tool   Source File: BrokerConfigView.java    License: MIT License 5 votes vote down vote up
private StringExpression composeConfigWindowTitle() {
    return new ReadOnlyStringWrapper("Broker configuration")
        .concat(" '").concat(config.nameProperty()).concat("' (")
        .concat(config.hostNameProperty())
        .concat(":")
        .concat(config.portProperty())
        .concat(")");
}
 
Example 11
Source Project: phoebus   Source File: WidgetInfoDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private Tab createProperties(final Widget widget)
 {
     // Use text field to allow copying the name (for use in scripts)
     // and value, but not the localized description and category
     // which are just for information
     final TableColumn<WidgetProperty<?>, String> cat = new TableColumn<>(Messages.WidgetInfoDialog_Category);
     cat.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getCategory().getDescription()));

     final TableColumn<WidgetProperty<?>, String> descr = new TableColumn<>(Messages.WidgetInfoDialog_Property);
     descr.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getDescription()));

     final TableColumn<WidgetProperty<?>, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
     name.setCellFactory(col -> new ReadOnlyTextCell<>());
     name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getName()));

     final TableColumn<WidgetProperty<?>, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
     value.setCellFactory(col -> new ReadOnlyTextCell<>());
     value.setCellValueFactory(param -> new ReadOnlyStringWrapper(Objects.toString(param.getValue().getValue())));

     final TableView<WidgetProperty<?>> table =
         new TableView<>(FXCollections.observableArrayList(widget.getProperties()));
     table.getColumns().add(cat);
     table.getColumns().add(descr);
     table.getColumns().add(name);
     table.getColumns().add(value);
     table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

     return new Tab(Messages.WidgetInfoDialog_TabProperties, table);
}
 
Example 12
Source Project: phoebus   Source File: FormulaTreeController.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@FXML
public void initialize() {
    signature.setCellValueFactory(cellValue -> new ReadOnlyStringWrapper(cellValue.getValue().getValue().getSignature()));
    description.setCellValueFactory(cellValue -> new ReadOnlyStringWrapper(cellValue.getValue().getValue().getDescription()));

    FormulaTreeRootNode root = new FormulaTreeRootNode();
    ServiceLoader.load(FormulaFunction.class).forEach(func -> root.addChild(func));

    treeTableView.setRoot(root);
    treeTableView.setShowRoot(false);
}
 
Example 13
Source Project: xltsearch   Source File: MessageDisplay.java    License: Apache License 2.0 5 votes vote down vote up
@FXML
private void initialize() {
    // replaces CONSTRAINED_RESIZE_POLICY
    summaryCol.prefWidthProperty().bind(
        table.widthProperty()
        .subtract(timeCol.widthProperty())
        .subtract(levelCol.widthProperty())
        .subtract(fromCol.widthProperty())
    );

    table.itemsProperty().bind(MessageLogger.messagesProperty());

    final DateFormat df = DateFormat.getTimeInstance();
    timeCol.setCellValueFactory((r) ->
        new ReadOnlyStringWrapper(df.format(new Date(r.getValue().timestamp))));
    levelCol.setCellValueFactory((r) ->
        new ReadOnlyStringWrapper(r.getValue().level.toString()));
    fromCol.setCellValueFactory((r) ->
        new ReadOnlyStringWrapper(r.getValue().from));
    summaryCol.setCellValueFactory((r) ->
        new ReadOnlyStringWrapper(r.getValue().summary));

    table.getSelectionModel().selectedItemProperty().addListener((o, oldValue, newValue) -> {
        if (newValue != null) {
            detailsField.setText(newValue.summary + '\n' + newValue.details);
        } else {
            detailsField.setText("");
        }
    });

    logLevel.getItems().setAll(Message.Level.values());
    logLevel.getSelectionModel().select(MessageLogger.logLevelProperty().get());
    logLevel.getSelectionModel().selectedItemProperty().addListener(
        (o, oldValue, newValue) -> MessageLogger.logLevelProperty().set(newValue));
}
 
Example 14
public ObservableEntity(Entity entity) {
    this.entity = entity;
    index = new ReadOnlyStringWrapper(String.valueOf(entity.getIndex()));
    name = new ReadOnlyStringWrapper(entity.getDtClass().getDtName());
    Iterator<FieldPath> iter = entity.getState().fieldPathIterator();
    while (iter.hasNext()) {
        FieldPath fp = iter.next();
        indices.add(fp);
        properties.add(new ObservableEntityProperty(entity, fp));
    }
}
 
Example 15
Source Project: curly   Source File: BatchRunner.java    License: Apache License 2.0 5 votes vote down vote up
public BatchRunner(AuthHandler auth, int concurrency, List<Action> actions, List<Map<String, String>> batchData, Map<String, StringProperty> defaultValues, Set<String> displayColumns) {
    clientThread = ThreadLocal.withInitial(auth::getAuthenticatedClient);
    result = new BatchRunnerResult();
    tasks = new ArrayBlockingQueue<>(batchData.size());
    this.concurrency = concurrency;
    defaultValues.put("server", new ReadOnlyStringWrapper(auth.getUrlBase()));
    buildWorkerPool = ()->buildTasks(actions, batchData, defaultValues, displayColumns);
}
 
Example 16
Source Project: curly   Source File: ErrorBehaviorTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    ApplicationState.getInstance().runningProperty().set(true);
    handler = new AuthHandler(
            new ReadOnlyStringWrapper("localhost:" + webserver.port),
            new ReadOnlyBooleanWrapper(false),
            new ReadOnlyStringWrapper(TEST_USER),
            new ReadOnlyStringWrapper(TEST_PASSWORD)
    );
    client = handler.getAuthenticatedClient();
}
 
Example 17
Source Project: kafka-message-tool   Source File: SenderConfigView.java    License: MIT License 4 votes vote down vote up
public SenderConfigView(KafkaSenderConfig config,
                        AnchorPane parentPane,
                        ModelConfigObjectsGuiInformer guiInformer,
                        Runnable refreshCallback,
                        ObservableList<KafkaTopicConfig> topicConfigs,
                        MessageTemplateSender msgTemplateSender,
                        VirtualizedScrollPane<StyleClassedTextArea> beforeAllMessagesSharedScriptScrollPane,
                        VirtualizedScrollPane<StyleClassedTextArea> beforeAllMessagesScriptScrollPane,
                        VirtualizedScrollPane<StyleClassedTextArea> beforeEachMessageScriptScrollPane,
                        VirtualizedScrollPane<StyleClassedTextArea> messageContentScrollPane,
                        KafkaClusterProxies kafkaClusterProxies,
                        ApplicationSettings applicationSettings) throws IOException {
    this.msgTemplateSender = msgTemplateSender;

    this.beforeAllMessagesSharedScriptScrollPane = beforeAllMessagesSharedScriptScrollPane;
    this.beforeAllMessagesScriptScrollPane = beforeAllMessagesScriptScrollPane;
    this.beforeEachMessageScriptScrollPane = beforeEachMessageScriptScrollPane;

    this.kafkaClusterProxies = kafkaClusterProxies;
    this.applicationSettings = applicationSettings;

    beforeAllmessagesSharedScriptCodeArea = this.beforeAllMessagesSharedScriptScrollPane.getContent();
    beforeAllMessagesScriptCodeArea = this.beforeAllMessagesScriptScrollPane.getContent();
    beforeEachMessagesScriptCodeArea = this.beforeEachMessageScriptScrollPane.getContent();


    this.messageContentScrollPane = messageContentScrollPane;
    messageContentTextArea = this.messageContentScrollPane.getContent();


    CustomFxWidgetsLoader.loadAnchorPane(this, FXML_FILE);

    this.config = config;
    this.refreshCallback = refreshCallback;
    this.topicConfigs = topicConfigs;

    final StringExpression windowTitle = new ReadOnlyStringWrapper("Message sender configuration");
    displayBehaviour = new DetachableDisplayBehaviour(parentPane,
                                                      windowTitle,
                                                      this,
                                                      detachPaneButton.selectedProperty(),
                                                      config,
                                                      guiInformer);

    configureMessageNameTextField();
    configureMessageContentTextArea();
    configureTopicComboBox();
    configureRepeatCountSpinner();
    configureMessageKeyCheckbox();
    configureScriptsTextAreas();
    configureMessageKeyTextField();
    configureSimulationSendingCheckBox();
    createProgressNotifier();
    GuiUtils.configureComboBoxToClearSelectedValueIfItsPreviousValueWasRemoved(topicConfigComboBox);
    comboBoxConfigurator = new TopicConfigComboBoxConfigurator<>(topicConfigComboBox, config);
    comboBoxConfigurator.configure();
    taskExecutor = new MessageSenderTaskExecutor(sendMsgPushButton.disableProperty(),
                                                 stopSendingButton.disableProperty());
}
 
Example 18
Source Project: kafka-message-tool   Source File: ListenerConfigView.java    License: MIT License 4 votes vote down vote up
public ListenerConfigView(KafkaListenerConfig config,
                          AnchorPane parentPane,
                          ModelConfigObjectsGuiInformer guiInformer,
                          Listeners activeConsumers,
                          Runnable refreshCallback,
                          ObservableList<KafkaTopicConfig> topicConfigs,
                          ToFileSaver toFileSaver,
                          FixedNumberRecordsCountLogger fixedRecordsLogger) throws IOException {
    this.parentPane = parentPane;
    this.guiInformer = guiInformer;
    this.toFileSaver = toFileSaver;
    this.fixedRecordsLogger = fixedRecordsLogger;
    partitionAssignmentHandler = new PartitionAssignmentChangeHandler(
        new FXNodeBlinker(Color.BLACK), config);

    CustomFxWidgetsLoader.loadAnchorPane(this, FXML_FILE);

    this.config = config;
    this.activeConsumers = activeConsumers;
    this.refreshCallback = refreshCallback;
    this.topicConfigs = topicConfigs;

    final StringExpression windowTitle = new ReadOnlyStringWrapper("Kafka listener configuration");
    displayBehaviour = new DetachableDisplayBehaviour(parentPane,
                                                      windowTitle,
                                                      this,
                                                      detachPaneButton.selectedProperty(),
                                                      config,
                                                      guiInformer);
    configureTopicConfigComboBox();
    configureOffsetResetComboBox();
    configureMessageNameTextField();
    configureConsumerGroupField();
    configureFetchTimeoutField();
    configureReceiveMsgLimitControls();
    setKafkaListenerBinding();

    configureGuiControlDisableStateBasedOnStartButtonState();
    GuiUtils.configureComboBoxToClearSelectedValueIfItsPreviousValueWasRemoved(topicConfigComboBox);

    comboBoxConfigurator = new TopicConfigComboBoxConfigurator<>(topicConfigComboBox, config);
    comboBoxConfigurator.configure();

}
 
Example 19
Source Project: phoebus   Source File: WidgetInfoDialog.java    License: Eclipse Public License 1.0 4 votes vote down vote up
private Tab createPVs(final Collection<NameStateValue> pvs)
{
    // Use text field to allow users to copy the name, value to clipboard
    final TableColumn<NameStateValue, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
    name.setCellFactory(col -> new ReadOnlyTextCell<>());
    name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().name));

    final TableColumn<NameStateValue, String> state = new TableColumn<>(Messages.WidgetInfoDialog_State);
    state.setCellFactory(col -> new ReadOnlyTextCell<>());
    state.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().state));

    final TableColumn<NameStateValue, String> path = new TableColumn<>(Messages.WidgetInfoDialog_Path);
    path.setCellFactory(col -> new ReadOnlyTextCell<>());
    path.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().path));

    final TableColumn<NameStateValue, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
    value.setCellFactory(col -> new AlarmColoredCell());
    value.setCellValueFactory(param ->
    {
        String text;
        final VType vtype = param.getValue().value;
        if (vtype == null)
            text = Messages.WidgetInfoDialog_Disconnected;
        else
        {   // Formatting arrays can be very slow,
            // so only show the basic type info
            if (vtype instanceof VNumberArray)
                text = vtype.toString();
            else
                text = VTypeUtil.getValueString(vtype, true);
            final Alarm alarm = Alarm.alarmOf(vtype);
            if (alarm != null  &&  alarm.getSeverity() != AlarmSeverity.NONE)
                text = text + " [" + alarm.getSeverity().toString() + ", " +
                                     alarm.getName() + "]";
        }
        return new ReadOnlyStringWrapper(text);
    });

    final ObservableList<NameStateValue> pv_data = FXCollections.observableArrayList(pvs);
    pv_data.sort((a, b) -> a.name.compareTo(b.name));
    final TableView<NameStateValue> table = new TableView<>(pv_data);
    table.getColumns().add(name);
    table.getColumns().add(state);
    table.getColumns().add(value);
    table.getColumns().add(path);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    return new Tab(Messages.WidgetInfoDialog_TabPVs, table);
}
 
Example 20
Source Project: xltsearch   Source File: App.java    License: Apache License 2.0 4 votes vote down vote up
@FXML
private void initialize() {
    // replaces CONSTRAINED_RESIZE_POLICY
    scoreCol.prefWidthProperty().bind(
        resultsTable.widthProperty()
        .subtract(fileNameCol.widthProperty())
        .subtract(titleCol.widthProperty())
    );

    searchButton.defaultButtonProperty().bind(searchButton.focusedProperty());
    limitField.setText(Integer.toString(DEFAULT_LIMIT));

    // DIALOGS
    configurator = new Configurator();
    messageDisplay = new MessageDisplay();

    // UI BINDINGS
    configurator.catalogProperty().bind(catalog);
    catalog.addListener((o, oldValue, newValue) -> {
        folderPathLabel.setText(newValue.getPath());
        // bind information controls to new catalog
        indexDetailsLabel.textProperty().unbind();
        indexDetailsLabel.textProperty().bind(newValue.indexDetailsProperty());
        searchMessageLabel.textProperty().unbind();
        searchMessageLabel.textProperty().bind(newValue.searchDetailsProperty());
        resultsTable.itemsProperty().unbind();
        resultsTable.itemsProperty().bind(newValue.searchResultsProperty());
        indexMessageLabel.textProperty().unbind();
        indexMessageLabel.textProperty().bind(newValue.indexMessageProperty());
        indexProgress.progressProperty().unbind();
        indexProgress.progressProperty().bind(newValue.indexProgressProperty());
    });

    fileNameCol.setCellValueFactory((r) ->
        new ReadOnlyStringWrapper(r.getValue().file.getName()));
    titleCol.setCellValueFactory((r) ->
        new ReadOnlyStringWrapper(r.getValue().title));
    scoreCol.setCellValueFactory((r) ->
        new ReadOnlyStringWrapper(String.format("%.0f", r.getValue().score*100)));

    // CALLBACKS
    resultsTable.getSelectionModel().selectedItemProperty().addListener(
            (o, oldValue, newValue) -> {
        if (newValue != null) {
            detailsField.setText(newValue.details);
        } else {
            detailsField.setText("");
        }
    });

    resultsTable.setOnKeyPressed((event) -> {
        SearchResult result = resultsTable.getSelectionModel().getSelectedItem();
        if (result != null && event.getCode() == KeyCode.ENTER) {
            catalog.get().openFile(result.file);
        }
    });

    resultsTable.setRowFactory((tv) -> {
        final TableRow<SearchResult> row = new TableRow<>();
        // open file on double-click
        row.setOnMouseClicked((event) -> {
            if (!row.isEmpty() && event.getClickCount() == 2) {
                catalog.get().openFile(row.getItem().file);
            }
        });
        // enable drag-and-drop
        row.setOnDragDetected((event) -> {
            if (!row.isEmpty()) {
                Dragboard db = row.startDragAndDrop(TransferMode.COPY, TransferMode.LINK);
                ClipboardContent content = new ClipboardContent();
                content.putFiles(Collections.singletonList(row.getItem().file));
                db.setContent(content);
                event.consume();
            }
        });
        return row;
    });
}
 
Example 21
public void initialize(java.net.URL location, java.util.ResourceBundle resources) {
    preferences = Preferences.userNodeForPackage(this.getClass());
    replayController = new ReplayController(slider);

    BooleanBinding runnerIsNull = Bindings.createBooleanBinding(() -> replayController.getRunner() == null, replayController.runnerProperty());
    buttonPlay.disableProperty().bind(runnerIsNull.or(replayController.playingProperty()));
    buttonPause.disableProperty().bind(runnerIsNull.or(replayController.playingProperty().not()));
    slider.disableProperty().bind(runnerIsNull);

    labelTick.textProperty().bind(replayController.tickProperty().asString());
    labelLastTick.textProperty().bind(replayController.lastTickProperty().asString());

    TableColumn<ObservableEntity, String> entityTableIdColumn = (TableColumn<ObservableEntity, String>) entityTable.getColumns().get(0);
    entityTableIdColumn.setCellValueFactory(param -> param.getValue() != null ? param.getValue().indexProperty() : new ReadOnlyStringWrapper(""));
    TableColumn<ObservableEntity, String> entityTableNameColumn = (TableColumn<ObservableEntity, String>) entityTable.getColumns().get(1);
    entityTableNameColumn.setCellValueFactory(param -> param.getValue() != null ? param.getValue().nameProperty() : new ReadOnlyStringWrapper(""));
    entityTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        log.info("entity table selection from {} to {}", oldValue, newValue);
        detailTable.setItems(newValue);
    });

    TableColumn<ObservableEntityProperty, String> idColumn =
        (TableColumn<ObservableEntityProperty, String>) detailTable.getColumns().get(0);
    idColumn.setCellValueFactory(param -> param.getValue().indexProperty());
    TableColumn<ObservableEntityProperty, String> nameColumn =
        (TableColumn<ObservableEntityProperty, String>) detailTable.getColumns().get(1);
    nameColumn.setCellValueFactory(param -> param.getValue().nameProperty());
    TableColumn<ObservableEntityProperty, String> valueColumn =
        (TableColumn<ObservableEntityProperty, String>) detailTable.getColumns().get(2);
    valueColumn.setCellValueFactory(param -> param.getValue().valueProperty());

    valueColumn.setCellFactory(v -> new TableCell<ObservableEntityProperty, String>() {
        final Animation animation = new Transition() {
            {
                setCycleDuration(Duration.millis(500));
                setInterpolator(Interpolator.EASE_OUT);
            }
            @Override
            protected void interpolate(double frac) {
                Color col = Color.YELLOW.interpolate(Color.WHITE, frac);
                getTableRow().setStyle(String.format(
                        "-fx-control-inner-background: #%02X%02X%02X;",
                        (int)(col.getRed() * 255),
                        (int)(col.getGreen() * 255),
                        (int)(col.getBlue() * 255)
                ));
            }
        };
        @Override
        protected void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
            setText(item);
            ObservableEntityProperty oep = (ObservableEntityProperty) getTableRow().getItem();
            if (oep != null) {
                animation.stop();
                animation.playFrom(Duration.millis(System.currentTimeMillis() - oep.getLastChangedAt()));
            }
        }
    });

    detailTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    detailTable.setOnKeyPressed(e -> {
        KeyCombination ctrlC = new KeyCodeCombination(KeyCode.C, KeyCodeCombination.CONTROL_DOWN);
        if (ctrlC.match(e)) {
            ClipboardContent cbc = new ClipboardContent();
            cbc.putString(detailTable.getSelectionModel().getSelectedIndices().stream()
                    .map(i -> detailTable.getItems().get(i))
                    .map(p -> String.format("%s %s %s", p.indexProperty().get(), p.nameProperty().get(), p.valueProperty().get()))
                    .collect(Collectors.joining("\n"))
            );
            Clipboard.getSystemClipboard().setContent(cbc);
        }
    });


    entityNameFilter.textProperty().addListener(observable -> {
        if (filteredEntityList != null) {
            filteredEntityList.setPredicate(allFilterFunc);
            filteredEntityList.setPredicate(filterFunc);
        }
    });

    mapControl = new MapControl();
    mapCanvasPane.getChildren().add(mapControl);

    mapCanvasPane.setTopAnchor(mapControl, 0.0);
    mapCanvasPane.setBottomAnchor(mapControl, 0.0);
    mapCanvasPane.setLeftAnchor(mapControl, 0.0);
    mapCanvasPane.setRightAnchor(mapControl, 0.0);
    mapCanvasPane.widthProperty().addListener(evt -> resizeMapControl());
    mapCanvasPane.heightProperty().addListener(evt -> resizeMapControl());

}
 
Example 22
public ObservableEntity(int index) {
    this.entity = null;
    this.index = new ReadOnlyStringWrapper(String.valueOf(index));
    this.name = new ReadOnlyStringWrapper("");
}
 
Example 23
@SuppressWarnings("unchecked")
@Override
public void initialize(final URL location, final ResourceBundle resources) {
	final String ctrl = InputEvent.getModifiersExText(InputEvent.CTRL_DOWN_MASK);
	final String shift = InputEvent.getModifiersExText(InputEvent.SHIFT_DOWN_MASK);
	final String leftClick = lang.getString("leftClick");
	final String catEdit = lang.getString("edit");
	final String catNav = lang.getString("navigation");
	final String catTran = lang.getString("transformation");
	final String catDraw = lang.getString("drawing");
	final String catFile = lang.getString("file");

	for(int i = 0, size = table.getColumns().size(); i < size; i++) {
		final int colIndex = i;
		final TableColumn<ObservableList<String>, String> col = (TableColumn<ObservableList<String>, String>) table.getColumns().get(i);
		col.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().get(colIndex)));
	}

	table.getColumns().forEach(col -> col.prefWidthProperty().bind(table.widthProperty().divide(3)));

	table.getItems().addAll(FXCollections.observableArrayList(ctrl + "+C", lang.getString("copy"), catEdit), //NON-NLS
		FXCollections.observableArrayList(ctrl + "+V", lang.getString("paste"), catEdit), //NON-NLS
		FXCollections.observableArrayList(ctrl + "+X", lang.getString("cut"), catEdit), //NON-NLS
		FXCollections.observableArrayList(ctrl + "+Z", lang.getString("close"), catEdit),  //NON-NLS
		FXCollections.observableArrayList(ctrl + "+Y", lang.getString("redo"), catEdit),  //NON-NLS
		FXCollections.observableArrayList(ctrl + "+N", lang.getString("newDrawing"), catFile), //NON-NLS
		FXCollections.observableArrayList(ctrl + "+O", lang.getString("openDrawing"), catFile), //NON-NLS
		FXCollections.observableArrayList(ctrl + "+S", lang.getString("saveDrawing"), catFile), //NON-NLS
		FXCollections.observableArrayList(ctrl + "+W", lang.getString("quit"), catFile),  //NON-NLS
		FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_ADD), lang.getString("zoomIn"), catNav),
		FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_SUBTRACT), lang.getString("zoomOut"), catNav),
		FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_DELETE), lang.getString("drawAxes"), catDraw),
		FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_RIGHT), lang.getString("moveScrollbarRight"), catNav),
		FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_LEFT), lang.getString("moveScrollbarLeft"), catNav),
		FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_UP), lang.getString("moveScrollbarTop"), catNav),
		FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_DOWN), lang.getString("moveScrollbarBottom"), catNav),
		FXCollections.observableArrayList(ctrl + "+U", lang.getString("updateShapes"), catTran), //NON-NLS
		FXCollections.observableArrayList(ctrl + "+A", lang.getString("selectAll"), catDraw), //NON-NLS
		FXCollections.observableArrayList(ctrl + '+' + leftClick, lang.getString("addClickedShape"), catDraw),
		FXCollections.observableArrayList(shift + '+' + leftClick, lang.getString("removeClickedShape"), catDraw),
		FXCollections.observableArrayList(ctrl + '+' + lang.getString("mouseWheel"),
			lang.getString("zoom"), catDraw)
	);
}