blob: 9a304a9908396c5f45fc625b70dfc26931dc502e [file] [log] [blame]
/**
* Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.runtime.web.vaadin.components.dialogs;
import java.util.Locale;
import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
import org.eclipse.osbp.ui.api.themes.IThemeResourceService;
import org.eclipse.osbp.ui.api.themes.IThemeResourceService.ThemeResourceType;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
/**
* Dialog to accept the reload of dirty data. Data will be lost if proceeded.
*/
public class AcceptReloadDialog extends OptionsDialog {
public static void showDialog(IDSLMetadataService service, IThemeResourceService themeResource, Runnable onDelete,
Runnable onCancel) {
if (service == null) {
throw new NullPointerException("Please pass an i18nService");
}
Locale locale = UI.getCurrent().getLocale();
String dialogTitle = service.translate(locale.toLanguageTag(), IDialogI18nKeys.ACCEPT_RELOAD_DIALOG_TITLE);
String dialogMessage = service.translate(locale.toLanguageTag(), IDialogI18nKeys.ACCEPT_RELOAD_DIALOG_MESSAGE);
String dialogDescription = service.translate(locale.toLanguageTag(),
IDialogI18nKeys.ACCEPT_RELOAD_DIALOG_DESCRIPTION);
String dialogIcon = IDialogI18nKeys.ACCEPT_RELOAD_DIALOG_ICON;
String optionDeleteCaption = service.translate(locale.toLanguageTag(),
IDialogI18nKeys.ACCEPT_RELOAD__DIALOG_OPTION__RELOAD_CAPTION);
String optionDeleteDescription = service.translate(locale.toLanguageTag(),
IDialogI18nKeys.ACCEPT_RELOAD__DIALOG_OPTION__RELOAD_DESCRIPTION);
String optionDeleteIcon = IDialogI18nKeys.ACCEPT_RELOAD__DIALOG_OPTION__RELOAD_ICON;
String optionCancelCaption = service.translate(locale.toLanguageTag(),
IDialogI18nKeys.DIALOG_OPTION__CANCEL_CAPTION);
String optionCancelDescription = service.translate(locale.toLanguageTag(),
IDialogI18nKeys.DIALOG_OPTION__CANCEL_DESCRIPTION);
String optionCancelIcon = IDialogI18nKeys.DIALOG_OPTION__CANCEL_ICON;
DialogConfig config = new DialogConfig(dialogTitle, dialogMessage, dialogDescription,
themeResource.getThemeResource(dialogIcon, ThemeResourceType.ICON)) {
@Override
public void config(Window window) {
super.config(window);
window.setHeight("170px");
window.setWidth("350px");
window.center();
}
};
AcceptReloadDialog dialog = new AcceptReloadDialog(config,
new Option(optionCancelCaption, optionCancelDescription,
themeResource.getThemeResource(optionCancelIcon, ThemeResourceType.ICON), onCancel),
new Option(optionDeleteCaption, optionDeleteDescription,
themeResource.getThemeResource(optionDeleteIcon, ThemeResourceType.ICON), onDelete));
dialog.open();
}
private AcceptReloadDialog(DialogConfig config, Option... options) {
super(config, options);
}
}