private void removeSelectedProperty() { Collection oldValues = ((AbstractOWLModel) owlModel).getDefaultAnnotationPropertiesInView(); oldValues.removeAll(list.getSelection()); ((AbstractOWLModel) owlModel).setDefaultAnnotationPropertiesInView(oldValues); list.setListData( ((AbstractOWLModel) owlModel).getDefaultAnnotationPropertiesInView().toArray()); }
public AnnotationsViewSettingsPanel(final OWLModel owlModel) { this.owlModel = owlModel; list = new SelectableList(); list.setListData( ((AbstractOWLModel) owlModel).getDefaultAnnotationPropertiesInView().toArray()); list.setCellRenderer(new ResourceRenderer()); LabeledComponent lc = new OWLLabeledComponent( "Default annotation properties to be shown in the Annotation Widget", new JScrollPane(list)); lc.addHeaderButton( new AbstractAction("Add property...", OWLIcons.getAddIcon(OWLIcons.RDF_PROPERTY)) { public void actionPerformed(ActionEvent e) { addProperty(); } }); lc.addHeaderButton( new AllowableAction( "Remove selected property", OWLIcons.getRemoveIcon(OWLIcons.RDF_PROPERTY), list) { public void actionPerformed(ActionEvent e) { removeSelectedProperty(); } }); setLayout(new BorderLayout()); add(BorderLayout.CENTER, lc); }
private void addProperty() { Collection oldValues = ((AbstractOWLModel) owlModel).getDefaultAnnotationPropertiesInView(); Collection properties = owlModel.getRDFProperties(); for (Iterator it = properties.iterator(); it.hasNext(); ) { RDFProperty property = (RDFProperty) it.next(); if (oldValues.contains(property) || (((Slot) property).getValueType() != ValueType.STRING && !property.isAnnotationProperty())) { it.remove(); } } Collection neo = new HashSet(oldValues); neo.addAll( ProtegeUI.getSelectionDialogFactory() .selectResourcesFromCollection(this, owlModel, properties, "Add properties...")); ((AbstractOWLModel) owlModel).setDefaultAnnotationPropertiesInView(neo); list.setListData( ((AbstractOWLModel) owlModel).getDefaultAnnotationPropertiesInView().toArray()); }