Example usage for com.vaadin.ui Window getContent

List of usage examples for com.vaadin.ui Window getContent

Introduction

In this page you can find the example usage for com.vaadin.ui Window getContent.

Prototype

@Override
    public Component getContent() 

Source Link

Usage

From source file:com.etest.view.testbank.cellitem.CellItemWindow.java

Window modifyKeyWindow(int itemKeyId, int cellItemId, String keyValue, String optionValue,
        boolean isOptionKeyExist) {
    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);/*from  w ww.  j a  va  2 s . c  om*/
    v.setSpacing(true);

    Window sub = new Window("MODIFY");
    sub.setWidth("400px");
    sub.setModal(true);
    sub.center();

    ComboBox actionDone = new ComboBox("Action: ");
    actionDone.setWidth("70%");
    actionDone.addStyleName(ValoTheme.COMBOBOX_SMALL);
    actionDone.setNullSelectionAllowed(false);
    actionDone.addItem("resolved");
    actionDone.addItem("clarified");
    actionDone.addItem("modified");
    actionDone.setImmediate(true);
    v.addComponent(actionDone);

    TextArea remarks = new TextArea("Remarks: ");
    remarks.setWidth("100%");
    remarks.setRows(3);
    v.addComponent(remarks);

    Button modify = new Button("UPDATE");
    modify.setWidth("70%");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add remarks!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (actionDone.getValue() == null) {
            Notification.show("Add action!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        boolean result = k.modifyItemKey(itemKeyId, cellItemId, keyValue, optionValue, isOptionKeyExist,
                remarks.getValue().trim(), actionDone.getValue().toString());
        if (result) {
            Notification.show("Key SUCCESSFULLY modified", Notification.Type.TRAY_NOTIFICATION);
            sub.close();
        }
    });
    v.addComponent(modify);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.testbank.cellitem.ViewStemWindow.java

Window removeKeyWindow(int itemKeyId) {
    Window sub = new Window("REMOVE KEY");
    sub.setWidth("300px");
    sub.setModal(true);//from   w w w.  j  a  v  a 2 s  .com
    sub.center();

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);

    Button remove = new Button("CONFIRM REMOVE KEY?");
    remove.setWidth("100%");
    remove.setIcon(FontAwesome.TRASH_O);
    remove.addStyleName(ValoTheme.BUTTON_PRIMARY);
    remove.addStyleName(ValoTheme.BUTTON_SMALL);
    remove.addClickListener((Button.ClickEvent event) -> {
        boolean result = k.removeItemKey(itemKeyId);
        if (result) {
            sub.close();
            close();
        }
    });
    v.addComponent(remove);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.tq.TQCoverageUI.java

Window getTopicWindow(Item item) {
    Window sub = new Window("TOPIC: ");
    sub.setWidth("500px");
    sub.setModal(true);/*from  ww w.  j a  v a2s .c om*/
    sub.center();
    sub.setResizable(false);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);
    v.setSpacing(true);

    topic.setInputPrompt("Select a Topic..");
    topic.addStyleName(ValoTheme.COMBOBOX_SMALL);
    topic.setWidth("100%");
    topic.addValueChangeListener((Property.ValueChangeEvent event) -> {
        if (event.getProperty().getValue() == null) {
        } else {
            syllabusId = (int) event.getProperty().getValue();
            topicStr = topic.getItem(topic.getValue()).toString();
        }
    });
    v.addComponent(topic);

    Button button = new Button("CLOSE");
    button.setWidth("50%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        if (topic.getValue() == null) {
            Notification.show("Select a Topic!", Notification.Type.WARNING_MESSAGE);
        } else {
            populateGridRow(item);
            populateGridFooter();
        }
        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.tq.TQCoverageUI.java

Window getPickWindow(Item item, String propertyId) {
    Window sub = new Window("Field Value: ");
    sub.setWidth("150px");
    sub.setModal(true);/*from   w  w  w  .j ava 2  s  .c om*/
    sub.center();
    sub.setResizable(false);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);
    v.setSpacing(true);

    TextField field = new CommonTextField("Enter Value..", "Enter a Value: ");
    v.addComponent(field);

    Button button = new Button("CLOSE");
    button.setWidth("100%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        boolean isNumeric = CommonUtilities.isNumeric(field.getValue().trim());
        if (!isNumeric) {
            return;
        }

        boolean isGreaterThanInTB = tq.isGreaterThanInTB(item, propertyId, field.getValue().trim());
        if (isGreaterThanInTB) {
            Notification.show("Not allowed to exceed in total Items in Test Bank!",
                    Notification.Type.ERROR_MESSAGE);
            return;
        } else {
            item.getItemProperty(CommonUtilities.replaceStringTBToPick(propertyId))
                    .setValue(CommonUtilities.convertStringToInt(field.getValue()));
            footer.getCell(CommonUtilities.replaceStringTBToPick(propertyId)).setText(String.valueOf(
                    tq.calculateTotalPickItems(grid, CommonUtilities.replaceStringTBToPick(propertyId))));
        }
        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.BOTTOM_CENTER);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.tq.TQCoverageUI.java

Window getMaxItemsWindow(Item item, double previousValue) {
    Window sub = new Window("Field Value: ");
    sub.setWidth("150px");
    sub.setModal(true);//from   w  w w  .  j a  v a 2 s  . c om
    sub.center();
    sub.setResizable(false);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);
    v.setSpacing(true);

    TextField field = new CommonTextField("Enter Value..", "Enter a Value: ");
    v.addComponent(field);

    Button button = new Button("CLOSE");
    button.setWidth("100%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        boolean isNumeric = CommonUtilities.isNumeric(field.getValue().trim());
        if (!isNumeric) {
            return;
        }

        item.getItemProperty("Max Items").setValue(CommonUtilities.convertStringToDouble(field.getValue()));
        if (tq.calculateTotalMaxItems(grid) == CommonUtilities
                .convertStringToDouble(totalItems.getValue().trim())) {
            footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid)));
        } else {
            item.getItemProperty("Max Items").setValue(previousValue);
            footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid)));
            ShowErrorNotification.warning("Total Max Items should be equal to Total Test Items");
            return;
        }

        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.BOTTOM_CENTER);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.tq.TQCoverageWindow.java

Window confirmDeleteWindow() {
    Window sub = new Window("TQ Coverage");
    sub.setWidth("250px");
    sub.setResizable(false);/*from  ww w . jav  a  2s  .  c  o  m*/
    sub.setModal(true);
    sub.center();

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);

    Button delete = new Button("DELETE TQ?");
    delete.setWidth("100%");
    delete.setIcon(FontAwesome.TRASH_O);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.addClickListener((Button.ClickEvent event) -> {
        boolean result = tq.deleteTQCoverage(getTQCoverageId());
        if (result) {
            sub.close();
            close();
        }
    });
    v.addComponent(delete);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.expressui.core.MainApplication.java

License:Open Source License

/**
 * Opens a separate error Window with the full stack trace of a throwable
 * and error box highlighting the root cause message.
 *
 * @param throwable full stack trace of this throwable is displayed in error Window
 *//*  ww  w  .  j a v  a 2 s .c  o  m*/
public void openErrorWindow(Throwable throwable) {
    showError(ExceptionUtils.getRootCauseMessage(throwable));

    String message = ExceptionUtils.getFullStackTrace(throwable);
    Window errorWindow = new Window(uiMessageSource.getMessage("mainApplication.errorWindowCaption"));
    errorWindow.addStyleName("opaque");
    VerticalLayout layout = (VerticalLayout) errorWindow.getContent();
    layout.setSpacing(true);
    layout.setWidth("100%");
    errorWindow.setWidth("100%");
    errorWindow.setModal(true);
    Label label = new Label(message);
    label.setContentMode(Label.CONTENT_PREFORMATTED);
    layout.addComponent(label);
    errorWindow.setClosable(true);
    errorWindow.setScrollable(true);
    getMainWindow().addWindow(errorWindow);
}

From source file:com.foc.vaadin.FocWebApplication.java

License:Apache License

@Override
public void addWindow(Window window) throws IllegalArgumentException, NullPointerException {
    boolean executedWithoutPopup = false;

    if (isMobile()) {
        Object content = window.getContent();
        if (content instanceof ICentralPanel) {
            if (getContent() != null && getContent() instanceof FocCentralPanel) {
                window.setContent(null);
                FocCentralPanel centralComponent = (FocCentralPanel) getContent();

                centralComponent.changeCentralPanelContent((ICentralPanel) content, true);

                executedWithoutPopup = true;
            }/*from  w w w . ja  va2  s . com*/
        }
    }

    if (!executedWithoutPopup) {
        window.setModal(true);
        super.addWindow(window);
    }
}

From source file:com.foc.web.unitTesting.methods.FUploadFile_UnitMethod.java

License:Apache License

@Override
public void executeMethod(FocUnitTestingCommand command, FocUnitXMLAttributes attributes) throws Exception {
    if (attributes != null) {
        String filename = attributes.getValue(FXMLUnit.ATT_FILE_NAME);
        if (filename == null) {
            command.getLogger().addFailure("No File name attribute! " + "[" + FXMLUnit.ATT_FILE_NAME + "]");
        } else if (filename.isEmpty()) {
            command.getLogger()/*from w  w w .  j  a  v a  2  s .c  om*/
                    .addFailure("File name attribute [" + FXMLUnit.ATT_FILE_NAME + "] is Empty String");
        } else {
            ICentralPanel centralPanel = command.getMainWindow().getCentralPanel();
            //            if(!(centralPanel instanceof FVUploadLayout_Form)){
            //               command.getLogger().addFailure("Expected Upload Form to be visible! FVUploadLayout_Form");
            //            }else{
            Collection<Window> coll = command.getMainWindow().getFocWebApplication().getWindows();
            Iterator<Window> iter = coll.iterator();
            while (iter.hasNext()) {
                Window window = iter.next();
                FocCentralPanel focCP = (FocCentralPanel) window.getContent();
                ICentralPanel cp = focCP.getCentralPanel();
                if (cp instanceof FVUploadLayout_Form) {
                    FVUploadLayout_Form uploadForm = (FVUploadLayout_Form) cp;
                    if (uploadForm != null) {
                        try {
                            InputStream fis = Globals.getInputStream(filename);
                            //                           FileInputStream fis = new FileInputStream(filename);
                            ByteArrayOutputStream baos = FocFileUtil.inputStreamToByteArrayOutputStream(fis);
                            uploadForm.setOutputStream_ForUnitTesting(baos);
                            uploadForm.uploadFinished(filename);
                        } catch (Exception e) {
                            Globals.logException(e);
                        }
                    }

                }
            }

            //            }
        }
    }
}

From source file:com.hris.connection.ErrorLoggedNotification.java

public static void showErrorLoggedOnWindow(String error, String className) {
    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();/* w  w  w.  ja v  a 2  s .  c  om*/
    v.setMargin(true);

    Window sub = new Window("ERROR MESSAGE!", v);
    sub.setWidth("500px");
    if (sub.getParent() == null) {
        UI.getCurrent().addWindow(sub);
    }
    sub.setModal(true);

    Panel panel = new Panel();
    panel.setSizeFull();
    panel.setContent(new Label(error + " on \n" + className, ContentMode.HTML));
    panel.getContent().setHeightUndefined();

    sub.setContent(panel);
    sub.getContent().setHeightUndefined();
}