Search in sources :

Example 1 with OwnedAnnotationEditor

use of gate.gui.annedit.OwnedAnnotationEditor in project gate-core by GateNLP.

the class AnnotationSetsView method createAnnotationEditor.

/**
 * Create the annotation editor (responsible for creating the window
 * used to edit individual annotations).
 * @throws ResourceInstantiationException if an error occurs
 */
protected gate.gui.annedit.OwnedAnnotationEditor createAnnotationEditor(TextualDocumentView textView, AnnotationSetsView asView) throws ResourceInstantiationException {
    // find the last VR that implements the AnnotationEditor interface
    List<String> vrTypes = new ArrayList<String>(Gate.getCreoleRegister().getPublicVrTypes());
    Collections.reverse(vrTypes);
    for (String aVrType : vrTypes) {
        ResourceData rData = Gate.getCreoleRegister().get(aVrType);
        try {
            Class<? extends Resource> resClass = rData.getResourceClass();
            if (OwnedAnnotationEditor.class.isAssignableFrom(resClass)) {
                OwnedAnnotationEditor newEditor = (OwnedAnnotationEditor) resClass.newInstance();
                newEditor.setOwner(this);
                newEditor.init();
                if (currentOrientation != null) {
                    newEditor.changeOrientation(currentOrientation);
                }
                return newEditor;
            }
        } catch (ClassNotFoundException cnfe) {
            // ignore
            Err.prln("Invalid CREOLE data:");
            cnfe.printStackTrace(Err.getPrintWriter());
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    // if we got this far, we couldn't find an editor
    Err.prln("Could not find any annotation editors. Editing annotations disabled.");
    return null;
}
Also used : ResourceData(gate.creole.ResourceData) ArrayList(java.util.ArrayList) OwnedAnnotationEditor(gate.gui.annedit.OwnedAnnotationEditor) ResourceInstantiationException(gate.creole.ResourceInstantiationException)

Aggregations

ResourceData (gate.creole.ResourceData)1 ResourceInstantiationException (gate.creole.ResourceInstantiationException)1 OwnedAnnotationEditor (gate.gui.annedit.OwnedAnnotationEditor)1 ArrayList (java.util.ArrayList)1