Skip to content

Commit

Permalink
#4032 - Allow using externalized strings from backend code
Browse files Browse the repository at this point in the history
- Use getStrings to fetch name of AnnotatorJS in backend factory class
- Bit of cleaning up
- Remove more support for `.vue` files which are no longer used by INCEpTION
- Remove unused rat-plugin excludes
- Some minor cleaning up
- Document that annotation processing needs to be turned on in Eclipse
  • Loading branch information
reckart committed May 29, 2023
1 parent 9ab916a commit 927f15e
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static de.tudarmstadt.ukp.clarin.webanno.model.Mode.CURATION;
import static de.tudarmstadt.ukp.clarin.webanno.support.WebAnnoConst.CHAIN_TYPE;
import static org.slf4j.LoggerFactory.getLogger;

import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
Expand All @@ -37,7 +38,6 @@
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.tudarmstadt.ukp.clarin.webanno.api.CasProvider;
import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer;
Expand All @@ -46,27 +46,23 @@
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token;
import de.tudarmstadt.ukp.inception.editor.action.AnnotationActionHandler;
import de.tudarmstadt.ukp.inception.rendering.coloring.ColoringService;
import de.tudarmstadt.ukp.inception.rendering.config.AnnotationEditorProperties;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;
import de.tudarmstadt.ukp.inception.rendering.pipeline.RenderingPipeline;
import de.tudarmstadt.ukp.inception.rendering.request.RenderRequest;
import de.tudarmstadt.ukp.inception.rendering.request.RenderRequestedEvent;
import de.tudarmstadt.ukp.inception.rendering.vmodel.VDocument;
import de.tudarmstadt.ukp.inception.rendering.vmodel.serialization.VDocumentSerializer;
import de.tudarmstadt.ukp.inception.schema.AnnotationSchemaService;
import de.tudarmstadt.ukp.inception.schema.adapter.AnnotationException;

public abstract class AnnotationEditorBase
extends Panel
{
private static final long serialVersionUID = 8637373389151630602L;
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final Logger LOG = getLogger(MethodHandles.lookup().lookupClass());

private @SpringBean AnnotationEditorProperties properties;
private @SpringBean AnnotationEditorExtensionRegistry extensionRegistry;
private @SpringBean AnnotationSchemaService annotationService;
private @SpringBean ColoringService coloringService;
private @SpringBean UserDao userService;
private @SpringBean RenderingPipeline renderingPipeline;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public interface AnnotationEditorFactory
*/
String getBeanName();

/**
* @return the name of the editor as shown to the user.
*/
String getDisplayName();

default int accepts(Project aProject, String aFormat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,15 @@
import de.tudarmstadt.ukp.clarin.webanno.brat.schema.BratSchemaGenerator;
import de.tudarmstadt.ukp.inception.diam.editor.DiamAjaxBehavior;
import de.tudarmstadt.ukp.inception.diam.editor.actions.EditorAjaxRequestHandlerBase;
import de.tudarmstadt.ukp.inception.diam.editor.actions.EditorAjaxRequestHandlerExtensionPoint;
import de.tudarmstadt.ukp.inception.diam.model.ajax.AjaxResponse;
import de.tudarmstadt.ukp.inception.diam.model.ajax.DefaultAjaxResponse;
import de.tudarmstadt.ukp.inception.editor.AnnotationEditorExtensionRegistry;
import de.tudarmstadt.ukp.inception.editor.action.AnnotationActionHandler;
import de.tudarmstadt.ukp.inception.externaleditor.ExternalAnnotationEditorBase;
import de.tudarmstadt.ukp.inception.externaleditor.command.EditorCommand;
import de.tudarmstadt.ukp.inception.externaleditor.command.LoadAnnotationsCommand;
import de.tudarmstadt.ukp.inception.externaleditor.command.QueuedEditorCommandsMetaDataKey;
import de.tudarmstadt.ukp.inception.externaleditor.model.AnnotationEditorProperties;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;
import de.tudarmstadt.ukp.inception.schema.AnnotationSchemaService;

/**
* Brat annotator component.
Expand All @@ -73,11 +70,8 @@ public class BratAnnotationEditor

private static final long serialVersionUID = -1537506294440056609L;

private @SpringBean AnnotationSchemaService annotationService;
private @SpringBean AnnotationEditorExtensionRegistry extensionRegistry;
private @SpringBean BratMetrics metrics;
private @SpringBean BratAnnotationEditorProperties bratProperties;
private @SpringBean EditorAjaxRequestHandlerExtensionPoint handlers;
private @SpringBean BratSerializer bratSerializer;
private @SpringBean BratSchemaGenerator bratSchemaGenerator;
private @SpringBean ServletContext servletContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ We recommend you start from a *Eclipse IDE for Java Developers* package.

== Use a JDK

On Linux or OS X, the following setting is not necessary. Having a full JDK installed on your
system is generally sufficient. You can skip on to the next section.
On Linux or OS X, having a full JDK installed on your system is generally sufficient. You can skip
on to the next section.

On Windows, you need to edit the `eclipse.ini` file and directly before the `-vmargs` line, you
have to add the following two lines. Mind to replace `C:/Program Files/Java/jdk11` with the actual
Expand Down Expand Up @@ -59,8 +59,9 @@ C:/Program Files/Java/jdk11/jre/bin/server/jvm.dll

== Eclipse Workspace Settings

* You should check that Text file encoding is UTF-8 in *Preferences -> General -> Workspace* of
your Eclipse install.
* You should check that Text file encoding is `UTF-8` in *Preferences -> General -> Workspace*.
* You need to enable Java annotation preprocessors. Go to *Preferences -> Maven -> Annotation Processing*
and set the *Annotation Processing Mode* to *Automatic*.

== Importing {product-name} into the Workspace

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import de.tudarmstadt.ukp.inception.diam.model.ajax.DefaultAjaxResponse;
import de.tudarmstadt.ukp.inception.editor.AnnotationEditorBase;
import de.tudarmstadt.ukp.inception.editor.AnnotationEditorExtensionRegistry;
import de.tudarmstadt.ukp.inception.editor.AnnotationEditorRegistry;
import de.tudarmstadt.ukp.inception.editor.action.AnnotationActionHandler;
import de.tudarmstadt.ukp.inception.editor.view.DocumentViewExtensionPoint;
import de.tudarmstadt.ukp.inception.externaleditor.command.CommandQueue;
Expand All @@ -85,7 +84,6 @@ public abstract class ExternalAnnotationEditorBase

private @SpringBean DocumentViewExtensionPoint documentViewExtensionPoint;
private @SpringBean DocumentService documentService;
private @SpringBean AnnotationEditorRegistry annotationEditorRegistry;
private @SpringBean AnnotationEditorExtensionRegistry extensionRegistry;
private @SpringBean ServletContext context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.apache.wicket.model.Model;
import org.apache.wicket.spring.injection.annot.SpringBean;

import com.github.kklisura.java.processing.annotations.PropertySourceConstants;

import de.tudarmstadt.ukp.clarin.webanno.api.CasProvider;
import de.tudarmstadt.ukp.clarin.webanno.api.DocumentService;
import de.tudarmstadt.ukp.inception.annotatorjs.resources.AnnotatorJsCssResourceReference;
Expand All @@ -38,6 +40,7 @@
import de.tudarmstadt.ukp.inception.externaleditor.model.AnnotationEditorProperties;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;

@PropertySourceConstants(resourceName = "de/tudarmstadt/ukp/inception/annotatorjs/wicket-package.properties", className = "Messages_")
public class AnnotatorJsHtmlAnnotationEditor
extends ExternalAnnotationEditorBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import de.tudarmstadt.ukp.clarin.webanno.api.CasProvider;
import de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.NoPagingStrategy;
import de.tudarmstadt.ukp.clarin.webanno.model.Project;
import de.tudarmstadt.ukp.clarin.webanno.support.wicket.resource.Strings;
import de.tudarmstadt.ukp.inception.annotatorjs.config.AnnotatorJsAnnotationEditorSupportAutoConfiguration;
import de.tudarmstadt.ukp.inception.editor.AnnotationEditorBase;
import de.tudarmstadt.ukp.inception.editor.AnnotationEditorFactoryImplBase;
Expand All @@ -43,7 +44,7 @@ public class AnnotatorJsHtmlAnnotationEditorFactory
@Override
public String getDisplayName()
{
return "HTML (AnnotatorJS)";
return Strings.getString(Messages_.ANNOTATORJS_EDITOR_NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed to the Technische Universität Darmstadt under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The Technische Universität Darmstadt
# licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
annotatorjs-editor.name=HTML (AnnotatorJS)
9 changes: 9 additions & 0 deletions inception/inception-html-editor/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<suppress files=".*[/\\]target[/\\].*" checks=".*"/>
</suppressions>
22 changes: 15 additions & 7 deletions inception/inception-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<artifactId>inception-support</artifactId>
<name>INCEpTION - Support library</name>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>

<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-core</artifactId>
Expand Down Expand Up @@ -213,18 +218,21 @@
<excludes combine.children="append">
<!-- Trivial template file which a license header would bloat too much-->
<exclude>src/main/java/de/tudarmstadt/ukp/clarin/webanno/support/wicket/input/remove-input-behavior.js</exclude>
<!-- Apache License without header -->
<exclude>src/main/java/de/tudarmstadt/ukp/clarin/webanno/support/sass/*.java</exclude>
<!-- MIT License -->
<exclude>src/main/java/de/tudarmstadt/ukp/clarin/webanno/support/wicketstuff/UrlParametersReceivingBehavior.java</exclude>
<exclude>src/main/java/de/tudarmstadt/ukp/clarin/webanno/support/bootstrap/select/css/*</exclude>
<exclude>src/main/java/de/tudarmstadt/ukp/clarin/webanno/support/bootstrap/select/js/*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<usedDependencies>
<usedDependency>jakarta.annotation:jakarta.annotation-api</usedDependency>
</usedDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

public class Strings
{
public static String getString(String aKey)
{
return getString(aKey);
}

public static String getString(String aKey, String aDefaultValue)
{
return org.apache.wicket.Application.get().getResourceSettings().getLocalizer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@
"hasFiles": [
"de/tudarmstadt/ukp/clarin/webanno/support/wicket/AjaxDownloadBehavior.java"
]
},
{
"name": "vue3-sfc-loader",
"versionInfo": "0.2.21",
"originator": "Franck Freiburger",
"homepage": "https://github.com/FranckFreiburger/vue3-sfc-loader",
"licenseDeclared": "MIT",
"hasFiles": [
"de/tudarmstadt/ukp/inception/support/vue/vue3-sfc-loader.min.js",
"de/tudarmstadt/ukp/inception/support/vue/vue3-sfc-loader.min.js.map"
]
}
]
}
30 changes: 30 additions & 0 deletions inception/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
<!-- * 4.6.1 depends on Lucene 8.11.1 -->
<!-- 4.7.0 depends on Lucene 9.4.2 -->

<props-to-constants-generator.version>1.0.0</props-to-constants-generator.version>

<asciidoctor.plugin.version>2.2.3</asciidoctor.plugin.version>
<asciidoctor.version>2.5.8</asciidoctor.version>
<asciidoctor-diagram.version>2.2.7</asciidoctor-diagram.version>
Expand Down Expand Up @@ -333,6 +335,14 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<!-- Generation of constants for I18N properties files -->
<dependency>
<groupId>com.github.kklisura.java.processing</groupId>
<artifactId>props-to-constants-generator</artifactId>
<optional>true</optional>
</dependency>


<!-- JAXB is no longer included with Java 9+ by default -->
<dependency>
Expand Down Expand Up @@ -2281,6 +2291,12 @@
<artifactId>ivy</artifactId>
<version>2.5.1</version>
</dependency>

<dependency>
<groupId>com.github.kklisura.java.processing</groupId>
<artifactId>props-to-constants-generator</artifactId>
<version>${props-to-constants-generator.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -2446,6 +2462,16 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.github.kklisura.java.processing</groupId>
<artifactId>props-to-constants-generator</artifactId>
<version>${props-to-constants-generator.version}</version>
</path>
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</path>
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
Expand Down Expand Up @@ -2568,6 +2594,10 @@
- Generation of Spring Property Metadata files
-->
<dependency>org.springframework.boot:spring-boot-configuration-processor</dependency>
<!--
- Generation of constants for I18N properties files
-->
<dependency>com.github.kklisura.java.processing:props-to-constants-generator</dependency>
<!--
- Common test dependencies
-->
Expand Down

0 comments on commit 927f15e

Please sign in to comment.