use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class ConnectExceptionHandler method handle.
@Override
public boolean handle(Thread thread, Throwable exception) {
@SuppressWarnings("unchecked") List<Throwable> list = ExceptionUtils.getThrowableList(exception);
for (Throwable throwable : list) {
if (throwable instanceof RemoteAccessException) {
Messages messages = AppBeans.get(Messages.NAME);
String msg = messages.getMessage(getClass(), "connectException.message");
if (throwable.getCause() == null) {
App.getInstance().getMainFrame().showNotification(msg, Frame.NotificationType.ERROR);
} else {
String description = messages.formatMessage(getClass(), "connectException.description", throwable.getCause().toString());
App.getInstance().getMainFrame().showNotification(msg, description, Frame.NotificationType.ERROR);
}
return true;
}
}
return false;
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class LogWindow method initUI.
private void initUI() {
ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class);
String closeShortcut = clientConfig.getCloseShortcut();
KeyCombination closeCombination = KeyCombination.create(closeShortcut);
com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction("closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers()));
addActionHandler(new com.vaadin.event.Action.Handler() {
@Override
public com.vaadin.event.Action[] getActions(Object target, Object sender) {
return new com.vaadin.event.Action[] { closeShortcutAction };
}
@Override
public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
if (Objects.equals(action, closeShortcutAction)) {
close();
}
}
});
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
layout.setSizeFull();
setContent(layout);
Panel scrollablePanel = new Panel();
scrollablePanel.setSizeFull();
VerticalLayout scrollContent = new VerticalLayout();
scrollContent.setSizeUndefined();
scrollablePanel.setContent(scrollContent);
final Label label = new Label();
label.setContentMode(ContentMode.HTML);
label.setValue(writeLog());
label.setSizeUndefined();
label.setStyleName("c-log-content");
((Layout) scrollablePanel.getContent()).addComponent(label);
HorizontalLayout topLayout = new HorizontalLayout();
topLayout.setWidth("100%");
topLayout.setHeightUndefined();
Messages messages = AppBeans.get(Messages.NAME);
Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), (Button.ClickListener) event -> label.setValue(writeLog()));
topLayout.addComponent(refreshBtn);
layout.addComponent(topLayout);
layout.addComponent(scrollablePanel);
layout.setExpandRatio(scrollablePanel, 1.0f);
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class PresentationEditor method initLayout.
protected void initLayout() {
ThemeConstants theme = App.getInstance().getThemeConstants();
VerticalLayout root = new VerticalLayout();
root.setWidthUndefined();
root.setSpacing(true);
setContent(root);
messages = AppBeans.get(Messages.class);
nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
nameField.setValue(getPresentationCaption());
root.addComponent(nameField);
autoSaveField = new CheckBox();
autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
root.addComponent(autoSaveField);
defaultField = new CheckBox();
defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
root.addComponent(defaultField);
if (allowGlobalPresentations) {
globalField = new CheckBox();
globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
globalField.setValue(!isNew && presentation.getUser() == null);
root.addComponent(globalField);
}
HorizontalLayout buttons = new HorizontalLayout();
buttons.setSpacing(true);
buttons.setWidthUndefined();
root.addComponent(buttons);
root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);
Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
commitButton.addClickListener(event -> {
if (validate()) {
commit();
close();
}
});
buttons.addComponent(commitButton);
Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
closeButton.addClickListener(event -> {
close();
});
buttons.addComponent(closeButton);
nameField.focus();
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class NumericOverflowExceptionHandler method doHandle.
@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
Messages messages = AppBeans.get(Messages.NAME);
String msg = messages.getMessage(getClass(), "numericFieldOverflow.message");
windowManager.showNotification(msg, Frame.NotificationType.ERROR);
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class WebEntityLinkField method openEntityEditor.
protected void openEntityEditor() {
Object value = getValue();
Entity entity;
if (value instanceof Entity) {
entity = (Entity) value;
} else {
entity = datasource.getItem();
}
if (entity == null) {
return;
}
WindowManager wm;
Window window = ComponentsHelper.getWindow(this);
if (window == null) {
throw new IllegalStateException("Please specify Frame for EntityLinkField");
} else {
wm = window.getWindowManager();
}
if (screenOpenType.getOpenMode() == OpenMode.DIALOG && screenDialogParams != null) {
wm.getDialogParams().copyFrom(screenDialogParams);
}
if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) {
Messages messages = AppBeans.get(Messages.NAME);
wm.showNotification(messages.getMainMessage("OpenAction.objectIsDeleted"), Frame.NotificationType.HUMANIZED);
return;
}
DataSupplier dataSupplier = window.getDsContext().getDataSupplier();
entity = dataSupplier.reload(entity, View.MINIMAL);
String windowAlias = screen;
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
if (windowAlias == null) {
windowAlias = windowConfig.getEditorScreenId(entity.getMetaClass());
}
final Window.Editor editor = wm.openEditor(windowConfig.getWindowInfo(windowAlias), entity, screenOpenType, screenParams != null ? screenParams : Collections.<String, Object>emptyMap());
editor.addCloseListener(actionId -> {
// move focus to component
component.focus();
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
Entity item = editor.getItem();
afterCommitOpenedEntity(item);
}
if (screenCloseListener != null) {
screenCloseListener.windowClosed(editor, actionId);
}
});
}
Aggregations