Skip to content

Commit

Permalink
Merged controlsfx/controlsfx into default
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxoudela committed Feb 6, 2018
2 parents 5dcf009 + a6177c4 commit bddc197
Show file tree
Hide file tree
Showing 24 changed files with 436 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class HelloNotifications extends ControlsFXSample {
private CheckBox showCloseButtonChkBox;
private CheckBox darkStyleChkBox;
private CheckBox ownerChkBox;
private Slider fadeDelaySlider;
private Slider fadeDelaySlider, thresholdSlider;
protected String graphicMode = "";

public static void main(String[] args) {
Expand Down Expand Up @@ -288,8 +288,21 @@ private void updatePane() {
fadeDelaySlider.setMaxWidth(Double.MAX_VALUE);
GridPane.setHgrow(fadeDelaySlider, Priority.ALWAYS);
grid.add(fadeDelaySlider, 1, row++);



// threshold slider
final Label thresholdLabel = new Label("Threshold: ");
thresholdLabel.getStyleClass().add("property");
grid.add(thresholdLabel, 0, row);
thresholdSlider = new Slider(0, 10, 0);
thresholdSlider.setMajorTickUnit(1);
thresholdSlider.setMinorTickCount(0);
thresholdSlider.setShowTickMarks(true);
thresholdSlider.setShowTickLabels(true);
thresholdSlider.setSnapToTicks(true);
thresholdSlider.setMaxWidth(Double.MAX_VALUE);
GridPane.setHgrow(thresholdSlider, Priority.ALWAYS);
grid.add(thresholdSlider, 1, row++);

return grid;
}

Expand Down Expand Up @@ -320,17 +333,15 @@ private void notification(Pos pos) {
.graphic(graphic)
.hideAfter(Duration.seconds(fadeDelaySlider.getValue()))
.position(pos)
.onAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent arg0) {
System.out.println("Notification clicked on!");
}
});

if(ownerChkBox.isSelected()){
.onAction(e -> System.out.println("Notification clicked on!"))
.threshold((int) thresholdSlider.getValue(),
Notifications.create().title("Threshold Notification"));

if (ownerChkBox.isSelected()) {
notificationBuilder.owner(stage);
}
if (! showCloseButtonChkBox.isSelected()) {

if (!showCloseButtonChkBox.isSelected()) {
notificationBuilder.hideCloseButton();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public void start(Stage primaryStage) throws Exception {
table.setItems(sortedList);
sortedList.comparatorProperty().bind(table.comparatorProperty());


TableFilter<Flight> tableFilter = TableFilter.forTableView(table).lazy(true).apply();

tableFilter.setSearchStrategy((input,target) -> {
try {
return target.matches(input);
} catch (Exception e) {
return false;
}
});

table.setEditable(true);
TableColumn<Flight, Integer> flightNumCol = new TableColumn<>("FLIGHT NUM");
flightNumCol.setCellValueFactory(cellData -> new ReadOnlyObjectWrapper<>(cellData.getValue().getFlightNumber()));
Expand Down Expand Up @@ -90,16 +101,6 @@ public void start(Stage primaryStage) throws Exception {
gateNumber.setEditable(true);
table.getColumns().add(gateNumber);

TableFilter<Flight> tableFilter = TableFilter.forTableView(table).lazy(true).apply();

table.setEditable(true);
tableFilter.setSearchStrategy((input,target) -> {
try {
return target.matches(input);
} catch (Exception e) {
return false;
}
});

tableFilter.unSelectAllValues(origCol);
tableFilter.selectValue(origCol,"ABQ");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014, 2015, ControlsFX
* Copyright (c) 2014, 2017, ControlsFX
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -28,6 +28,7 @@


import com.sun.javafx.event.EventHandlerManager;
import java.util.UUID;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ObjectPropertyBase;
Expand Down Expand Up @@ -56,7 +57,6 @@ public class AutoCompletePopup<T> extends PopupControl{
* *
**************************************************************************/

private final static int TITLE_HEIGHT = 28; // HACK: Hard-coded title-bar height
private final ObservableList<T> suggestions = FXCollections.observableArrayList();
private StringConverter<T> converter;
/**
Expand All @@ -80,8 +80,8 @@ public class AutoCompletePopup<T> extends PopupControl{
*/
@SuppressWarnings("serial")
public static class SuggestionEvent<TE> extends Event {
@SuppressWarnings("rawtypes")
public static final EventType<SuggestionEvent> SUGGESTION = new EventType<>("SUGGESTION"); //$NON-NLS-1$
public static final EventType<SuggestionEvent<?>> SUGGESTION
= new EventType<>("SUGGESTION" + UUID.randomUUID().toString()); //$NON-NLS-1$

private final TE suggestion;

Expand Down Expand Up @@ -152,7 +152,7 @@ public void show(Node node){
parent.getX() + node.localToScene(0, 0).getX() +
node.getScene().getX(),
parent.getY() + node.localToScene(0, 0).getY() +
node.getScene().getY() + TITLE_HEIGHT);
node.getScene().getY() + node.getBoundsInParent().getHeight());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ public CheckComboBoxSkin(final CheckComboBox<T> control) {
comboBox.setCellFactory(new Callback<ListView<T>, ListCell<T>>() {
@Override public ListCell<T> call(ListView<T> listView) {
CheckBoxListCell<T> result = new CheckBoxListCell<>(item -> control.getItemBooleanProperty(item));
//clicking on the label checks/unchecks the item
result.setOnMouseClicked(e -> {
T item = result.getItem();
if (control.getCheckModel().isChecked(item)) {
control.getCheckModel().clearCheck(item);
} else {
control.getCheckModel().check(item);
}
});
result.converterProperty().bind(control.converterProperty());
return result;
};
Expand All @@ -115,11 +124,11 @@ public CheckComboBoxSkin(final CheckComboBox<T> control) {
// we ignore whatever item is selected, instead choosing
// to display the selected item text using commas to separate
// each item
setText(buildString());
setText(getTextString());
}
};
comboBox.setButtonCell(buttonCell);
comboBox.setValue((T)buildString());
comboBox.setValue((T)getTextString());

// The zero is a dummy value - it just has to be legally within the bounds of the
// item count for the CheckComboBox items list.
Expand Down Expand Up @@ -167,7 +176,19 @@ public CheckComboBoxSkin(final CheckComboBox<T> control) {
*
**************************************************************************/

protected String buildString() {
protected String getTextString() {

if (control.getTitle() != null) {
//if a title has been set, we use it...
return control.getTitle();
} else {
//...otherwise we generate a string concatenating the items
return buildString();
}

}

private String buildString() {
final StringBuilder sb = new StringBuilder();
for (int i = 0, max = selectedItems.size(); i < max; i++) {
T item = selectedItems.get(i);
Expand All @@ -189,5 +210,7 @@ protected String buildString() {
* Support classes / enums
*
**************************************************************************/



}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package impl.org.controlsfx.spreadsheet;

import com.sun.javafx.scene.control.skin.TableCellSkin;
import java.util.UUID;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.beans.value.WeakChangeListener;
Expand Down Expand Up @@ -60,7 +61,8 @@ public class CellViewSkin extends TableCellSkin<ObservableList<SpreadsheetCell>,
* This EventType can be used with an {@link EventHandler} in order to catch
* when a SpreadsheetCell filter is activated/deactivated on this column.
*/
public static final EventType FILTER_EVENT_TYPE = new EventType("FilterEventType"); //$NON-NLS-1$
public static final EventType<Event> FILTER_EVENT_TYPE
= new EventType<>("FilterEventType" + UUID.randomUUID().toString()); //$NON-NLS-1$

private final static String TOP_LEFT_CLASS = "top-left"; //$NON-NLS-1$
private final static String TOP_RIGHT_CLASS = "top-right"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private <T> void keyPressed(KeyEvent event) {
return;
}
}
String letter = code.impl_getChar();
String letter = event.getText();
if (event.getSource() instanceof ComboBox) {
ComboBox<T> comboBox = (ComboBox<T>) event.getSource();
T item = getEntryWithKey(letter, comboBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import javafx.util.Callback;

import com.sun.javafx.event.EventHandlerManager;
import java.util.UUID;

/**
* Represents a bread crumb bar. This control is useful to visualize and navigate
Expand Down Expand Up @@ -71,8 +72,8 @@ public static class BreadCrumbActionEvent<TE> extends Event {
* knowing when the {@link BreadCrumbBar#selectedCrumbProperty() selected crumb}
* has changed.
*/
@SuppressWarnings("rawtypes")
public static final EventType<BreadCrumbActionEvent> CRUMB_ACTION = new EventType<>("CRUMB_ACTION"); //$NON-NLS-1$
public static final EventType<BreadCrumbActionEvent<?>> CRUMB_ACTION
= new EventType<>("CRUMB_ACTION" + UUID.randomUUID().toString()); //$NON-NLS-1$

private final TreeItem<TE> selectedCrumb;

Expand Down
37 changes: 28 additions & 9 deletions controlsfx/src/main/java/org/controlsfx/control/CheckComboBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
Expand Down Expand Up @@ -88,7 +90,6 @@ public class CheckComboBox<T> extends ControlsFXControl {

private final ObservableList<T> items;
private final Map<T, BooleanProperty> itemBooleanMap;



/**************************************************************************
Expand Down Expand Up @@ -117,8 +118,7 @@ public CheckComboBox(final ObservableList<T> items) {
this.items = items == null ? FXCollections.<T>observableArrayList() : items;
setCheckModel(new CheckComboBoxBitSetCheckModel<>(this.items, itemBooleanMap));
}




/**************************************************************************
*
Expand Down Expand Up @@ -226,15 +226,34 @@ public final StringConverter<T> getConverter() {
return converterProperty().get();
}

// --- title
private StringProperty title = new SimpleStringProperty(null);

/**
* The title to use for this control. If a non null value is explicitly
* set by the client, then that string will be used, otherwise a title
* will be constructed concatenating the selected items
*/
public final StringProperty titleProperty() {
return title;
}

/**************************************************************************
*
* Implementation
*
**************************************************************************/

/**
* Sets the title to use. If it is not null it will be used as title,
* otherwise title will be constructed by the skin
* @param value the string to use as title
*/
public final void setTitle(String value) {
title.setValue(value);
}

/**
* The title set for this control, if it has been set explicitly by the client.
* @return the title if it has been set, null otherwise
*/
public final String getTitle() {
return title.getValue();
}


/**************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package org.controlsfx.control;

import impl.org.controlsfx.skin.NotificationPaneSkin;
import java.util.UUID;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
Expand Down Expand Up @@ -155,28 +156,31 @@ public class NotificationPane extends ControlsFXControl {
/**
* Called when the NotificationPane <b>will</b> be shown.
*/
public static final EventType<Event> ON_SHOWING =
new EventType<>(Event.ANY, "NOTIFICATION_PANE_ON_SHOWING"); //$NON-NLS-1$
public static final EventType<Event> ON_SHOWING = newEventType("NOTIFICATION_PANE_ON_SHOWING"); //$NON-NLS-1$

/**
* Called when the NotificationPane shows.
*/
public static final EventType<Event> ON_SHOWN =
new EventType<>(Event.ANY, "NOTIFICATION_PANE_ON_SHOWN"); //$NON-NLS-1$
public static final EventType<Event> ON_SHOWN = newEventType("NOTIFICATION_PANE_ON_SHOWN"); //$NON-NLS-1$

/**
* Called when the NotificationPane <b>will</b> be hidden.
*/
public static final EventType<Event> ON_HIDING =
new EventType<>(Event.ANY, "NOTIFICATION_PANE_ON_HIDING"); //$NON-NLS-1$
public static final EventType<Event> ON_HIDING = newEventType("NOTIFICATION_PANE_ON_HIDING"); //$NON-NLS-1$

/**
* Called when the NotificationPane is hidden.
*/
public static final EventType<Event> ON_HIDDEN =
new EventType<>(Event.ANY, "NOTIFICATION_PANE_ON_HIDDEN"); //$NON-NLS-1$

public static final EventType<Event> ON_HIDDEN = newEventType("NOTIFICATION_PANE_ON_HIDDEN"); //$NON-NLS-1$

/**
* Static factory method for NotificationPane EventTypes.
* @param name the name of the new EventType to create
* @return the new EventType instance
*/
private static EventType<Event> newEventType(String name) {
return new EventType<>(Event.ANY, name + UUID.randomUUID().toString());
}

/***************************************************************************
*
Expand Down
Loading

0 comments on commit bddc197

Please sign in to comment.