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

The following examples show how to use javafx.collections.ObservableList#iterator() . 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: CObjectArray.java    From Open-Lowcode with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * When this method is triggered, it reviews the number of rows in the table
 * that have been edited, and according to total data table, create or remove
 * the data update warning
 */
public void reviewDataWarningForTable() {
	if (this.unsavedupdatewarning) {
		logger.info("------------------- starting evaluating unsaved data -----------------------");
		ObservableList<ObjectTableRow> objecttablerow = thistable.getItems();
		Iterator<ObjectTableRow> rowiterator = objecttablerow.iterator();
		int updatedrow = 0;
		while (rowiterator.hasNext()) {
			ObjectTableRow thisrow = rowiterator.next();
			if (thisrow.isRowUpdate())
				updatedrow++;
		}
		if (updatedrow == 0) {
			// remove any present unsaved data warning for this component
			this.actionmanager.removedUnsavedDataWarningForNode(this);
			logger.fine("   * remove all updates ");
		} else {
			logger.fine("   * remove all updates ");
			this.actionmanager.addUnsavedDataWarning(new UnsavedDataWarning(this.updatewarningmessage, // message
					this.updatewarningcontinue, // continue message
					this.updatewarningstop, // stop message
					this)); // originnode

		}
	}
}
 
Example 2
Source File: TimingDAO.java    From pikatimer with GNU General Public License v3.0 6 votes vote down vote up
public void blockingRemoveTimingLocations(ObservableList<TimingLocation> removeList) {
    int max = removeList.size();
    int i=1;
    Session s=HibernateUtil.getSessionFactory().getCurrentSession();
    s.beginTransaction();
    int count = 0;
    Iterator<TimingLocation> deleteMeIterator = removeList.iterator();
    while (deleteMeIterator.hasNext()) {
        TimingLocation p = deleteMeIterator.next();
        
        s.delete(p); 
        if ( ++count % 20 == 0 ) {
            //flush a batch of updates and release memory:
            s.flush();
            s.clear();
        }

    }
    s.getTransaction().commit(); 

    //Platform.runLater(() -> {
            refreshTimingLocationList();
    //    });
            

}
 
Example 3
Source File: RaceDAO.java    From pikatimer with GNU General Public License v3.0 6 votes vote down vote up
public void removeRaces(ObservableList<Race> removeList) {

        Session s=HibernateUtil.getSessionFactory().getCurrentSession();
        s.beginTransaction();
        int count = 0;
        Iterator<Race> deleteMeIterator = removeList.iterator();
        while (deleteMeIterator.hasNext()) {
            Race p = deleteMeIterator.next();
            s.delete(p); 
            if ( ++count % 20 == 0 ) {
                //flush a batch of updates and release memory:
                s.flush();
                s.clear();
            }

        }
        s.getTransaction().commit(); 

        //Platform.runLater(() -> {
                refreshRaceList();
        //    });
    }
 
Example 4
Source File: RecordingListController.java    From archivo with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Recursively search our tree's data model for the recording to delete.
 */
private boolean removeRecordingFromList(Recording recording, ObservableList<TreeItem<Recording>> list) {
    Iterator<TreeItem<Recording>> i = list.iterator();

    while (i.hasNext()) {
        TreeItem<Recording> item = i.next();
        if (!item.isLeaf()) {
            if (removeRecordingFromList(recording, item.getChildren())) {
                return true;
            }
        } else {
            Recording other = item.getValue();
            if (other.equals(recording)) {
                promoteSingleElementGroup(item);
                i.remove();
                return true;
            }
        }
    }

    return false;
}
 
Example 5
Source File: RecordingListController.java    From archivo with GNU General Public License v3.0 6 votes vote down vote up
private void updateGroupStatus(TreeItem<Recording> group, ObservableList<TreeItem<Recording>> list) {
    if (!group.isLeaf()) {
        Iterator<TreeItem<Recording>> i = list.iterator();
        ArchiveStatus groupStatus = ArchiveStatus.EMPTY;
        while (i.hasNext()) {
            TreeItem<Recording> item = i.next();
            if (!item.isLeaf()) {
                updateGroupStatus(item, item.getChildren());
            } else {
                Recording recording = item.getValue();
                if (groupStatus.compareTo(recording.getStatus()) > 0) {
                    groupStatus = recording.getStatus();
                }
            }
        }
        group.getValue().setStatus(groupStatus);
    }
}
 
Example 6
Source File: CGrid.java    From Open-Lowcode with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * When this method is triggered, it reviews the number of rows in the table
 * that have been edited, and according to total data table, create or remove
 * the data update warning
 */
public void reviewDataWarningForGrid() {
	if (this.unsavedupdatewarning) {

		logger.fine("------------------- starting evaluating unsaved data -----------------------");
		int updatedrow = 0;
		if (!this.reversetree) {
			ObservableList<CObjectGridLine<String>> objecttablerow = tableview.getItems();
			Iterator<CObjectGridLine<String>> rowiterator = objecttablerow.iterator();
			while (rowiterator.hasNext()) {
				CObjectGridLine<String> thisrow = rowiterator.next();
				if (thisrow.isRowUpdate())
					updatedrow++;
			}
		} else {
			
			updatedrow = this.treetable.getUpdatedItems().size();
			logger.fine("Get all updated rows, result = "+updatedrow);
		}
		if (updatedrow == 0) {
			// remove any present unsaved data warning for this component
			this.actionmanager.removedUnsavedDataWarningForNode(this);
			logger.fine("   * remove all updates ");
		} else {
			logger.fine("   * remove all updates ");
			this.actionmanager.addUnsavedDataWarning(new UnsavedDataWarning(this.updatewarningmessage, // message
					this.updatewarningcontinue, // continue message
					this.updatewarningstop, // stop message
					this)); // originnode

		}
	}
}
 
Example 7
Source File: ParticipantDAO.java    From pikatimer with GNU General Public License v3.0 5 votes vote down vote up
public void addParticipant(ObservableList newParticipantList) {
    int max = newParticipantList.size();
    int i=1;
    Session s=HibernateUtil.getSessionFactory().getCurrentSession();
    s.beginTransaction();
    int count = 0;
    Iterator<Participant> addIterator = newParticipantList.iterator();
    while (addIterator.hasNext()) {
        Participant p = addIterator.next();
        s.save(p); 
        if ( ++count % 20 == 0 ) {
            //flush a batch of updates and release memory:
            s.flush();
            s.clear();
        }
        //updateProgress(i++, max);
        Participant2BibMap.put(p, p.getBib()); 
        Bib2ParticipantMap.put(p.getBib(),p); 
        ID2ParticipantMap.put(p.getID(),p);
        resultsDAO.getResultsQueue().add(p.getBib()); 

    }
    s.getTransaction().commit(); 

    Platform.runLater(() -> {
        //refreshParticipantsList();
        participantsList.addAll(newParticipantList); 
    });
}
 
Example 8
Source File: FXMLRaceDetailsController.java    From pikatimer with GNU General Public License v3.0 5 votes vote down vote up
public void deleteSegment(ActionEvent fxevent){
    ObservableList deleteMe = FXCollections.observableArrayList(raceSegmentsTableView.getSelectionModel().getSelectedItems());
    Segment s;
    Iterator<Segment> deleteMeIterator = deleteMe.iterator();
    while (deleteMeIterator.hasNext()) {
        s = deleteMeIterator.next();
        raceDAO.removeSegment(s); 
    }
}
 
Example 9
Source File: CObjectArray.java    From Open-Lowcode with Eclipse Public License 2.0 4 votes vote down vote up
public void mothball() {

		if (thistable != null) {
			if (thistable.getFocusModel() != null)
				thistable.getFocusModel().focus(null);

			if (this.readonlymousehandler != null) {
				thistable.removeEventHandler(MouseEvent.MOUSE_CLICKED, readonlymousehandler);
				readonlymousehandler.mothball();
			}
			if (this.updatemousehandler != null) {
				thistable.removeEventHandler(MouseEvent.MOUSE_CLICKED, updatemousehandler);
			}
			thistable.setOnMouseClicked(null);
			thistable.setOnKeyPressed(null);
			thistable.setOnKeyReleased(null);
			thistable.setSelectionModel(null);
			if (focuslostlistener != null)
				thistable.focusedProperty().removeListener(focuslostlistener);
			focuslostlistener = null;
			thistable.setOnContextMenuRequested(null);
			copydata.setOnAction(null);
			startupdate.setOnAction(null);
			commitupdate.setOnAction(null);
			this.actionmanager = null;
			ObservableList<ObjectTableRow> tablerows = thistable.getItems();
			Iterator<ObjectTableRow> rowiterator = tablerows.iterator();
			while (rowiterator.hasNext()) {
				ObjectTableRow thisrow = rowiterator.next();
				thisrow.mothball();
			}

			if (thistable.getItems() != null)
				if (thistable.getItems().size() > 0) {

					if (thistable.getSortOrder() != null)
						if (thistable.getSortOrder().size() > 0)
							thistable.getSortOrder().clear();
					thistable.getItems().clear();
				}
			if (thistable.getColumns() != null)
				if (thistable.getColumns().size() > 0) {

					thistable.getColumns().clear();
				}
			thistable = null;
			logger.finer("mothball succesfully done on table");
		} else {
			logger.info("mothball called on table with null tableview " + this.toString());
		}

	}
 
Example 10
Source File: CGrid.java    From Open-Lowcode with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void mothball() {

	if (tableview != null) {
		if (tableview.getFocusModel() != null)
			tableview.getFocusModel().focus(null);

		if (this.updatemousehandler != null) {
			tableview.removeEventHandler(MouseEvent.MOUSE_CLICKED, updatemousehandler);
		}
		tableview.setOnMouseClicked(null);
		tableview.setOnKeyPressed(null);
		tableview.setOnKeyReleased(null);
		tableview.setSelectionModel(null);

		tableview.setOnContextMenuRequested(null);
		copydata.setOnAction(null);
		startupdate.setOnAction(null);
		commitupdate.setOnAction(null);
		this.actionmanager = null;
		ObservableList<CObjectGridLine<String>> tablerows = tableview.getItems();
		Iterator<CObjectGridLine<String>> rowiterator = tablerows.iterator();
		while (rowiterator.hasNext()) {
			CObjectGridLine<String> thisrow = rowiterator.next();
			thisrow.mothball();
		}

		tableview.getSortOrder().clear();
		tableview.getItems().clear();

		if (tableview.getColumns() != null)
			if (tableview.getColumns().size() > 0) {

				tableview.getColumns().clear();
			}
		tableview = null;
		logger.fine("mothball succesfully done on table");
	} else {
		logger.warning("mothball called on table with null tableview " + this.toString());
	}

}