public FilterPopUp(ListProperty<T> allCellValues, ListProperty<T> blacklistedCellValues) { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FilterPopUp.fxml")); fxmlLoader.setController(this); fxmlLoader.setRoot(rootContent); try { fxmlLoader.load(); } catch (IOException e) { throw new RuntimeException("Could not load fxml", e); } this.blacklistedCellValues = blacklistedCellValues; listView.itemsProperty().bind(allCellValues); addSelectionProperties(allCellValues); allCellValues.addListener((ListChangeListener<T>) c -> { mapCellValueToSelectedProperty.clear(); addSelectionProperties(c.getList()); chkBox_selectAll.selectedProperty().set(true); }); initSelectAllCheckbox(); }
@Test public void testGeneratedOutputTypes() throws Exception { ObjectFactory of = new ObjectFactory(); TestType cut = of.createTestType(); assertTrue("StringProperty expected!", cut.aStringProperty() instanceof StringProperty); assertTrue("ObjectProperty expected!", cut.aBooleanProperty() instanceof ObjectProperty); assertTrue("ObjectProperty expected!", cut.aDoubleProperty() instanceof ObjectProperty); assertTrue("ObjectProperty expected!", cut.aFloatProperty() instanceof ObjectProperty); assertTrue("ObjectProperty expected!", cut.aLongProperty() instanceof ObjectProperty); cut.getAList(); assertTrue("ListProperty expected!", cut.aListProperty() instanceof ListProperty); assertTrue("ObjectProperty expected!", cut.anIntegerProperty() instanceof ObjectProperty); assertTrue("BooleanProperty expected!", cut.aPrimitiveBooleanProperty() instanceof BooleanProperty); assertTrue("DoubleProperty expected!", cut.aPrimitiveDoubleProperty() instanceof DoubleProperty); assertTrue("FloatProperty expected!", cut.aPrimitiveFloatProperty() instanceof FloatProperty); assertTrue("LongProperty expected!", cut.aPrimitiveLongProperty() instanceof LongProperty); assertTrue("IntegerProperty expected!", cut.aPrimitiveIntegerProperty() instanceof IntegerProperty); }
private String getJSONEpisodeList(ListProperty<List<Episode>> list) { ObservableList<List<Map<String, String>>> seasonList = FXCollections.observableArrayList(); for (List<Episode> episodes : list) { List<Map<String, String>> episodeList = new ArrayList<>(); for (Episode episode : episodes) { HashMap<String, String> map = new HashMap<>(); map.put("seasonNum", episode.getSeasonNum()); map.put("episodeName", episode.getEpisodeName()); map.put("watched", Boolean.toString(episode.getWatched())); episodeList.add(map); } seasonList.add(episodeList); } Type observableListType = new TypeToken<ObservableList<String>>(){}.getType(); return gson.toJson(seasonList, observableListType); }
/** * * @param object * The object which fields should be visited. * @return {@code true} when the object was a observable object, {@code false} when it was a simple object. * @throws SecurityException * If a {@link SecurityManager} is active and denies access to fields via reflection. * @throws IllegalAccessException * If access modifiers like {@code private} are enforced even when the model is accessed via reflection. */ private boolean visitFields(final Object object) throws IllegalAccessException { boolean isObservableObject = false; for (final Field field : getInheritedFields(object.getClass())) { field.setAccessible(true); currentField = field; final Class<?> fieldClass = field.getType(); if (!isObservableObject && classImplementsOrExtends(fieldClass, Property.class)) { startVisiting(object); isObservableObject = true; } if (classImplementsOrExtends(fieldClass, ListProperty.class)) { handle((ListProperty<?>) field.get(object)); } else if (classImplementsOrExtends(fieldClass, SetProperty.class)) { handle((SetProperty<?>) field.get(object)); } else if (classImplementsOrExtends(fieldClass, MapProperty.class)) { handle((MapProperty<?, ?>) field.get(object)); } else if (classImplementsOrExtends(fieldClass, Property.class)) { handle((Property<?>) field.get(object)); } } return isObservableObject; }
/** * Display the window with the automatically generated form that allows the user to set a method's parameters. * * @param callerClass Class to get class loader from, to use for loading the window's FXML file * @param injector Injector to use when loading FXML, so that the model etc. are injected automatically. * @param method Method that the window should display configuration options for. */ public static void displayModal(Class callerClass, Injector injector, IDocumentation method, ListProperty<JPair<String, Object>> paramsProperty) { Parent root; FXMLLoader loader = new FXMLLoader( callerClass.getClassLoader().getResource("wizard-fxml/DynamicConfiguration.fxml"), null, new JavaFXBuilderFactory(), injector::getInstance ); try { root = loader.load(); } catch (IOException e) { e.printStackTrace(); return; } root.getProperties().put("controller", loader.getController()); Object controller = loader.getController(); if (controller instanceof DynamicConfigurationController) { // Cast the controller instance since we know it's safe here DynamicConfigurationController popupController = (DynamicConfigurationController) controller; // Give the configuration options to the controller JsonArray params = method.getParameterConfiguration(); popupController.setParameters(params, paramsProperty); // Create the popup Stage dialog = new Stage(); dialog.setScene(new Scene(root)); dialog.setTitle("JedAI - Parameter Configuration"); dialog.initModality(Modality.APPLICATION_MODAL); dialog.show(); } else { // This shouldn't ever happen. System.err.println("Error when showing the parameter customization popup (Wrong controller instance?)"); } }
/** * Show the advanced configuration window for the pressed button * * @param actionEvent Button action event */ public void configBtnHandler(ActionEvent actionEvent) { if (actionEvent.getSource() instanceof Button) { // Get button ID String id = ((Button) actionEvent.getSource()).getId(); // Get the required parameters to give to configuration modal ListProperty<JPair<String, Object>> modelProperty = null; String readerType = null; boolean groundTruth = false; IDocumentation reader; switch (id) { case "entitiesD1ConfigBtn": readerType = model.getEntityProfilesD1Type(); modelProperty = model.entityProfilesD1ParametersProperty(); break; case "entitiesD2ConfigBtn": readerType = model.getEntityProfilesD2Type(); modelProperty = model.entityProfilesD2ParametersProperty(); break; case "gTruthConfigBtn": readerType = model.getGroundTruthType(); modelProperty = model.groundTruthParametersProperty(); groundTruth = true; break; } reader = MethodConfiguration.getDataReader(groundTruth, readerType); // Now that we have all required parameters, show the configuration window MethodConfiguration.displayModal(getClass(), injector, reader, modelProperty); } }
/** * Create a node for displaying the advanced configuration parameters of a method. * * @param parametersProperty List property, that contains the values of the method's parameters * @return Node that displays the given parameters and values */ private Node parametersNode(ListProperty<JPair<String, Object>> parametersProperty) { // Create the node to show the parameters ListView<JPair<String, Object>> paramsList = new ListView<>(); paramsList.setMaxHeight(60); //todo: add vgap to the list // Bind the ListView's items to the given parameters property paramsList.itemsProperty().bind(parametersProperty); return paramsList; }
public static <F, T> ListProperty<T> nestListProp(ObservableValue<F> pf, Function<F, ListProperty<T>> func) { ListProperty<T> current = func.apply(pf.getValue()); ListProperty<T> nestProp = new SimpleListProperty<>(); CacheUtil.set(BeanUtil.class, nestProp, current); nestProp.bindBidirectional(current); pf.addListener((ob, o, n) -> { CacheUtil.<ListProperty<T>> remove(BeanUtil.class, nestProp).ifPresent(p -> nestProp.unbindContentBidirectional(p)); ListProperty<T> pt = func.apply(n); CacheUtil.set(BeanUtil.class, nestProp, pt); nestProp.bindContentBidirectional(pt); }); return nestProp; }
public static <F, T> ObservableList<T> nestListValue(ObservableValue<F> pf, Function<F, ObservableList<T>> func) { ObservableList<T> current = func.apply(pf.getValue()); ListProperty<T> nestProp = new SimpleListProperty<>(); CacheUtil.set(BeanUtil.class, nestProp, current); nestProp.bindContent(current); pf.addListener((ob, o, n) -> { CacheUtil.<ListProperty<T>> remove(BeanUtil.class, nestProp).ifPresent(p -> nestProp.unbindContent(p)); ObservableList<T> pt = func.apply(n); CacheUtil.set(BeanUtil.class, nestProp, pt); nestProp.bindContent(pt); }); return nestProp; }
/** * Provides the underlying value class for a given {@link Property} * * @param property * the {@link Property} to check * @return the value class of the {@link Property} */ @SuppressWarnings("unchecked") protected static <T> Class<T> propertyValueClass(final Property<T> property) { Class<T> clazz = null; if (property != null) { if (StringProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) String.class; } else if (IntegerProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Integer.class; } else if (BooleanProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Boolean.class; } else if (DoubleProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Double.class; } else if (FloatProperty.class .isAssignableFrom(property.getClass())) { clazz = (Class<T>) Float.class; } else if (LongProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) Long.class; } else if (ListProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) List.class; } else if (MapProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) Map.class; } else { clazz = (Class<T>) Object.class; } } return clazz; }
@Override public void updateData(String text, ListProperty<BODTO<T>> list, BooleanProperty busy) { if (!Strings.isEmpty(text)) { final BusinessObjectQueryRemote<T> query = getContext().getBean(queryClass); busy.set(true); getContext().getBean(MExecutor.class) .call(() -> query.autoCompletion(text)) .whenCompleteUI((l,e) -> { busy.set(false); list.addAll(l); }); } }
/** * Bind a pair of type-differing JavaFX properties bidirectionally. Keeps the two properties internally * and synchronizes them via {@link javafx.beans.value.ChangeListener}s. * The String property is a comma-separated list of {@link Course#getName()}s from the list. * * @param registry the course registry from which to recognize inputted courses * @param listProperty the list property to bind * @param stringProperty the string property to bind */ public void bindBidirectional(CourseRegistry registry, ListProperty<Course> listProperty, StringProperty stringProperty) { this.courseRegistry = registry; this.listProperty = listProperty; this.stringProperty = stringProperty; this.listProperty.addListener(listListener); this.stringProperty.addListener(stringListener); listListener.changed(listProperty, null, listProperty.get()); }
public static void addChannelToList(final ListProperty<TwitchChannel> activeList, final TwitchChannel channel) { synchronized (activeList) { final ObservableList<TwitchChannel> activeChannelServices = FXCollections .observableArrayList(activeList.get()); activeChannelServices.add(channel); activeList.set(activeChannelServices); } }
private void setupToolBar() { final Button homeButton = GlyphsDude.createIconButton(FontAwesomeIcon.HOME); homeButton.setOnAction(event -> this.browserCore.goToHome()); final Button refreshButton = GlyphsDude.createIconButton(FontAwesomeIcon.REFRESH); refreshButton.setOnAction(event -> this.browserCore.refresh()); this.searchTextField.textProperty().addListener((obs, oldValue, newValue) -> { if (!"".equals(newValue)) { this.browserCore.filter(newValue); } }); final Label searchLabel = new Label("Filter"); final ComboBox<String> favouriteGameComboBox = new ComboBox<>(); final ListProperty<String> favouriteGames = Settings.getInstance().favouriteGamesProperty(); favouriteGameComboBox.itemsProperty().bind(favouriteGames); favouriteGameComboBox.getSelectionModel().selectedItemProperty().addListener((obs, oldValue, newValue) -> { if (newValue != null) { this.browserCore.openGame(newValue); Platform.runLater(() -> favouriteGameComboBox.setValue(null)); } }); this.qualityComboBox.getItems().add("Worst"); this.qualityComboBox.getItems().add("Best"); this.qualityComboBox.getSelectionModel().select(1); this.browserToolBar.getItems().add(homeButton); this.browserToolBar.getItems().add(new Separator(Orientation.VERTICAL)); this.browserToolBar.getItems().add(refreshButton); this.browserToolBar.getItems().add(new Separator(Orientation.VERTICAL)); this.browserToolBar.getItems().add(searchLabel); this.browserToolBar.getItems().add(this.searchTextField); this.browserToolBar.getItems().add(new Separator(Orientation.VERTICAL)); this.browserToolBar.getItems().add(favouriteGameComboBox); this.browserToolBar.getItems().add(new Separator(Orientation.VERTICAL)); this.browserToolBar.getItems().add(this.qualityComboBox); }
/** * Provides the underlying value class for a given {@linkplain Property} * * @param property * the {@linkplain Property} to check * @return the value class of the {@linkplain Property} */ @SuppressWarnings("unchecked") protected static <T> Class<T> propertyValueClass(final Property<T> property) { Class<T> clazz = null; if (property != null) { if (StringProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) String.class; } else if (IntegerProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Integer.class; } else if (BooleanProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Boolean.class; } else if (DoubleProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Double.class; } else if (FloatProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Float.class; } else if (LongProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Long.class; } else if (ListProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) List.class; } else if (MapProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Map.class; } else { clazz = (Class<T>) Object.class; } } return clazz; }
public static <A, B> void bindContentBidirectional(ObservableList<A> propertyA, ListProperty<B> propertyB, Consumer<ObservableList<B>> updateA, Consumer<List<A>> updateB) { bindContentBidirectional( propertyA, (ObservableValue<ObservableList<B>>) propertyB, updateA, updateB); }
public static <A, B> void bindContentBidirectional(ListProperty<A> listProperty, Property<B> property, Function<List<A>, B> mapToB, Function<B, List<A>> mapToList) { Consumer<B> updateList = newValueB -> listProperty.setAll(mapToList.apply(newValueB)); Consumer<List<A>> updateB = newValueList -> property.setValue(mapToB.apply(newValueList)); bindContentBidirectional( listProperty, property, updateList, updateB); }
/** * Creates a new TvShow object. * @param titleString is the title of the TvShow object. * @return a new TvShow object. */ public TvShow createTvShow(String titleString) { StringProperty title = new SimpleStringProperty(); title.set(titleString); StringProperty watched = new SimpleStringProperty(); watched.set("false"); StringProperty genre = new SimpleStringProperty(); genre.set(""); StringProperty runtime = new SimpleStringProperty(); runtime.set(""); StringProperty creator = new SimpleStringProperty(); creator.set(""); StringProperty network = new SimpleStringProperty(); network.set(""); StringProperty numSeasons = new SimpleStringProperty(); numSeasons.set("0"); StringProperty numEpisodes = new SimpleStringProperty(); numEpisodes.set("0"); StringProperty description = new SimpleStringProperty(); description.set(""); ListProperty<List<Episode>> episodeList = new SimpleListProperty<>(); episodeList.set(new ObservableListWrapper<>(new ArrayList<>())); ListProperty<Boolean> seasonWatchedList = new SimpleListProperty<>(); seasonWatchedList.set(new ObservableListWrapper<>(new ArrayList<>())); return new TvShow(title, watched, genre, runtime, description, creator, network, numSeasons, numEpisodes, episodeList, seasonWatchedList); }
/** * Constructor. */ public TvShow(StringProperty title, StringProperty watched, StringProperty genre, StringProperty runtime, StringProperty description, StringProperty creator, StringProperty network, StringProperty numSeasons, StringProperty numEpisodes, ListProperty<List<Episode>> episodeList, ListProperty<Boolean> seasonWatchedList) { super(title, watched, genre, runtime, description); this.creator = creator; this.network = network; this.numSeasons = numSeasons; this.numEpisodes = numEpisodes; this.episodeList = episodeList; this.seasonWatchedList = seasonWatchedList; gson = new Gson(); getMap().put("type", "tv"); getMap().put("title", title.get()); getMap().put("watched", watched.get()); getMap().put("genre", genre.get()); getMap().put("runtime", runtime.get()); getMap().put("creator", creator.get()); getMap().put("network", network.get()); getMap().put("numSeasons", numSeasons.get()); getMap().put("numEpisodes", numEpisodes.get()); getMap().put("description", description.get()); getMap().put("episodeList", getJSONEpisodeList(episodeList)); getMap().put("seasonWatchedList", gson.toJson(seasonWatchedList)); }
/** Replies the property that contains all the shapes in this multishape. * * @return the elements property. */ public ListProperty<T> elementsProperty() { if (this.elements == null) { this.elements = new SimpleListProperty<>(this, MathFXAttributeNames.ELEMENTS, new InternalObservableList<>()); } return this.elements; }
@Test public void elementsProperty() { ListProperty<Shape2dfx<?>> property = this.shape.elementsProperty(); assertNotNull(property); assertEquals(2, property.size()); assertSame(this.firstObject, property.get(0)); assertSame(this.secondObject, property.get(1)); }
@Test public void elementsProperty() { ListProperty<Shape3dfx<?>> property = this.shape.elementsProperty(); assertNotNull(property); assertEquals(2, property.size()); assertSame(this.firstObject, property.get(0)); assertSame(this.secondObject, property.get(1)); }
private void handle(final ListProperty<?> property) throws IllegalAccessException { if (visitCollectionProperty(property)) { Iterator<?> it = property.listIterator(); while (it.hasNext()) { visit(it.next()); } } }
Parent(final Property<?> parentProperty, final ListProperty<?> parentList, final SetProperty<?> parentSet, final MapProperty<?, ?> parentMap) { this.parentList = parentList; this.parentSet = parentSet; this.parentMap = parentMap; this.parentProperty = parentProperty; }
private void registerInMetaModel(final Object object, final UUID id) { objectRegistry.registerObject(object, id); if (object instanceof ListProperty) { final List<?> list = (List<?>) object; if (!listPropertyMetaDataStore.hasMetaDataFor(list)) { listPropertyMetaDataStore.storeMetaDataOrFail(list, new ListPropertyMetaData( CommandListCreator.INITIAL_LIST_VERSION, CommandListCreator.INITIAL_LIST_VERSION)); } } }
public ListProperty idsProperty() { return ids; }
/** * @return List of elements which should be transformed. */ public ListProperty<SourceType> modelListProperty() { return modelList; }
public ListProperty<JPair<String, Object>> entityProfilesD1ParametersProperty() { return entityProfilesD1Parameters; }
public ListProperty<JPair<String, Object>> entityProfilesD2ParametersProperty() { return entityProfilesD2Parameters; }
public ListProperty<JPair<String, Object>> groundTruthParametersProperty() { return groundTruthParameters; }
public ListProperty<JPair<String, Object>> blockBuildingParametersProperty() { return blockBuildingParameters; }
public ListProperty<String> blockCleaningMethodsProperty() { return blockCleaningMethods; }
public ListProperty<JPair<String, Object>> comparisonCleaningParametersProperty() { return comparisonCleaningParameters; }
public ListProperty<JPair<String, Object>> entityMatchingParametersProperty() { return entityMatchingParameters; }
public ListProperty<JPair<String, Object>> entityClusteringParametersProperty() { return entityClusteringParameters; }