use of annis.libgui.AnnisBaseUI in project ANNIS by korpling.
the class ExportPanel method attach.
@Override
public void attach() {
super.attach();
this.ui = UI.getCurrent();
if (this.ui instanceof AnnisBaseUI) {
PluginManagerUtil util = new PluginManagerUtil(((AnnisBaseUI) getUI()).getPluginManager());
for (ExporterPlugin e : util.getPlugins(ExporterPlugin.class)) {
exporterClassContainer.addItem(e.getClass());
}
}
exporterClassContainer.sort(new Object[] { "simpleName" }, new boolean[] { true });
cbExporter.setItemCaptionMode(ItemCaptionMode.PROPERTY);
cbExporter.setItemCaptionPropertyId("simpleName");
if (exporterClassContainer.size() > 0) {
cbExporter.setValue(exporterClassContainer.getIdByIndex(0));
}
}
use of annis.libgui.AnnisBaseUI in project ANNIS by korpling.
the class MainToolbar method attach.
@Override
public void attach() {
super.attach();
UI ui = UI.getCurrent();
if (ui instanceof AnnisBaseUI) {
((AnnisBaseUI) ui).getLoginDataLostBus().register(this);
}
IDGenerator.assignIDForFields(MainToolbar.this, btAboutAnnis, btOpenSource);
}
use of annis.libgui.AnnisBaseUI in project ANNIS by korpling.
the class MainToolbar method detach.
@Override
public void detach() {
UI ui = UI.getCurrent();
if (ui instanceof AnnisBaseUI) {
((AnnisBaseUI) ui).getLoginDataLostBus().unregister(this);
}
super.detach();
}
use of annis.libgui.AnnisBaseUI in project ANNIS by korpling.
the class HTMLVis method injectCSS.
private void injectCSS(String visConfigName, String corpusName, String wrapperClassName) {
InputStream inStreamCSSRaw = null;
if (visConfigName == null) {
inStreamCSSRaw = HTMLVis.class.getResourceAsStream("htmlvis.css");
} else {
WebResource resBinary = Helper.getAnnisWebResource().path("query/corpora/").path(corpusName).path(corpusName).path("binary").path(visConfigName + ".css");
ClientResponse response = resBinary.get(ClientResponse.class);
if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) {
inStreamCSSRaw = response.getEntityInputStream();
}
}
if (inStreamCSSRaw != null) {
try (InputStream inStreamCSS = inStreamCSSRaw) {
String cssContent = IOUtils.toString(inStreamCSS);
UI currentUI = UI.getCurrent();
if (currentUI instanceof AnnisBaseUI) {
// do not add identical CSS files
((AnnisBaseUI) currentUI).injectUniqueCSS(cssContent, wrapperClassName);
}
} catch (IOException ex) {
log.error("Could not parse the HTML visualizer CSS file", ex);
Notification.show("Could not parse the HTML visualizer CSS file", ex.getMessage(), Notification.Type.ERROR_MESSAGE);
}
}
}
use of annis.libgui.AnnisBaseUI in project ANNIS by korpling.
the class HTMLVis method injectWebFonts.
private void injectWebFonts(String visConfigName, String corpusName) {
InputStream inStreamJSONRaw = null;
if (visConfigName != null) {
WebResource resBinary = Helper.getAnnisWebResource().path("query/corpora/").path(corpusName).path(corpusName).path("binary").path(visConfigName + ".fonts.json");
ClientResponse response = resBinary.get(ClientResponse.class);
if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) {
inStreamJSONRaw = response.getEntityInputStream();
}
}
if (inStreamJSONRaw != null) {
try (InputStream inStreamJSON = inStreamJSONRaw) {
ObjectMapper mapper = createJsonMapper();
WebFontList fontConfigList = mapper.readValue(inStreamJSON, WebFontList.class);
for (WebFont fontConfig : fontConfigList.getWebFonts()) {
if (fontConfig != null && fontConfig.getName() != null) {
StringBuilder sb = new StringBuilder();
sb.append("@font-face {\n");
sb.append(" font-family: '" + fontConfig.getName() + "';\n");
sb.append(" font-weight: '" + fontConfig.getWeight() + "';\n");
sb.append(" font-style: '" + fontConfig.getStyle() + "';\n");
List<String> sourceDefs = new LinkedList<>();
for (Map.Entry<String, String> src : fontConfig.getSources().entrySet()) {
sourceDefs.add("url('" + src.getValue() + "') format('" + src.getKey() + "')");
}
if (!sourceDefs.isEmpty()) {
sb.append(" src: ");
sb.append(Joiner.on(",\n ").join(sourceDefs));
sb.append(";\n");
}
sb.append("}\n");
UI currentUI = UI.getCurrent();
if (currentUI instanceof AnnisBaseUI) {
// do not add identical CSS files
((AnnisBaseUI) currentUI).injectUniqueCSS(sb.toString());
}
}
}
} catch (IOException ex) {
log.error("Could not parse the HTML visualizer web-font configuration file", ex);
Notification.show("Could not parse the HTML visualizer web-font configuration file", ex.getMessage(), Notification.Type.ERROR_MESSAGE);
}
}
}
Aggregations