Example usage for com.vaadin.ui Window setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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 .  ja  v a  2  s .  co  m
    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);//w  w  w. j av  a 2s. c o  m
    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);/* w ww.j a  v a  2s.  com*/
    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  .  java 2  s. co  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.expressui.core.view.util.CodePopup.java

License:Open Source License

/**
 * Opens popup for given classes./*  w w w  . j ava  2s .c o m*/
 *
 * @param classes classes for displaying related source code and Javadoc. If
 *                class is within com.expressui.core or com.expressui.domain,
 *                then Javadoc is displayed, otherwise source code.
 */
public void open(Class... classes) {

    Window codeWindow = new Window();
    codeWindow.addStyleName("code-popup");
    codeWindow.setPositionX(20);
    codeWindow.setPositionY(40);
    codeWindow.setWidth("90%");
    codeWindow.setHeight("90%");

    TabSheet codePopupTabSheet = new TabSheet();
    String id = StringUtil.generateDebugId("e", this, codePopupTabSheet, "codePopupTabSheet");
    codePopupTabSheet.setDebugId(id);

    codePopupTabSheet.setSizeFull();
    codeWindow.addComponent(codePopupTabSheet);

    String windowCaption = "";
    Set<String> shownUrls = new HashSet<String>();
    for (Class clazz : classes) {
        String tabCaption;
        String url;
        if (clazz.getName().startsWith("com.expressui.core")
                || clazz.getName().startsWith("com.expressui.domain")) {
            url = applicationProperties.getDocUrl(clazz);
            if (shownUrls.contains(url))
                continue;
            tabCaption = clazz.getSimpleName() + " API";
            Embedded embedded = getEmbeddedDoc(url);
            codePopupTabSheet.addTab(embedded, tabCaption);
        } else {
            url = applicationProperties.getCodeUrl(clazz);
            if (shownUrls.contains(url))
                continue;
            tabCaption = clazz.getSimpleName() + ".java";
            String code = getCodeContents(url);
            Label label = new CodeLabel(code);
            codePopupTabSheet.addTab(label, tabCaption);
        }
        shownUrls.add(url);
        if (windowCaption.length() > 0)
            windowCaption += ", ";

        windowCaption += tabCaption;
    }

    codeWindow.setCaption(windowCaption);
    MainApplication.getInstance().getMainWindow().addWindow(codeWindow);
}

From source file:com.foc.vaadin.gui.components.FVTreeDropHandler_ObjectTree.java

License:Apache License

@Override
public void drop(DragAndDropEvent dropEvent) {
    if (dropEvent.getTransferable() instanceof DataBoundTransferable) {
        DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable();
        if (t.getSourceContainer() instanceof ContainerOrderedWrapper) {
            ContainerOrderedWrapper source = (ContainerOrderedWrapper) t.getSourceContainer();
            Object sourceItemId = t.getItemId();
            FocObject objDroped = (FocObject) source.getItem(sourceItemId);

            AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) dropEvent.getTargetDetails());
            Object targetItemId = dropData.getItemIdOver();

            if (focData != null && focData instanceof FocDataMap) {
                FocDataMap focDataMap = (FocDataMap) focData;
                focData = focDataMap.getMainFocData();
            }/*from   ww  w  .  ja v  a2  s . c  o  m*/

            if (focData != null && focData instanceof FObjectTree) {
                FObjectTree objectTree = (FObjectTree) focData;
                setObjectTree(objectTree);
                if (objectTree != null) {
                    targetNode = (FObjectNode) objectTree.findNode(((Long) targetItemId).longValue());
                    sourceNode = (FObjectNode) objectTree.findNode(objDroped.getReference().getLong());

                    if (targetNode != null && sourceNode != null && focXMLLayout != null) {

                        XMLViewKey xmlViewKey = new XMLViewKey(AdminWebModule.OPTION_WINDOW_STORAGE,
                                XMLViewKey.TYPE_FORM);
                        OptionDialog_Form optionDialogForm = (OptionDialog_Form) XMLViewDictionary.getInstance()
                                .newCentralPanel(focXMLLayout.getMainWindow(), xmlViewKey, null);

                        setOptionDialog_Form(optionDialogForm);

                        ClickListener clickListener = new ClickListener() {

                            @Override
                            public void buttonClick(ClickEvent event) {
                                FocObject targetObject = (FocObject) targetNode.getObject();
                                FocObject sourceObject = (FocObject) sourceNode.getObject();

                                boolean shouldExecute = (sourceObject != null && sourceObject != targetObject)
                                        && (!sourceNode.isAncestorOf(targetNode));

                                if (shouldExecute && getObjectTree() != null) {

                                    sourceObject.setPropertyObject(getObjectTree().getFatherNodeId(),
                                            targetObject);
                                    sourceNode.moveTo(targetNode);

                                    FVTableWrapperLayout bkdnTreeWrapper = (FVTableWrapperLayout) focXMLLayout
                                            .getComponentByName(treeName);
                                    if (bkdnTreeWrapper != null) {
                                        FVTreeTable treeTable = ((FVTreeTable) bkdnTreeWrapper
                                                .getTableOrTree());
                                        if (treeTable != null && treeTable instanceof FVTreeTable) {
                                            getOptionDialog_Form().goBack(null);
                                            treeTable.markAsDirty();
                                            treeTable.refreshRowCache_Foc();
                                            focXMLLayout.refresh();
                                        }
                                    }
                                }
                            }
                        };

                        optionDialogForm.addButton("Confirm node move", clickListener);

                        clickListener = new ClickListener() {

                            @Override
                            public void buttonClick(ClickEvent event) {
                                getOptionDialog_Form().goBack(null);
                            }

                        };
                        optionDialogForm.addButton("Cancel", clickListener);

                        FocCentralPanel centralPanel = new FocCentralPanel();
                        centralPanel.fill();
                        centralPanel.changeCentralPanelContent(getOptionDialog_Form(), false);
                        Window optionWindow = centralPanel.newWrapperWindow();
                        optionWindow.setCaption("Node Move Confirmation");
                        optionWindow.setWidth("400px");
                        optionWindow.setHeight("200px");
                        focXMLLayout.getUI().addWindow(optionWindow);
                    }
                }
            }
        }
    }
}

From source file:com.foc.vaadin.gui.xmlForm.FocXMLLayout.java

License:Apache License

public static void popupInDialog(ICentralPanel contentPanel, String title, String width, String height) {
    FocCentralPanel centralPanel = new FocCentralPanel();
    centralPanel.fill();//  w ww  .  java2 s  . c o m
    centralPanel.changeCentralPanelContent(contentPanel, false);

    Window optionWindow = centralPanel.newWrapperWindow();
    optionWindow.setResizable(true);
    optionWindow.setCaption(title);

    optionWindow.setWidth(width);
    optionWindow.setHeight(height);
    //ATTENTION-MAN
    //      optionWindow.getContent().setWidth(width);
    //      optionWindow.getContent().setHeight(width);
    //ATTENTION-MAN

    FocWebApplication.getInstanceForThread().addWindow(optionWindow);
}

From source file:com.foc.web.modules.admin.OptionDialog_Form.java

License:Apache License

public Window popup() {
    Window optionWindow = null;
    fillMessage();/*from  w ww .j  a  v a2s .c  om*/
    addButtons();

    if (FocWebApplication.getInstanceForThread().isMobile()) {
        getMainWindow().changeCentralPanelContent(OptionDialog_Form.this, true);
    } else {
        FocCentralPanel centralPanel = new FocCentralPanel();
        centralPanel.fill();
        centralPanel.changeCentralPanelContent(OptionDialog_Form.this, false);

        optionWindow = centralPanel.newWrapperWindow();

        optionWindow.setCaption(optionDialog.getTitle());
        optionWindow.setWidth(optionDialog.getWidth());
        optionWindow.setHeight(optionDialog.getHeight());

        FocWebApplication.getInstanceForThread().addWindow(optionWindow);
    }
    return optionWindow;
}

From source file:com.foc.web.modules.business.BusinessEssentialsWebModule.java

License:Apache License

public static FVUploadLayout_Form popupUploadLayout(IUploadReader iUploadReader) {
    FocCentralPanel centralPanel = new FocCentralPanel();
    XMLViewKey key = new XMLViewKey(BusinessEssentialsWebModule.STORAGE_UPLOAD_LAYOUT, XMLViewKey.TYPE_FORM);
    FVUploadLayout_Form uploadLayout = (FVUploadLayout_Form) XMLViewDictionary.getInstance()
            .newCentralPanel(centralPanel, key, null);
    uploadLayout.setUploadReader(iUploadReader);
    centralPanel.fill();//from  ww  w .  jav  a2 s  . c om
    centralPanel.changeCentralPanelContent(uploadLayout, true);
    Window window = centralPanel.newWrapperWindow();
    window.setWidth("400px");
    window.setHeight("300px");
    FocWebApplication.getInstanceForThread().addWindow(window);
    return uploadLayout;
}

From source file:com.garyclayburg.vconsole.TargetWindows.java

License:Open Source License

void showTargetWindow(User selectedUser, final String entitledTarget) {
    Window window = targetWindows.get(entitledTarget);
    if (window == null) { //only generate new window if user clicked on it - no new windows from policy update
        UI ui = UI.getCurrent();//from   w ww.j ava  2s . c  o  m
        if (ui != null) {
            window = new Window(entitledTarget);
            window.setWidth("300px");
            targetWindows.put(entitledTarget, window);
            window.addCloseListener(new Window.CloseListener() {
                @Override
                public void windowClose(Window.CloseEvent e) {
                    targetWindows.remove(entitledTarget);
                }
            });
            ui.addWindow(window);
        } else {
            return;
        }
    }
    populateTarget(selectedUser, entitledTarget);
}