-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ac21f5
commit 0ea5504
Showing
5 changed files
with
156 additions
and
47 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...itor-owl/src/main/java/org/protege/editor/owl/model/OWLEditorKitIRIShortFormProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.protege.editor.owl.model; | ||
|
||
import org.protege.editor.owl.OWLEditorKit; | ||
import org.semanticweb.owlapi.model.IRI; | ||
import org.semanticweb.owlapi.model.OWLEntity; | ||
import org.semanticweb.owlapi.util.IRIShortFormProvider; | ||
import org.semanticweb.owlapi.util.SimpleIRIShortFormProvider; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import java.util.Set; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* Matthew Horridge | ||
* Stanford Center for Biomedical Informatics Research | ||
* 7 Nov 2016 | ||
*/ | ||
public class OWLEditorKitIRIShortFormProvider implements IRIShortFormProvider { | ||
|
||
private final OWLEditorKit editorKit; | ||
|
||
private final SimpleIRIShortFormProvider delegateIRIShortFormProvider; | ||
|
||
public OWLEditorKitIRIShortFormProvider(@Nonnull OWLEditorKit editorKit, | ||
@Nonnull SimpleIRIShortFormProvider delegateIRIShortFormProvider) { | ||
this.editorKit = checkNotNull(editorKit); | ||
this.delegateIRIShortFormProvider = checkNotNull(delegateIRIShortFormProvider); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getShortForm(@Nonnull IRI iri) { | ||
OWLModelManager manager = editorKit.getOWLModelManager(); | ||
Set<OWLEntity> entityWithIri = manager.getActiveOntology().getEntitiesInSignature(iri); | ||
if(entityWithIri.isEmpty()) { | ||
return delegateIRIShortFormProvider.getShortForm(iri); | ||
} | ||
else { | ||
return manager.getRendering(entityWithIri.iterator().next()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters