List of usage examples for com.vaadin.ui PopupView setEnabled
@Override
public void setEnabled(boolean enabled)
From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java
License:Open Source License
@SuppressWarnings({ "unchecked", "serial" })
private void showViewOrDelete(final DeleteListener lis) {
dialog = new Window("View / Delete VIPs");
dialog.setModal(true);/*from ww w.j av a 2s .co m*/
VerticalLayout layout = new VerticalLayout();
dialog.setContent(layout);
layout.setMargin(true);
layout.setSpacing(true);
layout.setSizeFull();
List<VipPii> vLis = VHibPii.getAllVips();
vipListSelect = new ListSelect("Select items to delete");
StringBuffer sb = new StringBuffer(); // for popup
vipListSelect.addStyleName("m-greyborder");
String lf = System.getProperty("line.separator");
for (int i = 0; i < vLis.size(); i++) {
VipPii v;
vipListSelect.addItem(v = vLis.get(i));
sb.append(v.getEntry());
sb.append(lf);
}
if (sb.length() > 0)
sb.setLength(sb.length() - 1); // last space
vipListSelect.setNullSelectionAllowed(true);
vipListSelect.setMultiSelect(true);
vipListSelect.setImmediate(true);
vipListSelect.addValueChangeListener(new VipSelectListener());
layout.addComponent(vipListSelect);
Label copyPopupList = new HtmlLabel("<pre>" + sb.toString() + "</pre>");
Panel p = new Panel();
VerticalLayout lay = new VerticalLayout();
p.setContent(lay);
lay.addComponent(copyPopupList);
p.setWidth("400px");
p.setHeight("300px");
PopupView popup = new PopupView("Display list as copyable text", p);
popup.setHideOnMouseOut(false);
if (sb.length() <= 0)
popup.setEnabled(false);
layout.addComponent(popup);
layout.setComponentAlignment(popup, Alignment.MIDDLE_CENTER);
HorizontalLayout hl = new HorizontalLayout();
hl.setSpacing(true);
Button cancelButt = new Button("Cancel", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
dialog.close();
lis.continueOrCancel(null);
}
});
deleteButt = new Button("Delete & Close", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
Set<VipPii> set = (Set<VipPii>) vipListSelect.getValue();
if (set.size() <= 0)
set = null;
dialog.close();
lis.continueOrCancel(set);
}
});
deleteButt.setEnabled(false);
hl.addComponent(cancelButt);
hl.addComponent(deleteButt);
hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
hl.setExpandRatio(cancelButt, 1.0f);
// The components added to the window are actually added to the window's
// layout; you can use either. Alignments are set using the layout
layout.addComponent(hl);
dialog.setWidth("300px");
dialog.setHeight("350px");
hl.setWidth("100%");
vipListSelect.setWidth("99%");
vipListSelect.setHeight("99%");
layout.setExpandRatio(vipListSelect, 1.0f);
UI.getCurrent().addWindow(dialog);
dialog.center();
}