Comparar commits
1 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 2a881b0a72 |
-1
@@ -59,7 +59,6 @@ public interface OWLSelectionModel {
|
||||
*/
|
||||
public OWLNamedIndividual getLastSelectedIndividual();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the most recently selected datatype.
|
||||
* @return The selected datatype, or <code>null</code> if
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package org.protege.editor.owl.model.util;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Matthew Horridge
|
||||
* Stanford Center for Biomedical Informatics Research
|
||||
* 06/03/15
|
||||
*/
|
||||
public interface HasObjects<T> {
|
||||
|
||||
Set<T> getObjects();
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
package org.protege.editor.owl.model.util;
|
||||
|
||||
import org.semanticweb.owlapi.model.*;
|
||||
import org.semanticweb.owlapi.util.OWLObjectVisitorExAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Matthew Horridge
|
||||
* Stanford Center for Biomedical Informatics Research
|
||||
* 06/03/15
|
||||
*/
|
||||
public class OWLObjectRemover {
|
||||
|
||||
/**
|
||||
* Gets the changes to remove the specified object from the specified ontology.
|
||||
*
|
||||
* @param object The object. Not {@code null}.
|
||||
* @return The changes.
|
||||
*/
|
||||
public List<OWLOntologyChange> getChangesToRemoveObject(OWLObject object, final OWLOntology ontology) {
|
||||
return object.accept(new OWLObjectVisitorExAdapter<List<OWLOntologyChange>>() {
|
||||
@Override
|
||||
public List<OWLOntologyChange> visit(OWLDatatype datatype) {
|
||||
return getChangesForEntity(datatype, ontology);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OWLOntologyChange> visit(OWLDataProperty property) {
|
||||
return getChangesForEntity(property, ontology);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OWLOntologyChange> visit(OWLObjectProperty property) {
|
||||
return getChangesForEntity(property, ontology);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OWLOntologyChange> visit(OWLNamedIndividual individual) {
|
||||
return getChangesForEntity(individual, ontology);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OWLOntologyChange> visit(OWLClass desc) {
|
||||
return getChangesForEntity(desc, ontology);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OWLOntologyChange> visit(OWLAnonymousIndividual individual) {
|
||||
return getChangesForAnonymousIndividual(individual, ontology);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OWLOntologyChange> visit(OWLAnnotationProperty property) {
|
||||
List<OWLOntologyChange> changes = getChangesForEntity(property, ontology);
|
||||
changes.addAll(getChangesForOntologyAnnotations(property, ontology));
|
||||
return changes;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<OWLOntologyChange> getChangesForAnonymousIndividual(OWLAnonymousIndividual individual, OWLOntology ont) {
|
||||
List<OWLOntologyChange> changes = new ArrayList<>();
|
||||
for (OWLAxiom ax : ont.getReferencingAxioms(individual)) {
|
||||
changes.add(new RemoveAxiom(ont, ax));
|
||||
}
|
||||
changes.addAll(getChangesForAnnotationSubject(individual, ont));
|
||||
changes.addAll(getChangesForAnnotationValue(individual, ont));
|
||||
return changes;
|
||||
}
|
||||
|
||||
private List<OWLOntologyChange> getChangesForEntity(OWLEntity entity, OWLOntology ont) {
|
||||
List<OWLOntologyChange> changes = new ArrayList<>();
|
||||
for (OWLAxiom ax : ont.getReferencingAxioms(entity)) {
|
||||
changes.add(new RemoveAxiom(ont, ax));
|
||||
}
|
||||
IRI entityIRI = entity.getIRI();
|
||||
changes.addAll(getChangesForAnnotationSubject(entityIRI, ont));
|
||||
changes.addAll(getChangesForAnnotationValue(entityIRI, ont));
|
||||
changes.addAll(getChangesForOntologyAnnotations(entityIRI, ont));
|
||||
return changes;
|
||||
}
|
||||
|
||||
|
||||
private List<OWLOntologyChange> getChangesForAnnotationSubject(OWLAnnotationSubject subject, OWLOntology ont) {
|
||||
List<OWLOntologyChange> changes = new ArrayList<>();
|
||||
for (OWLAnnotationAssertionAxiom ax : ont.getAnnotationAssertionAxioms(subject)) {
|
||||
changes.add(new RemoveAxiom(ont, ax));
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
private List<OWLOntologyChange> getChangesForAnnotationValue(OWLAnnotationValue object, OWLOntology ont) {
|
||||
List<OWLOntologyChange> changes = new ArrayList<>();
|
||||
for (OWLAnnotationAssertionAxiom ax : ont.getAxioms(AxiomType.ANNOTATION_ASSERTION)) {
|
||||
if (ax.getValue().equals(object)) {
|
||||
changes.add(new RemoveAxiom(ont, ax));
|
||||
}
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
private List<OWLOntologyChange> getChangesForOntologyAnnotations(OWLAnnotationProperty annotationProperty, OWLOntology ont) {
|
||||
List<OWLOntologyChange> changes = new ArrayList<>();
|
||||
for (OWLAnnotation annotation : ont.getAnnotations()) {
|
||||
if (annotation.getProperty().equals(annotationProperty)) {
|
||||
changes.add(new RemoveOntologyAnnotation(ont, annotation));
|
||||
}
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
private List<OWLOntologyChange> getChangesForOntologyAnnotations(OWLAnnotationValue value, OWLOntology ont) {
|
||||
List<OWLOntologyChange> changes = new ArrayList<>();
|
||||
for (OWLAnnotation annotation : ont.getAnnotations()) {
|
||||
if (annotation.getValue().equals(value)) {
|
||||
changes.add(new RemoveOntologyAnnotation(ont, annotation));
|
||||
}
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
}
|
||||
+17
-8
@@ -1,13 +1,20 @@
|
||||
package org.protege.editor.owl.ui.action;
|
||||
|
||||
import org.protege.editor.owl.OWLEditorKit;
|
||||
import org.protege.editor.owl.model.util.HasObjects;
|
||||
import org.protege.editor.owl.model.util.OWLObjectRemover;
|
||||
import org.protege.editor.owl.ui.OWLIcons;
|
||||
import org.protege.editor.owl.ui.view.OWLSelectionViewAction;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLOntology;
|
||||
import org.semanticweb.owlapi.model.OWLOntologyChange;
|
||||
import org.semanticweb.owlapi.util.OWLEntityRemover;
|
||||
import org.semanticweb.owlapi.util.OWLEntitySetProvider;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,10 +27,10 @@ public class DeleteIndividualAction extends OWLSelectionViewAction {
|
||||
|
||||
private OWLEditorKit owlEditorKit;
|
||||
|
||||
private OWLEntitySetProvider<OWLNamedIndividual> indSetProvider;
|
||||
private HasObjects<OWLIndividual> indSetProvider;
|
||||
|
||||
|
||||
public DeleteIndividualAction(OWLEditorKit owlEditorKit, OWLEntitySetProvider<OWLNamedIndividual> indSetProvider) {
|
||||
public DeleteIndividualAction(OWLEditorKit owlEditorKit, HasObjects<OWLIndividual> indSetProvider) {
|
||||
super("Delete individual(s)", OWLIcons.getIcon("individual.delete.png"));
|
||||
this.owlEditorKit = owlEditorKit;
|
||||
this.indSetProvider = indSetProvider;
|
||||
@@ -31,7 +38,7 @@ public class DeleteIndividualAction extends OWLSelectionViewAction {
|
||||
|
||||
|
||||
public void updateState() {
|
||||
setEnabled(!indSetProvider.getEntities().isEmpty());
|
||||
setEnabled(!indSetProvider.getObjects().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +47,13 @@ public class DeleteIndividualAction extends OWLSelectionViewAction {
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
OWLEntityRemover remover = new OWLEntityRemover(owlEditorKit.getModelManager().getOWLOntologyManager(),
|
||||
owlEditorKit.getModelManager().getOntologies());
|
||||
for (OWLNamedIndividual ind : indSetProvider.getEntities()) {
|
||||
ind.accept(remover);
|
||||
OWLObjectRemover remover = new OWLObjectRemover();
|
||||
List<OWLOntologyChange> changes = new ArrayList<>();
|
||||
for (OWLIndividual ind : indSetProvider.getObjects()) {
|
||||
for (OWLOntology ontology : owlEditorKit.getOWLModelManager().getOntologies()) {
|
||||
changes.addAll(remover.getChangesToRemoveObject(ind, ontology));
|
||||
}
|
||||
}
|
||||
owlEditorKit.getModelManager().applyChanges(remover.getChanges());
|
||||
owlEditorKit.getModelManager().applyChanges(changes);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -2,6 +2,7 @@ package org.protege.editor.owl.ui.editor;
|
||||
|
||||
import org.protege.editor.owl.OWLEditorKit;
|
||||
import org.protege.editor.owl.ui.selector.OWLIndividualSelectorPanel;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -14,7 +15,7 @@ import java.util.Set;
|
||||
* Date: 09-Feb-2007<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OWLIndividualEditor extends AbstractOWLObjectEditor<OWLNamedIndividual> {
|
||||
public class OWLIndividualEditor extends AbstractOWLObjectEditor<OWLIndividual> {
|
||||
|
||||
private OWLIndividualSelectorPanel selectorPanel;
|
||||
|
||||
@@ -41,7 +42,7 @@ public class OWLIndividualEditor extends AbstractOWLObjectEditor<OWLNamedIndivid
|
||||
|
||||
|
||||
public boolean canEdit(Object object) {
|
||||
return object instanceof OWLNamedIndividual;
|
||||
return object instanceof OWLIndividual;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,17 +56,17 @@ public class OWLIndividualEditor extends AbstractOWLObjectEditor<OWLNamedIndivid
|
||||
}
|
||||
|
||||
|
||||
public OWLNamedIndividual getEditedObject() {
|
||||
public OWLIndividual getEditedObject() {
|
||||
return selectorPanel.getSelectedObject();
|
||||
}
|
||||
|
||||
|
||||
public Set<OWLNamedIndividual> getEditedObjects() {
|
||||
public Set<OWLIndividual> getEditedObjects() {
|
||||
return selectorPanel.getSelectedObjects();
|
||||
}
|
||||
|
||||
|
||||
public boolean setEditedObject(OWLNamedIndividual editedObject) {
|
||||
public boolean setEditedObject(OWLIndividual editedObject) {
|
||||
selectorPanel.setSelection(editedObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
+4
-3
@@ -4,6 +4,7 @@ import org.protege.editor.core.ui.util.InputVerificationStatusChangedListener;
|
||||
import org.protege.editor.core.ui.util.VerifiedInputEditor;
|
||||
import org.protege.editor.owl.OWLEditorKit;
|
||||
import org.protege.editor.owl.ui.selector.OWLIndividualSelectorPanel;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -18,7 +19,7 @@ import java.util.Set;
|
||||
* Bio-Health Informatics Group<br>
|
||||
* Date: 22-Feb-2007<br><br>
|
||||
*/
|
||||
public class OWLIndividualSetEditor extends AbstractOWLObjectEditor<Set<OWLNamedIndividual>> implements VerifiedInputEditor {
|
||||
public class OWLIndividualSetEditor extends AbstractOWLObjectEditor<Set<OWLIndividual>> implements VerifiedInputEditor {
|
||||
|
||||
private OWLIndividualSelectorPanel panel;
|
||||
|
||||
@@ -36,12 +37,12 @@ public class OWLIndividualSetEditor extends AbstractOWLObjectEditor<Set<OWLNamed
|
||||
}
|
||||
|
||||
|
||||
public Set<OWLNamedIndividual> getEditedObject() {
|
||||
public Set<OWLIndividual> getEditedObject() {
|
||||
return panel.getSelectedObjects();
|
||||
}
|
||||
|
||||
|
||||
public boolean setEditedObject(Set<OWLNamedIndividual> individuals) {
|
||||
public boolean setEditedObject(Set<OWLIndividual> individuals) {
|
||||
panel.setSelection(individuals != null ? individuals : Collections.EMPTY_SET);
|
||||
return true;
|
||||
}
|
||||
|
||||
+8
-8
@@ -35,7 +35,7 @@ import org.semanticweb.owlapi.reasoner.NodeSet;
|
||||
* Date: 27-Jan-2007<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OWLClassAssertionAxiomMembersSection extends AbstractOWLClassAxiomFrameSection<OWLClassAssertionAxiom, OWLNamedIndividual> {
|
||||
public class OWLClassAssertionAxiomMembersSection extends AbstractOWLClassAxiomFrameSection<OWLClassAssertionAxiom, OWLIndividual> {
|
||||
|
||||
public static final String LABEL = "Instances";
|
||||
|
||||
@@ -88,7 +88,7 @@ public class OWLClassAssertionAxiomMembersSection extends AbstractOWLClassAxiomF
|
||||
NodeSet<OWLNamedIndividual> instances = getOWLModelManager().getReasoner().getInstances(getRootObject(), SHOW_DIRECT_INSTANCES);
|
||||
if (instances != null) {
|
||||
for (OWLIndividual ind : instances.getFlattened()) {
|
||||
if (!ind.isAnonymous() && !added.contains(ind.asOWLNamedIndividual())) {
|
||||
if (added.contains(ind)) {
|
||||
addRow(new OWLClassAssertionAxiomMembersSectionRow(getOWLEditorKit(),
|
||||
OWLClassAssertionAxiomMembersSection.this,
|
||||
null,
|
||||
@@ -103,12 +103,12 @@ public class OWLClassAssertionAxiomMembersSection extends AbstractOWLClassAxiomF
|
||||
}
|
||||
|
||||
|
||||
protected OWLClassAssertionAxiom createAxiom(OWLNamedIndividual individual) {
|
||||
protected OWLClassAssertionAxiom createAxiom(OWLIndividual individual) {
|
||||
return getOWLDataFactory().getOWLClassAssertionAxiom(getRootObject(), individual);
|
||||
}
|
||||
|
||||
|
||||
public OWLObjectEditor<OWLNamedIndividual> getObjectEditor() {
|
||||
public OWLObjectEditor<OWLIndividual> getObjectEditor() {
|
||||
return new OWLIndividualEditor(getOWLEditorKit(), ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
}
|
||||
|
||||
@@ -143,10 +143,10 @@ public class OWLClassAssertionAxiomMembersSection extends AbstractOWLClassAxiomF
|
||||
* @return A comparator if to sort the rows in this section, or
|
||||
* <code>null</code> if the rows shouldn't be sorted.
|
||||
*/
|
||||
public Comparator<OWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLNamedIndividual>> getRowComparator() {
|
||||
return new Comparator<OWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLNamedIndividual>>() {
|
||||
public int compare(OWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLNamedIndividual> o1,
|
||||
OWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLNamedIndividual> o2) {
|
||||
public Comparator<OWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLIndividual>> getRowComparator() {
|
||||
return new Comparator<OWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLIndividual>>() {
|
||||
public int compare(OWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLIndividual> o1,
|
||||
OWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLIndividual> o2) {
|
||||
final String s1 = getOWLModelManager().getRendering(o1.getAxiom().getIndividual());
|
||||
final String s2 = getOWLModelManager().getRendering(o2.getAxiom().getIndividual());
|
||||
return s1.compareToIgnoreCase(s2);
|
||||
|
||||
+4
-4
@@ -20,17 +20,17 @@ import org.semanticweb.owlapi.model.OWLOntology;
|
||||
* Bio-Health Informatics Group<br>
|
||||
* Date: 27-Jan-2007<br><br>
|
||||
*/
|
||||
public class OWLClassAssertionAxiomMembersSectionRow extends AbstractOWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLNamedIndividual> {
|
||||
public class OWLClassAssertionAxiomMembersSectionRow extends AbstractOWLFrameSectionRow<OWLClassExpression, OWLClassAssertionAxiom, OWLIndividual> {
|
||||
|
||||
public OWLClassAssertionAxiomMembersSectionRow(OWLEditorKit owlEditorKit,
|
||||
OWLFrameSection<OWLClassExpression, OWLClassAssertionAxiom, OWLNamedIndividual> section,
|
||||
OWLFrameSection<OWLClassExpression, OWLClassAssertionAxiom, OWLIndividual> section,
|
||||
OWLOntology ontology, OWLClassExpression rootObject,
|
||||
OWLClassAssertionAxiom axiom) {
|
||||
super(owlEditorKit, section, ontology, rootObject, axiom);
|
||||
}
|
||||
|
||||
|
||||
protected OWLObjectEditor<OWLNamedIndividual> getObjectEditor() {
|
||||
protected OWLObjectEditor<OWLIndividual> getObjectEditor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class OWLClassAssertionAxiomMembersSectionRow extends AbstractOWLFrameSec
|
||||
return true;
|
||||
}
|
||||
|
||||
protected OWLClassAssertionAxiom createAxiom(OWLNamedIndividual editedObject) {
|
||||
protected OWLClassAssertionAxiom createAxiom(OWLIndividual editedObject) {
|
||||
return getOWLDataFactory().getOWLClassAssertionAxiom(getRoot(), editedObject);
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -21,28 +21,28 @@ import java.util.Set;
|
||||
* Bio-Health Informatics Group<br>
|
||||
* Date: 29-Jan-2007<br><br>
|
||||
*/
|
||||
public class OWLDifferentIndividualAxiomFrameSectionRow extends AbstractOWLFrameSectionRow<OWLNamedIndividual, OWLDifferentIndividualsAxiom, Set<OWLNamedIndividual>> {
|
||||
public class OWLDifferentIndividualAxiomFrameSectionRow extends AbstractOWLFrameSectionRow<OWLIndividual, OWLDifferentIndividualsAxiom, Set<OWLIndividual>> {
|
||||
|
||||
public OWLDifferentIndividualAxiomFrameSectionRow(OWLEditorKit owlEditorKit,
|
||||
OWLFrameSection<OWLNamedIndividual, OWLDifferentIndividualsAxiom, Set<OWLNamedIndividual>> section,
|
||||
OWLOntology ontology, OWLNamedIndividual rootObject,
|
||||
OWLFrameSection<OWLIndividual, OWLDifferentIndividualsAxiom, Set<OWLIndividual>> section,
|
||||
OWLOntology ontology, OWLIndividual rootObject,
|
||||
OWLDifferentIndividualsAxiom axiom) {
|
||||
super(owlEditorKit, section, ontology, rootObject, axiom);
|
||||
}
|
||||
|
||||
|
||||
protected OWLObjectEditor<Set<OWLNamedIndividual>> getObjectEditor() {
|
||||
protected OWLObjectEditor<Set<OWLIndividual>> getObjectEditor() {
|
||||
return new OWLIndividualSetEditor(getOWLEditorKit());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEditorResults(OWLObjectEditor<Set<OWLNamedIndividual>> editor) {
|
||||
Set<OWLNamedIndividual> equivalents = editor.getEditedObject();
|
||||
public boolean checkEditorResults(OWLObjectEditor<Set<OWLIndividual>> editor) {
|
||||
Set<OWLIndividual> equivalents = editor.getEditedObject();
|
||||
return !equivalents.contains(getRootObject());
|
||||
}
|
||||
|
||||
|
||||
protected OWLDifferentIndividualsAxiom createAxiom(Set<OWLNamedIndividual> editedObject) {
|
||||
protected OWLDifferentIndividualsAxiom createAxiom(Set<OWLIndividual> editedObject) {
|
||||
editedObject.add(getRootObject());
|
||||
return getOWLDataFactory().getOWLDifferentIndividualsAxiom(editedObject);
|
||||
}
|
||||
@@ -53,12 +53,11 @@ public class OWLDifferentIndividualAxiomFrameSectionRow extends AbstractOWLFrame
|
||||
* could be placed on the clip board during a copy operation,
|
||||
* or navigated to etc.
|
||||
*/
|
||||
public List<OWLNamedIndividual> getManipulatableObjects() {
|
||||
//@@TODO v3 port - what about anon indivs?
|
||||
public List<OWLIndividual> getManipulatableObjects() {
|
||||
Set<OWLIndividual> individuals = getAxiom().getIndividuals();
|
||||
List<OWLNamedIndividual> results = new ArrayList<OWLNamedIndividual>();
|
||||
List<OWLIndividual> results = new ArrayList<>();
|
||||
for (OWLIndividual ind : individuals){
|
||||
if (!ind.isAnonymous() && !ind.equals(getRootObject())){
|
||||
if (!ind.equals(getRootObject())){
|
||||
results.add(ind.asOWLNamedIndividual());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -22,7 +22,7 @@ import org.semanticweb.owlapi.model.OWLOntologyChange;
|
||||
* Bio-Health Informatics Group<br>
|
||||
* Date: 29-Jan-2007<br><br>
|
||||
*/
|
||||
public class OWLDifferentIndividualsAxiomFrameSection extends AbstractOWLFrameSection<OWLNamedIndividual, OWLDifferentIndividualsAxiom, Set<OWLNamedIndividual>> {
|
||||
public class OWLDifferentIndividualsAxiomFrameSection extends AbstractOWLFrameSection<OWLIndividual, OWLDifferentIndividualsAxiom, Set<OWLIndividual>> {
|
||||
|
||||
public static final String LABEL = "Different Individuals";
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.semanticweb.owlapi.model.OWLOntologyChange;
|
||||
}
|
||||
|
||||
|
||||
public OWLDifferentIndividualsAxiomFrameSection(OWLEditorKit editorKit, OWLFrame<? extends OWLNamedIndividual> frame) {
|
||||
public OWLDifferentIndividualsAxiomFrameSection(OWLEditorKit editorKit, OWLFrame<? extends OWLIndividual> frame) {
|
||||
super(editorKit, LABEL, "Different individuals", frame);
|
||||
}
|
||||
|
||||
@@ -55,19 +55,19 @@ import org.semanticweb.owlapi.model.OWLOntologyChange;
|
||||
}
|
||||
|
||||
|
||||
protected OWLDifferentIndividualsAxiom createAxiom(Set<OWLNamedIndividual> object) {
|
||||
protected OWLDifferentIndividualsAxiom createAxiom(Set<OWLIndividual> object) {
|
||||
object.add(getRootObject());
|
||||
return getOWLDataFactory().getOWLDifferentIndividualsAxiom(object);
|
||||
}
|
||||
|
||||
|
||||
public OWLObjectEditor<Set<OWLNamedIndividual>> getObjectEditor() {
|
||||
public OWLObjectEditor<Set<OWLIndividual>> getObjectEditor() {
|
||||
return new OWLIndividualSetEditor(getOWLEditorKit());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEditorResults(OWLObjectEditor<Set<OWLNamedIndividual>> editor) {
|
||||
Set<OWLNamedIndividual> equivalents = editor.getEditedObject();
|
||||
public boolean checkEditorResults(OWLObjectEditor<Set<OWLIndividual>> editor) {
|
||||
Set<OWLIndividual> equivalents = editor.getEditedObject();
|
||||
return !equivalents.contains(getRootObject());
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ import org.semanticweb.owlapi.model.OWLOntologyChange;
|
||||
* @return A comparator if to sort the rows in this section,
|
||||
* or <code>null</code> if the rows shouldn't be sorted.
|
||||
*/
|
||||
public Comparator<OWLFrameSectionRow<OWLNamedIndividual, OWLDifferentIndividualsAxiom, Set<OWLNamedIndividual>>> getRowComparator() {
|
||||
public Comparator<OWLFrameSectionRow<OWLIndividual, OWLDifferentIndividualsAxiom, Set<OWLIndividual>>> getRowComparator() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package org.protege.editor.owl.ui.frame.individual;
|
||||
|
||||
import org.protege.editor.owl.OWLEditorKit;
|
||||
import org.protege.editor.owl.ui.frame.AbstractOWLFrame;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
|
||||
|
||||
@@ -11,7 +12,7 @@ import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
* Bio-Health Informatics Group<br>
|
||||
* Date: 29-Jan-2007<br><br>
|
||||
*/
|
||||
public class OWLIndividualFrame extends AbstractOWLFrame<OWLNamedIndividual> {
|
||||
public class OWLIndividualFrame extends AbstractOWLFrame<OWLIndividual> {
|
||||
|
||||
public OWLIndividualFrame(OWLEditorKit editorKit) {
|
||||
super(editorKit.getModelManager().getOWLOntologyManager());
|
||||
|
||||
+28
-25
@@ -25,12 +25,12 @@ import org.semanticweb.owlapi.model.OWLSameIndividualAxiom;
|
||||
* Bio-Health Informatics Group<br>
|
||||
* Date: 29-Jan-2007<br><br>
|
||||
*/
|
||||
public class OWLSameIndividualsAxiomFrameSection extends AbstractOWLFrameSection<OWLNamedIndividual, OWLSameIndividualAxiom, Set<OWLNamedIndividual>> {
|
||||
public class OWLSameIndividualsAxiomFrameSection extends AbstractOWLFrameSection<OWLIndividual, OWLSameIndividualAxiom, Set<OWLIndividual>> {
|
||||
|
||||
public static final String LABEL = "Same Individual As";
|
||||
|
||||
|
||||
public OWLSameIndividualsAxiomFrameSection(OWLEditorKit editorKit, OWLFrame<? extends OWLNamedIndividual> frame) {
|
||||
public OWLSameIndividualsAxiomFrameSection(OWLEditorKit editorKit, OWLFrame<? extends OWLIndividual> frame) {
|
||||
super(editorKit, LABEL, LABEL, frame);
|
||||
}
|
||||
|
||||
@@ -57,28 +57,31 @@ public class OWLSameIndividualsAxiomFrameSection extends AbstractOWLFrameSection
|
||||
return;
|
||||
}
|
||||
Set<OWLIndividual> existingSameIndividuals = getCurrentlyDisplayedSameIndividuals();
|
||||
Set<OWLNamedIndividual> newSameIndividuals = new HashSet<OWLNamedIndividual>();
|
||||
for (OWLNamedIndividual i : getCurrentReasoner().getSameIndividuals(getRootObject()).getEntities()) {
|
||||
if (!i.equals(getRootObject()) && !existingSameIndividuals.contains(i)) {
|
||||
newSameIndividuals.add(i);
|
||||
}
|
||||
}
|
||||
if (!newSameIndividuals.isEmpty()) {
|
||||
newSameIndividuals.add(getRootObject());
|
||||
addRow(new OWLSameIndividualsAxiomFrameSectionRow(getOWLEditorKit(),
|
||||
OWLSameIndividualsAxiomFrameSection.this,
|
||||
null,
|
||||
getRootObject(),
|
||||
getOWLDataFactory().getOWLSameIndividualAxiom(newSameIndividuals)
|
||||
));
|
||||
}
|
||||
}
|
||||
Set<OWLIndividual> newSameIndividuals = new HashSet<>();
|
||||
OWLIndividual rootObject = getRootObject();
|
||||
if (rootObject.isNamed()) {
|
||||
for (OWLIndividual i : getCurrentReasoner().getSameIndividuals(rootObject.asOWLNamedIndividual()).getEntities()) {
|
||||
if (!i.equals(rootObject) && !existingSameIndividuals.contains(i)) {
|
||||
newSameIndividuals.add(i);
|
||||
}
|
||||
}
|
||||
if (!newSameIndividuals.isEmpty()) {
|
||||
newSameIndividuals.add(rootObject);
|
||||
addRow(new OWLSameIndividualsAxiomFrameSectionRow(getOWLEditorKit(),
|
||||
OWLSameIndividualsAxiomFrameSection.this,
|
||||
null,
|
||||
rootObject,
|
||||
getOWLDataFactory().getOWLSameIndividualAxiom(newSameIndividuals)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Set<OWLIndividual> getCurrentlyDisplayedSameIndividuals() {
|
||||
Set<OWLIndividual> existingSameIndividuals = new HashSet<OWLIndividual>();
|
||||
for (OWLFrameSectionRow<OWLNamedIndividual, OWLSameIndividualAxiom, Set<OWLNamedIndividual>> existingRow : getRows()) {
|
||||
for (OWLFrameSectionRow<OWLIndividual, OWLSameIndividualAxiom, Set<OWLIndividual>> existingRow : getRows()) {
|
||||
OWLSameIndividualAxiom existingAxiom = existingRow.getAxiom();
|
||||
for (OWLIndividual existingSameIndividual : existingAxiom.getIndividuals()) {
|
||||
existingSameIndividuals.add(existingSameIndividual);
|
||||
@@ -88,20 +91,20 @@ public class OWLSameIndividualsAxiomFrameSection extends AbstractOWLFrameSection
|
||||
}
|
||||
|
||||
|
||||
protected OWLSameIndividualAxiom createAxiom(Set<OWLNamedIndividual> object) {
|
||||
protected OWLSameIndividualAxiom createAxiom(Set<OWLIndividual> object) {
|
||||
object.add(getRootObject());
|
||||
OWLSameIndividualAxiom ax = getOWLDataFactory().getOWLSameIndividualAxiom(object);
|
||||
return ax;
|
||||
}
|
||||
|
||||
|
||||
public OWLObjectEditor<Set<OWLNamedIndividual>> getObjectEditor() {
|
||||
public OWLObjectEditor<Set<OWLIndividual>> getObjectEditor() {
|
||||
return new OWLIndividualSetEditor(getOWLEditorKit());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEditorResults(OWLObjectEditor<Set<OWLNamedIndividual>> editor) {
|
||||
Set<OWLNamedIndividual> equivalents = editor.getEditedObject();
|
||||
public boolean checkEditorResults(OWLObjectEditor<Set<OWLIndividual>> editor) {
|
||||
Set<OWLIndividual> equivalents = editor.getEditedObject();
|
||||
return !equivalents.contains(getRootObject());
|
||||
}
|
||||
|
||||
@@ -123,7 +126,7 @@ public class OWLSameIndividualsAxiomFrameSection extends AbstractOWLFrameSection
|
||||
* @return A comparator if to sort the rows in this section,
|
||||
* or <code>null</code> if the rows shouldn't be sorted.
|
||||
*/
|
||||
public Comparator<OWLFrameSectionRow<OWLNamedIndividual, OWLSameIndividualAxiom, Set<OWLNamedIndividual>>> getRowComparator() {
|
||||
public Comparator<OWLFrameSectionRow<OWLIndividual, OWLSameIndividualAxiom, Set<OWLIndividual>>> getRowComparator() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-13
@@ -6,7 +6,7 @@ import org.protege.editor.owl.ui.editor.OWLObjectEditor;
|
||||
import org.protege.editor.owl.ui.frame.AbstractOWLFrameSectionRow;
|
||||
import org.protege.editor.owl.ui.frame.OWLFrameSection;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLOntology;
|
||||
import org.semanticweb.owlapi.model.OWLSameIndividualAxiom;
|
||||
|
||||
@@ -21,28 +21,28 @@ import java.util.Set;
|
||||
* Bio-Health Informatics Group<br>
|
||||
* Date: 29-Jan-2007<br><br>
|
||||
*/
|
||||
public class OWLSameIndividualsAxiomFrameSectionRow extends AbstractOWLFrameSectionRow<OWLNamedIndividual, OWLSameIndividualAxiom, Set<OWLNamedIndividual>> {
|
||||
public class OWLSameIndividualsAxiomFrameSectionRow extends AbstractOWLFrameSectionRow<OWLIndividual, OWLSameIndividualAxiom, Set<OWLIndividual>> {
|
||||
|
||||
public OWLSameIndividualsAxiomFrameSectionRow(OWLEditorKit owlEditorKit,
|
||||
OWLFrameSection<OWLNamedIndividual, OWLSameIndividualAxiom, Set<OWLNamedIndividual>> section,
|
||||
OWLOntology ontology, OWLNamedIndividual rootObject,
|
||||
OWLFrameSection<OWLIndividual, OWLSameIndividualAxiom, Set<OWLIndividual>> section,
|
||||
OWLOntology ontology, OWLIndividual rootObject,
|
||||
OWLSameIndividualAxiom axiom) {
|
||||
super(owlEditorKit, section, ontology, rootObject, axiom);
|
||||
}
|
||||
|
||||
|
||||
protected OWLObjectEditor<Set<OWLNamedIndividual>> getObjectEditor() {
|
||||
protected OWLObjectEditor<Set<OWLIndividual>> getObjectEditor() {
|
||||
return new OWLIndividualSetEditor(getOWLEditorKit());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEditorResults(OWLObjectEditor<Set<OWLNamedIndividual>> editor) {
|
||||
Set<OWLNamedIndividual> equivalents = editor.getEditedObject();
|
||||
public boolean checkEditorResults(OWLObjectEditor<Set<OWLIndividual>> editor) {
|
||||
Set<OWLIndividual> equivalents = editor.getEditedObject();
|
||||
return !equivalents.contains(getRootObject());
|
||||
}
|
||||
|
||||
|
||||
protected OWLSameIndividualAxiom createAxiom(Set<OWLNamedIndividual> editedObject) {
|
||||
protected OWLSameIndividualAxiom createAxiom(Set<OWLIndividual> editedObject) {
|
||||
editedObject.add(getRootObject());
|
||||
return getOWLDataFactory().getOWLSameIndividualAxiom(editedObject);
|
||||
}
|
||||
@@ -53,13 +53,12 @@ public class OWLSameIndividualsAxiomFrameSectionRow extends AbstractOWLFrameSect
|
||||
* could be placed on the clip board during a copy operation,
|
||||
* or navigated to etc.
|
||||
*/
|
||||
public List<OWLNamedIndividual> getManipulatableObjects() {
|
||||
//@@TODO v3 port - what about anon indivs?
|
||||
public List<OWLIndividual> getManipulatableObjects() {
|
||||
Set<OWLIndividual> individuals = getAxiom().getIndividuals();
|
||||
List<OWLNamedIndividual> results = new ArrayList<OWLNamedIndividual>();
|
||||
List<OWLIndividual> results = new ArrayList<OWLIndividual>();
|
||||
for (OWLIndividual ind : individuals){
|
||||
if (!ind.isAnonymous() && !ind.equals(getRootObject())){
|
||||
results.add(ind.asOWLNamedIndividual());
|
||||
if (!ind.equals(getRootObject())){
|
||||
results.add(ind);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
|
||||
+6
-5
@@ -7,6 +7,7 @@ import org.protege.editor.core.ui.workspace.Workspace;
|
||||
import org.protege.editor.owl.OWLEditorKit;
|
||||
import org.protege.editor.owl.ui.renderer.OWLSystemColors;
|
||||
import org.protege.editor.owl.ui.view.individual.OWLIndividualListViewComponent;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLOntology;
|
||||
|
||||
@@ -25,7 +26,7 @@ import java.util.Set;
|
||||
* www.cs.man.ac.uk/~horridgm<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OWLIndividualSelectorPanel extends AbstractSelectorPanel<OWLNamedIndividual> {
|
||||
public class OWLIndividualSelectorPanel extends AbstractSelectorPanel<OWLIndividual> {
|
||||
|
||||
private OWLIndividualListViewComponent vc;
|
||||
|
||||
@@ -63,7 +64,7 @@ public class OWLIndividualSelectorPanel extends AbstractSelectorPanel<OWLNamedIn
|
||||
this.vc.setSelectionMode(selectionMode);
|
||||
}
|
||||
|
||||
public void setSelection(OWLNamedIndividual ind) {
|
||||
public void setSelection(OWLIndividual ind) {
|
||||
if (vc.getView() != null) {
|
||||
vc.getView().setPinned(false);
|
||||
}
|
||||
@@ -71,16 +72,16 @@ public class OWLIndividualSelectorPanel extends AbstractSelectorPanel<OWLNamedIn
|
||||
}
|
||||
|
||||
|
||||
public void setSelection(Set<OWLNamedIndividual> entities) {
|
||||
public void setSelection(Set<OWLIndividual> entities) {
|
||||
vc.setSelectedIndividuals(entities);
|
||||
}
|
||||
|
||||
|
||||
public OWLNamedIndividual getSelectedObject() {
|
||||
public OWLIndividual getSelectedObject() {
|
||||
return vc.getSelectedIndividual();
|
||||
}
|
||||
|
||||
public Set<OWLNamedIndividual> getSelectedObjects() {
|
||||
public Set<OWLIndividual> getSelectedObjects() {
|
||||
return vc.getSelectedIndividuals();
|
||||
}
|
||||
|
||||
|
||||
+15
-6
@@ -32,7 +32,7 @@ public class UsageByEntityTreeModel extends DefaultTreeModel implements UsageTre
|
||||
|
||||
private Map<OWLEntity, DefaultMutableTreeNode> nodeMap;
|
||||
|
||||
private OWLEntity entity;
|
||||
private OWLObject entity;
|
||||
|
||||
private Map<OWLEntity, Set<OWLAxiom>> axiomsByEntityMap;
|
||||
|
||||
@@ -57,21 +57,30 @@ public class UsageByEntityTreeModel extends DefaultTreeModel implements UsageTre
|
||||
setOWLEntity(entity);
|
||||
}
|
||||
|
||||
private String getRootContent(OWLModelManager mngr, OWLEntity entity){
|
||||
private String getRootContent(OWLModelManager mngr, OWLObject entity){
|
||||
return entity != null ? "Found " + usageCount + " uses of " + mngr.getRendering(entity) : "";
|
||||
}
|
||||
|
||||
public void setOWLEntity(OWLEntity owlEntity) {
|
||||
if (owlEntity == null) {
|
||||
public void setOWLEntity(OWLObject object) {
|
||||
if (object == null) {
|
||||
return;
|
||||
}
|
||||
this.entity = owlEntity;
|
||||
this.entity = object;
|
||||
axiomsByEntityMap.clear();
|
||||
usageCount = 0;
|
||||
|
||||
for (OWLOntology ont : owlModelManager.getActiveOntologies()) {
|
||||
currentOntology = ont;
|
||||
Set<OWLAxiom> axioms = ont.getReferencingAxioms(owlEntity);
|
||||
Set<OWLAxiom> axioms;
|
||||
if(entity instanceof OWLEntity) {
|
||||
axioms = ont.getReferencingAxioms((OWLEntity) object);
|
||||
}
|
||||
else if(entity instanceof OWLAnonymousIndividual) {
|
||||
axioms = ont.getReferencingAxioms((OWLAnonymousIndividual) object);
|
||||
}
|
||||
else {
|
||||
axioms = Collections.emptySet();
|
||||
}
|
||||
for (OWLAxiom ax : axioms) {
|
||||
axiomSorter.setAxiom(ax);
|
||||
ax.accept(axiomSorter);
|
||||
|
||||
+3
-6
@@ -1,10 +1,7 @@
|
||||
package org.protege.editor.owl.ui.usage;
|
||||
|
||||
import org.protege.editor.owl.OWLEditorKit;
|
||||
import org.semanticweb.owlapi.model.OWLClass;
|
||||
import org.semanticweb.owlapi.model.OWLEntity;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLProperty;
|
||||
import org.semanticweb.owlapi.model.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -33,7 +30,7 @@ public class UsagePanel extends JPanel {
|
||||
private JCheckBox showDifferentCheckbox;
|
||||
private JCheckBox showNamedSubSuperclassesCheckbox;
|
||||
|
||||
private OWLEntity currentSelection;
|
||||
private OWLObject currentSelection;
|
||||
|
||||
public UsagePanel(OWLEditorKit owlEditorKit) {
|
||||
setLayout(new BorderLayout());
|
||||
@@ -84,7 +81,7 @@ public class UsagePanel extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
public void setOWLEntity(OWLEntity entity) {
|
||||
public void setOWLEntity(OWLObject entity) {
|
||||
currentSelection = entity;
|
||||
showNamedSubSuperclassesCheckbox.setVisible(entity != null && entity instanceof OWLClass);
|
||||
showDisjointsCheckbox.setVisible(entity != null && (entity instanceof OWLProperty || entity instanceof OWLClass));
|
||||
|
||||
+7
-4
@@ -5,6 +5,7 @@ import org.protege.editor.owl.ui.renderer.OWLCellRenderer;
|
||||
import org.protege.editor.owl.ui.tree.OWLLinkedObjectTree;
|
||||
import org.semanticweb.owlapi.model.OWLAxiom;
|
||||
import org.semanticweb.owlapi.model.OWLEntity;
|
||||
import org.semanticweb.owlapi.model.OWLObject;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
@@ -26,7 +27,7 @@ public class UsageTree extends OWLLinkedObjectTree {
|
||||
|
||||
private OWLEditorKit owlEditorKit;
|
||||
|
||||
private OWLEntity entity;
|
||||
private OWLObject object;
|
||||
|
||||
|
||||
public UsageTree(OWLEditorKit owlEditorKit) {
|
||||
@@ -36,8 +37,8 @@ public class UsageTree extends OWLLinkedObjectTree {
|
||||
}
|
||||
|
||||
|
||||
public void setOWLEntity(OWLEntity entity) {
|
||||
this.entity = entity;
|
||||
public void setOWLEntity(OWLObject entity) {
|
||||
this.object = entity;
|
||||
|
||||
final UsagePreferences p = UsagePreferences.getInstance();
|
||||
final UsageTreeModel model = new UsageByEntityTreeModel(owlEditorKit);
|
||||
@@ -65,7 +66,9 @@ public class UsageTree extends OWLLinkedObjectTree {
|
||||
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
|
||||
boolean leaf, int row, boolean hasFocus) {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
|
||||
setFocusedEntity(entity);
|
||||
if (object instanceof OWLEntity) {
|
||||
setFocusedEntity((OWLEntity) object);
|
||||
}
|
||||
JComponent c = (JComponent) super.getTreeCellRendererComponent(tree,
|
||||
node.getUserObject(),
|
||||
sel,
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
package org.protege.editor.owl.ui.usage;
|
||||
|
||||
import org.semanticweb.owlapi.model.OWLEntity;
|
||||
import org.semanticweb.owlapi.model.OWLObject;
|
||||
import org.semanticweb.owlapi.model.OWLPrimitive;
|
||||
|
||||
import javax.swing.tree.TreeModel;
|
||||
import java.util.Set;
|
||||
@@ -20,7 +22,7 @@ import java.util.Set;
|
||||
*/
|
||||
public interface UsageTreeModel extends TreeModel {
|
||||
|
||||
void setOWLEntity(OWLEntity owlEntity);
|
||||
void setOWLEntity(OWLObject owlEntity);
|
||||
|
||||
void addFilter(UsageFilter filter);
|
||||
|
||||
|
||||
+4
-3
@@ -2,6 +2,7 @@ package org.protege.editor.owl.ui.view.individual;
|
||||
|
||||
import org.protege.editor.owl.ui.view.AbstractOWLSelectionViewComponent;
|
||||
import org.semanticweb.owlapi.model.OWLEntity;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
|
||||
|
||||
@@ -37,8 +38,8 @@ public abstract class AbstractOWLIndividualViewComponent extends AbstractOWLSele
|
||||
}
|
||||
|
||||
|
||||
final protected OWLEntity updateView() {
|
||||
OWLNamedIndividual selIndividual = updateView(getSelectedOWLIndividual());
|
||||
final protected OWLIndividual updateView() {
|
||||
OWLIndividual selIndividual = updateView(getSelectedOWLIndividual());
|
||||
if (selIndividual != null) {
|
||||
updateRegisteredActions();
|
||||
}
|
||||
@@ -49,7 +50,7 @@ public abstract class AbstractOWLIndividualViewComponent extends AbstractOWLSele
|
||||
}
|
||||
|
||||
|
||||
public abstract OWLNamedIndividual updateView(OWLNamedIndividual individual);
|
||||
public abstract OWLIndividual updateView(OWLIndividual individual);
|
||||
|
||||
|
||||
public abstract void initialiseIndividualsView() throws Exception;
|
||||
|
||||
+13
-3
@@ -3,6 +3,7 @@ package org.protege.editor.owl.ui.view.individual;
|
||||
import org.protege.editor.owl.ui.frame.OWLAnnotationsFrame;
|
||||
import org.protege.editor.owl.ui.framelist.OWLFrameList;
|
||||
import org.semanticweb.owlapi.model.OWLAnnotationSubject;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -23,7 +24,7 @@ public class OWLIndividualAnnotationsViewComponent extends AbstractOWLIndividual
|
||||
|
||||
|
||||
public void initialiseIndividualsView() throws Exception {
|
||||
list = new OWLFrameList<OWLAnnotationSubject>(getOWLEditorKit(), new OWLAnnotationsFrame(getOWLEditorKit()));
|
||||
list = new OWLFrameList<>(getOWLEditorKit(), new OWLAnnotationsFrame(getOWLEditorKit()));
|
||||
setLayout(new BorderLayout());
|
||||
JScrollPane sp = new JScrollPane(list);
|
||||
sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
@@ -36,8 +37,17 @@ public class OWLIndividualAnnotationsViewComponent extends AbstractOWLIndividual
|
||||
}
|
||||
|
||||
|
||||
public OWLNamedIndividual updateView(OWLNamedIndividual selectedIndividual) {
|
||||
list.setRootObject(selectedIndividual == null ? null : selectedIndividual.getIRI());
|
||||
public OWLIndividual updateView(OWLIndividual selectedIndividual) {
|
||||
list.setRootObject(selectedIndividual == null ? null : getAnnotationSubject(selectedIndividual));
|
||||
return selectedIndividual;
|
||||
}
|
||||
|
||||
private OWLAnnotationSubject getAnnotationSubject(OWLIndividual individual) {
|
||||
if(individual.isNamed()) {
|
||||
return individual.asOWLNamedIndividual().getIRI();
|
||||
}
|
||||
else {
|
||||
return individual.asOWLAnonymousIndividual();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -3,6 +3,7 @@ package org.protege.editor.owl.ui.view.individual;
|
||||
import org.protege.editor.owl.ui.frame.individual.OWLIndividualFrame;
|
||||
import org.protege.editor.owl.ui.framelist.CreateNewEquivalentClassAction;
|
||||
import org.protege.editor.owl.ui.framelist.OWLFrameList;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -21,14 +22,14 @@ public class OWLIndividualDescriptionViewComponent extends AbstractOWLIndividual
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -9201605931160593993L;
|
||||
private OWLFrameList<OWLNamedIndividual> list;
|
||||
private OWLFrameList<OWLIndividual> list;
|
||||
|
||||
|
||||
public void initialiseIndividualsView() throws Exception {
|
||||
list = new OWLFrameList<OWLNamedIndividual>(getOWLEditorKit(), new OWLIndividualFrame(getOWLEditorKit()));
|
||||
list = new OWLFrameList<>(getOWLEditorKit(), new OWLIndividualFrame(getOWLEditorKit()));
|
||||
setLayout(new BorderLayout());
|
||||
add(new JScrollPane(list));
|
||||
list.addToPopupMenu(new CreateNewEquivalentClassAction<OWLNamedIndividual>());
|
||||
list.addToPopupMenu(new CreateNewEquivalentClassAction<OWLIndividual>());
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +38,7 @@ public class OWLIndividualDescriptionViewComponent extends AbstractOWLIndividual
|
||||
}
|
||||
|
||||
|
||||
public OWLNamedIndividual updateView(OWLNamedIndividual selelectedIndividual) {
|
||||
public OWLIndividual updateView(OWLIndividual selelectedIndividual) {
|
||||
list.setRootObject(selelectedIndividual);
|
||||
return selelectedIndividual;
|
||||
}
|
||||
|
||||
+40
-14
@@ -6,6 +6,7 @@ import org.protege.editor.owl.model.entity.OWLEntityCreationSet;
|
||||
import org.protege.editor.owl.model.event.EventType;
|
||||
import org.protege.editor.owl.model.event.OWLModelManagerChangeEvent;
|
||||
import org.protege.editor.owl.model.event.OWLModelManagerListener;
|
||||
import org.protege.editor.owl.model.util.HasObjects;
|
||||
import org.protege.editor.owl.ui.OWLIcons;
|
||||
import org.protege.editor.owl.ui.action.DeleteIndividualAction;
|
||||
import org.protege.editor.owl.ui.list.OWLObjectList;
|
||||
@@ -45,14 +46,14 @@ public class OWLIndividualListViewComponent extends AbstractOWLIndividualViewCom
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1519269944342726754L;
|
||||
private OWLObjectList<OWLNamedIndividual> list;
|
||||
private OWLObjectList<OWLIndividual> list;
|
||||
private OWLOntologyChangeListener listener;
|
||||
private ChangeListenerMediator changeListenerMediator;
|
||||
private OWLModelManagerListener modelManagerListener;
|
||||
private int selectionMode = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION;
|
||||
private boolean selectionChangedByUser = true;
|
||||
|
||||
protected Set<OWLNamedIndividual> individualsInList;
|
||||
protected Set<OWLIndividual> individualsInList;
|
||||
|
||||
private ListSelectionListener listSelectionListener = new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
@@ -103,8 +104,8 @@ public class OWLIndividualListViewComponent extends AbstractOWLIndividualViewCom
|
||||
protected void setupActions() {
|
||||
addAction(new AddIndividualAction(), "A", "A");
|
||||
addAction(new DeleteIndividualAction(getOWLEditorKit(),
|
||||
new OWLEntitySetProvider<OWLNamedIndividual>() {
|
||||
public Set<OWLNamedIndividual> getEntities() {
|
||||
new HasObjects<OWLIndividual>() {
|
||||
public Set<OWLIndividual> getObjects() {
|
||||
return getSelectedIndividuals();
|
||||
}
|
||||
}), "B", "A");
|
||||
@@ -121,6 +122,7 @@ public class OWLIndividualListViewComponent extends AbstractOWLIndividualViewCom
|
||||
individualsInList.clear();
|
||||
for (OWLOntology ont : getOntologies()) {
|
||||
individualsInList.addAll(ont.getIndividualsInSignature());
|
||||
individualsInList.addAll(ont.getReferencedAnonymousIndividuals());
|
||||
}
|
||||
reset();
|
||||
}
|
||||
@@ -137,7 +139,7 @@ public class OWLIndividualListViewComponent extends AbstractOWLIndividualViewCom
|
||||
|
||||
|
||||
protected void reset() {
|
||||
OWLNamedIndividual[] objects = individualsInList.toArray(new OWLNamedIndividual[individualsInList.size()]);
|
||||
OWLIndividual [] objects = individualsInList.toArray(new OWLIndividual[individualsInList.size()]);
|
||||
list.setListData(objects);
|
||||
OWLNamedIndividual individual = getSelectedOWLIndividual();
|
||||
selectionChangedByUser = false;
|
||||
@@ -149,7 +151,7 @@ public class OWLIndividualListViewComponent extends AbstractOWLIndividualViewCom
|
||||
}
|
||||
}
|
||||
|
||||
public OWLNamedIndividual updateView(OWLNamedIndividual selelectedIndividual) {
|
||||
public OWLIndividual updateView(OWLIndividual selelectedIndividual) {
|
||||
if (!isPinned()) {
|
||||
list.setSelectedValue(selelectedIndividual, true);
|
||||
}
|
||||
@@ -161,11 +163,11 @@ public class OWLIndividualListViewComponent extends AbstractOWLIndividualViewCom
|
||||
getOWLModelManager().removeListener(modelManagerListener);
|
||||
}
|
||||
|
||||
public OWLNamedIndividual getSelectedIndividual() {
|
||||
public OWLIndividual getSelectedIndividual() {
|
||||
return list.getSelectedValue();
|
||||
}
|
||||
|
||||
public Set<OWLNamedIndividual> getSelectedIndividuals() {
|
||||
public Set<OWLIndividual> getSelectedIndividuals() {
|
||||
return new LinkedHashSet<>(list.getSelectedValuesList());
|
||||
}
|
||||
|
||||
@@ -243,7 +245,7 @@ public class OWLIndividualListViewComponent extends AbstractOWLIndividualViewCom
|
||||
}
|
||||
|
||||
|
||||
public void setSelectedIndividuals(Set<OWLNamedIndividual> individuals) {
|
||||
public void setSelectedIndividuals(Set<OWLIndividual> individuals) {
|
||||
list.setSelectedValues(individuals, true);
|
||||
}
|
||||
|
||||
@@ -275,12 +277,36 @@ public class OWLIndividualListViewComponent extends AbstractOWLIndividualViewCom
|
||||
}
|
||||
|
||||
public void handleDelete() {
|
||||
OWLEntityRemover entityRemover = new OWLEntityRemover(getOWLModelManager().getOWLOntologyManager(),
|
||||
getOWLModelManager().getOntologies());
|
||||
for (OWLNamedIndividual ind : getSelectedIndividuals()) {
|
||||
ind.accept(entityRemover);
|
||||
List<OWLOntologyChange> changes = new ArrayList<>();
|
||||
for (OWLIndividual ind : getSelectedIndividuals()) {
|
||||
for(OWLOntology ont : getOWLModelManager().getOntologies()) {
|
||||
if(ind.isNamed()) {
|
||||
OWLNamedIndividual namedIndividual = ind.asOWLNamedIndividual();
|
||||
for(OWLAxiom ax : ont.getReferencingAxioms(namedIndividual)) {
|
||||
changes.add(new RemoveAxiom(ont, ax));
|
||||
}
|
||||
for(OWLAnnotationAssertionAxiom ax : ont.getAnnotationAssertionAxioms(namedIndividual.getIRI())) {
|
||||
changes.add(new RemoveAxiom(ont, ax));
|
||||
}
|
||||
}
|
||||
else {
|
||||
OWLAnonymousIndividual anonymousIndividual = ind.asOWLAnonymousIndividual();
|
||||
for(OWLAxiom ax : ont.getReferencingAxioms(anonymousIndividual)) {
|
||||
changes.add(new RemoveAxiom(ont, ax));
|
||||
}
|
||||
for(OWLAnnotationAssertionAxiom ax : ont.getAnnotationAssertionAxioms(anonymousIndividual)) {
|
||||
changes.add(new RemoveAxiom(ont, ax));
|
||||
}
|
||||
}
|
||||
|
||||
for(OWLAnnotationAssertionAxiom ax : ont.getAxioms(AxiomType.ANNOTATION_ASSERTION)) {
|
||||
if(ax.getValue().equals(ind)) {
|
||||
changes.add(new RemoveAxiom(ont, ax));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
getOWLModelManager().applyChanges(entityRemover.getChanges());
|
||||
getOWLModelManager().applyChanges(changes);
|
||||
}
|
||||
|
||||
public boolean canDelete() {
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ public class OWLIndividualPropertyAssertionsViewComponent extends AbstractOWLInd
|
||||
|
||||
|
||||
public void initialiseIndividualsView() throws Exception {
|
||||
list = new OWLFrameList<OWLIndividual>(getOWLEditorKit(),
|
||||
list = new OWLFrameList<>(getOWLEditorKit(),
|
||||
new OWLIndividualPropertyAssertionsFrame(getOWLEditorKit()));
|
||||
setLayout(new BorderLayout());
|
||||
add(new JScrollPane(list));
|
||||
@@ -41,7 +41,7 @@ public class OWLIndividualPropertyAssertionsViewComponent extends AbstractOWLInd
|
||||
}
|
||||
|
||||
|
||||
public OWLNamedIndividual updateView(OWLNamedIndividual selelectedIndividual) {
|
||||
public OWLIndividual updateView(OWLIndividual selelectedIndividual) {
|
||||
list.setRootObject(selelectedIndividual);
|
||||
return selelectedIndividual;
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package org.protege.editor.owl.ui.view.individual;
|
||||
|
||||
import org.protege.editor.owl.ui.usage.UsagePanel;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -28,7 +29,7 @@ public class OWLIndividualUsageViewComponent extends AbstractOWLIndividualViewCo
|
||||
}
|
||||
|
||||
|
||||
public OWLNamedIndividual updateView(OWLNamedIndividual individual) {
|
||||
public OWLIndividual updateView(OWLIndividual individual) {
|
||||
usagePanel.setOWLEntity(individual);
|
||||
return individual;
|
||||
}
|
||||
|
||||
+4
-3
@@ -8,6 +8,7 @@ import org.protege.editor.owl.ui.tree.CountingOWLObjectTreeCellRenderer;
|
||||
import org.protege.editor.owl.ui.tree.OWLModelManagerTree;
|
||||
import org.protege.editor.owl.ui.tree.OWLObjectTree;
|
||||
import org.semanticweb.owlapi.model.OWLEntity;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLObject;
|
||||
|
||||
@@ -68,8 +69,8 @@ public class OWLIndividualsByInferredTypeViewComponent extends AbstractOWLIndivi
|
||||
getOWLModelManager().addListener(managerListener);
|
||||
|
||||
provider = new IndividualsByInferredTypeHierarchyProvider(getOWLModelManager().getOWLOntologyManager());
|
||||
tree = new OWLModelManagerTree<OWLObject>(getOWLEditorKit(), provider);
|
||||
tree.setCellRenderer(new CountingOWLObjectTreeCellRenderer<OWLObject>(getOWLEditorKit(), tree));
|
||||
tree = new OWLModelManagerTree<>(getOWLEditorKit(), provider);
|
||||
tree.setCellRenderer(new CountingOWLObjectTreeCellRenderer<>(getOWLEditorKit(), tree));
|
||||
|
||||
add(new JScrollPane(tree));
|
||||
|
||||
@@ -83,7 +84,7 @@ public class OWLIndividualsByInferredTypeViewComponent extends AbstractOWLIndivi
|
||||
}
|
||||
|
||||
|
||||
public OWLNamedIndividual updateView(OWLNamedIndividual selelectedIndividual) {
|
||||
public OWLIndividual updateView(OWLIndividual selelectedIndividual) {
|
||||
OWLObject selObj = tree.getSelectedOWLObject();
|
||||
if (selelectedIndividual != null && selObj != null) {
|
||||
if (selelectedIndividual.equals(selObj)) {
|
||||
|
||||
+9
-8
@@ -4,6 +4,7 @@ import org.protege.editor.core.ui.RefreshableComponent;
|
||||
import org.protege.editor.core.ui.view.DisposableAction;
|
||||
import org.protege.editor.owl.model.entity.OWLEntityCreationSet;
|
||||
import org.protege.editor.owl.model.hierarchy.IndividualsByTypeHierarchyProvider;
|
||||
import org.protege.editor.owl.model.util.HasObjects;
|
||||
import org.protege.editor.owl.ui.OWLIcons;
|
||||
import org.protege.editor.owl.ui.action.DeleteIndividualAction;
|
||||
import org.protege.editor.owl.ui.tree.CountingOWLObjectTreeCellRenderer;
|
||||
@@ -151,8 +152,8 @@ public class OWLIndividualsByTypeViewComponent extends AbstractOWLSelectionViewC
|
||||
}
|
||||
} , "A", "A");
|
||||
addAction(new DeleteIndividualAction(getOWLEditorKit(),
|
||||
new OWLEntitySetProvider<OWLNamedIndividual>() {
|
||||
public Set<OWLNamedIndividual> getEntities() {
|
||||
new HasObjects<OWLIndividual>() {
|
||||
public Set<OWLIndividual> getObjects() {
|
||||
return getSelectedIndividuals();
|
||||
}
|
||||
}), "B", "A");
|
||||
@@ -176,7 +177,7 @@ public class OWLIndividualsByTypeViewComponent extends AbstractOWLSelectionViewC
|
||||
final protected OWLObject updateView() {
|
||||
OWLObject sel = null;
|
||||
OWLEntity entity = getOWLWorkspace().getOWLSelectionModel().getSelectedEntity();
|
||||
if (entity instanceof OWLClass || entity instanceof OWLNamedIndividual){
|
||||
if (entity instanceof OWLClass || entity instanceof OWLIndividual){
|
||||
sel = updateView(entity);
|
||||
if (sel != null) {
|
||||
updateRegisteredActions();
|
||||
@@ -189,12 +190,12 @@ public class OWLIndividualsByTypeViewComponent extends AbstractOWLSelectionViewC
|
||||
}
|
||||
|
||||
|
||||
private Set<OWLNamedIndividual> getSelectedIndividuals(){
|
||||
private Set<OWLIndividual> getSelectedIndividuals(){
|
||||
List<OWLObject> sel = tree.getSelectedOWLObjects();
|
||||
Set<OWLNamedIndividual> selIndivs = new HashSet<OWLNamedIndividual>();
|
||||
Set<OWLIndividual> selIndivs = new HashSet<>();
|
||||
for (OWLObject obj : sel){
|
||||
if (obj instanceof OWLNamedIndividual){
|
||||
selIndivs.add((OWLNamedIndividual)obj);
|
||||
if (obj instanceof OWLIndividual){
|
||||
selIndivs.add((OWLIndividual)obj);
|
||||
}
|
||||
}
|
||||
return selIndivs;
|
||||
@@ -227,7 +228,7 @@ public class OWLIndividualsByTypeViewComponent extends AbstractOWLSelectionViewC
|
||||
//////// Findable
|
||||
|
||||
public List<OWLNamedIndividual> find(String match) {
|
||||
return new ArrayList<OWLNamedIndividual>(getOWLModelManager().getOWLEntityFinder().getMatchingOWLIndividuals(match));
|
||||
return new ArrayList<>(getOWLModelManager().getOWLEntityFinder().getMatchingOWLIndividuals(match));
|
||||
}
|
||||
|
||||
public void show(OWLNamedIndividual owlEntity) {
|
||||
|
||||
+6
-14
@@ -7,14 +7,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.protege.editor.owl.model.selection.OWLSelectionModelListener;
|
||||
import org.semanticweb.owlapi.model.AddAxiom;
|
||||
import org.semanticweb.owlapi.model.OWLAxiom;
|
||||
import org.semanticweb.owlapi.model.OWLClass;
|
||||
import org.semanticweb.owlapi.model.OWLClassExpression;
|
||||
import org.semanticweb.owlapi.model.OWLIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLNamedIndividual;
|
||||
import org.semanticweb.owlapi.model.OWLOntology;
|
||||
import org.semanticweb.owlapi.model.OWLOntologyChange;
|
||||
import org.semanticweb.owlapi.model.*;
|
||||
|
||||
/**
|
||||
* Author: drummond<br>
|
||||
@@ -56,11 +49,10 @@ public class OWLMembersListViewComponent extends OWLIndividualListViewComponent{
|
||||
protected void refill() {
|
||||
individualsInList.clear();
|
||||
OWLClass cls = getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass();
|
||||
if (cls != null){
|
||||
Set<OWLIndividual> individuals = cls.getIndividuals(getOntologies());
|
||||
for (OWLIndividual ind : individuals){
|
||||
if (!ind.isAnonymous()){ //TODO: why are anonymous individuals filtered out?
|
||||
individualsInList.add(ind.asOWLNamedIndividual());
|
||||
if (cls != null) {
|
||||
for(OWLOntology ontology : getOntologies()) {
|
||||
for(OWLClassAssertionAxiom ax : ontology.getClassAssertionAxioms(cls)) {
|
||||
individualsInList.add(ax.getIndividual());
|
||||
}
|
||||
}
|
||||
if (cls.equals(getOWLModelManager().getOWLDataFactory().getOWLThing())) {
|
||||
@@ -72,7 +64,7 @@ public class OWLMembersListViewComponent extends OWLIndividualListViewComponent{
|
||||
|
||||
//TODO: do we want to cache this?
|
||||
protected Set<OWLNamedIndividual> getUntypedIndividuals() {
|
||||
Set<OWLNamedIndividual> untypedIndividuals = new HashSet<OWLNamedIndividual>();
|
||||
Set<OWLNamedIndividual> untypedIndividuals = new HashSet<>();
|
||||
OWLOntology activeOntology = getOWLModelManager().getActiveOntology();
|
||||
Set<OWLOntology> importsClosure = activeOntology.getImportsClosure();
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário