Java Code Examples for javafx.collections.FXCollections

The following are top voted examples for showing how to use javafx.collections.FXCollections. 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: xbrowser   File: TableView.java   Source Code and License 14 votes vote down vote up
private TableColumn processChoiceBoxColumnName(String name, JsonArray items){
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
    ObservableList list = FXCollections.observableArrayList();
    if(items!=null) list.addAll(items.getList());
    column.setCellFactory(ChoiceBoxTableCell.forTableColumn(list));
    column.setOnEditCommit( t -> {
        int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
        Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
        item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
    });
    columnMap.put(name, column);
    return column;
}
 
Example 2
Project: Automekanik   File: ShikoKonsumatoret.java   Source Code and License 10 votes vote down vote up
public void mbushTabelen(){
    Thread t = new Thread(new Runnable() {
        public void run() {
            try {
                Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
                Statement stmt = conn.createStatement();
                ResultSet rs = stmt.executeQuery("select * from Konsumatori");
                ObservableList<TabelaKonsumatori> data = FXCollections.observableArrayList();
                while (rs.next()){
                    data.add(new TabelaKonsumatori(rs.getInt("id"), rs.getString("emri"), rs.getString("mbiemri"),
                            rs.getString("makina"), rs.getString("komuna"), rs.getString("pershkrimi")));
                }
                table.setItems(data);
                conn.close();
            }catch (Exception ex){ex.printStackTrace();}
        }
    });
    t.start();
}
 
Example 3
Project: incubator-netbeans   File: ChartLine.java   Source Code and License 9 votes vote down vote up
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    NumberAxis xAxis = new NumberAxis("Values for X-Axis", 0, 3, 1);
    NumberAxis yAxis = new NumberAxis("Values for Y-Axis", 0, 3, 1);
    ObservableList<XYChart.Series<Double,Double>> lineChartData = FXCollections.observableArrayList(
        new LineChart.Series<Double,Double>("Series 1", FXCollections.observableArrayList(
            new XYChart.Data<Double,Double>(0.0, 1.0),
            new XYChart.Data<Double,Double>(1.2, 1.4),
            new XYChart.Data<Double,Double>(2.2, 1.9),
            new XYChart.Data<Double,Double>(2.7, 2.3),
            new XYChart.Data<Double,Double>(2.9, 0.5)
        )),
        new LineChart.Series<Double,Double>("Series 2", FXCollections.observableArrayList(
            new XYChart.Data<Double,Double>(0.0, 1.6),
            new XYChart.Data<Double,Double>(0.8, 0.4),
            new XYChart.Data<Double,Double>(1.4, 2.9),
            new XYChart.Data<Double,Double>(2.1, 1.3),
            new XYChart.Data<Double,Double>(2.6, 0.9)
        ))
    );
    LineChart chart = new LineChart(xAxis, yAxis, lineChartData);
    root.getChildren().add(chart);
}
 
Example 4
Project: dialog-tool   File: MainWindowController.java   Source Code and License 8 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 5
Project: qiniu   File: MainWindowController.java   Source Code and License 7 votes vote down vote up
/**
 * 搜索资源文件,忽略大小写
 */
public void searchFile(KeyEvent event) {
	ArrayList<FileInfo> files = new ArrayList<FileInfo>();
	String search = Checker.checkNull(searchTextField.getText());
	logger.info("search file: " + search);
	QiniuApplication.totalLength = 0;
	QiniuApplication.totalSize = 0;
	try {
		// 正则匹配查询
		Pattern pattern = Pattern.compile(search, Pattern.CASE_INSENSITIVE);
		for (FileInfo file : QiniuApplication.data) {
			if (pattern.matcher(file.getName()).find()) {
				files.add(file);
				QiniuApplication.totalLength++;
				QiniuApplication.totalSize += Formatter.sizeToLong(file.getSize());
			}
		}
	} catch (Exception e) {
		logger.warn("pattern '" + search + "' compile error, message: " + e.getMessage());
	}
	setBucketCount();
	resTable.setItems(FXCollections.observableArrayList(files));
}
 
Example 6
Project: marathonv5   File: BubbleChartSample.java   Source Code and License 7 votes vote down vote up
public BubbleChartSample() {
    NumberAxis xAxis = new NumberAxis("X", 0d, 150d, 20d);

    NumberAxis yAxis = new NumberAxis("Y", 0d, 150d, 20d);

    ObservableList<BubbleChart.Series> bubbleChartData = FXCollections.observableArrayList(
        new BubbleChart.Series("Series 1", FXCollections.observableArrayList(
            new XYChart.Data(30d, 40d, 10d),
            new XYChart.Data(60d, 20d, 13d),
            new XYChart.Data(10d, 90d, 7d),
            new XYChart.Data(100d, 40d, 10d),
            new XYChart.Data(50d, 23d, 5d)))
        ,
        new BubbleChart.Series("Series 2", FXCollections.observableArrayList(
            new XYChart.Data(13d, 100d, 7d),
            new XYChart.Data(20d, 80d, 13d),
            new XYChart.Data(100d, 60d, 10d),
            new XYChart.Data(30d, 40d, 6d),
            new XYChart.Data(50d, 20d, 12d)
        ))
    );

    BubbleChart chart = new BubbleChart(xAxis, yAxis, bubbleChartData);
    getChildren().add(chart);
}
 
Example 7
Project: IP1   File: SearchController.java   Source Code and License 7 votes vote down vote up
private void displayData() {
    ObservableList<BookEntity> data = book.getAllBooksList();
    
    title.setCellValueFactory(new PropertyValueFactory<>("title"));
    category.setCellValueFactory(new PropertyValueFactory<>("category"));
    author.setCellValueFactory(new PropertyValueFactory<>("author"));
    isbn.setCellValueFactory(new PropertyValueFactory<>("isbn"));
    publisher.setCellValueFactory(new PropertyValueFactory<>("publisher"));
    date.setCellValueFactory(new PropertyValueFactory<>("date"));
    pages.setCellValueFactory(new PropertyValueFactory<>("pages"));
    quantity.setCellValueFactory(new PropertyValueFactory<>("quantity"));
 
    table.setItems(data);
    
    ObservableList<String> options = FXCollections.observableArrayList("Title", "Category", "Author", "Publisher");
    search_combo.setItems(options);
    search_combo.getSelectionModel().selectFirst();
}
 
Example 8
Project: aem-epic-tool   File: PackageInfoController.java   Source Code and License 7 votes vote down vote up
private void showPackageContents(PackageContents packageContents) {
    packageConfirmPanel.setVisible(false);
    downloadingPane.setVisible(false);
    analysisPane.setVisible(true);
    pkgContents = packageContents;

    downloadFileLabel.setText(packageContents.getFile().getPath());
    fileCountLabel.setText(String.valueOf(packageContents.getFileCount()));
    folderCountLabel.setText(String.valueOf(packageContents.getFolderCount()));
    rootSummaryTable.setItems(FXCollections.observableArrayList(packageContents.getBaseCounts().entrySet()));
    typeSummaryTable.setItems(FXCollections.observableArrayList(packageContents.getFilesByType().entrySet()));

    downloadFileLabel.setOnMouseClicked(evt -> {
        if (evt.getButton() == MouseButton.PRIMARY && evt.getClickCount() == 2) {
            String path;
            if (evt.isShiftDown() || evt.isControlDown()) {
                path = packageContents.getFile().getParent();
            } else {
                path = packageContents.getFile().getPath();
            }
            HostServices services = ApplicationState.getInstance().getApplication().getHostServices();
            services.showDocument(path);
        }
    });
}
 
Example 9
Project: Squid   File: SpotManagerController.java   Source Code and License 7 votes vote down vote up
private void setUpPrawnFile() {

        shrimpRuns = FXCollections.observableArrayList(squidProject.getPrawnFileRuns());

        setUpShrimpFractionList();
        saveSpotNameButton.setDisable(false);
        setFilteredSpotsAsRefMatButton.setDisable(false);
        setFilteredSpotsAsConcRefMatButton.setDisable(false);

        // filter runs to populate ref mat list 
        filterRuns(squidProject.getFilterForRefMatSpotNames());
        updateReferenceMaterialsList(false);

        // filter runs to populate concentration ref mat list 
        filterRuns(squidProject.getFilterForConcRefMatSpotNames());
        updateConcReferenceMaterialsList(false);

        // restore spot list to full population
        filterRuns("");
    }
 
Example 10
Project: AlphaLab   File: ManutencaoSoftware.java   Source Code and License 7 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
    software = new SoftwareEntity();
    negocio = new Software(DAOFactory.getDAOFactory().getSoftwareDAO());
    tbcDescricao.setCellValueFactory(new PropertyValueFactory<>("descricao"));
    tbcLink.setCellValueFactory(new PropertyValueFactory<>("link"));
    tbcId.setCellValueFactory(new PropertyValueFactory<>("id"));
    tbcObservacao.setCellValueFactory(new PropertyValueFactory<>("observacaoInstalacao"));
    tbcTipo.setCellValueFactory(new PropertyValueFactory<>("tipo"));
    tbcVersao.setCellValueFactory(new PropertyValueFactory<>("versao"));
    cbxManutencaoTipoSoftware.getItems().addAll(TipoSoftwareEnum.values());
    cbxManutencaoTipoSoftware.getSelectionModel().selectFirst();
    cbxSoftwareTipo.getItems().addAll(TipoSoftwareEnum.values());
    listaSoftwares = FXCollections.observableArrayList();
    listaSoftwares.addAll(negocio.buscarTodosSoftwares());
    tblManutencaoSoftware.setItems(listaSoftwares);
    tbpGerenciaSoftware.getSelectionModel().selectLast();
}
 
Example 11
Project: legendary-guide   File: NotificationBarPane.java   Source Code and License 7 votes vote down vote up
public NotificationBarPane(Node content) {
    super(content);
    progressBar = new ProgressBar();
    label = new Label("infobar!");
    bar = new HBox(label);
    bar.setMinHeight(0.0);
    bar.getStyleClass().add("info-bar");
    bar.setFillHeight(true);
    setBottom(bar);
    // Figure out the height of the bar based on the CSS. Must wait until after we've been added to the parent node.
    sceneProperty().addListener(o -> {
        if (getParent() == null) return;
        getParent().applyCss();
        getParent().layout();
        barHeight = bar.getHeight();
        bar.setPrefHeight(0.0);
    });
    items = FXCollections.observableArrayList();
    items.addListener((ListChangeListener<? super Item>) change -> {
        config();
        showOrHide();
    });
}
 
Example 12
Project: Steam-trader-tools   File: AppController.java   Source Code and License 7 votes vote down vote up
@FXML
void searchApp(KeyEvent event)
{
    ArrayList<AbstractSteamAppWithKey> searchResult = new ArrayList<>();
    String search = searchText.getText();
    if (!search.isEmpty())
        searchGraphic.setImage(new Image("/com/matthieu42/steamtradertools/bundles/images/close.png"));
    else
        searchGraphic.setImage(new Image("/com/matthieu42/steamtradertools/bundles/images/magnify.png"));

    search = search.toLowerCase();
    for (AbstractSteamAppWithKey curVal : currentAppList)
    {
        if (curVal.getName().toLowerCase().contains(search))
        {
            searchResult.add(curVal);
        }
    }
    appList.setItems(FXCollections.observableArrayList(searchResult));

}
 
Example 13
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 14
Project: hygene   File: SimpleBookmarkStore.java   Source Code and License 6 votes vote down vote up
/**
 * Create an instance of a {@link SimpleBookmarkStore}.
 * <p>
 * If it observed that the {@link org.dnacronym.hygene.parser.GfaFile} in {@link GraphStore} has changed, it will
 * clear all current {@link SimpleBookmark}s and load the {@link Bookmark}s associated with the new
 * {@link org.dnacronym.hygene.parser.GfaFile}.
 * <p>
 * It uses the {@link GraphDimensionsCalculator} as a reference for each internal {@link SimpleBookmark}.
 *
 * @param graphStore                the {@link GraphStore} to be observed by this class
 * @param graphVisualizer           the {@link GraphVisualizer} to be used by this class
 * @param graphDimensionsCalculator the {@link GraphDimensionsCalculator} to be used by this class
 * @param sequenceVisualizer        the {@link SequenceVisualizer} to be used by this class
 * @see SimpleBookmark
 */
@Inject
public SimpleBookmarkStore(final GraphStore graphStore, final GraphVisualizer graphVisualizer,
                           final GraphDimensionsCalculator graphDimensionsCalculator,
                           final SequenceVisualizer sequenceVisualizer) {
    this.graphDimensionsCalculator = graphDimensionsCalculator;
    this.graphVisualizer = graphVisualizer;
    this.sequenceVisualizer = sequenceVisualizer;

    simpleBookmarks = new ArrayList<>();
    observableSimpleBookmarks = FXCollections.observableList(simpleBookmarks);
    observableSimpleBookmarks.addListener((ListChangeListener<SimpleBookmark>) listener -> graphVisualizer.draw());

    graphStore.getGfaFileProperty().addListener((observable, oldValue, newValue) -> {
        try {
            fileBookmarks = new FileBookmarks(new FileDatabase(newValue.getFileName()));

            simpleBookmarks.clear();
            addBookmarks(fileBookmarks.getAll());
        } catch (final SQLException | IOException e) {
            LOGGER.error("Unable to load bookmarks from file.", e);
        }
    });
}
 
Example 15
Project: SnapDup   File: MainDisplay.java   Source Code and License 6 votes vote down vote up
@FXML
private void btnMapDevicesAction()
{
	try
	{
	    FXMLLoader loader = new FXMLLoader(MainDisplay.class.getResource("/fxml/MapDevicesDialog.fxml"));
	    Parent root = loader.load();
	    Scene scene = new Scene(root);
	    Stage stage = new Stage();
	    stage.initModality(Modality.APPLICATION_MODAL);
	    stage.initStyle(StageStyle.UNDECORATED);
	    stage.setScene(scene);
	    stage.show();
	    
	    Node node = scene.lookup("#tblMapDevice");
	    
	    if(node instanceof TableView)
	    {
	    	TableView<Pair<String, String>> table = (TableView)node;
	    	ArrayList<Pair<String, String>> pairList = new ArrayList<>();
	    	
	    	dataContainer.getDeviceMap().entrySet().forEach(entry -> pairList.add(new Pair<String, String>(entry.getKey(), entry.getValue())));
	    	
	    	ObservableList<Pair<String, String>> tableModel = FXCollections.<Pair<String, String>> observableArrayList(pairList);
	    	    	
	    	table.setItems(tableModel);
	    }
	}
	catch(IOException e)
	{
	    e.printStackTrace();
	}
}
 
Example 16
Project: Automekanik   File: ShikoPunetoret.java   Source Code and License 6 votes vote down vote up
public void mbushPunetoret(){
    try {
        String sql = "select * from Punetoret";
        Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        ObservableList<TabelaPunetoret> data = FXCollections.observableArrayList();
        Format format = new SimpleDateFormat("dd/MM/yyyy");
        while (rs.next()){
            String s = format.format(rs.getDate("regjistrimi"));
            data.add(new TabelaPunetoret(rs.getInt("id"), rs.getString("emri"),
                    rs.getString("mbiemri"), rs.getString("komuna"), rs.getString("pozita"),
                    s, rs.getFloat("paga")));
        }

        table.setItems(data);
        conn.close();
    }catch (Exception ex){ex.printStackTrace();}
}
 
Example 17
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 18
Project: marathonv5   File: SimpleListViewScrollSample.java   Source Code and License 6 votes vote down vote up
@Override public void start(Stage primaryStage) throws Exception {
    final ListView<String> listView = new ListView<String>();
    listView.setItems(FXCollections.observableArrayList("Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6", "Row 7",
            "Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13", "Row 14", "Row 15", "Row 16", "Row 17", "Row 18",
            "Row 19", "Row 20", "Row 21", "Row 22", "Row 23", "Row 24", "Row 25"));
    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    Button button = new Button("Debug");
    button.setOnAction((e) -> {
        ObservableList<Integer> selectedIndices = listView.getSelectionModel().getSelectedIndices();
        for (Integer index : selectedIndices) {
            ListCell cellAt = getCellAt(listView, index);
            System.out.println("SimpleListViewScrollSample.SimpleListViewScrollSampleApp.start(" + cellAt + ")");
        }
    });
    VBox root = new VBox(listView, button);
    primaryStage.setScene(new Scene(root, 300, 400));
    primaryStage.show();
}
 
Example 19
Project: code-tracker   File: MainController.java   Source Code and License 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void initialize(URL location, ResourceBundle resources) {
    // Initializes test base, tester and test map to access and modify the algorithm base
    testBase = TestBase.INSTANCE;   // Gets a reference to the test base
    tester = new Tester();          //
    testMap = tester.getTestMap();

    // Binds the list view with a list of algorithms (list items)
    listItems = FXCollections.observableList(new ArrayList<>(testMap.keySet()));
    list.itemsProperty().bindBidirectional(new SimpleListProperty<>(listItems));
    list.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    list.getSelectionModel().selectedItemProperty().addListener((((observable, oldValue, newValue) -> {
        if(newValue != null) {
            textArea.setText(testMap.get(newValue).getContent());
        } else {
            textArea.clear();
        }
    })));
    list.getSelectionModel().select(0);

    // Initializes the trie that stores all algorithm names
    algorithmNameTrie = new Trie();
    for(String algorithmName : testMap.keySet()) {
        algorithmNameTrie.addWord(algorithmName);
    }

    // Binds search field with the list view (displays search result)
    searchField.textProperty().addListener((observable, oldValue, newValue) -> {
        listItems.setAll(algorithmNameTrie.getWords(newValue.toLowerCase()));
        if(!listItems.isEmpty()) {
            list.getSelectionModel().select(0);
        }
    });

    // For unknown reasons, this style does not work on css, so I put it in here
    textArea.setStyle("-fx-focus-color: transparent; -fx-text-box-border: transparent;");
    textArea.setFocusTraversable(false);
}
 
Example 20
Project: AlphaLab   File: GerenciarInstalacaoSoftware.java   Source Code and License 6 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
    
    negocio=new SolicitacaoSoftware(DAOFactory.getDAOFactory().getSolicitacaoSoftwareDAO());
    tbcSituacao.setCellValueFactory(new PropertyValueFactory<>("situacaoInstalacao"));
    tbcProfessor.setCellValueFactory(new PropertyValueFactory<>("solicitante"));
    tbcSoftware.setCellValueFactory(new PropertyValueFactory<>("descricao"));
    tbcObservacaoInstalacao.setCellValueFactory(new PropertyValueFactory<>("observacaoInstalacao"));
    tbcLaboratorio.setCellValueFactory(new PropertyValueFactory<>("laboratorio"));
    tbcId.setCellValueFactory(new PropertyValueFactory<>("idSolicitacao"));
    tbcTipo.setCellValueFactory(new PropertyValueFactory<>("tipo"));
    tbcDataSolicitacao.setCellValueFactory(new PropertyValueFactory<>("dataSolicitacao"));
    
    tbcInstalado.setCellValueFactory(new PropertyValueFactory<>("instalado"));
    //tbcInstalado.setCellFactory();
    listaSolicitacao=FXCollections.observableArrayList((new SolicitacaoSoftwareView()).setSolicitacao(negocio.buscarTodas()).getList());
    
    tblSolicitacao.setItems(listaSolicitacao);
    /*Deve ser substituido pelo carregamento a partir da classe de negócio, porém esta não estava disponível até o momento da criação*/
    cbxLaboratorio.setItems(FXCollections.observableArrayList(MockLaboratorioDAO.getInstance().buscarTodos()));
    cbxSituacao.setItems(FXCollections.observableArrayList(SituacaoSolicitacaoEnum.values()));
}
 
Example 21
Project: Luna-Exam-Builder   File: GenerateExamsCtrl.java   Source Code and License 5 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {

	//Set fields
	titleField.setText(MainApp.currentExam.title);
	authorField.setText(MainApp.currentExam.author);
	//Set format selection box
	formatBox.setItems(FXCollections.observableArrayList(FORMATS));
	formatBox.getSelectionModel().select(3);
	//set max export label
	System.out.println(MainApp.questionObservableList.size());
	int max = factorial(MainApp.questionObservableList.size());
	maxExportLabel.setText("You can generate up to "+ NumberFormat.getIntegerInstance().format(max) + " different exams");

	//make the tree
	TreeItem root = new TreeItem<>("Exam");
	root.setExpanded(true);
	questionTreeView.setRoot(root);
	//add each question
	for (Question question: MainApp.questionObservableList) {
		TreeItem<String> q = new TreeItem<>(question.getTitle());
		for (String option: question.options) {
			TreeItem<String> o = new TreeItem<>(option);
			q.getChildren().add(o);
		}
		q.setExpanded(true);
		root.getChildren().add(q);
	}
	questionTreeView.setShowRoot(false);
}
 
Example 22
Project: Lernkartei_2017   File: GroupMemberView.java   Source Code and License 5 votes vote down vote up
@Override
public Parent constructContainer()
{
	bp.setId("loginviewbg");
	
	list = new ListView<String>();
	items = FXCollections.observableArrayList("Philippe Kr�ttli","Irina Deck","Javier Martinez Alvarez","Frithjof Hoppe");
	list.setItems(items);		
	
	AllFields = new VBox(50);
	AllFields.setAlignment(Pos.CENTER);
	AllFields.setMaxWidth(300);
	AllFields.setPadding(new Insets(20));
	
	GroupName = new HBox(50);
	Option = new HBox(50);
	
	name = new Label("Name:");
	groupname = new Label("{Gruppenname}");
	
	btnAdd = new AppButton("Hinzuf�gen");
	btnRemove = new AppButton("Entfernen");
	back = new BackButton(getFXController(),"Zur�ck");
	
	
	
	GroupName.getChildren().addAll(name,groupname);
	Option.getChildren().addAll(back,btnAdd,btnRemove);
	
	AllFields.getChildren().addAll(GroupName,Option,list);
	
	
	bp.setCenter(AllFields);
	
	back.setOnAction(e -> getFXController().showView("groupview"));
	btnAdd.setOnAction(e -> getFXController().showView("userlistview"));
	
	btnRemove.setOnAction(e -> {
	Alert alert = new Alert(AlertType.CONFIRMATION);
	alert.setTitle("Mitglied l�schen");
	alert.setHeaderText("Sie sind gerade dabei ein Mitglied aus der Gruppe zu entfernen.");
	alert.setContentText("Sind Sie sich sicher, dass sie das tun wollen?");
	Optional<ButtonType> result = alert.showAndWait();
	if (result.get() == ButtonType.OK){
	    // ... user chose OK
	} else {
		Alert noDeletion = new Alert(AlertType.INFORMATION);
		noDeletion.setTitle("L�schvorgang abgebrochen");
		noDeletion.setHeaderText("Mitglied nicht gel�scht");
		noDeletion.setContentText("Der L�schvorgang wurde abgebrochen.");
		noDeletion.showAndWait();
	    alert.close();
	}});
	
	return bp;
}
 
Example 23
Project: charts   File: TreeNode.java   Source Code and License 5 votes vote down vote up
public TreeNode(final T ITEM, final TreeNode PARENT) {
    item      = ITEM;
    parent    = PARENT;
    depth     = -1;
    children  = FXCollections.observableArrayList();
    listeners = new CopyOnWriteArrayList<>();
    init();
}
 
Example 24
Project: Anime-Downloader   File: NineAnimeController.java   Source Code and License 5 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
	// TODO Auto-generated method stub
	name.setCellValueFactory(new PropertyValueFactory<Anime,String>("name"));
	status.setCellValueFactory(new PropertyValueFactory<Anime,String>("status"));
	
	table.setItems(list);
	errormsg.setTextFill(Paint.valueOf("red"));
	
	choicebox.setItems(FXCollections.observableArrayList("Provide Anime Name",
			"Provide URL to a particular episode"));

}
 
Example 25
Project: marathonv5   File: MarathonModuleStage.java   Source Code and License 5 votes vote down vote up
private void initComponents() {
    moduleNameField.setPrefColumnCount(20);
    moduleNameField.textProperty().addListener((observable, oldValue, newValue) -> validateModuleName());

    descriptionArea.setPrefColumnCount(20);
    descriptionArea.setPrefRowCount(4);

    if (moduleInfo.isNeedModuleFile()) {
        moduleDirComboBox.setItems(FXCollections.observableArrayList(moduleInfo.getModuleDirElements()));
        moduleDirComboBox.getSelectionModel().selectedItemProperty().addListener((e) -> {
            moduleInfo.populateFiles(moduleDirComboBox.getSelectionModel().getSelectedItem());
        });

        if (moduleDirComboBox.getItems().size() > 0) {
            moduleDirComboBox.getSelectionModel().select(0);
        }
        moduleFileComboBox.setItems(moduleInfo.getModuleFileElements());
        moduleFileComboBox.setEditable(true);
        TextField editor = moduleFileComboBox.getEditor();
        editor.textProperty().addListener((observable, oldValue, newValue) -> validateModuleName());
    }

    errorMessageLabel.setGraphic(FXUIUtils.getIcon("error"));
    errorMessageLabel.setVisible(false);

    buttonBar.setId("ModuleButtonBar");
    okButton.setOnAction((e) -> onOK());
    okButton.setDisable(true);
    cancelButton.setOnAction((e) -> onCancel());
    buttonBar.getButtons().addAll(okButton, cancelButton);
}
 
Example 26
Project: joanne   File: FXMLDocumentController.java   Source Code and License 5 votes vote down vote up
private void setFavoritesToList(){
    image_list.refresh();
    ObservableList<String> l = FXCollections.observableArrayList(images);
    if(l.size() > 0){
      image_list.setItems(l);
      image_list.setCellFactory(new CallbackImpl());
    }else{
        System.out.print("List length is 0");
    }
    System.gc();
}
 
Example 27
Project: gatepass   File: VisitorsReports.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.setMaxWidth(90);
	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 28
Project: GameAuthoringEnvironment   File: AuthorshipData.java   Source Code and License 5 votes vote down vote up
/**
 * Just for show and picking. Will not edit the overall lists!
 *
 * @return all the created sprites
 */

public ObservableList<SpriteDefinition> getAllCreatedSpritesAsList () {
    List<SpriteDefinition> sprites = new ArrayList<>();
    getMyCreatedSpritesMap().values().stream().forEach(col -> sprites.addAll(col.getItems()));
    return FXCollections.observableArrayList(sprites);
}
 
Example 29
Project: gatepass   File: Office_Entry.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void configureBox(HBox root) {
	  StackPane container = new StackPane();
	  //container.setPrefHeight(700);
	  container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
	  container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");

	 table= new TableView<OfficeClass>();
	  Label lview= new Label();
	  lview.setText("View Records");
	  lview.setId("lview");
	  bottomPane= new VBox();
	  
	  tclock= new Text(); 
	  tclock.setId("lview");
		//tclock.setFont(Font.font("Calibri", 20));
		final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {  
		     @Override  
		     public void handle(ActionEvent event) {  
		          tclock.setText(DateFormat.getDateTimeInstance().format(new Date()));
		     }  
		}));  
		timeline.setCycleCount(Animation.INDEFINITE);  
		timeline.play();
	  
	  bottomPane.getChildren().addAll(tclock, lview);
	  bottomPane.setAlignment(Pos.CENTER);
	  
	  nocol= new TableColumn<>("no");
	  nocol.setMinWidth(130);
	  nocol.setCellValueFactory(new PropertyValueFactory<>("no"));
		
	  
	  namecol= new TableColumn<>("First Name");
		namecol.setMinWidth(170);
		namecol.setCellValueFactory(new PropertyValueFactory<>("name"));
		
		admcol= new TableColumn<>("Admission Number");
		admcol.setMinWidth(180);
		admcol.setCellValueFactory(new PropertyValueFactory<>("adm"));
		
		
		timecol= new TableColumn<>("Signin");
		timecol.setMinWidth(140);
		timecol.setCellValueFactory(new PropertyValueFactory<>("timein"));
		
		datecol= new TableColumn<>("Date");
		datecol.setMinWidth(180);
		datecol.setCellValueFactory(new PropertyValueFactory<>("date"));
		
		table.getColumns().addAll(nocol,namecol, admcol, timecol, datecol);
		table.setItems(getAtt());
		att= getAtt();
        table.setItems(FXCollections.observableArrayList(att));
        table.setMinHeight(500);
       
        btnrefresh = new Button("Refresh");
        btnrefresh.setOnAction(new EventHandler<ActionEvent>() {
            public void handle(ActionEvent t) {
            	table.setItems(getAtt());
            }
        });
        laytable= new VBox(10);
        laytable.getChildren().addAll(table, btnrefresh);
        laytable.setAlignment(Pos.TOP_LEFT);
        
        container.getChildren().addAll(bottomPane,laytable);
		setAnimation();
		sc.setContent(container);
		root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)");
		root.getChildren().addAll(getActionPane(),sc);
		
		//service.start();
	 }
 
Example 30
Project: git-rekt   File: GuestRegistryScreenController.java   Source Code and License 5 votes vote down vote up
/**
 * Initializes the FXML controller class.
 *
 * Called by JavaFX.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    // Prepare to display the data
    bookings = FXCollections.observableArrayList();
    registryTable.setItems(bookings);
    guestNameColumn.setCellValueFactory(
        (param) -> {
            return new SimpleStringProperty(
                String.valueOf(param.getValue().getGuest().getLastName() + " , "
                    + param.getValue().getGuest().getFirstName())
            );
        }
    );

    checkedInColumn.setCellValueFactory((param) -> {
        return new SimpleBooleanProperty(param.getValue().isCheckedIn());
    });

    // Use a check box to display booleans rather than a string
    checkedInColumn.setCellFactory(
        (param) -> {
            return new CheckBoxTableCell<>();
        }
    );

    bookingNumberColumn.setCellValueFactory(
        (param) -> {
            return new SimpleLongProperty(
                param.getValue().getId()
            ).asObject();
        }
    );

    // Load the registry data from the database
    BookingService bookingService = new BookingService();
    bookings.addAll(bookingService.getDailyRegistry());
}
 
Example 31
Project: easyMvvmFx   File: ModelWrapper.java   Source Code and License 5 votes vote down vote up
public FxListPropertyField(ListPropertyAccessor<M, E> accessor, Supplier<ListProperty<E>> propertySupplier, List<E> defaultValue) {
	this.accessor = accessor;
	this.defaultValue = defaultValue;

	this.targetProperty = propertySupplier.get();
	this.targetProperty.setValue(FXCollections.observableArrayList());
	
	this.targetProperty.addListener((ListChangeListener<E>) change -> ModelWrapper.this.propertyWasChanged());
}
 
Example 32
Project: boomer-tuner   File: MediaLibrary.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void readSerializedLibrary(final File location) {
	try {
		FileInputStream fileIn = new FileInputStream(location);
		ObjectInputStream in = new ObjectInputStream(fileIn);
		songs = FXCollections.observableList((List<Song>) in.readObject());
		playlists = FXCollections.observableList((List<Playlist>) in.readObject());
		videos = FXCollections.observableList((List<Video>) in.readObject());
		images = FXCollections.observableList((List<Image>) in.readObject());
		for (Song song : songs) {
			if (!artists.contains(song.getArtist())) {
				artists.add(song.getArtist());
			}
			if (!albums.contains(song.getAlbum())) {
				albums.add(song.getAlbum());
			}
		}

		Collections.sort(albums, Comparator.comparing(Album::getName));
		Collections.sort(artists, Comparator.comparing(Artist::getName));
		Collections.sort(songs, Comparator.comparing(Song::getTitle));
		Collections.sort(images, Comparator.comparing(Image::getName));

		in.close();
		fileIn.close();
	} catch (IOException | ClassNotFoundException e) {
		e.printStackTrace();
	}
}
 
Example 33
Project: Dr-Assistant   File: PatientGetway.java   Source Code and License 5 votes vote down vote up
public ObservableList<Patient> searchPatient(Paginate paginate, String query) {
    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 where name like ? or phone like ? or email like ? limit " + paginate.getStart() + "," + paginate.getEnd());
        pst.setString(1, query + "%");
        pst.setString(2, query + "%");
        pst.setString(3, query + "%");
        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 34
Project: OneClient   File: TableDialog.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public TableDialog(Collection<T> files) {
	dialogPane = getDialogPane();
	setResizable(true);
	this.table = new TableView<>(FXCollections.observableArrayList(files));
	this.table.setMaxWidth(Double.MAX_VALUE);

	GridPane.setHgrow(table, Priority.ALWAYS);
	GridPane.setFillWidth(table, true);

	label = createContentLabel(dialogPane.getContentText());
	label.setPrefWidth(Region.USE_COMPUTED_SIZE);
	label.textProperty().bind(dialogPane.contentTextProperty());

	this.grid = new GridPane();
	this.grid.setHgap(10);
	this.grid.setMaxWidth(Double.MAX_VALUE);
	this.grid.setAlignment(Pos.CENTER_LEFT);

	dialogPane.contentTextProperty().addListener(o -> updateGrid());
	updateGrid();

	setResultConverter((dialogButton) -> {
		ButtonBar.ButtonData data = dialogButton == null ? null : dialogButton.getButtonData();
		return data == ButtonBar.ButtonData.OK_DONE ? table.getSelectionModel().getSelectedItem() : null;
	});
}
 
Example 35
Project: Shield   File: HomeController.java   Source Code and License 5 votes vote down vote up
@FXML
private void refreshSongs(){
    ArrayList<String[]> songs = Functions.addRandomSongs();
    ObservableList<String[]> dataobv = FXCollections.observableArrayList();
    dataobv.addAll(songs);
    songList.setItems(dataobv);
    
}
 
Example 36
Project: gatepass   File: Officebar.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private ObservableList<XYChart.Series<String, Double>> getChartData() {
       double aValue = 0;
       ObservableList<XYChart.Series<String, Double>> answer = FXCollections.observableArrayList();
       Series<String, Double> aSeries = new Series<String, Double>();
       aSeries.setName("dates");
       
       String qcount= "SELECT date, COUNT(date) FROM  officeentry GROUP BY date";
	DBConnect.connect();
	try 
	{
		ResultSet rec = DBConnect.stmt.executeQuery(qcount);
		while(rec.next())
		{
			String date = rec.getString("date");
			int count= rec.getInt("COUNT(date)");
			aSeries.getData().add(new XYChart.Data(date, count));
            aValue = aValue + Math.random() - .5;
		}
		
	} catch (SQLException e) 
	{
		ErrorMessage.display("SQL Error", e.getMessage()+"\n error");
		e.printStackTrace();
	}
       
       answer.addAll(aSeries);
       return answer;
   }
 
Example 37
Project: marathonv5   File: StackedBarChartSample.java   Source Code and License 5 votes vote down vote up
public StackedBarChartSample() {
    String[] years = {"2007", "2008", "2009"};
    CategoryAxis xAxis = CategoryAxisBuilder.create()
            .categories(FXCollections.<String>observableArrayList(years)).build();
    NumberAxis yAxis = NumberAxisBuilder.create()
                       .label("Units Sold")
                       .lowerBound(0.0d)
                       .upperBound(10000.0d)
                       .tickUnit(1000.0d).build();
    ObservableList<StackedBarChart.Series> barChartData = FXCollections.observableArrayList(
        new StackedBarChart.Series("Region 1", FXCollections.observableArrayList(
           new StackedBarChart.Data(years[0], 567d),
           new StackedBarChart.Data(years[1], 1292d),
           new StackedBarChart.Data(years[2], 1292d)
        )),
        new StackedBarChart.Series("Region 2", FXCollections.observableArrayList(
           new StackedBarChart.Data(years[0], 956),
           new StackedBarChart.Data(years[1], 1665),
           new StackedBarChart.Data(years[2], 2559)
        )),
        new StackedBarChart.Series("Region 3", FXCollections.observableArrayList(
           new StackedBarChart.Data(years[0], 1154),
           new StackedBarChart.Data(years[1], 1927),
           new StackedBarChart.Data(years[2], 2774)
        ))
    );
    
    StackedBarChart chart = new StackedBarChart(xAxis, yAxis, barChartData, 25.0d);
    getChildren().add(chart);
}
 
Example 38
Project: infxnity   File: IFXContentBindingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void listInitializationTest()
{
    final ObservableList<Model> collection1 = FXCollections.observableArrayList(new Model("value1"),
                                                                                new Model("value2"),
                                                                                new Model("value3"),
                                                                                new Model("value4"));
    final List<String> collection2 = new ArrayList<>();

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

    assertEquals(Arrays.asList("value1", "value2", "value3", "value4"), collection2);
}
 
Example 39
Project: campingsimulator2017   File: ProductController.java   Source Code and License 5 votes vote down vote up
public void sell(Product lastClickedValue) {
    ObservableList<Client> choices = FXCollections.observableArrayList();
    GenericDAO<Client, Integer> clientDao = new GenericDAO<>(Client.class);
    for (Client c : clientDao.findAll())
        choices.add(c);

    SellProductDialog dialog = new SellProductDialog(choices, lastClickedValue, this);
    dialog.showAndWait();

    dao.update(lastClickedValue);
}
 
Example 40
Project: Goliath-Overclocking-Utility-FX   File: InformationPane.java   Source Code and License 5 votes vote down vote up
public InformationPane()
{
    super();
    super.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
    super.setPrefWidth(AppTabPane.CONTENT_WIDTH);
    
    infoTable = new TableView<>(FXCollections.observableArrayList(InstanceProvider.getAttributes()));
    
    if(AppSettings.getShowExtraAttributeInfo())
    {
        cmdName = new TableColumn<>("Cmd Name");
        cmdName.setCellValueFactory(new PropertyValueFactory("cmdName"));
    
        cmdValue = new TableColumn<>("Cmd Value");
        cmdValue.setCellValueFactory(new PropertyValueFactory("cmdValue"));
    }
    
    displayName = new TableColumn<>("Name");
    displayName.setCellValueFactory(new PropertyValueFactory("displayName"));
    
    displayValue = new TableColumn<>("Value");
    displayValue.setCellValueFactory(new PropertyValueFactory("displayValue"));
    
    if(!AppSettings.getShowExtraAttributeInfo())
        infoTable.getColumns().addAll(displayName, displayValue);
    else
        infoTable.getColumns().addAll(cmdName, displayName, cmdValue, displayValue);
    
    infoTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    infoTable.setPrefWidth(AppTabPane.CONTENT_WIDTH);
    infoTable.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
    infoTable.setEditable(false);
    
    super.getChildren().add(infoTable);
}