Java Code Examples for javafx.collections.ObservableList#addAll()

The following examples show how to use javafx.collections.ObservableList#addAll() . 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 File: EditArrayRegistersController.java    From CPUSim with GNU General Public License v3.0 7 votes vote down vote up
/**
 * save the current changes and close the window when clicking on OK button.
 *
 * @param e a type of action when a button is clicked.
 */
@FXML
public void onOKButtonClick(ActionEvent e) {
    //get the current edited clones
    ObservableList objList = activeTable.getItems();
    try {
        ObservableList<Register> list = FXCollections.observableArrayList();
        list.addAll(registerController.getItems());
        for (RegisterArrayTableView r : tableMap.getMap().values()) {
            list.addAll(r.getItems());
        }
        Validate.allNamesAreUnique(list.toArray());
        getCurrentController().checkValidity(objList);
        //update the machine with the new values
        updateRegisters();
        //get a handle to the stage.
        Stage stage = (Stage) okButton.getScene().getWindow();
        //close window.
        stage.close();
    } catch (Exception ex) {
        Dialogs.createErrorDialog(tablePane.getScene().getWindow(),
                "Registers Error", ex.getMessage()).showAndWait();
    }
}
 
Example 2
Source File: FileBrowserController.java    From ariADDna with Apache License 2.0 6 votes vote down vote up
/**
 * Method for generate file items for fileBrowser and add it into container(temporary realization)
 */
private void showContent() {
    ObservableList<FileItem> list = FXCollections.observableArrayList();
    GridView<FileItem> myGrid = new GridView<>(list);
    myGrid.setCellFactory(gridView -> new GridCell<FileItem>() {
        @Override
        public void updateItem(FileItem item, boolean empty) {
            if (empty || item == null) {
                setText(null);
                setGraphic(null);
            } else {
                //setText(item.getName());
                setGraphic(item);
            }

        }
    });
    list.addAll(new FileItem("icon", "Folder1"),
            new FileItem("icon", "Documents"),
            new FileItem("icon", "WorkFiles"),
            new FileItem("icon", "Projects"));
    container.getChildren().add(myGrid);
}
 
Example 3
Source File: OfferBookChartViewModelTest.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testMaxCharactersForFiatBuyVolume() {
    OfferBook offerBook = mock(OfferBook.class);
    PriceFeedService service = mock(PriceFeedService.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcBuyItem));

    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);

    final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, service, null, null);
    model.activate();
    assertEquals(1, model.maxPlacesForBuyVolume.intValue()); //0
    offerBookListItems.addAll(make(btcBuyItem.but(with(OfferBookListItemMaker.amount, 100000000L))));
    assertEquals(2, model.maxPlacesForBuyVolume.intValue()); //10
    offerBookListItems.addAll(make(btcBuyItem.but(with(OfferBookListItemMaker.amount, 22128600000L))));
    assertEquals(4, model.maxPlacesForBuyVolume.intValue()); //2213
}
 
Example 4
Source File: OfferBookChartViewModelTest.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testMaxCharactersForFiatSellPrice() {
    OfferBook offerBook = mock(OfferBook.class);
    PriceFeedService service = mock(PriceFeedService.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcSellItem));

    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);

    final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, service, null, null);
    model.activate();
    assertEquals(7, model.maxPlacesForSellPrice.intValue()); // 10.0000 default price
    offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.price, 94016475L))));
    assertEquals(9, model.maxPlacesForSellPrice.intValue()); // 9401.6475
    offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.price, 101016475L))));
    assertEquals(10, model.maxPlacesForSellPrice.intValue()); // 10101.6475
}
 
Example 5
Source File: AlertHelper.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
public static Optional<String> showOldConfiguration(List<String> paths) {
    Alert alert = new WindowModalAlert(AlertType.INFORMATION);

    DialogPane dialogPane = alert.getDialogPane();

    ListView listView = new ListView();
    listView.getStyleClass().clear();
    ObservableList items = listView.getItems();
    items.addAll(paths);
    listView.setEditable(false);

    dialogPane.setContent(listView);

    alert.setTitle("Load previous configuration?");
    alert.setHeaderText(String.format("You have configuration files from previous AsciidocFX versions\n\n" +
            "Select the configuration which you want to load configuration \n" +
            "or continue with fresh configuration"));
    alert.getButtonTypes().clear();
    alert.getButtonTypes().addAll(ButtonType.APPLY);
    alert.getButtonTypes().addAll(ButtonType.CANCEL);
    ButtonType buttonType = alert.showAndWait().orElse(ButtonType.CANCEL);

    Object selectedItem = listView.getSelectionModel().getSelectedItem();
    return (buttonType == ButtonType.APPLY) ?
            Optional.ofNullable((String) selectedItem) :
            Optional.empty();
}
 
Example 6
Source File: UnSavedHistoryStage.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private void onManageFavourites() {
    FavouriteHistoryStage favouriteHistoryStage = new FavouriteHistoryStage(new RunHistoryInfo("favourites"));
    favouriteHistoryStage.getStage().showAndWait();
    ObservableList<JSONObject> items = historyView.getItems();
    items.clear();
    items.addAll(runHistoryInfo.getTests());
}
 
Example 7
Source File: ScenarioEditorController.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private ObservableList<Scenario> getChapterRecipes(String chapter) {
    ObservableList<Scenario> chap = FXCollections.observableArrayList();
    Collections.sort(map.get(chapter), new Comparator<Scenario>(){
        public int compare(Scenario r1, Scenario r2) {
            return (r1.getSortOrderProperty()<r2.getSortOrderProperty() ? -1 : (r1==r2 ? 0 : 1));
        }
    });
    
    chap.addAll(map.get(chapter));
    return chap;
}
 
Example 8
Source File: MainController.java    From ApkCustomizationTool with Apache License 2.0 5 votes vote down vote up
@Override
public void initialized(URL location, ResourceBundle resources) {
    image.setImage(new Image("/android_heander.png"));

    Data data = new Data();
    buildInfo.appName = data.getAppName();
    buildInfo.channelName = data.getChannelName();
    buildInfo.personName = data.getPersonName();

    List<Product> products = data.getProduct();
    ObservableList list = product.getItems();
    list.addAll(products);
    product.getSelectionModel().select(0);
    buildInfo.product = product.getSelectionModel().getSelectedItem();

    List<Channel> channels = data.getChannel();
    addDefChannel(channels);
    list = channel.getItems();
    list.addAll(channels);
    channel.getSelectionModel().select(0);
    buildInfo.channel.addAll(channels);

    List<Person> persons = data.getPerson();
    list = person.getItems();
    list.addAll(persons);
    person.getSelectionModel().select(0);
    buildInfo.person = person.getSelectionModel().getSelectedItem();

    buildInfo.manifest = data.getManifest();
    buildInfo.resource = data.getResource();
    version.setText("1.0.0");
    buildInfo.version = version.getText();

}
 
Example 9
Source File: PrintStudents2Controller.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@FXML
void loadGrades() {
    ArrayList arrayList = null;
    try {
        arrayList = GradeController.getGrades();
    } catch (ClassNotFoundException | SQLException e) {
        e.printStackTrace();
    }
    ObservableList observableArray = FXCollections.observableArrayList();
    observableArray.addAll(arrayList);

    if (observableArray != null) {
        loadGrades.setItems(observableArray);
    }
}
 
Example 10
Source File: BetonQuestEditor.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return all conversations from loaded packages, the ones from current package first
 */
public ObservableList<Conversation> getAllConversations() {
	ObservableList<Conversation> list = FXCollections.observableArrayList();
	list.addAll(currentPackage.getConversations());
	currentPackage.getSet().getPackages().forEach(pack -> {
		if (!pack.equals(currentPackage)) {
			list.addAll(pack.getConversations());
		}
	});
	return list;
}
 
Example 11
Source File: TransferStudentsController.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@FXML
void loadComboBox() {
    ArrayList arrayList = null;
    try {
        arrayList = GradeController.getGrades();
    } catch (ClassNotFoundException | SQLException e) {
        e.printStackTrace();
    }
    ObservableList observableArray = FXCollections.observableArrayList();
    observableArray.addAll(arrayList);

    if (observableArray != null) {
        loadCombo.setItems(observableArray);
    }
}
 
Example 12
Source File: PaymentAccountUtil.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static ObservableList<PaymentAccount> getPossiblePaymentAccounts(Offer offer,
                                                                        Set<PaymentAccount> paymentAccounts,
                                                                        AccountAgeWitnessService accountAgeWitnessService) {
    ObservableList<PaymentAccount> result = FXCollections.observableArrayList();
    result.addAll(paymentAccounts.stream()
            .filter(paymentAccount -> isTakerPaymentAccountValidForOffer(offer, paymentAccount))
            .filter(paymentAccount -> isAmountValidForOffer(offer, paymentAccount, accountAgeWitnessService))
            .collect(Collectors.toList()));
    return result;
}
 
Example 13
Source File: LogEntryController.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public void refresh() {
    if (logEntry != null) {

        // System.out.println("expand att: "+!logEntry.getAttachments().isEmpty()+ "
        // tags: " + !logEntry.getTags().isEmpty() + "
        // logbooks:"+!logEntry.getLogbooks().isEmpty());

        LogAttchments.setExpanded(logEntry.getAttachments() != null && !logEntry.getAttachments().isEmpty());
        LogAttchments.setVisible(logEntry.getAttachments() != null && !logEntry.getAttachments().isEmpty());
        LogLogbooksPane.setExpanded(!logEntry.getLogbooks().isEmpty());
        logTagsPane.setExpanded(!logEntry.getTags().isEmpty());

        logDescription.setWrapText(true);
        logDescription.setText(logEntry.getDescription());

        StringBuilder text = new StringBuilder();
        if (logEntry.getCreatedDate() != null) {
            text.append(logEntry.getCreatedDate().toString()).append(System.lineSeparator());
        }
        if (logEntry.getTitle() != null) {
            text.append(logEntry.getTitle());
        }
        logTime.setText(text.toString());

        ObservableList<String> logbookList = FXCollections.observableArrayList();
        logbookList.addAll(logEntry.getLogbooks().stream().map(Logbook::getName).collect(Collectors.toList()));
        LogLogbooks.setItems(logbookList);

        ObservableList<String> tagList = FXCollections.observableArrayList();
        tagList.addAll(logEntry.getTags().stream().map(Tag::getName).collect(Collectors.toList()));
        logTags.setItems(tagList);

        imageGallery.getChildren().clear();
        logEntry.getAttachments().forEach(attachment -> {
            ImageView imageView;
            imageView = createImageView(attachment.getFile());
            imageGallery.getChildren().addAll(imageView);
        });
    }
}
 
Example 14
Source File: MainAction.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void serviceFilterKeyUpAction() {
    ObservableList items = mc.serviceList.getItems();
    if (itemsCache.isEmpty() && items != null) {
        items.forEach((item) -> {
            itemsCache.add((DubboServiceModel) item);
        });
    }
    String filter = mc.serviceFilter.getText();
    if ((filter == null || filter.trim().isEmpty()) && items != null) {
        items.clear();
        items.addAll(itemsCache.toArray());
    } else {
        items.clear();
        FilterType ft = (FilterType) mc.filterType.getSelectionModel().getSelectedItem();
        switch (ft) {
            case SERVICE_NAME:
                itemsCache.stream().filter((object) -> (object.getInterfaceFullName().toLowerCase().contains(filter.toLowerCase()))).forEachOrdered((object) -> {
                    items.add(object);
                });
                break;
            case APP_NAME:
                itemsCache.stream().filter((dsm) -> (dsm.getApplication().toLowerCase().contains(filter.toLowerCase()))).forEachOrdered((dsm) -> {
                    items.add(dsm);
                });
                break;
            case SERVER_IP:
                itemsCache.stream().filter((dsm) -> (dsm.getClientStr().contains(filter))).forEachOrdered((dsm) -> {
                    items.add(dsm);
                });
                break;
        }
    }
    mc.listViewStatusLabel.setText(String.format("共%d条,显示%d条", itemsCache.size(), items.size()));
    saveSetting();
}
 
Example 15
Source File: QuestPackage.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return all PlayerOptions from loaded conversations in this package, the ones from current conversation first
 */
public ObservableList<PlayerOption> getAllPlayerOptions() {
	ObservableList<PlayerOption> list = FXCollections.observableArrayList();
	list.addAll(ConversationController.getDisplayedConversation().getPlayerOptions());
	conversations.forEach(conv -> {
		if (!conv.equals(ConversationController.getDisplayedConversation())) {
			list.addAll(conv.getPlayerOptions());
		}
	});
	return list;
}
 
Example 16
Source File: BetonQuestEditor.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return all tags from loaded packages, the ones from current package first
 */
public ObservableList<Tag> getAllTags() {
	ObservableList<Tag> list = FXCollections.observableArrayList();
	list.addAll(currentPackage.getTags());
	currentPackage.getSet().getPackages().forEach(pack -> {
		if (!pack.equals(currentPackage)) {
			list.addAll(pack.getTags());
		}
	});
	return list;
}
 
Example 17
Source File: BetonQuestEditor.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return all objectives from loaded packages, the ones from current package first
 */
public ObservableList<Objective> getAllObjectives() {
	ObservableList<Objective> list = FXCollections.observableArrayList();
	list.addAll(currentPackage.getObjectives());
	currentPackage.getSet().getPackages().forEach(pack -> {
		if (!pack.equals(currentPackage)) {
			list.addAll(pack.getObjectives());
		}
	});
	return list;
}
 
Example 18
Source File: AttributeEditorPanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * multi value pane showing multiple values for an attribute
 *
 * @param attribute
 * @param attributePane
 * @param values
 */
private void createMultiValuePane(final AttributeData attribute, final TitledPane attributePane, final Object[] values) {
    final VBox dataAndMoreButtonBox = new VBox(5); // 5 = spacing

    final ScrollPane multiValuePane = new ScrollPane();

    multiValuePane.setFitToWidth(true);

    final ObservableList<Object> listData = FXCollections.observableArrayList();

    if (values.length > VISIBLE_ROWS) {
        for (int i = 0; i < VISIBLE_ROWS; i++) {
            listData.add(values[i]);
        }
    } else {
        listData.addAll(values);
    }
    final ListView<Object> listView = createListView(attribute, listData);
    final boolean moreToLoad = values.length > VISIBLE_ROWS;
    int visibleRow = moreToLoad ? VISIBLE_ROWS : listData.size();
    listView.setPrefHeight((CELL_HEIGHT * visibleRow) + 2); // +2 because if it is == then there is still a scrollbar.
    multiValuePane.setPrefHeight((CELL_HEIGHT * visibleRow) + 1);
    multiValuePane.setContent(listView);
    multiValuePane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    dataAndMoreButtonBox.setAlignment(Pos.CENTER);
    dataAndMoreButtonBox.setPadding(new Insets(0, 0, 5, 0));
    dataAndMoreButtonBox.getChildren().add(multiValuePane);
    if (moreToLoad) {
        Button loadMoreButton = createLoadMoreButton(dataAndMoreButtonBox, attribute);
        dataAndMoreButtonBox.getChildren().add(loadMoreButton);
    }
    dataAndMoreButtonBox.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
        if (event.isShortcutDown() && (event.getCode() == KeyCode.A)) {
            listView.getSelectionModel().selectAll();
            event.consume();
        }
    });
    attributePane.setContent(dataAndMoreButtonBox);
}
 
Example 19
Source File: QuestPackage.java    From BetonQuest-Editor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @return all NpcOptions from loaded conversations in this package, the ones from current conversation first
 */
public ObservableList<NpcOption> getAllNpcOptions() {
	ObservableList<NpcOption> list = FXCollections.observableArrayList();
	list.addAll(ConversationController.getDisplayedConversation().getNpcOptions());
	conversations.forEach(conv -> {
		if (!conv.equals(ConversationController.getDisplayedConversation())) {
			list.addAll(conv.getNpcOptions());
		}
	});
	return list;
}
 
Example 20
Source File: ArtistsMainController.java    From MusicPlayer with MIT License 4 votes vote down vote up
void selectAlbum(Album album) {

        if (selectedAlbum == album) {

            albumList.getSelectionModel().clearSelection();
            showAllSongs(artistList.getSelectionModel().getSelectedItem(), false);

        } else {
        	
        	if (selectedSong != null) {
        		selectedSong.setSelected(false);
        	}
        	selectedSong = null;
            selectedAlbum = album;
            albumList.getSelectionModel().select(selectedAlbum);
            ObservableList<Song> songs = FXCollections.observableArrayList();
            songs.addAll(album.getSongs());
            Collections.sort(songs);
            songTable.getSelectionModel().clearSelection();
            songTable.setItems(songs);
            scrollPane.setVvalue(0);
            albumLabel.setText(album.getTitle());
            songTable.setMinHeight(0);
            songTable.setPrefHeight(0);
            songTable.setVisible(true);
            double height = (songs.size() + 1) * 50 + 2;
            Animation songTableLoadAnimation = new Transition() {
            	{
            		setCycleDuration(Duration.millis(250));
                    setInterpolator(Interpolator.EASE_BOTH);
            	}
            	
            	protected void interpolate(double frac) {
            		songTable.setMinHeight(frac * height);
                    songTable.setPrefHeight(frac * height);
            	}
            };
            new Thread(() -> {
            	try {
					loadedLatch.await();
					loadedLatch = new CountDownLatch(1);
				} catch (Exception e) {
					e.printStackTrace();
				}
            	songTableLoadAnimation.play();
            }).start();
        }
    }