use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.
the class ReferenceLinkEditor method attach.
@Override
public void attach() {
super.attach();
if (getUI() instanceof AnnisUI) {
AnnisUI annisUI = (AnnisUI) getUI();
UrlShortener shortener = annisUI.getUrlShortener();
dataProvider = createDataProvider(shortener).withConfigurableFilter();
grid.setDataProvider(dataProvider);
addEditableBindings(temporaryColumn, dataProvider, annisUI);
}
Optional<OAuth2User> user = Helper.getUser(getUI());
if (user.isPresent()) {
Set<String> roles = Helper.getUserRoles(user.get());
if (roles.contains("admin")) {
setContent(grid);
}
}
}
use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.
the class ExceptionDialog method buttonClick.
@Override
public void buttonClick(Button.ClickEvent event) {
if (event.getButton() == btDetails) {
if (detailsPanel.isVisible()) {
detailsPanel.setVisible(false);
btDetails.setCaption("Show Details");
layout.setExpandRatio(detailsPanel, 0.0f);
layout.setExpandRatio(actionsLayout, 1.0f);
} else {
detailsPanel.setVisible(true);
btDetails.setCaption("Hide Details");
layout.setExpandRatio(detailsPanel, 1.0f);
layout.setExpandRatio(actionsLayout, 0.0f);
}
} else if (event.getButton() == btClose) {
this.close();
} else if (event.getButton() == btReportBug) {
this.close();
UI ui = UI.getCurrent();
if (ui instanceof AnnisUI) {
((AnnisUI) ui).reportBug(cause);
}
}
}
use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.
the class RawTextVisualizer method createComponent.
@Override
public Panel createComponent(VisualizerInput visInput, VisualizationToggle visToggle) {
// get config for alignment
boolean vertical = Boolean.parseBoolean(visInput.getMappings().getOrDefault("vertical", "true"));
// get the texts
RawTextWrapper texts = visInput.getRawText();
// create the main panel
Panel p = new Panel();
p.setSizeFull();
// some layout configuration
p.addStyleName(ValoTheme.PANEL_BORDERLESS);
p.addStyleName(PANEL_CLASS);
// enable webfonts
p.addStyleName(Helper.CORPUS_FONT_FORCE);
Layout l;
// if no text available inform user and exit
if (texts == null) {
Label text = new Label(NO_TEXT);
text.addStyleName(LABEL_CLASS);
text.setSizeFull();
p.setContent(text);
return p;
}
if (texts.hasMultipleTexts()) {
// set the aligmnent
if (vertical) {
l = new VerticalLayout();
} else {
l = new GridLayout(texts.getTexts().size(), 1);
}
// limit the size to the parent panel.
l.setSizeFull();
// add the texts to the layout
for (int i = 0; i < texts.getTexts().size(); i++) {
String s = texts.getTexts().get(i);
Label lblText;
// check if the text is empty
if (s == null || hasOnlyWhiteSpace(s)) {
lblText = new Label(NO_TEXT);
} else {
lblText = new Label(s, ContentMode.TEXT);
}
if (visInput.getUI() instanceof AnnisUI) {
if (!((AnnisUI) visInput.getUI()).getConfig().isDisableRTL() && Helper.containsRTLText(s)) {
lblText.addStyleName("rtl");
}
}
lblText.setCaption("text " + (i + 1));
lblText.addStyleName(LABEL_CLASS);
lblText.setWidth(98, Sizeable.Unit.PERCENTAGE);
l.addComponent(lblText);
}
// apply the panel
p.setContent(l);
return p;
}
Label lblText;
if (texts.hasTexts() && !hasOnlyWhiteSpace(texts.getFirstText())) {
lblText = new Label(texts.getFirstText(), ContentMode.TEXT);
if (visInput.getUI() instanceof AnnisUI) {
if (!((AnnisUI) visInput.getUI()).getConfig().isDisableRTL() && Helper.containsRTLText(texts.getFirstText())) {
lblText.addStyleName("rtl");
}
}
} else {
lblText = new Label(NO_TEXT);
}
lblText.setSizeFull();
lblText.addStyleName(LABEL_CLASS);
p.setContent(lblText);
return p;
}
use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.
the class SearchOptionsPanel method updateSearchPanelConfigurationInBackground.
public void updateSearchPanelConfigurationInBackground(final Collection<String> corpora) {
setLoadingState(true);
// remove custom adjustments
cbLeftContext.setItems();
cbRightContext.setItems();
cbSegmentation.setItems();
UI ui = getUI();
if (ui instanceof AnnisUI) {
// reload the config in the background
Background.run(new CorpusConfigUpdater((AnnisUI) ui, corpora, true));
}
}
use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.
the class ShareQueryReferenceWindow method attach.
@Override
public void attach() {
super.attach();
String shortURL = "ERROR";
UI ui = UI.getCurrent();
if (query != null && ui instanceof AnnisUI) {
AnnisUI annisUI = (AnnisUI) ui;
URI appURI = UI.getCurrent().getPage().getLocation();
String fragment;
try {
fragment = StringUtils.join(query.toCitationFragment(), "&");
URI url = new URI(appURI.getScheme(), null, appURI.getHost(), appURI.getPort(), appURI.getPath(), null, fragment);
if (shorten) {
shortURL = annisUI.getUrlShortener().shortenURL(url, annisUI);
} else {
shortURL = url.toASCIIString();
}
} catch (URISyntaxException e) {
log.error("Could not generate query share link", e);
ExceptionDialog.show(e, "Could not generate query share link", UI.getCurrent());
}
}
txtCitation.setReadOnly(false);
txtCitation.setValue(shortURL);
txtCitation.setReadOnly(true);
}
Aggregations