本文整理汇总了Java中com.vaadin.shared.ui.ContentMode.PREFORMATTED属性的典型用法代码示例。如果您正苦于以下问题:Java ContentMode.PREFORMATTED属性的具体用法?Java ContentMode.PREFORMATTED怎么用?Java ContentMode.PREFORMATTED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.vaadin.shared.ui.ContentMode
的用法示例。
在下文中一共展示了ContentMode.PREFORMATTED属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNoLogsText
private Label getNoLogsText(Application app, Environment env, String loggingPath, String loggingFile) {
String loggingPathUnavailable;
if(StringUtils.isEmpty(loggingPath)) {
loggingPathUnavailable = "- Property 'logging.path' is not set";
} else {
loggingPathUnavailable = String.format("- Property 'logging.path' is set to '%s'", loggingPath);
}
String loggingFileUnavailable;
if(StringUtils.isEmpty(loggingFile)) {
loggingFileUnavailable = "- Property 'logging.file' is not set";
} else {
loggingFileUnavailable = String.format("- Property 'logging.file' is set to '%s'", loggingFile);
}
String noLogsText = new StringBuilder()
.append(String.format("Endpoint %s is not available because:", app.endpoints().logfile()))
.append("\n")
.append(loggingPathUnavailable)
.append("\n")
.append(loggingFileUnavailable)
.append("\n")
.append("(at least one of those properties have to be properly set)")
.append("\n\n")
.append(String.format("Generated value for LOG_FILE property: %s", env.get("LOG_FILE")))
.toString();
return new Label(noLogsText, ContentMode.PREFORMATTED);
}
示例2: setMessageToHtml
public static void setMessageToHtml(String message, ContentMode contentMode, HTML widget) {
if(contentMode == ContentMode.HTML) {
widget.setHTML(message);
} else if(contentMode == ContentMode.PREFORMATTED) {
PreElement preElement = Document.get().createPreElement();
preElement.setInnerText(message);
widget.setHTML(preElement.getString());
} else {
widget.setText(message);
}
}
示例3: onStateChanged
@Override
public void onStateChanged(StateChangeEvent event) {
super.onStateChanged(event);
clickEventHandler.handleEventHandlerRegistration();
String url = getResourceUrl(AbstractEmbeddedState.SOURCE_RESOURCE);
getWidget().setUrl(url);
for(String property : getState().styleValues.keySet()) {
String value = getState().styleValues.get(property);
Style elementStyle = getWidget().getElement().getStyle();
if(value == null || value.isEmpty()) {
elementStyle.clearProperty(property);
} else {
elementStyle.setProperty(property, value);
}
}
if(getState().innerContentMode == ContentMode.HTML) {
getWidget().setInnerHtml(getState().innerContent);
} else if(getState().innerContentMode == ContentMode.PREFORMATTED) {
PreElement preElement = Document.get().createPreElement();
preElement.setInnerText(getState().innerContent);
getWidget().getElement().removeAllChildren();
getWidget().getElement().appendChild(preElement);
} else {
getWidget().setInnerText(getState().innerContent);
}
getWidget().setAriaLabel(getState().alternateText);
}
示例4: getLogsPanel
private Panel getLogsPanel(Application app, String logs, String propertyLoggingPath) {
// Logs text area
Label logsLabel = new Label(logs, ContentMode.PREFORMATTED);
logsLabel.setStyleName("app-logs");
// Create panel
VerticalLayout layout = new VerticalLayout(logsLabel);
layout.setSpacing(false);
layout.setSizeUndefined();
Panel panel = new Panel(String.format("Application Logs (from %s)", propertyLoggingPath), layout);
panel.setHeight(500, Unit.PIXELS);
scrollToBottom(panel);
// Auto refresh logs
ajaxRefreshInit(args -> {
int uiId = ((PersephoneUI)getUI()).getUIId();
LOGGER.trace("UI-{}: Logs Refresh Start", uiId);
// Get current session range
LogsRange currentSessionRange = ((PersephoneUI)getUI()).getUserData().getCurrentRange();
LOGGER.trace("UI-{}: Logs Refresh: Current Range: {}-{}", uiId, currentSessionRange.getStart(), currentSessionRange.getEnd());
// Get next logs range to retrieve
LogsRange nextRange = logsService.getLogsRange(app, currentSessionRange, bytesToRetrieveRefresh);
LOGGER.trace("UI-{}: Logs Refresh: Next Range: {}-{}", uiId, nextRange.getStart(), nextRange.getEnd());
// Update current range into user session
((PersephoneUI)getUI()).getUserData().setCurrentRange(nextRange);
// Get logs
String newLogs = logsService.getLogs(app, nextRange);
// Update UI
if(!StringUtils.isEmpty(newLogs)) {
String oldLogs = logsLabel.getValue();
// Too much logs displayed => let's strip them out
if(oldLogs.length() + newLogs.length() > bytesToDisplayMax) {
newLogs = oldLogs + newLogs;
LOGGER.trace("UI-{}: Logs Refresh: Too much logs are going to be displayed (length={}), it will be stripped to {} chars", uiId, newLogs.length(), bytesToDisplayMax);
newLogs = newLogs.substring(newLogs.length() - bytesToDisplayMax);
logsLabel.setValue(newLogs);
}
// max length not reached yet
else {
logsLabel.setValue(oldLogs + newLogs);
}
}
scrollToBottom(panel);
LOGGER.trace("UI-{} Logs Refresh End", uiId);
});
return panel;
}
示例5: setContentMode
/**
* Set the ContentMode
*
* @param contentMode The new content mode
*/
public void setContentMode(ContentMode contentMode) {
getState().descriptionContentMode = Objects.isNull(contentMode) ? ContentMode.PREFORMATTED : contentMode;
}