Java Code Examples for javafx.collections.ObservableList

The following are top voted examples for showing how to use javafx.collections.ObservableList. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: dialog-tool   File: MainWindowController.java   Source Code and License 9 votes vote down vote up
protected void refreshListView () {

        this.questionList.getItems().clear();

        //create list with all questions
        ObservableList<String> questions = FXCollections.observableArrayList();

        //iterate through all questions
        for (Map.Entry<String,QuestionEntry> entry : this.questionMap.entrySet()) {
            //add question name to list
            questions.add(entry.getKey());
        }

        Collections.sort(questions);

        if (questions.size() <= 0) {
            //hide delete button
            this.deleteButton.setVisible(false);
        } else {
            //show delete button
            this.deleteButton.setVisible(true);
        }

        this.questionList.setItems(questions);
    }
 
Example 2
Project: MythRedisClient   File: SetAction.java   Source Code and License 7 votes vote down vote up
/**
 * 装载面板数据.
 *
 * @param key 数据库中的键
 */
@Override
public void setValue(String key) {
    ObservableList<TableEntity> values = FXCollections.observableArrayList();
    Set<String> sets = redisSet.getMembersSet(key);
    int i = 0;
    for (String set : sets) {
        TableEntity value = new TableEntity("" + i, key, set);
        values.add(value);
        i++;
    }
    this.dataTable.setItems(values);
    this.rowColumn.setCellValueFactory(cellData -> cellData.getValue().rowProperty());
    this.keyColumn.setCellValueFactory(cellData -> cellData.getValue().keyProperty());
    this.valueColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
}
 
Example 3
Project: marathonv5   File: CollatedTreeItem.java   Source Code and License 6 votes vote down vote up
public CollatedTreeItem() {
    children = FXCollections.observableArrayList();
    filteredChildren = new FilteredList<>(children, new Predicate<TreeItem<T>>() {
        @Override public boolean test(TreeItem<T> t) {
            return filter.test(t.getValue());
        }
    });
    sortedChildren = new SortedList<>(filteredChildren);
    ObservableList<TreeItem<T>> original = super.getChildren();
    sortedChildren.addListener(new ListChangeListener<TreeItem<T>>() {
        @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<T>> c) {
            while (c.next()) {
                original.removeAll(c.getRemoved());
                original.addAll(c.getFrom(), c.getAddedSubList());
            }
        }
    });
}
 
Example 4
Project: voogasalad-ltub   File: SpriteCreationScreen.java   Source Code and License 6 votes vote down vote up
private ComponentSelectorPane instantiateSelector() {
	List<Class<? extends Component>> basicComponents = new ArrayList<>();
	ObservableList<Class<? extends Component>> observableComponents = FXCollections.observableList(basicComponents);
	observableComponents.add(Cost.class);
	observableComponents.add(Attacker.class);
	observableComponents.add(Collidable.class);
	observableComponents.add(Health.class);
	observableComponents.add(Images.class);
	observableComponents.add(Owner.class);
	observableComponents.add(PathFollower.class);
	observableComponents.add(Range.class);
	observableComponents.add(RangeShootingAI.class);
	observableComponents.add(Selectable.class);
	observableComponents.add(SoundEffect.class);
	observableComponents.add(Speed.class);
	observableComponents.add(SkillSet.class);
	observableComponents.add(TowerDefenceTypeInformation.class);
	observableComponents.add(Upgrade.class);

	return new ComponentSelectorPane(myResources.getString("addComponents"), observableComponents, infoPane);
}
 
Example 5
Project: CNU_TermProject_SoftwareEngineering   File: SalesStatusController.java   Source Code and License 6 votes vote down vote up
public ObservableList<TableRowDataModel> convertPaymentArrayListToObservableList(ArrayList Payments) {
    ObservableList<TableRowDataModel> tempList = FXCollections.observableArrayList();
    for (Object dateAndPrice : Payments) {
        String oldstring = (String) ((Pair) dateAndPrice).getKey();
        try {
            Date old = new SimpleDateFormat("yyyy-MM-dd").parse(oldstring);
            String newstring = new SimpleDateFormat("yyyy년MM월dd일").format(old);

        SimpleStringProperty date = new SimpleStringProperty(newstring);
        int price = (int) ((Pair) dateAndPrice).getValue();
        tempList.add(new TableRowDataModel(date, new SimpleStringProperty(price + "원")));
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    return tempList;
}
 
Example 6
Project: keyboard-light-composer   File: LayerBaseTreeCell.java   Source Code and License 6 votes vote down vote up
private void droppedOnTreeItem(DragEvent event,
		TreeItem<LayerBaseContainer<? extends LayerBase>> currentlyDraggedLayerTreeItem,
		LayerBaseContainer<? extends LayerBase> targetItem) {
	LayerBase targetLayer = targetItem.getLayerBase();

	double y = event.getY();
	double height = getHeight();
	boolean above = y < height / 2;

	TreeItem<LayerBaseContainer<? extends LayerBase>> targetParent = this.getTreeItem().getParent();
	ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> targetParentChildren = targetParent
			.getChildren();

	TreeItem<LayerBaseContainer<? extends LayerBase>> draggedItem = currentlyDraggedLayerTreeItem;
	TreeItem<LayerBaseContainer<? extends LayerBase>> draggedParent = draggedItem.getParent();
	ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> draggedParentChildren = draggedParent != null
			? draggedParent.getChildren() : null;

	if (targetLayer instanceof EffectGroupLayer && (y >= height / 4 && y < height * 3 / 4)) {
		// inside group
		ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> groupChildren = getTreeItem()
				.getChildren();
		if (!groupChildren.equals(draggedParentChildren)) {
			if (draggedParentChildren != null) {
				draggedParentChildren.remove(draggedItem);
			}
			DelayedExecuter.execute(100, () -> groupChildren.add(0, draggedItem));
		}
	} else {
		if (draggedParentChildren != null) {
			ListItemUtil.swapItemsJavaFxThread(draggedParentChildren, targetParentChildren, draggedItem, this.getTreeItem(),
					above);
		} else {
			ListItemUtil.insertItem(targetParentChildren, draggedItem, this.getTreeItem(), above);
		}
	}
}
 
Example 7
Project: jmonkeybuilder   File: VirtualResourceTree.java   Source Code and License 6 votes vote down vote up
/**
 * Fill the tree item.
 *
 * @param item the tree item.
 */
@FXThread
private void fill(@NotNull final TreeItem<VirtualResourceElement<?>> item) {

    final VirtualResourceElement<?> element = item.getValue();
    if(!element.hasChildren()) {
        return;
    }

    final ObservableList<TreeItem<VirtualResourceElement<?>>> items = item.getChildren();

    final Array<VirtualResourceElement<?>> children = element.getChildren();
    children.sort(NAME_COMPARATOR);
    children.forEach(child -> items.add(new TreeItem<>(child)));

    items.forEach(this::fill);
}
 
Example 8
Project: Coconut-IDE   File: CustomTreeItem.java   Source Code and License 6 votes vote down vote up
@SneakyThrows(IOException.class)
private ObservableList<TreeItem<Path>> buildChildren() {
    if (Files.isDirectory(getValue())) {
        return Files.list(getValue())
                .map(e -> {
                    WatcherStructure watcherStructure = null;
                    if (Files.isDirectory(e)) {
                        watcherStructure = new WatcherStructure(e, project, tabUpdater, treeUpdater);
                    }

                    CustomTreeItem item = new CustomTreeItem(e, watcherStructure, project, tabUpdater, treeUpdater);

                    CustomIcons customIcons = new CustomIcons();
                    item.setGraphic(new ImageView(item.isDirectory() ? customIcons.getFolderCollapseImage() : customIcons.getFileImage()));
                    if (isDirectory()) {
                        item.expandedProperty().addListener(treeUpdater.expanderListener());
                    }

                    return item;
                })
                .collect(Collectors.toCollection(FXCollections::observableArrayList));
    }

    return FXCollections.emptyObservableList();
}
 
Example 9
Project: jmonkeybuilder   File: SpatialTreeNode.java   Source Code and License 6 votes vote down vote up
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree,
                            @NotNull final ObservableList<MenuItem> items) {
    if (!(nodeTree instanceof ModelNodeTree)) return;

    final T element = getElement();
    final AssetLinkNode linkNode = findParent(element, AssetLinkNode.class::isInstance);

    if (linkNode == null) {
        final Menu createMenu = createCreationMenu(nodeTree);
        if (createMenu != null) items.add(createMenu);
        final Menu toolMenu = createToolMenu(nodeTree);
        if (toolMenu != null) items.add(toolMenu);
    }

    if (linkNode == null || element == linkNode) {
        items.add(new AddUserDataAction(nodeTree, this));
    }

    if (canRemove()) {
        items.add(new RemoveNodeAction(nodeTree, this));
    }

    super.fillContextMenu(nodeTree, items);
}
 
Example 10
Project: Java-oscilloscope-project   File: ZoomManager.java   Source Code and License 6 votes vote down vote up
static <X, Y> ObservableList<XYChart.Data<X, Y>> deepCopySeriesData(
        final Collection<? extends XYChart.Data<X, Y>> data) {
    final ObservableList<XYChart.Data<X, Y>> result = FXCollections.observableArrayList();
    for (final Data<X, Y> i : data) {
        result.add(new Data<>(i.getXValue(), i.getYValue()));
    }
    return result;
}
 
Example 11
Project: marathonv5   File: ModalDialog.java   Source Code and License 6 votes vote down vote up
private ObservableList<Node> getChildren(Node node) {
    if (node instanceof ButtonBar) {
        return ((ButtonBar) node).getButtons();
    }
    if (node instanceof ToolBar) {
        return ((ToolBar) node).getItems();
    }
    if (node instanceof Pane) {
        return ((Pane) node).getChildren();
    }
    if (node instanceof TabPane) {
        ObservableList<Node> contents = FXCollections.observableArrayList();
        ObservableList<Tab> tabs = ((TabPane) node).getTabs();
        for (Tab tab : tabs) {
            contents.add(tab.getContent());
        }
        return contents;
    }
    return FXCollections.observableArrayList();
}
 
Example 12
Project: voogasalad-ltub   File: PathSetter.java   Source Code and License 6 votes vote down vote up
public PathSetter(ObservableList<Path> paths, String variableName){
	super(Path.class,variableName);
	this.myPaths=paths;		
	
	pathChoices= new ComboBox<>(myPaths);
	
	pathChoices.setCellFactory(new Callback<ListView<Path>, ListCell<Path>>(){
		@Override
		public ListCell<Path> call(ListView<Path> list){
			return new PathCell();
		}
	});
	pathChoices.setButtonCell(new PathButtonCell());
	
	this.getChildren().add(pathChoices);
	
}
 
Example 13
Project: ABC-List   File: SqlProviderTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testFindAllTermsWithTitle() {
    LoggerFacade.getDefault().own(SqlProviderTest.class, "testFindAllTermsWithTitle()"); // NOI18N
    
    // ---------------------------------------------------------------------
    try { Thread.sleep(15); } catch (InterruptedException e) { }
    
    Term term1 = ModelProvider.getDefault().getTerm("Term1");
    SqlProvider.getDefault().createTerm(term1);
    
    ObservableList<Term> terms = FXCollections.observableArrayList();
    terms.addAll(SqlProvider.getDefault().findAllTermsWithTitle("hello?"));
    assertTrue(terms.isEmpty());
    
    terms.clear();
    terms.addAll(SqlProvider.getDefault().findAllTermsWithTitle("Term1"));
    assertFalse(terms.isEmpty());
    assertTrue(terms.size() == 1);
    assertEquals("Term1", terms.get(0).getTitle());
    
    // ---------------------------------------------------------------------
    DatabaseFacade.getDefault()
            .getCrudService("testFindAllTerms()")
            .delete(Term.class, term1.getId());
}
 
Example 14
Project: marathonv5   File: JavaFXTargetLocator.java   Source Code and License 6 votes vote down vote up
private Stage[] getValidWindows() {
    ObservableList<Stage> stages = StageHelper.getStages();
    List<Stage> valid = new ArrayList<Stage>();
    for (Stage window : stages) {
        if (window.isShowing()) {
            valid.add(window);
        }
    }
    return valid.toArray(new Stage[valid.size()]);
}
 
Example 15
Project: marathonv5   File: ChildSelector.java   Source Code and License 6 votes vote down vote up
protected List<IJavaFXElement> found(List<IJavaFXElement> pElements, IJavaFXAgent driver) {
    List<IJavaFXElement> r = new ArrayList<IJavaFXElement>();
    for (IJavaFXElement je : pElements) {
        if (!(je.getComponent() instanceof Parent)) {
            continue;
        }
        JFXWindow topContainer = driver.switchTo().getTopContainer();
        ObservableList<Node> components = ((Parent) je.getComponent()).getChildrenUnmodifiable();
        for (Node c : components) {
            IJavaFXElement je2 = JavaFXElementFactory.createElement(c, driver, driver.switchTo().getTopContainer());
            List<IJavaFXElement> matched = child.matchesSelector(je2);
            for (IJavaFXElement javaElement : matched) {
                IJavaFXElement e = topContainer.addElement(javaElement);
                if (!r.contains(e)) {
                    r.add(e);
                }
            }
        }
    }
    return r;
}
 
Example 16
Project: marathonv5   File: AreaChartSample.java   Source Code and License 5 votes vote down vote up
public AreaChartSample() {
    NumberAxis xAxis = new NumberAxis("X Values", 1.0d, 9.0d, 2.0d);
    xAxis.setTickLength(12.0f);
    NumberAxis yAxis = new NumberAxis("Y Values", 0.0d, 10.0d, 2.0d);
    ObservableList<AreaChart.Series> areaChartData = FXCollections.observableArrayList(
            new AreaChart.Series("Series 1",FXCollections.observableArrayList(
                new AreaChart.Data(0,4),
                new AreaChart.Data(2,5),
                new AreaChart.Data(4,4),
                new AreaChart.Data(6,2),
                new AreaChart.Data(8,6),
                new AreaChart.Data(10,8)
            )),
            new AreaChart.Series("Series 2", FXCollections.observableArrayList(
                new AreaChart.Data(0,8),
                new AreaChart.Data(2,2),
                new AreaChart.Data(4,9),
                new AreaChart.Data(6,7),
                new AreaChart.Data(8,5),
                new AreaChart.Data(10,7)
            )),
            new AreaChart.Series("Series 3", FXCollections.observableArrayList(
                new AreaChart.Data(0,2),
                new AreaChart.Data(2,5),
                new AreaChart.Data(4,8),
                new AreaChart.Data(6,6),
                new AreaChart.Data(8,9),
                new AreaChart.Data(10,7)
            ))
    );
    AreaChart chart = new AreaChart(xAxis, yAxis, areaChartData);
    getChildren().add(chart);
}
 
Example 17
Project: stvs   File: TimingDiagramView.java   Source Code and License 5 votes vote down vote up
/**
 * Instantiates a new Timing diagram view.
 *
 * @param xaxis the x axis
 * @param yaxis the y axis
 */
public TimingDiagramView(NumberAxis xaxis, Axis<A> yaxis) {
  super(xaxis, yaxis);
  this.xaxis = xaxis;
  this.yaxis = yaxis;

  setPrefHeight(80);

  getPlotChildren().addAll(cycleSelectionPane, durationLinesPane, dataPane);
  ViewUtils.setupView(this);

  ObservableList<Series<Number, A>> seriesObservableList = FXCollections.observableArrayList();
  setData(seriesObservableList);
  seriesObservableList.addListener((InvalidationListener) change -> {
    Platform.runLater(TimingDiagramView.this::requestRelayout);
  });
}
 
Example 18
Project: attics   File: UIController.java   Source Code and License 5 votes vote down vote up
public void initialize() {
    // populate year list
    List<Year> years = Database.getInstance().getYearsWithCollection(collection);

    ObservableList<Year> yearList = FXCollections.observableArrayList();
    yearList.addAll(years);

    // add the set to the list view
    yearsListView.setItems(yearList);
    yearsListView.setCellFactory(param -> new YearListViewCell());

    initializeListeners();

}
 
Example 19
Project: Example.EMA.Java.SpeedGuide   File: SpeedGuideViewController.java   Source Code and License 5 votes vote down vote up
public void updateStatus(String status, StatusIndicator indicator, String item)
  {
// This will avoid a InvalidState Exception to ensure we are within the JavaFX thread
  	Platform.runLater(new Runnable()
{
	@Override
	public void run()
	{
		if ( !item.isEmpty() )
	    	ric.setText(item);

    	ObservableList<Node> nodes = statusText.getChildren();

		Text time = new Text();
   		time.setId("status-time");		// Defined in CSS
		time.setText(new SimpleDateFormat("HH.mm.ss: ").format(new java.util.Date()));

    	Text txt = new Text();
    	txt.setText(status + SpeedGuide.NEWLINE);

    	switch (indicator)
    	{
	    	case REQUEST:
	    		txt.setId("status-request");			// Defined in CSS
	    		break;
	    	case RESPONSE_SUCCESS:
	    		txt.setId("status-response-success");	// Defined in CSS
	    		break;
	    	case RESPONSE_ERROR:
	    		txt.setId("status-response-error");		// Defined in CSS
	    		break;
    	}

    	nodes.add(0, txt);
    	nodes.add(0, time);
	}
});
  }
 
Example 20
Project: GazePlay   File: Utils.java   Source Code and License 5 votes vote down vote up
/**
 * @return CSS files found in the styles folder
 */
public static void addStylesheets(ObservableList<String> styleSheets) {

    File F = new File(getStylesFolder());

    if (F.exists()) {

        File[] Tfiles = F.listFiles();
        for (int i = 0; i < Tfiles.length; i++) {

            if (Tfiles[i].toString().endsWith(".css"))
                styleSheets.add("file://" + Tfiles[i].toString());
        }
    }
}
 
Example 21
Project: desktop-gmail-client   File: ZoomInMailView.java   Source Code and License 5 votes vote down vote up
public void goBack(){
    final WebHistory history = webEngine.getHistory();
    ObservableList<WebHistory.Entry> entryList = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            try {
                history.go(-1);
            }catch(Exception e){
                webEngine.loadContent(body);
            }
        }
    });
}
 
Example 22
Project: OneClient   File: MiscUtil.java   Source Code and License 5 votes vote down vote up
public static <T> Collector<T, ?, ObservableList<T>> toObservableList() {
	return Collector.of(
		FXCollections::observableArrayList,
		ObservableList::add,
		(l1, l2) -> {
			l1.addAll(l2);
			return l1;
		});
}
 
Example 23
Project: vars-annotation   File: DeleteSelectedAnnotationsBC.java   Source Code and License 5 votes vote down vote up
private void apply() {
    ObservableList<Annotation> annotations = toolBox.getData().getSelectedAnnotations();
    final int count = annotations.size();
    ResourceBundle i18n = toolBox.getI18nBundle();
    String content = i18n.getString("buttons.delete.dialog.content1") + " " +
            count + " " + i18n.getString("buttons.delete.dialog.content2");
    alert.setContentText(content);
    Optional<ButtonType> buttonType = alert.showAndWait();
    if (buttonType.get() == ButtonType.OK) {
        toolBox.getEventBus()
                .send(new DeleteAnnotationsCmd(annotations));
    }
}
 
Example 24
Project: ShowMilhaoPOOJava   File: ControllerLayoutRanking.java   Source Code and License 5 votes vote down vote up
@FXML
private void limparRanking(ActionEvent e) {    	
	
	jogadorDao.limparRanking();
	
	tblClmPosicao.setCellValueFactory(new PropertyValueFactory<ModelJogadorTable, Integer>("linhaTable"));        
    tblClmNome.setCellValueFactory(new PropertyValueFactory<ModelJogadorTable, String>("nomeTable"));
    tblClmPontuacao.setCellValueFactory(new PropertyValueFactory<ModelJogadorTable, Integer>("pontuacaoTable"));       
    
    ObservableList<ModelJogadorTable> jogadorTable = FXCollections.observableArrayList(mostrarRankingView());
    tblRanking.setItems(jogadorTable);
}
 
Example 25
Project: can4eve   File: ClockControl.java   Source Code and License 5 votes vote down vote up
private static void calcNoOfNodes(Node node) {
    if (node instanceof Parent) {
        if (((Parent) node).getChildrenUnmodifiable().size() != 0) {
            ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable();
            noOfNodes += tempChildren.size();
            tempChildren.forEach(n -> calcNoOfNodes(n));
        }
    }
}
 
Example 26
Project: gatepass   File: StudentsReports.java   Source Code and License 5 votes vote down vote up
private void initFilter() {
	txtsearch = TextFields.createSearchField();
	txtsearch.setStyle("-fx-background-radius:10;");
	txtsearch.setPromptText("Search The Records");
	txtsearch.setMinWidth(200);
	txtsearch.textProperty().addListener(new InvalidationListener() {
           @Override
	public void invalidated(Observable o) {
           if(txtsearch.textProperty().get().isEmpty()) {
               tableView.setItems(att);
               return;
           }
           ObservableList<Reports> tableItems = FXCollections.observableArrayList();
           ObservableList<TableColumn<Reports, ?>> cols = tableView.getColumns();
           for(int i=0; i<att.size(); i++) {
               
               for(int j=0; j<cols.size(); j++) {
                   TableColumn<Reports, ?> col = cols.get(j);
                   String cellValue = col.getCellData(att.get(i)).toString();
                   cellValue = cellValue.toLowerCase();
                   if(cellValue.contains(txtsearch.textProperty().get().toLowerCase())) {
                       tableItems.add(att.get(i));
                       break;
                   }                        
               }
           }
           tableView.setItems(tableItems);
       }
});
}
 
Example 27
Project: sbc-qsystem   File: BrowserFX.java   Source Code and License 5 votes vote down vote up
public String goForward() {
    final WebHistory history = webEngine.getHistory();
    ObservableList<WebHistory.Entry> entryList = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    //    Out("currentIndex = "+currentIndex);
    //    Out(entryList.toString().replace("],","]\n"));
    Platform.runLater(() -> {
        history.go(1);
    });
    return entryList
        .get(currentIndex < entryList.size() - 1 ? currentIndex + 1 : currentIndex)
        .getUrl();
}
 
Example 28
Project: WebPLP   File: WatcherWindow.java   Source Code and License 5 votes vote down vote up
private ComboBox<String> createDisplayOptionsDropdown()
{
	ObservableList<String> options = FXCollections.observableArrayList();
	options.addAll(valueDisplayOptions.keySet());
	
	ComboBox<String> dropdown = new ComboBox<>(options);
	dropdown.getSelectionModel().select(0);
	return dropdown;
}
 
Example 29
Project: Dr-Assistant   File: PatientGetway.java   Source Code and License 5 votes vote down vote up
public ObservableList<Patient> patients(Paginate paginate) {
    DBConnection connection = new DBConnection();
    Connection con = null;
    PreparedStatement pst = null;
    ResultSet rs = null;
    ObservableList<Patient> listData = FXCollections.observableArrayList();
    con = connection.geConnection();
    try {
        pst = con.prepareStatement("select * from patient limit " + paginate.getStart() + "," + paginate.getEnd());
        rs = pst.executeQuery();
        while (rs.next()) {
            listData.add(new Patient(
                    rs.getInt(1),
                    rs.getString(2),
                    rs.getString(3),
                    LocalDate.parse(rs.getString(4)),
                    rs.getInt(5),
                    rs.getString(6),
                    rs.getString(7),
                    rs.getString(8),
                    rs.getString(9),
                    totalPrescriptionByPatient(rs.getInt(1))
            ));
        }
        rs.close();
        pst.close();
        con.close();
        connection.con.close();
    } catch (SQLException ex) {
        Logger.getLogger(PatientGetway.class.getName()).log(Level.SEVERE, null, ex);
    }
    return listData;
}
 
Example 30
Project: infxnity   File: IFXContentBindingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void addElementsTest()
{
    final ObservableList<Model> collection1 = FXCollections.observableArrayList(new Model("value1"),
                                                                                new Model("value2"),
                                                                                new Model("value3"),
                                                                                new Model("value4"));
    final ObservableList<String> collection2 = FXCollections.observableArrayList();

    IFXContentBinding.bind(collection2, collection1, Model::getText);

    final AtomicReference<ListChangeListener.Change<? extends String>> change = new AtomicReference<>(null);
    collection2.addListener((ListChangeListener<String>) c -> {
        change.set(c);
    });

    collection1.addAll(2, Arrays.asList(new Model("value2bis"), new Model("value2ter")));

    assertNotNull("Change event", change.get());
    assertTrue("Has change", change.get().next());
    assertTrue("Was added", change.get().wasAdded());
    assertFalse("Was removed", change.get().wasRemoved());
    assertFalse("Was update", change.get().wasUpdated());
    assertFalse("Was permuted", change.get().wasPermutated());
    assertEquals("from", 2, change.get().getFrom());
    assertEquals("to", 4, change.get().getTo());
    assertEquals("Added sub-list", Arrays.asList("value2bis", "value2ter"), change.get().getAddedSubList());
    assertFalse("Has more change", change.get().next());

    assertEquals(Arrays.asList("value1", "value2", "value2bis", "value2ter", "value3", "value4"), collection2);
}
 
Example 31
Project: marathonv5   File: TableSample1.java   Source Code and License 5 votes vote down vote up
public TableSample1() {
    final ObservableList<Person> data = FXCollections.observableArrayList(
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"));
    TableColumn firstNameCol = new TableColumn();
    firstNameCol.setText("First");
    firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
    TableColumn lastNameCol = new TableColumn();
    lastNameCol.setText("Last");
    lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
    TableColumn emailCol = new TableColumn();
    emailCol.setText("Email");
    emailCol.setMinWidth(200);
    emailCol.setCellValueFactory(new PropertyValueFactory("email"));
    TableView tableView = new TableView();
    tableView.setItems(data);
    tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
    getChildren().add(tableView);
}
 
Example 32
Project: TechnicalAnalysisTool   File: OnBalanceVolume.java   Source Code and License 5 votes vote down vote up
/**
 * Do OBV Calculation when input is a ObservableList
 * @param orgData 
 */
public void doCalculation(ObservableList<OHLC> orgData){
    //Convert list to array
    Object[] rawData;
    rawData = (Object[])orgData.toArray();
    calculateObv(rawData);
}
 
Example 33
Project: Squid   File: ExpressionBuilderController.java   Source Code and License 5 votes vote down vote up
private void populateNumberListViews() {
    // constants and numbers ===============================================
    List<String> constantStrings = new ArrayList<>();
    constantStrings.add(numberString + operationFlagDelimeter + "placeholder for custom number");
    for (Map.Entry<String, ExpressionTreeInterface> constant : squidProject.getTask().getNamedConstantsMap().entrySet()) {
        constantStrings.add(constant.getKey() + operationFlagDelimeter + ((ConstantNode) constant.getValue()).getValue());
    }

    ObservableList<String> items = FXCollections.observableArrayList(constantStrings);
    constantsListView.setItems(items);
}
 
Example 34
Project: Planchester   File: MusicianTableHelper.java   Source Code and License 5 votes vote down vote up
public static ObservableList<KeyValuePair> getSectionTypeList() {
    ObservableList<KeyValuePair> list = FXCollections.observableArrayList(
            new KeyValuePair("Brass", SectionType.BRASS),
            new KeyValuePair("Doublebass", SectionType.DOUBLEBASS),
            new KeyValuePair("Percussion", SectionType.PERCUSSION),
            new KeyValuePair("Viola", SectionType.VIOLA),
            new KeyValuePair("Violin 1", SectionType.VIOLIN1),
            new KeyValuePair("Violin 2", SectionType.VIOLIN2),
            new KeyValuePair("Violincello", SectionType.VIOLINCELLO),
            new KeyValuePair("Woodwind", SectionType.WOODWIND));

    return list;
}
 
Example 35
Project: Java-9-Programming-Blueprints   File: FXMLController.java   Source Code and License 5 votes vote down vote up
@FXML
public void deleteSelectedFiles(ActionEvent event) {
    final ObservableList<FileInfo> selectedFiles = matchingFilesListView.getSelectionModel().getSelectedItems();
    if (selectedFiles.size() > 0) {
        showConfirmationDialog("Are you sure you want to delete the selected files",
                () -> selectedFiles.forEach(f -> {
                    if (Desktop.getDesktop().moveToTrash(new File(f.getPath()))) {
                        matchingFilesListView.getItems().remove(f);
                        dupes.get(dupeFileGroupListView.getSelectionModel().getSelectedItem())
                                .remove(f);
                    }
                }));
    }
}
 
Example 36
Project: jmonkeybuilder   File: AnimationControlTreeNode.java   Source Code and License 5 votes vote down vote up
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree,
                            @NotNull final ObservableList<MenuItem> items) {
    items.add(new PlaySettingsAction(nodeTree, this));
    super.fillContextMenu(nodeTree, items);
}
 
Example 37
Project: marathonv5   File: TabDockingContainer.java   Source Code and License 5 votes vote down vote up
private void populateMenuItems(ContextMenu contextMenu, Tab tab) {
    int tabCount = getTabs().size();
    int tabIndex = getTabs().indexOf(tab);
    ObservableList<MenuItem> items = contextMenu.getItems();
    items.clear();
    MenuItem closeMenuItem = new MenuItem("Close");
    closeMenuItem.setOnAction((e) -> requestClose(tab));
    items.add(closeMenuItem);
    if (tabCount > 1) {
        MenuItem closeRestMenuItem = new MenuItem("Close Others");
        closeRestMenuItem.setOnAction((e) -> closeOtherTabs(tab));
        items.add(closeRestMenuItem);
    }
    if (tabCount > 1 && tabIndex != 0) {
        MenuItem closeLeftTabsMenuItem = new MenuItem("Close Tabs to the Left");
        closeLeftTabsMenuItem.setOnAction((e) -> closeTabsToLeft(tab));
        items.add(closeLeftTabsMenuItem);
    }
    if (tabCount > 1 && tabIndex != tabCount - 1) {
        MenuItem closeRigthTabsMenuItem = new MenuItem("Close Tabs to the Right");
        closeRigthTabsMenuItem.setOnAction((e) -> closeTabsToRight(tab));
        items.add(closeRigthTabsMenuItem);
    }
    if (tabCount > 1) {
        MenuItem closeAllMenuItem = new MenuItem("Close All");
        closeAllMenuItem.setOnAction((e) -> closeAllTabs());
        items.addAll(new SeparatorMenuItem(), closeAllMenuItem);
    }
}
 
Example 38
Project: GameAuthoringEnvironment   File: TypeFactory.java   Source Code and License 5 votes vote down vote up
public ObservableList<ProfileDisplay> getEffectTypes (ResourceBundle typeFile) {
    List<ProfileDisplay> list = Collections.list(typeFile.getKeys())
            .stream()
            .map(s -> new ProfileDisplay(s))
            .collect(Collectors.toList());
    return FXCollections.observableArrayList(list);
}
 
Example 39
Project: passepartout   File: ServiceControl.java   Source Code and License 5 votes vote down vote up
public ServiceControl(ServerControl serverControl, ServiceModel service) {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("fxml/service.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {
        fxmlLoader.load();
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }

    this.serverControl = serverControl;
    this.service = service;

    final ConfigurationModel configuration = App.getConfiguration();

    final String actionName = service.getActionName();
    action = configuration.getActionByName(actionName);

    this.setText(action.getDescription());

    final ObservableList<Node> formEntriesControls = formEntriesContainer.getChildren();

    formEntryControls = buildUserParamsControls();
    formEntriesControls.addAll(formEntryControls);

    if (formEntriesControls.isEmpty()) {
        formEntriesContainer.getChildren().add(0, new Label("Nothing to configure for this service."));
    }
}
 
Example 40
Project: ABC-List   File: TermSqlService.java   Source Code and License 5 votes vote down vote up
ObservableList<Term> findAllTerms() {
    final ObservableList<Term> allTerms = FXCollections.observableArrayList();
    final List<Term> terms = DatabaseFacade.getDefault().getCrudService()
            .findByNamedQuery(Term.class, NAMED_QUERY__NAME__FIND_ALL);
    
    allTerms.addAll(terms);
    Collections.sort(allTerms);

    return allTerms;
}