use of com.haulmont.cuba.web.AppUI in project cuba by cuba-platform.
the class DefaultExceptionHandler method showDialog.
protected void showDialog(App app, Throwable exception) {
Throwable rootCause = ExceptionUtils.getRootCause(exception);
if (rootCause == null) {
rootCause = exception;
}
ExceptionDialog dialog = new ExceptionDialog(rootCause);
AppUI ui = app.getAppUI();
for (Window window : ui.getWindows()) {
if (window.isModal()) {
dialog.setModal(true);
break;
}
}
ui.addWindow(dialog);
dialog.focus();
}
use of com.haulmont.cuba.web.AppUI in project cuba by cuba-platform.
the class NoUserSessionHandler method showNoUserSessionDialog.
protected void showNoUserSessionDialog(App app) {
Messages messages = AppBeans.get(Messages.NAME);
Window dialog = new NoUserSessionExceptionDialog();
dialog.setStyleName("c-nousersession-dialog");
dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
dialog.setClosable(false);
dialog.setResizable(false);
dialog.setModal(true);
AppUI ui = app.getAppUI();
if (ui.isTestMode()) {
dialog.setCubaId("optionDialog");
dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
}
Label messageLab = new CubaLabel();
messageLab.setWidthUndefined();
messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
layout.setWidthUndefined();
layout.setStyleName("c-nousersession-dialog-layout");
layout.setSpacing(true);
dialog.setContent(layout);
Button reloginBtn = new Button();
if (ui.isTestMode()) {
reloginBtn.setCubaId("reloginBtn");
reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
}
reloginBtn.addStyleName(WebButton.ICON_STYLE);
reloginBtn.addStyleName("c-primary-action");
reloginBtn.addClickListener(event -> relogin());
reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));
String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
reloginBtn.setIcon(AppBeans.get(IconResolver.class).getIconResource(iconName));
ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());
reloginBtn.focus();
layout.addComponent(messageLab);
layout.addComponent(reloginBtn);
layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);
ui.addWindow(dialog);
dialog.center();
}
use of com.haulmont.cuba.web.AppUI in project cuba by cuba-platform.
the class WindowBreadCrumbs method update.
public void update() {
AppUI ui = AppUI.getCurrent();
boolean isTestMode = ui.isTestMode();
linksLayout.removeAllComponents();
btn2win.clear();
for (Iterator<Window> it = windows.iterator(); it.hasNext(); ) {
Window window = it.next();
Button button = new CubaButton(StringUtils.trimToEmpty(window.getCaption()), new BtnClickListener());
button.setSizeUndefined();
button.setStyleName(BaseTheme.BUTTON_LINK);
button.setTabIndex(-1);
if (isTestMode) {
button.setCubaId("breadCrubms_Button_" + window.getId());
button.setId(ui.getTestIdManager().getTestId("breadCrubms_Button_" + window.getId()));
}
btn2win.put(button, window);
if (it.hasNext()) {
linksLayout.addComponent(button);
Label separatorLab = new Label(" > ");
separatorLab.setStyleName("c-breadcrumbs-separator");
separatorLab.setSizeUndefined();
separatorLab.setContentMode(ContentMode.HTML);
linksLayout.addComponent(separatorLab);
} else {
Label captionLabel = new Label(window.getCaption());
captionLabel.setStyleName("c-breadcrumbs-win-caption");
captionLabel.setSizeUndefined();
linksLayout.addComponent(captionLabel);
this.label = captionLabel;
}
}
}
use of com.haulmont.cuba.web.AppUI in project cuba by cuba-platform.
the class WebWindow method stopTimers.
/**
* Completely stop and remove timers of the window.
*/
public void stopTimers() {
AppUI appUI = AppUI.getCurrent();
if (timers != null) {
for (Timer timer : timers) {
timer.stop();
WebTimer webTimer = (WebTimer) timer;
appUI.removeTimer(webTimer.getTimerImpl());
}
timers.clear();
}
}
use of com.haulmont.cuba.web.AppUI in project cuba by cuba-platform.
the class WebAbstractComponent method assignAutoDebugId.
public void assignAutoDebugId() {
AppUI ui = AppUI.getCurrent();
if (ui != null && ui.isTestMode()) {
String alternativeDebugId = getAlternativeDebugId();
// always change cuba id, do not assign auto id for components
if (getId() == null && component != null) {
component.setCubaId(alternativeDebugId);
}
if (frame == null || StringUtils.isEmpty(frame.getId()))
return;
String fullFrameId = ComponentsHelper.getFullFrameId(frame);
TestIdManager testIdManager = ui.getTestIdManager();
String candidateId = fullFrameId + "." + alternativeDebugId;
if (getDebugId() != null) {
String postfix = StringUtils.replace(getDebugId(), testIdManager.normalize(candidateId), "");
if (StringUtils.isEmpty(postfix) || NumberUtils.isDigits(postfix)) {
// do not assign new Id
return;
}
}
setDebugId(testIdManager.getTestId(candidateId));
}
}
Aggregations