org.protege.editor.owl.diff.DifferenceActivator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of owl-diff Show documentation
Show all versions of owl-diff Show documentation
Plug-in for the Protege Desktop ontology editor for comparing two OWL ontologies.
The newest version!
package org.protege.editor.owl.diff;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.protege.editor.core.ui.error.ErrorLogPanel;
import org.protege.owl.diff.align.AlignmentAlgorithm;
import org.protege.owl.diff.present.PresentationAlgorithm;
import org.protege.owl.diff.util.ClassLoaderWrapper;
import org.protege.owl.diff.util.Util;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
public final class DifferenceActivator implements BundleActivator {
private static BundleContext context;
public static List> createAlignmentAlgorithms() {
List> algorithms = new ArrayList>();
for (Bundle b : context.getBundles()) {
try {
algorithms.addAll(Util.createDeclaredAlignmentAlgorithms(wrapBundle(b)));
}
catch (IOException ioe) {
ErrorLogPanel.showErrorDialog(ioe);
}
}
return algorithms;
}
public static List> createPresentationAlgorithms() {
List> algorithms = new ArrayList>();
for (Bundle b : context.getBundles()) {
try {
algorithms.addAll(Util.createDeclaredPresentationAlgorithms(wrapBundle(b)));
}
catch (IOException ioe) {
ErrorLogPanel.showErrorDialog(ioe);
}
}
return algorithms;
}
private static ClassLoaderWrapper wrapBundle(final Bundle b) {
return new ClassLoaderWrapper() {
public Class loadClass(String name) throws ClassNotFoundException {
return b.loadClass(name);
}
@SuppressWarnings("unchecked")
public Enumeration getResources(String name) throws IOException {
return b.getResources(name);
}
};
}
public void start(BundleContext context) {
DifferenceActivator.context = context;
}
public void stop(BundleContext context) {
}
}