Skip to content

Commit

Permalink
fixes #387
Browse files Browse the repository at this point in the history
Merge branch 'fix/387' into release/2.1.1
  • Loading branch information
nilsreiter committed Jun 21, 2022
2 parents 4baf056 + c3f87cf commit 21f45cc
Show file tree
Hide file tree
Showing 3 changed files with 595 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.EventObject;
import java.util.Map;
Expand Down Expand Up @@ -809,7 +810,13 @@ public void setDocumentModel(DocumentModel model) {
segmentIndicator.setLastCharacterPosition(model.getJcas().getDocumentText().length());
}

for (Flag f : model.getFlagModel().getFlags()) {
for (Flag f : model.getFlagModel().getFlags().toSortedList(new Comparator<Flag>() {

@Override
public int compare(Flag o1, Flag o2) {
return o1.getLabel().compareTo(o2.getLabel());
}
})) {
ToggleFlagAction a = new ToggleFlagAction(DocumentWindow.this, model.getFlagModel(), f);
tree.addTreeSelectionListener(a);
try {
Expand Down Expand Up @@ -1610,28 +1617,26 @@ protected JMenu getMentionItem(Mention m) {
StringBuilder b = new StringBuilder();
b.append(m.getAddress());

String mention = StringUtils
.abbreviateMiddle(UimaUtil.getCoveredText(m), "...", 20);
String mention = StringUtils.abbreviateMiddle(UimaUtil.getCoveredText(m), "...", 20);

if (m.getEntity().getLabel() != null) {
String entity = StringUtils.abbreviateMiddle(
getDocumentModel().getCoreferenceModel().getLabel(m.getEntity()), "...",
Constants.UI_MAX_STRING_WIDTH_IN_MENU / 2);
b.append(String.format(": %s (%s)", mention, entity));
}

JMenu mentionMenu = new JMenu(b.toString());
mentionMenu.setIcon(FontIcon.of(MaterialDesign.MDI_ACCOUNT, new Color(m.getEntity().getColor())));
Action a = new ShowMentionInTreeAction(DocumentWindow.this, m);
mentionMenu.add(String.format("\"%s\"", mention));
mentionMenu.getItem(mentionMenu.getItemCount() - 1).setEnabled(false);
mentionMenu.add(a);
mentionMenu.add(new DeleteAction(DocumentWindow.this, m));

if (m.getSurface().size() > 1) {
for (MentionSurface ms : m.getSurface()) {
JMenu mentionSurfaceMenu = new JMenu(StringUtils.abbreviateMiddle(
ms.getCoveredText(), "...",
JMenu mentionSurfaceMenu = new JMenu(StringUtils.abbreviateMiddle(ms.getCoveredText(), "...",
Constants.UI_MAX_STRING_WIDTH_IN_MENU));
mentionSurfaceMenu.add(new DeleteAction(DocumentWindow.this, ms));
mentionMenu.add(mentionSurfaceMenu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import de.unistuttgart.ims.coref.annotator.DocumentWindow;
import de.unistuttgart.ims.coref.annotator.action.ToggleFlagAction;
import de.unistuttgart.ims.coref.annotator.api.v2.Flag;
import de.unistuttgart.ims.coref.annotator.api.v2.Flag;
import de.unistuttgart.ims.coref.annotator.document.FeatureStructureEvent;
import de.unistuttgart.ims.coref.annotator.document.FlagModel;
import de.unistuttgart.ims.coref.annotator.document.FlagModelListener;
Expand All @@ -25,12 +25,14 @@ public class FlagMenu extends JMenu implements FlagModelListener {
public FlagMenu(String s, DocumentWindow dw) {
super(s);
this.dw = dw;
MenuScroller.setScrollerFor(this, 20, 125, 3, 1);
}

public FlagMenu(String s, DocumentWindow dw, Class<? extends FeatureStructure> tClass) {
super(s);
this.dw = dw;
this.targetClass = tClass;
MenuScroller.setScrollerFor(this, 20, 125, 3, 1);
}

public JMenuItem add(Flag f, JMenuItem mi) {
Expand Down
Loading

0 comments on commit 21f45cc

Please sign in to comment.