List of usage examples for javafx.beans.property SimpleStringProperty SimpleStringProperty
public SimpleStringProperty(String initialValue)
From source file:aajavafx.CustomerMedicineController.java
@Override public void initialize(URL url, ResourceBundle rb) { //initialize columns idCustomer.setCellValueFactory(//w w w . j a v a 2 s . c om cellData -> new SimpleStringProperty("" + cellData.getValue().getCustomers().getCuId())); firstNameColumn.setCellValueFactory( cellData -> new SimpleStringProperty(cellData.getValue().getCustomers().getCuFirstname())); lastNameColumn.setCellValueFactory( cellData -> new SimpleStringProperty(cellData.getValue().getCustomers().getCuLastname())); doseColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().getMedDosage())); startColumn .setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().getMedStartDate())); schedColumn.setCellValueFactory( cellData -> new SimpleStringProperty("" + cellData.getValue().getMedicationintakeschedule())); medIdColumn.setCellValueFactory( cellData -> new SimpleStringProperty("" + cellData.getValue().getMedicines().getmedId())); medNameColumn.setCellValueFactory( cellData -> new SimpleStringProperty("" + cellData.getValue().getMedicines().getMedName())); volumeColumn.setCellValueFactory( cellData -> new SimpleStringProperty("" + cellData.getValue().getMedicines().getVolume())); medMeasurementUnitColumn.setCellValueFactory(cellData -> new SimpleStringProperty( "" + cellData.getValue().getMedicines().getMedMeasurementUnit())); dose.setEditable(false); startDate.setEditable(false); customerBox.setEditable(false); customerBox.setDisable(true); schedule.setEditable(false); try { //Populate table custTakeMedicines = getCustomersTakesMedicines(); tableCustomer.setItems(custTakeMedicines); customerBox.setItems(getCustomer()); customerBox.getItems().add("Add Customer"); medicinesBox.setItems(getMedicines()); medicinesBox.getItems().add("Add Medicine"); } catch (IOException ex) { Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex); } catch (JSONException ex) { Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex); } tableCustomer.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> { if (newSelection != null) { dose.setText(newSelection.getMedDosage()); startDate.setText(newSelection.getMedStartDate()); schedule.setText("" + newSelection.getMedicationintakeschedule()); customerBox.setValue(newSelection.getCustomers()); medicinesBox.setValue(newSelection.getMedicines()); } }); }
From source file:context.ui.control.tabular.TabularViewController.java
private void initialTableData() { data.loadTableData();//from w w w. j a v a 2 s .c o m // double minWidth = tableView.getWidth() / data.getHeaders().size(); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); int index = 0; for (String header : data.getHeaders()) { final int j = index; TableColumn tableColumn = new TableColumn(header); tableColumn.setComparator(new Comparator<String>() { @Override public int compare(String s1, String s2) { if (NumberUtils.isNumber(s1) && NumberUtils.isNumber(s2)) { return Double.compare(Double.parseDouble(s1), Double.parseDouble(s2)); } return Collator.getInstance().compare(s1, s2); } }); tableColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<List<String>, String>, ObservableValue<String>>() { public ObservableValue<String> call(TableColumn.CellDataFeatures<List<String>, String> p) { final String val = p.getValue().get(j); if (isRoundDoubles() && NumberUtils.isNumber(val) && val.contains(".")) { DecimalFormat df = new DecimalFormat("#.##"); Double d = Double.parseDouble(val); return new SimpleStringProperty(df.format(d)); } else { return new SimpleStringProperty(val); } } }); index++; tableView.getColumns().add(tableColumn); // if (index < data.getHeaders().size() - 1) { // tableColumn.setMinWidth(minWidth); // } // System.out.println("width=" + tableColumn.getMinWidth()); } System.out.println("columns Count:" + tableView.getColumns().size()); // which will make your table view dynamic // ObservableList<ObservableList> csvData = FXCollections.observableArrayList(); // // for (List<StringProperty> dataList : data.getRows()) { // ObservableList<String> row = FXCollections.observableArrayList(); // for (StringProperty rowData : dataList) { // row.add(rowData.get()); // } // csvData.add(row); // add each row to cvsData // } System.out.println("Rows Count=" + data.getRows().size()); tableView.setItems(data.getRows()); // finally add data to tableview System.out.println("after Rows Count=" + tableView.getItems().size()); }
From source file:com.QuarkLabs.BTCeClientJavaFX.PublicTradesController.java
@FXML void initialize() { assert publicTradesTable != null : "fx:id=\"publicTradesTable\" was not injected: check your FXML file 'markettrades.fxml'."; assert publicTradesTableAmountColumn != null : "fx:id=\"publicTradesTableAmountColumn\" was not injected: check your FXML file 'markettrades.fxml'."; assert publicTradesTableDateColumn != null : "fx:id=\"publicTradesTableDateColumn\" was not injected: check your FXML file 'markettrades.fxml'."; assert publicTradesTableItemColumn != null : "fx:id=\"publicTradesTableItemColumn\" was not injected: check your FXML file 'markettrades.fxml'."; assert publicTradesTablePriceColumn != null : "fx:id=\"publicTradesTablePriceColumn\" was not injected: check your FXML file 'markettrades.fxml'."; assert publicTradesTablePriceCurrencyColumn != null : "fx:id=\"publicTradesTablePriceCurrencyColumn\" was not injected: check your FXML file 'markettrades.fxml'."; assert publicTradesTableTIDColumn != null : "fx:id=\"publicTradesTableTIDColumn\" was not injected: check your FXML file 'markettrades.fxml'."; assert publicTradesTableTradeTypeColumn != null : "fx:id=\"publicTradesTableTradeTypeColumn\" was not injected: check your FXML file 'markettrades.fxml'."; publicTradesTable.setItems(publicTrades); publicTradesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); publicTradesTableAmountColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Double>("amount")); publicTradesTableDateColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<PublicTrade, String>, ObservableValue<String>>() { @Override//w w w.ja v a 2 s.c o m public ObservableValue<String> call( TableColumn.CellDataFeatures<PublicTrade, String> publicTradeStringCellDataFeatures) { PublicTrade publicTrade = publicTradeStringCellDataFeatures.getValue(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(publicTrade.getDate() * 1000); DateFormat dateFormat = DateFormat.getDateTimeInstance(); return new SimpleStringProperty(dateFormat.format(calendar.getTime())); } }); publicTradesTableItemColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("item")); publicTradesTablePriceColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Double>("price")); publicTradesTablePriceCurrencyColumn .setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("priceCurrency")); publicTradesTableTIDColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Long>("tid")); publicTradesTableTradeTypeColumn .setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("tradeType")); Task<JSONArray> loadPublicTrades = new Task<JSONArray>() { @Override protected JSONArray call() throws Exception { return App.getPublicTrades(pair); } }; loadPublicTrades.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { JSONArray jsonArray = (JSONArray) workerStateEvent.getSource().getValue(); publicTrades.clear(); for (int i = 0; i < jsonArray.length(); i++) { JSONObject item = jsonArray.getJSONObject(i); PublicTrade publicTrade = new PublicTrade(); publicTrade.setDate(item.getLong("date")); publicTrade.setAmount(item.getDouble("amount")); publicTrade.setItem(item.getString("item")); publicTrade.setPrice(item.getDouble("price")); publicTrade.setPriceCurrency(item.getString("price_currency")); publicTrade.setTid(item.getLong("tid")); publicTrade.setTradeType(item.getString("trade_type")); publicTrades.add(publicTrade); } } }); Thread thread = new Thread(loadPublicTrades); thread.start(); }
From source file:org.sleuthkit.autopsy.imagegallery.gui.MetaDataPane.java
@FXML void initialize() { assert attributeColumn != null : "fx:id=\"attributeColumn\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert imageView != null : "fx:id=\"imageView\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert tableView != null : "fx:id=\"tableView\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert valueColumn != null : "fx:id=\"valueColumn\" was not injected: check your FXML file 'MetaDataPane.fxml'."; TagUtils.registerListener(this); ImageGalleryController.getDefault().getCategoryManager().registerListener(this); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tableView.setPlaceholder(new Label("Select a file to show its details here.")); attributeColumn.setCellValueFactory((param) -> new SimpleObjectProperty<>(param.getValue().getKey())); attributeColumn.setCellFactory(/*from w w w . j a v a2 s.com*/ (param) -> new TableCell<Pair<DrawableAttribute<?>, ? extends Object>, DrawableAttribute<?>>() { @Override protected void updateItem(DrawableAttribute<?> item, boolean empty) { super.updateItem(item, empty); //To change body of generated methods, choose Tools | Templates. if (item != null) { setText(item.getDisplayName()); setGraphic(new ImageView(item.getIcon())); } else { setGraphic(null); setText(null); } } }); attributeColumn.setPrefWidth(USE_COMPUTED_SIZE); valueColumn.setCellValueFactory((p) -> { if (p.getValue().getKey() == DrawableAttribute.TAGS) { return new SimpleStringProperty( ((Collection<TagName>) p.getValue().getValue()).stream().map(TagName::getDisplayName) .filter((String t) -> t.startsWith(Category.CATEGORY_PREFIX) == false) .collect(Collectors.joining(" ; ", "", ""))); } else { return new SimpleStringProperty(StringUtils.join((Iterable<?>) p.getValue().getValue(), " ; ")); } }); valueColumn.setPrefWidth(USE_COMPUTED_SIZE); valueColumn.setCellFactory((p) -> new TableCell<Pair<DrawableAttribute<?>, ? extends Object>, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { Text text = new Text(item); text.wrappingWidthProperty().bind(getTableColumn().widthProperty()); setGraphic(text); } else { setGraphic(null); } } }); tableView.getColumns().setAll(Arrays.asList(attributeColumn, valueColumn)); //listen for selection change controller.getSelectionModel().lastSelectedProperty().addListener((observable, oldFileID, newFileID) -> { setFile(newFileID); }); // MetaDataPane.this.visibleProperty().bind(controller.getMetaDataCollapsed().not()); // MetaDataPane.this.managedProperty().bind(controller.getMetaDataCollapsed().not()); }
From source file:pl.betoncraft.betonquest.editor.model.QuestPackage.java
/** * Loads a package using a hashmap containing all data. The key is a file * name, the value is a hashmap containing keys and values of that YAML * file.//from w w w. j a va 2 s . com * * @param map */ public QuestPackage(PackageSet set, String id, HashMap<String, LinkedHashMap<String, String>> data) { this.set = set; packName = new SimpleStringProperty(id); try { // handling journal.yml HashMap<String, String> journalMap = data.get("journal"); if (journalMap != null) { int journalIndex = 0; for (Entry<String, String> entry : journalMap.entrySet()) { String value = entry.getValue(); String[] parts = entry.getKey().split("\\."); // getting the right entry JournalEntry journalEntry = newByID(parts[0], name -> new JournalEntry(this, name)); if (journalEntry.getIndex() < 0) journalEntry.setIndex(journalIndex++); // handling entry data if (parts.length > 1) { String lang = parts[1]; if (!languages.containsKey(lang)) { languages.put(lang, 1); } else { languages.put(lang, languages.get(lang) + 1); } journalEntry.getText().addLang(lang, value); } else { journalEntry.getText().setDef(value); } } } // handling items.yml HashMap<String, String> itemsMap = data.get("items"); if (itemsMap != null) { int itemIndex = 0; for (String key : itemsMap.keySet()) { Item item = newByID(key, name -> new Item(this, name)); item.getInstruction().set(itemsMap.get(key)); if (item.getIndex() < 0) item.setIndex(itemIndex++); } } // handling conditions.yml HashMap<String, String> conditionsMap = data.get("conditions"); if (conditionsMap != null) { int conditionIndex = 0; for (String key : conditionsMap.keySet()) { Condition condition = newByID(key, name -> new Condition(this, name)); condition.getInstruction().set(conditionsMap.get(key)); if (condition.getIndex() < 0) condition.setIndex(conditionIndex++); } } // handling event.yml HashMap<String, String> eventsMap = data.get("events"); if (eventsMap != null) { int eventIndex = 0; for (String key : eventsMap.keySet()) { Event event = newByID(key, name -> new Event(this, name)); event.getInstruction().set(eventsMap.get(key)); if (event.getIndex() < 0) event.setIndex(eventIndex++); } } // handling objectives.yml HashMap<String, String> objectivesMap = data.get("objectives"); if (objectivesMap != null) { int objectiveIndex = 0; for (String key : objectivesMap.keySet()) { Objective objective = newByID(key, name -> new Objective(this, name)); objective.getInstruction().set(objectivesMap.get(key)); if (objective.getIndex() < 0) objective.setIndex(objectiveIndex++); } } // handling conversations/ int convIndex = 0; for (Entry<String, LinkedHashMap<String, String>> entry : data.entrySet()) { String key = entry.getKey(); HashMap<String, String> value = entry.getValue(); if (key.startsWith("conversations.")) { HashMap<String, String> convData = value; String convName = key.substring(14); Conversation conv = newByID(convName, name -> new Conversation(this, name)); if (conv.getIndex() < 0) conv.setIndex(convIndex++); int playerIndex = 0; int npcIndex = 0; // handling conversation.yml for (Entry<String, String> subEntry : convData.entrySet()) { String subKey = subEntry.getKey(); String subValue = subEntry.getValue(); // reading NPC name, optionally in multiple languages if (subKey.equals("quester")) { conv.getNPC().setDef(subValue); } else if (subKey.startsWith("quester.")) { String lang = subKey.substring(8); if (!languages.containsKey(lang)) { languages.put(lang, 1); } else { languages.put(lang, languages.get(lang) + 1); } conv.getNPC().addLang(lang, subValue); } // reading the stop option else if (subKey.equals("stop")) { conv.getStop().set(subValue.equalsIgnoreCase("true")); } // reading starting options else if (subKey.equals("first")) { String[] pointerNames = subValue.split(","); ArrayList<IdWrapper<NpcOption>> options = new ArrayList<>(pointerNames.length); for (int i = 0; i < pointerNames.length; i++) { IdWrapper<NpcOption> startingOption = new IdWrapper<>(this, conv.newNpcOption(pointerNames[i].trim())); options.add(i, startingOption); startingOption.setIndex(i); } conv.getStartingOptions().addAll(options); } // reading final events else if (subKey.equals("final")) { String[] eventNames = subValue.split(","); ArrayList<IdWrapper<Event>> events = new ArrayList<>(eventNames.length); for (int i = 0; i < eventNames.length; i++) { IdWrapper<Event> finalEvent = new IdWrapper<>(this, newByID(eventNames[i].trim(), name -> new Event(this, name))); events.add(i, finalEvent); finalEvent.setIndex(i); } conv.getFinalEvents().addAll(events); } // reading NPC options else if (subKey.startsWith("NPC_options.")) { String[] parts = subKey.split("\\."); if (parts.length > 1) { String optionName = parts[1]; // resolving an option NpcOption option = conv.newNpcOption(optionName); if (option.getIndex() < 0) option.setIndex(npcIndex++); if (parts.length > 2) { // getting specific values switch (parts[2]) { case "text": if (parts.length > 3) { String lang = parts[3]; if (!languages.containsKey(lang)) { languages.put(lang, 1); } else { languages.put(lang, languages.get(lang) + 1); } option.getText().addLang(lang, subValue); } else { option.getText().setDef(subValue); } break; case "event": case "events": String[] eventNames = subValue.split(","); ArrayList<IdWrapper<Event>> events = new ArrayList<>(eventNames.length); for (int i = 0; i < eventNames.length; i++) { IdWrapper<Event> event = new IdWrapper<>(this, newByID(eventNames[i].trim(), name -> new Event(this, name))); events.add(i, event); event.setIndex(i); } option.getEvents().addAll(events); break; case "condition": case "conditions": String[] conditionNames = subValue.split(","); ArrayList<ConditionWrapper> conditions = new ArrayList<>( conditionNames.length); for (int i = 0; i < conditionNames.length; i++) { String name = conditionNames[i].trim(); boolean negated = false; while (name.startsWith("!")) { name = name.substring(1, name.length()); negated = true; } ConditionWrapper condition = new ConditionWrapper(this, newByID(name, idString -> new Condition(this, idString))); condition.setNegated(negated); conditions.add(i, condition); condition.setIndex(i); } option.getConditions().addAll(conditions); break; case "pointer": case "pointers": String[] pointerNames = subValue.split(","); ArrayList<IdWrapper<ConversationOption>> options = new ArrayList<>( pointerNames.length); for (int i = 0; i < pointerNames.length; i++) { IdWrapper<ConversationOption> pointer = new IdWrapper<>(this, conv.newPlayerOption(pointerNames[i].trim())); options.add(i, pointer); pointer.setIndex(i); } option.getPointers().addAll(options); break; } } } } // reading player options else if (subKey.startsWith("player_options.")) { String[] parts = subKey.split("\\."); if (parts.length > 1) { String optionName = parts[1]; // resolving an option PlayerOption option = conv.newPlayerOption(optionName); if (option.getIndex() < 0) { option.setIndex(playerIndex++); } if (parts.length > 2) { // getting specific values switch (parts[2]) { case "text": if (parts.length > 3) { String lang = parts[3]; if (!languages.containsKey(lang)) { languages.put(lang, 1); } else { languages.put(lang, languages.get(lang) + 1); } option.getText().addLang(lang, subValue); } else { option.getText().setDef(subValue); } break; case "event": case "events": String[] eventNames = subValue.split(","); ArrayList<IdWrapper<Event>> events = new ArrayList<>(eventNames.length); for (int i = 0; i < eventNames.length; i++) { IdWrapper<Event> event = new IdWrapper<>(this, newByID(eventNames[i].trim(), name -> new Event(this, name))); events.add(i, event); event.setIndex(i); } option.getEvents().addAll(events); break; case "condition": case "conditions": String[] conditionNames = subValue.split(","); ArrayList<ConditionWrapper> conditions = new ArrayList<>( conditionNames.length); for (int i = 0; i < conditionNames.length; i++) { String name = conditionNames[i].trim(); boolean negated = false; while (name.startsWith("!")) { name = name.substring(1, name.length()); negated = true; } ConditionWrapper condition = new ConditionWrapper(this, newByID(name, idString -> new Condition(this, idString))); condition.setNegated(negated); conditions.add(i, condition); condition.setIndex(i); } option.getConditions().addAll(conditions); break; case "pointer": case "pointers": String[] pointerNames = subValue.split(","); ArrayList<IdWrapper<ConversationOption>> options = new ArrayList<>( pointerNames.length); for (int i = 0; i < pointerNames.length; i++) { IdWrapper<ConversationOption> pointer = new IdWrapper<>(this, conv.newNpcOption(pointerNames[i].trim())); options.add(i, pointer); pointer.setIndex(i); } option.getPointers().addAll(options); break; } } } } } } } // handling main.yml LinkedHashMap<String, String> config = data.get("main"); for (Entry<String, String> entry : config.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); // handling variables if (key.startsWith("variables.")) { variables.add(new GlobalVariable(this, key.substring(10), value)); } // handling global locations else if (key.startsWith("global_locations")) { for (String globLoc : value.split(",")) { locations.add(new GlobalLocation(newByID(globLoc, name -> new Objective(this, name)))); } } // handling static events else if (key.startsWith("static_events.")) { StaticEvent staticEvent = new StaticEvent(this, key.substring(14)); staticEvent.getEvent().set(newByID(value, name -> new Event(this, name))); staticEvents.add(staticEvent); } // handling NPC-conversation bindings else if (key.startsWith("npcs.")) { npcBindings.add(new NpcBinding(this, key.substring(5), newByID(value, name -> new Conversation(this, name)))); } // handling quest cancelers else if (key.startsWith("cancel.")) { String[] parts = key.split("\\."); if (parts.length > 1) { // getting the right canceler or creating new one QuestCanceler canceler = newByID(parts[1], name -> new QuestCanceler(this, name)); // handling canceler properties if (parts.length > 2) { switch (parts[2]) { case "name": if (parts.length > 3) { String lang = parts[3]; if (!languages.containsKey(lang)) { languages.put(lang, 1); } else { languages.put(lang, languages.get(lang) + 1); } canceler.getName().addLang(lang, value); } else { canceler.getName().setDef(value); } break; case "events": String[] eventNames = value.split(","); ArrayList<IdWrapper<Event>> events = new ArrayList<>(eventNames.length); for (int i = 0; i < eventNames.length; i++) { IdWrapper<Event> event = new IdWrapper<>(this, newByID(eventNames[i].trim(), name -> new Event(this, name))); events.add(i, event); event.setIndex(i); } canceler.getEvents().addAll(events); break; case "conditions": String[] conditionNames = value.split(","); ArrayList<ConditionWrapper> conditions = new ArrayList<>(conditionNames.length); for (int i = 0; i < conditionNames.length; i++) { String name = conditionNames[i].trim(); boolean negated = false; while (name.startsWith("!")) { name = name.substring(1, name.length()); negated = true; } ConditionWrapper condition = new ConditionWrapper(this, newByID(name, idString -> new Condition(this, idString))); condition.setNegated(negated); conditions.add(i, condition); condition.setIndex(i); } canceler.getConditions().addAll(conditions); break; case "objectives": String[] objectiveNames = value.split(","); ArrayList<IdWrapper<Objective>> objectives = new ArrayList<>(objectiveNames.length); for (int i = 0; i < objectiveNames.length; i++) { IdWrapper<Objective> wrapper = new IdWrapper<>(this, newByID(objectiveNames[i].trim(), name -> new Objective(this, name))); objectives.add(i, wrapper); wrapper.setIndex(i); } canceler.getObjectives().addAll(objectives); break; case "tags": String[] tagNames = value.split(","); ArrayList<IdWrapper<Tag>> tags = new ArrayList<>(tagNames.length); for (int i = 0; i < tagNames.length; i++) { IdWrapper<Tag> wrapper = new IdWrapper<>(this, newByID(tagNames[i].trim(), name -> new Tag(this, name))); tags.add(i, wrapper); wrapper.setIndex(i); } canceler.getTags().addAll(tags); break; case "points": String[] pointNames = value.split(","); ArrayList<IdWrapper<PointCategory>> points = new ArrayList<>(pointNames.length); for (int i = 0; i < pointNames.length; i++) { IdWrapper<PointCategory> wrapper = new IdWrapper<>(this, newByID(pointNames[i].trim(), name -> new PointCategory(this, name))); points.add(i, wrapper); wrapper.setIndex(i); } canceler.getPoints().addAll(points); break; case "journal": String[] journalNames = value.split(","); ArrayList<IdWrapper<JournalEntry>> journal = new ArrayList<>(journalNames.length); for (int i = 0; i < journalNames.length; i++) { IdWrapper<JournalEntry> wrapper = new IdWrapper<>(this, newByID(journalNames[i].trim(), name -> new JournalEntry(this, name))); journal.add(i, wrapper); wrapper.setIndex(i); } canceler.getJournal().addAll(journal); break; case "loc": canceler.setLocation(value); break; } } } } // handling journal main page else if (key.startsWith("journal_main_page")) { String[] parts = key.split("\\."); if (parts.length > 1) { MainPageLine line = newByID(parts[1], name -> new MainPageLine(this, name)); if (parts.length > 2) { switch (parts[2]) { case "text": if (parts.length > 3) { String lang = parts[3]; if (!languages.containsKey(lang)) { languages.put(lang, 1); } else { languages.put(lang, languages.get(lang) + 1); } line.getText().addLang(lang, value); } else { line.getText().setDef(value); } break; case "priority": try { line.getPriority().set(Integer.parseInt(value)); } catch (NumberFormatException e) { // TODO error, need a number } break; case "conditions": String[] conditionNames = value.split(","); ArrayList<ConditionWrapper> conditions = new ArrayList<>(conditionNames.length); for (int i = 0; i < conditionNames.length; i++) { String name = conditionNames[i].trim(); boolean negated = false; while (name.startsWith("!")) { name = name.substring(1, name.length()); negated = true; } ConditionWrapper condition = new ConditionWrapper(this, newByID(name, idString -> new Condition(this, idString))); condition.setNegated(negated); conditions.add(i, condition); condition.setIndex(i); } line.getConditions().addAll(conditions); break; } } } } // handling default language else if (key.equalsIgnoreCase("default_language")) { defLang = value; } } // check which language is used most widely and set it as default if (defLang == null) { int max = 0; String maxLang = null; for (Entry<String, Integer> entry : languages.entrySet()) { if (entry.getValue() > max) { max = entry.getValue(); maxLang = entry.getKey(); } } defLang = maxLang; } } catch (Exception e) { ExceptionController.display(e); } }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.MetaDataPane.java
@FXML void initialize() { assert attributeColumn != null : "fx:id=\"attributeColumn\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert imageView != null : "fx:id=\"imageView\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert tableView != null : "fx:id=\"tableView\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert valueColumn != null : "fx:id=\"valueColumn\" was not injected: check your FXML file 'MetaDataPane.fxml'."; TagUtils.registerListener(this); Category.registerListener(this); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tableView.setPlaceholder(new Label("Select a file to show its details here.")); attributeColumn.setCellValueFactory((param) -> new SimpleObjectProperty<>(param.getValue().getKey())); attributeColumn.setCellFactory(//from ww w . j a v a 2s . c o m (param) -> new TableCell<Pair<DrawableAttribute<?>, ? extends Object>, DrawableAttribute<?>>() { @Override protected void updateItem(DrawableAttribute<?> item, boolean empty) { super.updateItem(item, empty); //To change body of generated methods, choose Tools | Templates. if (item != null) { setText(item.getDisplayName()); setGraphic(new ImageView(item.getIcon())); } else { setGraphic(null); setText(null); } } }); attributeColumn.setPrefWidth(USE_COMPUTED_SIZE); valueColumn.setCellValueFactory((p) -> { if (p.getValue().getKey() == DrawableAttribute.TAGS) { return new SimpleStringProperty( ((Collection<TagName>) p.getValue().getValue()).stream().map(TagName::getDisplayName) .filter((String t) -> t.startsWith(Category.CATEGORY_PREFIX) == false) .collect(Collectors.joining(" ; ", "", ""))); } else { return new SimpleStringProperty(StringUtils.join((Collection<?>) p.getValue().getValue(), " ; ")); } }); valueColumn.setPrefWidth(USE_COMPUTED_SIZE); valueColumn.setCellFactory((p) -> new TableCell<Pair<DrawableAttribute<?>, ? extends Object>, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { Text text = new Text(item); text.wrappingWidthProperty().bind(getTableColumn().widthProperty()); setGraphic(text); } else { setGraphic(null); } } }); tableView.getColumns().setAll(Arrays.asList(attributeColumn, valueColumn)); //listen for selection change controller.getSelectionModel().lastSelectedProperty().addListener((observable, oldFileID, newFileID) -> { setFile(newFileID); }); // MetaDataPane.this.visibleProperty().bind(controller.getMetaDataCollapsed().not()); // MetaDataPane.this.managedProperty().bind(controller.getMetaDataCollapsed().not()); }
From source file:context.ui.control.codebooknetwork.CodebookNetworkController.java
/** * * @param event//from w w w. j av a2 s . c om */ @Override public void handleStep3RunButton(ActionEvent event) { if (!this.validateInputOutput()) { return; } CodebookApplicationTaskInstance instance = (CodebookApplicationTaskInstance) getTaskInstance(); CodebookNetworkConfigurationController confController = (CodebookNetworkConfigurationController) configurationController; StringProperty inputPath = basicInputViewController.getSelectedItemLabel().textProperty(); StringProperty inputname = basicInputViewController.getSelectedCorpusName(); CorpusData input = new CorpusData(inputname, inputPath); instance.setInput(input); final StringProperty outputPath = basicOutputViewController.getOutputDirTextField().textProperty(); final String subdirectory = outputPath.get() + "/CB-Results/"; FileHandler.createDirectory(subdirectory); System.out.println("Created sub dir: " + subdirectory); FileList output = new FileList(NamingPolicy.generateOutputName(inputname.get(), outputPath.get(), instance), subdirectory); instance.setTextOutput(output); StringProperty tabularName = NamingPolicy.generateTabularName(inputname.get(), outputPath.get(), instance); StringProperty csvTabularPath = NamingPolicy.generateTabularPath(inputname.get(), outputPath.get(), instance); StringProperty gexfTabularPath = NamingPolicy.generateTabularPath(inputname.get(), outputPath.get(), instance, ".gexf"); csvTabularPath.set(FilenameUtils.getFullPath(csvTabularPath.get()) + "CorpusNetwork.csv"); gexfTabularPath.set(FilenameUtils.getFullPath(gexfTabularPath.get()) + "CorpusNetwork.gexf"); System.out.println("CSV Path: " + csvTabularPath.get() + "\nGexF Path: " + gexfTabularPath.get()); List<TabularData> td = new ArrayList<TabularData>(); td.add(0, new TabularData(tabularName, csvTabularPath)); td.add(1, new TabularData(new SimpleStringProperty(tabularName.get() + "-gexf"), gexfTabularPath)); instance.setTabularOutput(td); instance.setCodebookFile(confController.getCodebookFile()); instance.setDistance(confController.getDistance()); instance.setIsDrop(confController.getCodebookMode()); instance.setIsNormal(confController.getCodebookMethod()); if (confController.getAggregationType() == 0) { // per document instance.setNetInputCorpus(false); } else { //per corpus instance.setNetInputCorpus(true); } instance.setNetOutputCSV(true); instance.setNetOutputGEXF(true); instance.setNetOutputType(confController.getNetworkType()); instance.setNetwork(true); instance.setSeparator(confController.getUnitOfAnalysis()); instance.setCustomTag(confController.getCustomTag()); CTask task = new CodebookApplicationTask(this.getProgress(), this.getProgressMessage()); task.setTaskInstance(instance); task.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent t) { activeAllControls(); nextStepsViewController = new CodebookNetworkNextStepsController( NamingPolicy.generateTaskName(CodebookApplicationTaskInstance.class).get()); nextStepsViewController.setParent(CodebookNetworkController.this); nextStepsViewController.setOutputDir(outputPath.get()); nextStepsViewController.setTabular(getTaskInstance().getTabularOutput(0)); nextStepsViewController.setFilelist((FileList) getTaskInstance().getTextOutput()); nextStepsViewController.init(); ProjectManager.getThisProject().addResult(getTaskInstance().getTabularOutput(0)); ProjectManager.getThisProject().addData(getTaskInstance().getTextOutput()); // ProjectManager.getThisProject().addResult(getTaskInstance().getTabularOutput(1)); if (isNew()) { ProjectManager.getThisProject().addTask(getTaskInstance()); setNew(false); } showNextStepPane(nextStepsViewController); } }); getProgressBar().setVisible(true); deactiveAllControls(); task.start(); setTaskInstance(task.getTaskInstance()); }
From source file:org.opendolphin.mvndemo.clientlazy.DemoController.java
private void createTableLazy(List<Map> data) { //Tabellen Spalten wieder sortieren. SortedMap<Integer, String> ms = new TreeMap<>(data.get(0)); colNames = ms.values().toArray(colNames); // Model Listener initLazyModle(colNames);/*from w ww. ja va 2 s. co m*/ DemoApp.clientDolphin.addModelStoreListener(TYPE_LAZY, new ModelStoreListener() { @Override public void modelStoreChanged(ModelStoreEvent event) { PresentationModel pm = event.getPresentationModel(); used.setValue(used.get() + 1); unused.setValue(lazyRows.size() - used.get()); // int i = 0; for (Map<String, SimpleStringProperty> m : lazyModel) { String v = null; Attribute atr = pm.getAt(colNames[i]); if (atr != null) { v = (String) atr.getValue(); } m.get(pm.getId()).setValue(v); i++; } } }); //Create table columns TableColumn<Integer, String> tableColID = new TableColumn<>("rowID"); tableColID.setSortable(true); tableColID.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<Integer, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<Integer, String> cellDataFeature) { return new SimpleStringProperty(cellDataFeature.getValue().toString()); } }); tableLazy.getColumns().add(tableColID); for (int i = 0; i < colNames.length; i++) { TableColumn<Integer, String> tableCol = new TableColumn<>(colNames[i]); tableCol.setSortable(false); tableLazy.getColumns().add(tableCol); final int index = i; tableCol.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<Integer, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<Integer, String> cellDataFeature) { String lazyId = cellDataFeature.getValue().toString(); SimpleStringProperty placeholder = lazyModel.get(index).get(lazyId); if ("...".equals(placeholder.getValue())) { DemoApp.clientDolphin.getClientModelStore().withPresentationModel(lazyId, (pm) -> { /*NOP*/ }); // Wrong Way // GetPresentationModelCommand pmc = new GetPresentationModelCommand(); // pmc.setPmId(lazyId); // MonitorApp.clientDolphin.getClientConnector().send(pmc); } return placeholder; } }); } // tableLazy.setItems(lazyRows); }
From source file:edu.kit.trufflehog.model.configdata.SettingsDataModelTest.java
/** * <p>/*from w ww . ja va 2 s . c om*/ * Checks if the retrieved values match the expected values and changes some of the values, and then checks if * the file was updated by changing the value back to the original value. * </p> * * @param classType The class of the value * @param key The key of the value * @param oldValue The starting value to check against * @param newValue The new value to check against after is has been set * @throws Exception Passes any errors that occurred during the test on */ private void testGetEntrySuccess(Class classType, String key, String oldValue, String newValue) throws Exception { settingsDataModel = new SettingsDataModel(fileSystem); StringProperty property1 = settingsDataModel.get(classType, key); assertEquals(true, property1.getValue().equals(oldValue)); StringProperty property2 = new SimpleStringProperty(property1.getValue()); property1.bindBidirectional(property2); property2.setValue(newValue); Thread.sleep(1000); // sleep because the saving to file happens in another thread settingsDataModel = new SettingsDataModel(fileSystem); property1 = settingsDataModel.get(classType, key); assertEquals(true, property1.getValue().equals(newValue)); property1.setValue(oldValue); Thread.sleep(1000); // sleep because the saving to file happens in another thread settingsDataModel = new SettingsDataModel(fileSystem); property1 = settingsDataModel.get(classType, key); assertEquals(true, property1.getValue().equals(oldValue)); }