List of usage examples for javafx.beans.property ReadOnlyStringWrapper ReadOnlyStringWrapper
public ReadOnlyStringWrapper(String initialValue)
From source file:org.beryx.viewreka.fxapp.BundleChooser.java
@SuppressWarnings("deprecation") @Override// w w w. ja v a 2 s . c om public void initialize(URL location, ResourceBundle resources) { check("ttvBundles", ttvBundles); check("ttColName", ttColName); check("ttColVersion", ttColVersion); check("ttColId", ttColId); check("ttColDescription", ttColDescription); ttvBundles.getColumns().forEach(col -> col.impl_setReorderable(false)); CatalogManager catalogManager = new CatalogManager(guiSettingsManager.getSettings()); Map<String, Map<Pair<String, Version>, BundleInfo>> categoryMap = new TreeMap<>(); catalogManager.getCatalogUrls().forEach(url -> { CatalogRepo repo = new CatalogRepo(url, catalogManager.getCatalogCache()); List<BundleInfo> infoEntries = Collections.emptyList(); try { infoEntries = repo.getEntries(); } catch (Exception e) { Dialogs.error("Cannot read from repository " + repo.getCatalogUrl(), e.getMessage(), e); } infoEntries.forEach(entry -> entry.getCategories().forEach(category -> { Map<Pair<String, Version>, BundleInfo> idMap = categoryMap.get(category); if (idMap == null) { idMap = new TreeMap<>(); categoryMap.put(category, idMap); } String bundleId = entry.getId(); Version version = entry.getVersion(); Pair<String, Version> infoPair = new ImmutablePair<>(bundleId, version); BundleInfo oldEntry = idMap.get(infoPair); if (oldEntry == null) { idMap.put(infoPair, entry); } else if (entry.getUrl().equals(oldEntry.getUrl())) { log.warn("Different URLs for " + entry.getName() + " " + version + ": " + entry.getUrl() + " and " + oldEntry.getUrl()); } })); }); ttvBundles.setRowFactory(item -> new BundleInfoTreeTableRow()); ttColName.setCellFactory(p -> new BundleInfoNameTreeTableCell<>()); ttColName.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getValue())); ttColVersion.setCellValueFactory( param -> new ReadOnlyStringWrapper(param.getValue().getValue().getVersion().toString())); ttColId.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getValue().getId())); ttColDescription.setCellValueFactory( param -> new ReadOnlyStringWrapper(param.getValue().getValue().getDescription())); TreeItem<BundleInfo> root = new TreeItem<>(new NullBundleInfo("Bundles")); root.setExpanded(true); ttvBundles.setRoot(root); ttvBundles.setShowRoot(false); categoryMap.entrySet().forEach(categoryEntry -> { String category = categoryEntry.getKey(); TreeItem<BundleInfo> categoryItem = new TreeItem<>(new NullBundleInfo(category)); categoryItem.setExpanded(true); root.getChildren().add(categoryItem); List<BundleInfo> bInfo = new ArrayList<>(categoryEntry.getValue().values()); bInfo.sort((b1, b2) -> { int res = b1.getName().compareTo(b2.getName()); if (res == 0) { res = b1.getVersion().compareTo(b2.getVersion()); } return res; }); bInfo.forEach(bundleInfo -> { boolean existing = existingBundles.stream() .anyMatch(pair -> bundleInfo.getId().equals(pair.getKey()) && bundleInfo.getVersion().equals(pair.getValue())); BundleInfoTreeItem bundleItem = new BundleInfoTreeItem(bundleInfo, existing); bundleItem.setIndependent(true); Pair<String, Version> infoPair = new ImmutablePair<>(bundleInfo.getId(), bundleInfo.getVersion()); bundleItem.setSelected(initialInfoEntries.stream().anyMatch( entry -> new ImmutablePair<>(entry.getId(), entry.getVersion()).equals(infoPair))); bundleItem.selectedProperty() .addListener((obs, oldVal, newVal) -> updateSelection(bundleInfo, newVal)); categoryItem.getChildren().add(bundleItem); }); }); }
From source file:org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableAttribute.java
private DrawableAttribute(AttributeName name, String displayName, Boolean isDBColumn, String imageName, Function<DrawableFile<?>, Collection<T>> extractor) { this.attrName = name; this.displayName = new ReadOnlyStringWrapper(displayName); this.isDBColumn = isDBColumn; this.imageName = imageName; this.extractor = extractor; }
From source file:spdxedit.PackageEditor.java
@FXML private void initialize() { assert tabFiles != null : "fx:id=\"tabFiles\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert tabPackageProperties != null : "fx:id=\"tabPackageProperties\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert tabExternalRefs != null : "fx:id=\"tabExternalRefs\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert filesTable != null : "fx:id=\"filesTable\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert tblColumnFile != null : "fx:id=\"tblColumnFile\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert chkListFileTypes != null : "fx:id=\"chkListFileTypes\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert tabRelationships != null : "fx:id=\"tabRelationships\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert btnOk != null : "fx:id=\"btnOk\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert btnDeleteFileFromPackage != null : "fx:id=\"btnDeleteFileFromPackage\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert btnAddFile != null : "fx:id=\"btnAddFile\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert btnCopyright != null : "fx:id=\"btnCopyright\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert btnFileLicense != null : "fx:id=\"btnFileLicense\" was not injected: check your FXML file 'PackageEditor.fxml'."; //File relationship checkboxes assert chkDataFile != null : "fx:id=\"chkDataFile\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert chkTestCase != null : "fx:id=\"chkTestCase\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert chkDocumentation != null : "fx:id=\"chkDocumentation\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert chkOptionalComponent != null : "fx:id=\"chkOptionalComponent\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert chkMetafile != null : "fx:id=\"chkMetafile\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert chkBuildTool != null : "fx:id=\"chkBuildTool\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert chkExcludeFile != null : "fx:id=\"chkExcludeFile\" was not injected: check your FXML file 'PackageEditor.fxml'."; //Initialise file relationship checkbox handling //TODO: Could make this easier by extending the CheckBox control? chkDataFile.selectedProperty().addListener((observable, oldValue, newValue) -> addOrRemoveFileRelationshipToPackage(RelationshipType.DATA_FILE_OF, newValue)); chkTestCase.selectedProperty().addListener((observable, oldValue, newValue) -> addOrRemoveFileRelationshipToPackage(RelationshipType.TEST_CASE_OF, newValue)); chkDocumentation.selectedProperty().addListener((observable, oldValue, newValue) -> addOrRemoveFileRelationshipToPackage(RelationshipType.DOCUMENTATION_OF, newValue)); chkOptionalComponent.selectedProperty() .addListener((observable, oldValue, newValue) -> addOrRemoveFileRelationshipToPackage( RelationshipType.OPTIONAL_COMPONENT_OF, newValue)); chkMetafile.selectedProperty().addListener((observable, oldValue, newValue) -> addOrRemoveFileRelationshipToPackage(RelationshipType.METAFILE_OF, newValue)); chkBuildTool.selectedProperty().addListener((observable, oldValue, newValue) -> addOrRemoveFileRelationshipToPackage(RelationshipType.BUILD_TOOL_OF, newValue)); chkExcludeFile.selectedProperty()/* w ww . j av a 2 s . c o m*/ .addListener((observable, oldValue, newValue) -> handleChkExcludeFileChange(newValue)); //Package relationship controls assert lstTargetPackages != null : "fx:id=\"lstTargetPackages\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert chcNewRelationshipType != null : "fx:id=\"chcNewRelationshipType\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert btnAddRelationship != null : "fx:id=\"btnAddRelationship\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert btnRemoveRelationship != null : "fx:id=\"btnRemoveRelationship\" was not injected: check your FXML file 'PackageEditor.fxml'."; //Initialize package relationship controls lstTargetPackages.getSelectionModel().selectedItemProperty() .addListener((observable1, oldValue1, newValue1) -> handleTargetPackageSelected(newValue1)); lstTargetPackages.setCellFactory(listView -> new MainSceneController.SpdxPackageListCell()); lstPackageRelationships.getSelectionModel().selectedItemProperty().addListener( (observable1, oldValue1, newValue1) -> btnRemoveRelationship.setDisable(newValue1 == null)); //Package relationship types chcNewRelationshipType.setConverter(RELATIONSHIP_TYPE_STRING_CONVERTER); chcNewRelationshipType.getItems() .setAll(Stream.of(RelationshipType.AMENDS, RelationshipType.DESCENDANT_OF, RelationshipType.DYNAMIC_LINK, RelationshipType.GENERATED_FROM, RelationshipType.GENERATES, RelationshipType.HAS_PREREQUISITE, RelationshipType.PREREQUISITE_FOR, RelationshipType.STATIC_LINK, RelationshipType.OTHER).collect(Collectors.toList())); chcNewRelationshipType.getSelectionModel().selectFirst(); assert (otherPackages != null); //Constructor finished executing lstTargetPackages.getItems().setAll(otherPackages); //Package license editor assert tabPkgLicenses != null : "fx:id=\"tabPkgLicenses\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert tabPkgDeclaredLicense != null : "fx:id=\"tabPkgDeclaredLicense\" was not injected: check your FXML file 'PackageEditor.fxml'."; assert tabPkgConcludedLicense != null : "fx:id=\"tabPkgConcludedLicense\" was not injected: check your FXML file 'PackageEditor.fxml'."; pkgConcludedLicenseEdit = new LicenseEditControl(documentContainer); pkgConcludedLicenseEdit.setInitialValue(pkg.getLicenseConcluded()); pkgConcludedLicenseEdit .setOnLicenseChange(license -> SpdxWithoutExeption.setLicenseConcluded(pkg, license)); tabPkgConcludedLicense.setContent(pkgConcludedLicenseEdit.getUi()); pkgDeclaredLicenseEdit = new LicenseEditControl(documentContainer); pkgDeclaredLicenseEdit.setInitialValue(SpdxWithoutExeption.getLicenseDeclared(pkg)); pkgDeclaredLicenseEdit.setOnLicenseChange(license -> SpdxWithoutExeption.setLicenseDeclared(pkg, license)); tabPkgDeclaredLicense.setContent(pkgDeclaredLicenseEdit.getUi()); //Initialize other elements tblColumnFile.setCellValueFactory( (TreeTableColumn.CellDataFeatures<SpdxFile, String> param) -> new ReadOnlyStringWrapper( param.getValue().getValue().getName())); //Load all file types into the file type list in order. chkListFileTypes.getItems().setAll(Stream.of(FileType.values()).sorted(Ordering.usingToString()) //Sort .map(fileType -> StringableWrapper.wrap(fileType, SpdxLogic::toString)) //Wrap so that the nice toString function gets used by the checkbox .collect(Collectors.toList())); chkListFileTypes.getCheckModel().getCheckedItems().addListener(this::handleFileTypeCheckedOrUnchecked); filesTable.getSelectionModel().selectedItemProperty() .addListener((observable, oldValue, newValue) -> handleFileSelected(newValue)); filesTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); filesTable.setShowRoot(false); AnchorPane externalRefControl = new ExternalRefListControl(pkg).getUi(); externalRefControl.setPadding(new Insets(12, 10, 5, 10)); tabExternalRefs.setContent(externalRefControl); externalRefControl.setManaged(true); new PackagePropertyEditor(pkg).initialize(tabPackageProperties); }