List of usage examples for javafx.beans.property SimpleBooleanProperty SimpleBooleanProperty
public SimpleBooleanProperty()
From source file:Main.java
/** * Returns a property that defines the state of the given worker. Once the worker is done the value of the * property will be set to true//from w w w . j a va2s .c o m * @param worker the worker * @return the property */ public static ReadOnlyBooleanProperty createIsDoneProperty(Worker<?> worker) { final BooleanProperty property = new SimpleBooleanProperty(); Consumer<Worker.State> stateChecker = (s) -> { if (s.equals(Worker.State.CANCELLED) || s.equals(Worker.State.FAILED) || s.equals(Worker.State.SUCCEEDED)) { property.setValue(true); } else { property.setValue(false); } }; worker.stateProperty().addListener((o, oldValue, newValue) -> stateChecker.accept(newValue)); stateChecker.accept(worker.getState()); return property; }
From source file:mesclasses.model.EleveData.java
public EleveData() { super();/* w w w .j a v a 2s .co m*/ this.id = "donnee_" + RandomStringUtils.randomAlphanumeric(10); date = new SimpleObjectProperty<>(); retard = new SimpleIntegerProperty(); absent = new SimpleBooleanProperty(); travailPasFait = new SimpleBooleanProperty(); devoir = new SimpleBooleanProperty(); motCarnet = new SimpleBooleanProperty(); motSigne = new SimpleBooleanProperty(); exclus = new SimpleBooleanProperty(); oubliMateriel = new SimpleStringProperty(); motif = new SimpleStringProperty(); }
From source file:com.rvantwisk.cnctools.operations.customgcode.GCodeTaskModel.java
public Object readResolve() { if (gCodeFile == null) { gCodeFile = new SimpleStringProperty(); }/*from w ww . j av a 2 s .c o m*/ if (referencedFile == null) { referencedFile = new SimpleBooleanProperty(); } return this; }
From source file:ijfx.core.batch.BatchService.java
public Boolean applyWorkflow(ProgressHandler progress, List<? extends BatchSingleInput> inputs, Workflow workflow) {/* ww w .j a v a 2 s. co m*/ final Timer t = timerService.getTimer("Workflow"); if (progress == null) { progress = new SilentProgressHandler(); } Boolean lock = new Boolean(true); if (workflow == null) { logger.warning("No workflow was provided"); return true; } int totalOps = inputs.size() * (2 + workflow.getStepList().size()); progress.setStatus("Starting batch processing..."); boolean success = true; BooleanProperty successProperty = new SimpleBooleanProperty(); Exception error = null; setRunning(true); BiConsumer<String, String> logTime = (step, msg) -> { t.elapsed(String.format("[%s][%s]%s", workflow.getName(), step, msg)); }; progress.setTotal(totalOps); for (int i = 0; i != inputs.size(); i++) { //inputs.parallelStream().forEach(input->{ logger.info("Running..."); final BatchSingleInput input = inputs.get(i); if (progress.isCancelled()) { progress.setStatus("Batch Processing cancelled"); success = false; //return; break; } t.start(); synchronized (lock) { logger.info("Loading input..."); progress.setStatus("Loading %s...", input.getName()); try { getContext().inject(input); } catch (IllegalStateException ise) { logger.warning("Context already injected"); } try { input.load(); } catch (Exception e) { logger.log(Level.SEVERE, "Couldn't load input", e); error = e; success = false; break; } logger.info("Input loaded"); } logTime.accept("loading", "done"); progress.increment(1); if (i < inputs.size() - 1) { // loading the next one while processing the current one BatchSingleInput next = inputs.get(i + 1); ImageJFX.getThreadPool().execute(() -> { synchronized (lock) { logger.info("Loading next input..."); next.load(); logger.info("Next input loaded."); } }); } for (WorkflowStep step : workflow.getStepList()) { logger.info("Executing step : " + step.getId()); String title; try { title = step.getModule().getInfo().getTitle(); progress.setStatus(String.format("Processing %s with %s", input.getName(), title)); } catch (NullPointerException e) { title = "???"; progress.setStatus("..."); } progress.increment(1); final Module module = moduleService.createModule(step.getModule().getInfo()); try { getContext().inject(module.getDelegateObject()); } catch (Exception e) { logger.warning("Context already injected in module ?"); } logTime.accept("injection", "done"); logger.info("Module created : " + module.getDelegateObject().getClass().getSimpleName()); if (!executeModule(input, module, step.getParameters())) { progress.setStatus("Error :-("); progress.setProgress(0, 1); success = false; logger.info("Error when executing module : " + module.getInfo().getName()); break; } ; logTime.accept(title, "done"); } if (success == false) { break; } synchronized (lock) { progress.setStatus("Saving %s...", input.getName()); input.save(); progress.increment(1); } logTime.accept("saving", "done"); input.dispose(); } if (success) { logger.info("Batch processing completed"); progress.setStatus("Batch processing completed."); progress.setProgress(1.0); } else if (progress.isCancelled()) { progress.setStatus("Batch processing cancelled"); } else { progress.setStatus("An error happend during the process."); progress.setProgress(1, 1); } setRunning(false); return success; }
From source file:csg.files.CSGFiles.java
@Override public void loadData(AppDataComponent data, AppDataComponent recData, AppDataComponent schData, AppDataComponent projectData, AppDataComponent courseData, String filePath) throws IOException { // CLEAR THE OLD DATA OUT TAData dataManager = (TAData) data;// ww w.j av a 2s . co m ScheduleData schDataManager = (ScheduleData) schData; RecitationData recDataManager = (RecitationData) recData; ProjectData projectDataManager = (ProjectData) projectData; CourseData courseDataManager = (CourseData) courseData; workspace = (CSGWorkspace) app.getWorkspaceComponent(); // LOAD THE JSON FILE WITH ALL THE DATA JsonObject json = loadJSONFile(filePath); // LOAD THE START AND END HOURS String startHour = json.getString(JSON_START_HOUR); String endHour = json.getString(JSON_END_HOUR); dataManager.initHours(startHour, endHour); // NOW RELOAD THE WORKSPACE WITH THE LOADED DATA app.getWorkspaceComponent().reloadWorkspace(app.getTADataComponent()); int startDay = json.getInt(JSON_STARTDAY); int startMonth = json.getInt(JSON_STARTMONTH); int startYear = json.getInt(JSON_STARTYEAR); courseDataManager.setStartDay(startDay); courseDataManager.setStartMonth(startMonth); courseDataManager.setStartYear(startYear); if (startDay != 0 && startMonth != 0 && startYear != 0) { LocalDate startDate = LocalDate.of(startYear, startMonth, startDay); workspace.getMonStartDatePicker().setValue(startDate); } else { workspace.getMonStartDatePicker().setValue(null); } int endDay = json.getInt(JSON_ENDDAY); int endMonth = json.getInt(JSON_ENDMONTH); int endYear = json.getInt(JSON_ENDYEAR); courseDataManager.setEndDay(endDay); courseDataManager.setEndMonth(endMonth); courseDataManager.setEndYear(endYear); if (endDay != 0 && endMonth != 0 && endYear != 0) { LocalDate endDate = LocalDate.of(endYear, endMonth, endDay); workspace.getFriEndDatePicker().setValue(endDate); } else { workspace.getFriEndDatePicker().setValue(null); } // NOW LOAD ALL THE UNDERGRAD TAs JsonArray jsonTAArray = json.getJsonArray(JSON_UNDERGRAD_TAS); for (int i = 0; i < jsonTAArray.size(); i++) { JsonObject jsonTA = jsonTAArray.getJsonObject(i); String name = jsonTA.getString(JSON_NAME); String email = jsonTA.getString(JSON_EMAIL); boolean ug = jsonTA.getBoolean(JSON_UG); BooleanProperty isUndergrad = new SimpleBooleanProperty(); isUndergrad.setValue(ug); dataManager.addTA(name, email, isUndergrad); } // AND THEN ALL THE OFFICE HOURS JsonArray jsonOfficeHoursArray = json.getJsonArray(JSON_OFFICE_HOURS); for (int i = 0; i < jsonOfficeHoursArray.size(); i++) { JsonObject jsonOfficeHours = jsonOfficeHoursArray.getJsonObject(i); String day = jsonOfficeHours.getString(JSON_DAY); String time = jsonOfficeHours.getString(JSON_TIME); String name = jsonOfficeHours.getString(JSON_NAME); dataManager.addOfficeHoursReservation(day, time, name); } JsonArray jsonRecitationArray = json.getJsonArray(JSON_RECITATION); for (int i = 0; i < jsonRecitationArray.size(); i++) { JsonObject jsonRec = jsonRecitationArray.getJsonObject(i); String section = jsonRec.getString(JSON_SECTION); String instructor = jsonRec.getString(JSON_INSTRUCTOR); String dayTime = jsonRec.getString(JSON_DAYTIME); String location = jsonRec.getString(JSON_LOCATION); String firstTA = jsonRec.getString(JSON_FIRSTTA); String secondTA = jsonRec.getString(JSON_SECONDTA); recDataManager.addRecitation(section, instructor, dayTime, location, firstTA, secondTA); } JsonArray jsonScheduleArray = json.getJsonArray(JSON_SCHEDULEITEM); for (int i = 0; i < jsonScheduleArray.size(); i++) { JsonObject jsonSch = jsonScheduleArray.getJsonObject(i); String type = jsonSch.getString(JSON_TYPE); int month = jsonSch.getInt(JSON_MONTH); int day = jsonSch.getInt(JSON_DAY); int year = jsonSch.getInt(JSON_YEAR); String time = jsonSch.getString(JSON_TIME); String title = jsonSch.getString(JSON_TITLE); String topic = jsonSch.getString(JSON_TOPIC); String link = jsonSch.getString(JSON_LINK); String criteria = jsonSch.getString(JSON_CRITERIA); schDataManager.addScheduleItem(type, LocalDate.of(year, month, day), time, title, topic, link, criteria); } JsonArray jsonTeamArray = json.getJsonArray(JSON_TEAMS); for (int i = 0; i < jsonTeamArray.size(); i++) { JsonObject jsonTeam = jsonTeamArray.getJsonObject(i); String name = jsonTeam.getString(JSON_NAME); String color = jsonTeam.getString(JSON_COLOR); String textColor = jsonTeam.getString(JSON_TEXTCOLOR); String link = jsonTeam.getString(JSON_LINK); projectDataManager.addTeam(name, color, textColor, link); } JsonArray jsonStudentArray = json.getJsonArray(JSON_STUDENTS); for (int i = 0; i < jsonStudentArray.size(); i++) { JsonObject jsonStudent = jsonStudentArray.getJsonObject(i); String firstName = jsonStudent.getString(JSON_FIRSTNAME); String lastName = jsonStudent.getString(JSON_LASTNAME); String team = jsonStudent.getString(JSON_TEAM); String role = jsonStudent.getString(JSON_ROLE); projectDataManager.addStudent(firstName, lastName, team, role); } JsonArray jsonTemplateArray = json.getJsonArray(JSON_COURSETEMPLATE); courseDataManager.getTemplates().clear(); for (int i = 0; i < jsonTemplateArray.size(); i++) { JsonObject jsonTemplate = jsonTemplateArray.getJsonObject(i); boolean use = jsonTemplate.getBoolean(JSON_USE); String navbar = jsonTemplate.getString(JSON_NAVBAR); String fileName = jsonTemplate.getString(JSON_FILENAME); String script = jsonTemplate.getString(JSON_SCRIPT); courseDataManager.addTemplate(use, navbar, fileName, script); } JsonObject courseJson = json.getJsonObject(JSON_COURSE); courseDataManager.setNumber(courseJson.getString(JSON_NUMBER)); courseDataManager.setSemester(courseJson.getString(JSON_SEMESTER)); courseDataManager.setSubject(courseJson.getString(JSON_SUBJECT)); courseDataManager.setYear(courseJson.getString(JSON_YEAR)); courseDataManager.setTitle(courseJson.getString(JSON_TITLE)); courseDataManager.setInsName(courseJson.getString(JSON_INSTRUCTORNAME)); courseDataManager.setInsHome(courseJson.getString(JSON_INSTRUCTORHOME)); courseDataManager.setBannerLink(courseJson.getString(JSON_BANNER)); courseDataManager.setLeftFooterLink(courseJson.getString(JSON_LEFTFOOTER)); courseDataManager.setRightFooterLink(courseJson.getString(JSON_RIGHTFOOTER)); courseDataManager.setTemplateDir(courseJson.getString(JSON_TEMPLATEDIR)); courseDataManager.setExportDir(courseJson.getString(JSON_EXPORTDIR)); courseDataManager.setStyleSheet(courseJson.getString(JSON_STYLESHEET)); workspace.getSubjectCombo().setValue(courseDataManager.getSubject()); workspace.getNumCombo().setValue(courseDataManager.getNumber()); workspace.getSemCombo().setValue(courseDataManager.getSemester()); workspace.getYearCombo().setValue(courseDataManager.getYear()); workspace.getTitleTextField().setText(courseDataManager.getTitle()); workspace.getInsNameTextField().setText(courseDataManager.getInsName()); workspace.getInsHomeTextField().setText(courseDataManager.getInsHome()); workspace.getStyleSheetCombo().setValue(courseDataManager.getStyleSheet()); if (!courseDataManager.getBannerLink().isEmpty()) { FileInputStream bannerLocation = new FileInputStream(courseJson.getString(JSON_BANNER)); Image newImg = new Image(bannerLocation); workspace.getBannerImage().setImage(newImg); } else { workspace.getBannerImage().setImage(null); } if (!courseDataManager.getLeftFooterLink().isEmpty()) { FileInputStream leftFooterLocation = new FileInputStream(courseJson.getString(JSON_LEFTFOOTER)); Image newImg2 = new Image(leftFooterLocation); workspace.getLeftFooterImage().setImage(newImg2); } else { workspace.getLeftFooterImage().setImage(null); } if (!courseDataManager.getRightFooterLink().isEmpty()) { FileInputStream rightFooterLocation = new FileInputStream(courseJson.getString(JSON_RIGHTFOOTER)); Image newImg3 = new Image(rightFooterLocation); workspace.getRightFooterImage().setImage(newImg3); } else { workspace.getRightFooterImage().setImage(null); } workspace.getCourseTemplateLocLabel().setText(courseJson.getString(JSON_TEMPLATEDIR)); workspace.getExportLabel().setText(courseJson.getString(JSON_EXPORTDIR)); }