Example usage for com.vaadin.ui Window getParent

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

Introduction

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

Prototype

@Override
    public HasComponents getParent() 

Source Link

Usage

From source file:org.escidoc.browser.ui.navigation.ActionHandlerImpl.java

License:Open Source License

private void deleteOrgUnit(final OrgUnitModel model, final Object sender) {
    final Window subwindow = buildSubWindow();

    final Button okConfirmed = new Button(ViewConstants.YES, new Button.ClickListener() {

        @Override/*from   ww w .ja v a2 s .c  o m*/
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
            try {
                deleteFromRepository(model);
                closeView(model, sender);
                removeFromTree(model);
                showSuccesfulMessage();
            } catch (final EscidocClientException e) {
                mainWindow.showNotification(
                        new Window.Notification("Error deleting Organization. " + ViewConstants.ERROR,
                                e.getMessage(), Notification.TYPE_ERROR_MESSAGE));
            }
        }

        private void showSuccesfulMessage() {
            mainWindow.showNotification(
                    new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION));
        }

        private void removeFromTree(final OrgUnitModel model) {
            treeDataSource.remove(model);
        }

        private void deleteFromRepository(final OrgUnitModel model) throws EscidocClientException {
            repositories.organization().delete(model.getId());
        }

        private void closeView(final OrgUnitModel model, final Object sender) {
            router.getLayout().closeView(model, treeDataSource.getParent(model), sender);
        }

    });
    final Button cancel = new Button("Cancel", new Button.ClickListener() {

        @Override
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    final HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(okConfirmed);
    hl.addComponent(cancel);
    subwindow.addComponent(hl);
    mainWindow.addWindow(subwindow);
}

From source file:org.escidoc.browser.ui.navigation.ActionHandlerImpl.java

License:Open Source License

private void deleteContext(final ContextModel model, final Object sender) {
    final Window subwindow = buildSubWindow();

    final Button okConfirmed = new Button(ViewConstants.YES, new Button.ClickListener() {

        @Override/*from  ww  w .j  a va 2 s  .c o  m*/
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
            try {
                repositories.context().delete(model.getId());
                router.getLayout().closeView(model, treeDataSource.getParent(model), sender);
                mainWindow.showNotification(
                        new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION));
            } catch (final EscidocClientException e) {
                mainWindow.showNotification(
                        new Window.Notification("Error deleting context" + ViewConstants.ERROR, e.getMessage(),
                                Notification.TYPE_ERROR_MESSAGE));
            }
        }

    });
    final Button cancel = new Button("Cancel", new Button.ClickListener() {

        @Override
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    final HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(okConfirmed);
    hl.addComponent(cancel);
    subwindow.addComponent(hl);
    mainWindow.addWindow(subwindow);
}

From source file:org.escidoc.browser.ui.navigation.ActionHandlerImpl.java

License:Open Source License

private void deleteItem(final ItemModel selectedItem, final Object sender) {
    final Window subwindow = new Window(DELETE_RESOURCE_WND_NAME);
    subwindow.setModal(true);//from ww  w .  ja  va 2  s  . com
    Label message = new Label(DELETE_RESOURCE);
    subwindow.addComponent(message);

    Button okConfirmed = new Button(ViewConstants.YES, new Button.ClickListener() {
        @Override
        public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
            try {
                repositories.item().finalDelete(selectedItem);
                router.getLayout().closeView(selectedItem, treeDataSource.getParent(selectedItem), sender);
                mainWindow.showNotification(
                        new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION));
            } catch (EscidocClientException e) {
                mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE));
            }
        }

    });

    Button cancel = new Button("Cancel", new Button.ClickListener() {
        @Override
        public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(okConfirmed);
    hl.addComponent(cancel);
    subwindow.addComponent(hl);
    mainWindow.addWindow(subwindow);
}

From source file:org.escidoc.browser.ui.navigation.ActionHandlerImpl.java

License:Open Source License

public void deleteContainer(final ContainerModel model, final Object sender) {
    final Window subwindow = new Window(DELETE_RESOURCE_WND_NAME);
    subwindow.setModal(true);/*from  w  w  w . j  av a 2  s  .c  o  m*/
    final Label message = new Label(DELETE_RESOURCE);
    subwindow.addComponent(message);

    final Button okConfirmed = new Button(ViewConstants.YES, new Button.ClickListener() {
        @Override
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
            deleteAllChildrenOfContainer(model, sender);
        }

    });
    final Button cancel = new Button("Cancel", new Button.ClickListener() {
        @Override
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    final HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(okConfirmed);
    hl.addComponent(cancel);
    subwindow.addComponent(hl);
    mainWindow.addWindow(subwindow);
}

From source file:org.escidoc.browser.ui.UserGroupView.java

License:Open Source License

private void addOrgUnitTable(VerticalLayout layout) {
    selectorTable = new Table();
    selectorTable.setWidth("60%");
    selectorTable.setPageLength(7);/*from   w  ww.  ja va 2 s.  c o  m*/
    selectorTable.setSelectable(true);
    selectorTable.setImmediate(true);
    selectorTable.setColumnReorderingAllowed(true);

    final BeanItemContainer<ResourceModel> dataSource;
    dataSource = populateContainerTable();

    selectorTable.setContainerDataSource(dataSource);
    selectorTable.setVisibleColumns(new String[] { PropertyId.NAME, (String) PropertyId.ID });
    selectorTable.addActionHandler(new Action.Handler() {

        @Override
        public Action[] getActions(@SuppressWarnings("unused") Object target,
                @SuppressWarnings("unused") Object sender) {
            return ACTIONS_LIST;
        }

        @Override
        public void handleAction(Action action, @SuppressWarnings("unused") Object sender, Object target) {
            if (action.equals(ACTION_ADD)) {
                // mainWindow.addWindow(new OrganizationSelectionView(repositories, resourceProxy, nameField,
                // mainWindow, dataSource).modalWindow());
                openViewAddRemoveOUs();
            } else {
                try {
                    repositories.group().removeOrganization(resourceProxy.getId(),
                            ((ResourceModel) target).getId());
                    selectorTable.removeItem(target);
                    mainWindow.showNotification(
                            "Organization with the id " + resourceProxy.getId() + " is removed from the group.",
                            Window.Notification.TYPE_TRAY_NOTIFICATION);
                } catch (EscidocClientException e) {
                    mainWindow.showNotification("Error removing organizationunit: ", e.getMessage(),
                            Window.Notification.TYPE_ERROR_MESSAGE);

                }
            }
        }

        private void openViewAddRemoveOUs() {
            final Window subwindow = new Window("A modal subwindow");
            subwindow.setModal(true);
            subwindow.setWidth("650px");
            VerticalLayout layout = (VerticalLayout) subwindow.getContent();
            layout.setMargin(true);
            layout.setSpacing(true);

            try {
                subwindow.addComponent(new AddOrgUnitstoGroup(router, resourceProxy, controller));
            } catch (EscidocClientException e) {
                controller.showError(e);
            }
            Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() {
                @Override
                public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                    subwindow.getParent().removeWindow(subwindow);
                }
            });
            layout.addComponent(close);
            layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

            router.getMainWindow().addWindow(subwindow);

        }
    });
    layout.addComponent(selectorTable);

}

From source file:org.escidoc.browser.ui.view.helpers.DeleteContainerShowLogsHelper.java

License:Open Source License

public void showWindow() {
    final Window subwindow = new Window("Change Category Type");
    subwindow.setModal(true);//from www.j  a v a 2 s  . c om

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);

    Table tblDeleted = new Table("Successfully deleted resources");
    tblDeleted.setWidth("90%");
    tblDeleted.addContainerProperty("Id", String.class, null);
    tblDeleted.addContainerProperty("Resource ", String.class, null);

    for (Map.Entry<String, String> entry : listDeleted.entrySet()) {
        tblDeleted.addItem(new Object[] { entry.getKey(), entry.getValue() }, entry.getKey());
    }
    layout.addComponent(tblDeleted);

    Table tblNotDeleted = new Table("Resources that could not be deleted");
    tblNotDeleted.setWidth("90%");
    tblNotDeleted.addContainerProperty("Resource Id", String.class, null);
    tblNotDeleted.addContainerProperty("Resource & Error", String.class, null);

    for (Map.Entry<String, String> entry : listNotDeleted.entrySet()) {
        tblNotDeleted.addItem(new Object[] { entry.getKey(), entry.getValue() }, entry.getKey());
    }
    layout.addComponent(tblNotDeleted);

    Button close = new Button("Close", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });

    layout.addComponent(close);

    subwindow.setWidth("600px");
    subwindow.addComponent(layout);
    router.getMainWindow().addWindow(subwindow);

}

From source file:org.escidoc.browser.ui.view.helpers.OnEditContextMetadata.java

License:Open Source License

private Button buildSaveButton(final Window modalWindow) {
    @SuppressWarnings("serial")
    final Button saveBtn = new Button(ViewConstants.SAVE, new Button.ClickListener() {

        private AdminDescriptor metadata;

        @Override//from   ww  w  . j a  v  a 2  s . co m
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            try {
                metadata = controller.getMetadata(md.name);
                metadata.setContent(metadataContent);
                controller.updateMetadata(metadata);
                controller.refreshView();
                message.setValue("");
                upload.setEnabled(true);
            } catch (final EscidocClientException e) {
                LOG.error(e.getMessage());
                mainWindow.showNotification(e.getMessage());
            }
            modalWindow.getParent().removeWindow(modalWindow);
        }
    });
    return saveBtn;
}

From source file:org.escidoc.browser.ui.view.helpers.OnEditContextMetadata.java

License:Open Source License

@SuppressWarnings("serial")
private static Button buildCancelButton(final Window modalWindow) {
    final Button cancelBtn = new Button(ViewConstants.CANCEL, new Button.ClickListener() {

        @Override/*from w ww.  j  a  va  2s .c o  m*/
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            modalWindow.getParent().removeWindow(modalWindow);
        }
    });
    return cancelBtn;
}

From source file:org.escidoc.browser.ui.view.helpers.OrganizationalUnitsTableVH.java

License:Open Source License

@Override
protected void addActionLists() {
    // if (contextController.canUpdateContext()) {
    table.addActionHandler(new Action.Handler() {
        @Override//from w  w  w .  j  av a  2  s  . c o m
        public Action[] getActions(Object target, Object sender) {
            return ACTIONS_LIST;
        }

        @Override
        public void handleAction(Action action, Object sender, Object target) {
            if ((ACTION_DELETE == action) && (target != null)) {
                confirmActionWindow(target);
            } else {
                openViewAddRemoveOUs();
            }

        }

        private void openViewAddRemoveOUs() {
            final Window subwindow = new Window("A modal subwindow");
            subwindow.setModal(true);
            subwindow.setWidth("650px");
            VerticalLayout layout = (VerticalLayout) subwindow.getContent();
            layout.setMargin(true);
            layout.setSpacing(true);

            try {
                subwindow.addComponent(new AddOrgUnitstoContext(router, resourceProxy, controller,
                        resourceProxy.getOrganizationalUnit()));
            } catch (EscidocClientException e) {
                controller.showError(e);
            }
            Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() {
                @Override
                public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                    subwindow.getParent().removeWindow(subwindow);
                }
            });
            layout.addComponent(close);
            layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

            router.getMainWindow().addWindow(subwindow);
        }
    });
    // }
}

From source file:org.escidoc.browser.ui.view.helpers.OUParentTableVH.java

License:Open Source License

@Override
protected void addActionLists() {
    table.addActionHandler(new Action.Handler() {
        @Override/*from   w  w w .j  a  v a 2 s .com*/
        public Action[] getActions(Object target, Object sender) {
            return ACTIONS_LIST;
        }

        @Override
        public void handleAction(Action action, Object sender, Object target) {
            if ((ACTION_DELETE == action) && (target != null)) {
                confirmActionWindow(target);
            } else {
                openViewAddRemoveOUs();
            }

        }

        private void openViewAddRemoveOUs() {
            final Window subwindow = new Window("A modal subwindow");
            subwindow.setModal(true);
            subwindow.setWidth("650px");
            VerticalLayout layout = (VerticalLayout) subwindow.getContent();
            layout.setMargin(true);
            layout.setSpacing(true);

            try {
                subwindow.addComponent(new OrgUnitParentEditView(orgUnitProxy, orgUnitProxy.getParentList(),
                        router, controller));
            } catch (EscidocClientException e) {
                controller.showError(e);
            }
            Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() {
                @Override
                public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                    subwindow.getParent().removeWindow(subwindow);
                }
            });
            layout.addComponent(close);
            layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

            router.getMainWindow().addWindow(subwindow);
        }
    });

}