Example usage for com.vaadin.ui Window setDraggable

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

Introduction

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

Prototype

public void setDraggable(boolean draggable) 

Source Link

Document

Enables or disables that a window can be dragged (moved) by the user.

Usage

From source file:com.cavisson.gui.dashboard.components.calender.BeanItemContainerTestUI.java

License:Apache License

/**
 * Opens up a modal dialog window where an event can be modified
 * // ww  w.  j  a  v  a2s .  c o  m
 * @param event
 *            The event to modify
 */
private void editEvent(final BasicEvent event) {
    Window modal = new Window("Add event");
    modal.setModal(true);
    modal.setResizable(false);
    modal.setDraggable(false);
    modal.setWidth("300px");
    final FieldGroup fieldGroup = new FieldGroup();

    FormLayout formLayout = new FormLayout();
    TextField captionField = new TextField("Caption");
    captionField.setImmediate(true);
    TextField descriptionField = new TextField("Description");
    descriptionField.setImmediate(true);
    DateField startField = new DateField("Start");
    startField.setResolution(Resolution.MINUTE);
    startField.setImmediate(true);
    DateField endField = new DateField("End");
    endField.setImmediate(true);
    endField.setResolution(Resolution.MINUTE);

    formLayout.addComponent(captionField);
    formLayout.addComponent(descriptionField);
    formLayout.addComponent(startField);
    formLayout.addComponent(endField);

    fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY);
    fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY);
    fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY);
    fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY);

    fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event,
            Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY,
                    ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY)));
    modal.setContent(formLayout);
    modal.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            // Commit changes to bean
            try {
                fieldGroup.commit();
            } catch (CommitException e1) {
                e1.printStackTrace();
            }

            if (events.containsId(event)) {
                /*
                 * BeanItemContainer does not notify container listeners
                 * when the bean changes so we need to trigger a
                 * ItemSetChange event
                 */
                BasicEvent dummy = new BasicEvent();
                events.addBean(dummy);
                events.removeItem(dummy);

            } else {
                events.addBean(event);
            }
        }
    });
    getUI().addWindow(modal);
}

From source file:com.hivesys.dashboard.view.search.TextualView.java

public void UpdateSearchPane(String searchString) {
    css.removeAllComponents();// w w w .ja  va2  s.c  om

    SearchResponse response = ElasticSearchContext.getInstance().searchSimpleQuery(searchString);
    logResponse(response);
    SearchHits results = response.getHits();

    Label labelResultSummary = new Label("About " + results.getHits().length + " results found <br><br>",
            ContentMode.HTML);
    css.addComponent(labelResultSummary);

    for (SearchHit hit : results) {
        CssLayout cssResult = new CssLayout();
        cssResult.setStyleName("search-result");

        try {
            String filename = DocumentDB.getInstance().getDocumentNameFromHash(hit.getId());
            String boxviewID = DocumentDB.getInstance().getBoxViewIDFromHash(hit.getId());

            String highlight = "";
            HighlightField objhighlight = hit.highlightFields().get("file");
            if (objhighlight != null) {
                for (Text fgmt : objhighlight.getFragments()) {
                    highlight += fgmt.string() + "<br>";
                }
            }

            Button lblfileName = new Button(filename);
            lblfileName.addClickListener((Button.ClickEvent event) -> {
                if (boxviewID != null) {
                    String url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                    if (url != null || !url.equals("")) {
                        url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                        BrowserFrame bframe = new BrowserFrame(filename, new ExternalResource(url));
                        VerticalLayout vlayout = new VerticalLayout(bframe);

                        final Window w = new Window();
                        w.setSizeFull();
                        w.setModal(true);
                        w.setWindowMode(WindowMode.MAXIMIZED);
                        w.setContent(vlayout);
                        vlayout.setSizeFull();
                        vlayout.setMargin(true);
                        w.setResizable(false);
                        w.setDraggable(false);

                        UI.getCurrent().addWindow(w);
                        bframe.setSizeFull();
                        return;
                    }
                    Notification.show("Preview not available for this document!");
                }
            });
            lblfileName.setPrimaryStyleName("filename");

            Label lblHighlight = new Label(highlight, ContentMode.HTML);
            lblHighlight.setStyleName("highlight");

            cssResult.addComponent(lblfileName);
            cssResult.addComponent(lblHighlight);

            css.addComponent(cssResult);
            css.addComponent(new Label("<br>", ContentMode.HTML));

        } catch (SQLException ex) {
        }

    }

}

From source file:com.iton.gittest.HelloWorld.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("My Vaadin Application");
    setMainWindow(window);/*from ww w. j  av a2s.  c o  m*/
    Button button = new Button("Click Me");
    button.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Window win = new Window("PopUp Form");
            win.setModal(true);
            win.setScrollable(false);
            win.setDraggable(false);
            win.setResizable(false);
            win.center();
            win.setWidth("350px");
            win.addComponent(new Form());
            window.addWindow(win);
        }
    });
    window.addComponent(button);

}

From source file:com.kelt.disk.db.web.DiskDBApplication.java

License:Apache License

@Override
public void init() {
    final Window mainWindow = new Window("Samplevaadin Application");
    final Window window = new Window("Some Window");
    window.setWidth(800, Sizeable.UNITS_PIXELS);
    window.setHeight(601, Sizeable.UNITS_PIXELS);
    window.setClosable(false);/*from ww w.ja v  a2s .c  o  m*/
    window.setDraggable(false);
    window.setResizable(false);
    window.center();
    setUpWindow(window);
    mainWindow.addWindow(window);
    setMainWindow(mainWindow);
}

From source file:com.mymita.vaadlets.VaadletsBuilder.java

License:Apache License

private static void setWindowAttributes(final com.vaadin.ui.Component vaadinComponent,
        final com.mymita.vaadlets.core.Component vaadletsComponent) {
    if (vaadletsComponent instanceof com.mymita.vaadlets.ui.Window) {
        final com.vaadin.ui.Window vaadinWindow = (com.vaadin.ui.Window) vaadinComponent;
        final com.mymita.vaadlets.ui.Window vaadletsWindow = (com.mymita.vaadlets.ui.Window) vaadletsComponent;
        if (vaadletsWindow.isCenter()) {
            vaadinWindow.center();//from  w  ww .  jav a2s . co  m
        }
        final Short positionX = vaadletsWindow.getPositionX();
        if (positionX != null) {
            vaadinWindow.setPositionX(positionX);
        }
        final Short positionY = vaadletsWindow.getPositionY();
        if (positionY != null) {
            vaadinWindow.setPositionY(positionY);
        }
        vaadinWindow.setBorder(vaadletsWindow.getBorder().ordinal());
        vaadinWindow.setModal(vaadletsWindow.isModal());
        vaadinWindow.setClosable(vaadletsWindow.isCloseable());
        vaadinWindow.setDraggable(vaadletsWindow.isDraggable());
        vaadinWindow.setResizable(vaadletsWindow.isResizeable());
        vaadinWindow.setResizeLazy(vaadletsWindow.isResizeLazy());
    }
}

From source file:com.tripoin.util.ui.calendar.BeanItemContainerTestUI.java

License:Apache License

/**
 * Opens up a modal dialog window where an event can be modified
 * /*  w  w  w  . j  a va  2s. c  om*/
 * @param event
 *            The event to modify
 */
private void editEvent(final BasicEvent event) {
    Window modal = new Window("Add event");
    modal.setModal(true);
    modal.setResizable(false);
    modal.setDraggable(false);
    modal.setWidth("300px");
    final FieldGroup fieldGroup = new FieldGroup();

    FormLayout formLayout = new FormLayout();
    TextField captionField = new TextField("Caption");
    captionField.setImmediate(true);
    TextField descriptionField = new TextField("Description");
    descriptionField.setImmediate(true);
    DateField startField = new DateField("Start");
    startField.setResolution(Resolution.MINUTE);
    startField.setImmediate(true);
    DateField endField = new DateField("End");
    endField.setImmediate(true);
    endField.setResolution(Resolution.MINUTE);

    formLayout.addComponent(captionField);
    formLayout.addComponent(descriptionField);
    formLayout.addComponent(startField);
    formLayout.addComponent(endField);

    fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY);
    fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY);
    fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY);
    fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY);

    fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event,
            Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY,
                    ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY)));
    modal.setContent(formLayout);
    modal.addCloseListener(new Window.CloseListener() {
        /**
        * 
        */
        private static final long serialVersionUID = -3427881784024691882L;

        @Override
        public void windowClose(CloseEvent e) {
            // Commit changes to bean
            try {
                fieldGroup.commit();
            } catch (CommitException e1) {
                e1.printStackTrace();
            }

            if (events.containsId(event)) {
                /*
                 * BeanItemContainer does not notify container listeners
                 * when the bean changes so we need to trigger a
                 * ItemSetChange event
                 */
                BasicEvent dummy = new BasicEvent();
                events.addBean(dummy);
                events.removeItem(dummy);

            } else {
                events.addBean(event);
            }
        }
    });
    getUI().addWindow(modal);
}

From source file:dhbw.clippinggorilla.userinterface.windows.ActivateWindow.java

public static Window get() {
    Window window = new Window();
    window.setModal(true);/*from  ww w.  j  a  v  a 2  s  .  co m*/
    window.setResizable(false);
    window.setDraggable(false);
    window.setCaption(Language.get(Word.ACTIVATION_CODE));
    window.addCloseShortcut(ShortcutAction.KeyCode.ENTER, null);

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setMargin(false);
    windowLayout.setSizeUndefined();

    FormLayout forms = new FormLayout();
    forms.setMargin(true);
    forms.setSizeUndefined();

    Button save = new Button(Language.get(Word.ACTIVATE));

    TextField activationCode = new TextField(Language.get(Word.ACTIVATION_CODE));
    activationCode.setMaxLength(6);
    activationCode.focus();
    activationCode.addValueChangeListener(e -> {
        if (activationCode.getValue().length() > 5) {
            save.setEnabled(true);
            activationCode.setComponentError(null);
        } else {
            save.setEnabled(false);
            activationCode.setComponentError(new UserError(Language.get(Word.ACTIVATION_CODE_SIX_CHARS),
                    AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_CODE_SIX_CHARS));
        }
    });
    forms.addComponent(activationCode);

    Button resendMail = new Button(Language.get(Word.RESEND_ACTIVATION_CODE));
    resendMail.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    resendMail.addClickListener(ce -> {
        try {
            UserUtils.resendActivationMail(UserUtils.getCurrent());
            VaadinUtils.infoNotification(Language.get(Word.RESEND_ACTIVATION_CODE_SUCCESSFUL));
        } catch (EmailException ex) {
            VaadinUtils.errorNotification(Language.get(Word.RESEND_ACTIVATION_CODE_FAILED));
        }
    });
    forms.addComponent(resendMail);

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE);

    Label placeholder = new Label();

    Button cancel = new Button(Language.get(Word.CANCEL));
    cancel.setIcon(VaadinIcons.CLOSE);
    cancel.addClickListener(ce -> {
        window.close();
    });
    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);

    save.setEnabled(false);
    save.setIcon(VaadinIcons.CHECK);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addClickListener(ce -> {
        try {
            String code = activationCode.getValue();
            User user = UserUtils.getCurrent();
            if (UserUtils.activateUser(user, code)) {
                VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_SUCCESSFUL));
                window.close();
            } else {
                activationCode.setValue("");
                VaadinUtils.errorNotification(Language.get(Word.ACTIVATION_FAILED));
            }
        } catch (NumberFormatException e) {
        }
    });
    save.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

    footer.setSizeUndefined();
    footer.setWidth("100%");
    footer.addComponents(placeholder, cancel, save);
    footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1);
    footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER);

    windowLayout.addComponent(forms);
    windowLayout.addComponent(footer);

    window.setContent(windowLayout);
    return window;
}

From source file:org.eclipse.hawkbit.ui.common.builder.WindowBuilder.java

License:Open Source License

private void decorateWindow(final Window window) {
    if (id != null) {
        window.setId(id);//from w  w  w. j a va 2 s .  co m
    }

    if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) {
        window.setDraggable(false);
        window.setClosable(true);
        window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);

    } else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
        window.setDraggable(true);
        window.setClosable(true);
    }
}

From source file:org.investovator.ui.main.AdminGameConfigLayout.java

License:Open Source License

private void startDailySummaryAddGameWizard() {
    // Create a sub-window and set the content
    Window subWindow = new Window("Create New Game");
    VerticalLayout subContent = new VerticalLayout();
    subContent.setMargin(true);// w  w  w  .j  a  v  a2s.co  m
    subWindow.setContent(subContent);

    // Put some components in it
    subContent.addComponent(new NewDataPlaybackGameWizard(subWindow));

    // set window characteristics
    subWindow.center();
    subWindow.setClosable(false);
    subWindow.setDraggable(false);
    subWindow.setResizable(false);
    subWindow.setModal(true);

    subWindow.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent closeEvent) {
            //getUI().getNavigator().navigateTo(UIConstants.MAINVIEW);
            getUI().getPage().reload();
        }
    });

    // Add it to the root component
    UI.getCurrent().addWindow(subWindow);
}

From source file:org.investovator.ui.main.components.AdminGameCreateView.java

License:Open Source License

private void startDailySummaryAddGameWizard() {
    // Create a sub-window and set the content
    Window subWindow = new Window("Create New Game");
    VerticalLayout subContent = new VerticalLayout();
    subContent.setMargin(true);/*ww  w . j a  va 2 s. co  m*/
    subWindow.setContent(subContent);

    // Put some components in it
    subContent.addComponent(new NewDataPlaybackGameWizard(subWindow));

    // set window characteristics
    subWindow.center();
    subWindow.setClosable(false);
    subWindow.setDraggable(false);
    subWindow.setResizable(false);
    subWindow.setModal(true);

    subWindow.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent closeEvent) {
            getUI().getNavigator().navigateTo(UIConstants.MAINVIEW);
            //                getUI().getPage().reload();
        }
    });

    // Add it to the root component
    UI.getCurrent().addWindow(subWindow);
}