blob: f6d0cb2d8769a96524ec586238011a78c8a05900 [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - 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 v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*/
package org.eclipse.osbp.utils.vaadin;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.osbp.eventbroker.EventBrokerMsg;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class YesNoDialog extends Window {
/**
*
*/
private static final long serialVersionUID = 3461161019240158996L;
private IEventBroker eventBroker;
private Label label;
private Button yes;
private Button no;
private Object item;
public YesNoDialog() {
super();
setClosable(false);
setModal(true);
VerticalLayout subContent = new VerticalLayout();
subContent.setMargin(true);
setContent(subContent);
label = new Label();
label.addStyleName("os-querylabel");
subContent.addComponent(label);
HorizontalLayout buttons = new HorizontalLayout();
subContent.addComponent(buttons);
yes = new Button();
yes.addClickListener(new Button.ClickListener() {
/**
*
*/
private static final long serialVersionUID = -2681219482010299972L;
@Override
public void buttonClick(ClickEvent event) {
if(eventBroker!=null) {
EventBrokerMsg msg = new EventBrokerMsg(EventBrokerMsg.QUERY_YES);
msg.setObject1(item);
eventBroker.send(EventBrokerMsg.QUERY_ANSWER, msg);
}
}
});
buttons.addComponent(yes);
no = new Button();
no.addClickListener(new Button.ClickListener() {
/**
*
*/
private static final long serialVersionUID = -7307026891472599110L;
@Override
public void buttonClick(ClickEvent event) {
if(eventBroker!=null) {
EventBrokerMsg msg = new EventBrokerMsg(EventBrokerMsg.QUERY_NO);
msg.setObject1(item);
eventBroker.send(EventBrokerMsg.QUERY_ANSWER, msg);
}
}
});
buttons.addComponent(no);
center();
}
public YesNoDialog init(IEventBroker eventBroker, Object item, String messageText, String yesText, String noText) {
this.eventBroker = eventBroker;
label.setCaption(messageText);
yes.setCaption(yesText);
no.setCaption(noText);
this.item = item;
return this;
}
}