Example usage for com.vaadin.ui.themes ValoTheme PANEL_BORDERLESS

List of usage examples for com.vaadin.ui.themes ValoTheme PANEL_BORDERLESS

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme PANEL_BORDERLESS.

Prototype

String PANEL_BORDERLESS

To view the source code for com.vaadin.ui.themes ValoTheme PANEL_BORDERLESS.

Click Source Link

Document

Remove borders and the background color of the panel.

Usage

From source file:org.ikasan.dashboard.ui.topology.component.WiretapTab.java

License:BSD License

public Layout createWiretapLayout() {
    this.wiretapTable = new Table();
    this.wiretapTable.setSizeFull();
    this.wiretapTable.addStyleName(ValoTheme.TABLE_SMALL);
    this.wiretapTable.addStyleName("ikasan");

    this.wiretapTable.addContainerProperty("Module Name", String.class, null);
    this.wiretapTable.addContainerProperty("Flow Name", String.class, null);
    this.wiretapTable.addContainerProperty("Component Name", String.class, null);
    this.wiretapTable.addContainerProperty("Event Id / Payload Id", String.class, null);
    this.wiretapTable.addContainerProperty("Timestamp", String.class, null);
    this.wiretapTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());

    this.wiretapTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override//from  www. j  ava 2  s.c  o  m
        public void itemClick(ItemClickEvent itemClickEvent) {
            WiretapEvent<String> wiretapEvent = (WiretapEvent<String>) itemClickEvent.getItemId();
            WiretapPayloadViewWindow wiretapPayloadViewWindow = new WiretapPayloadViewWindow(wiretapEvent);

            UI.getCurrent().addWindow(wiretapPayloadViewWindow);
        }
    });

    final Button searchButton = new Button("Search");
    searchButton.setStyleName(ValoTheme.BUTTON_SMALL);
    searchButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            ProgressBarWindow pbWindow = new ProgressBarWindow();

            UI.getCurrent().addWindow(pbWindow);

            wiretapTable.removeAllItems();

            HashSet<String> modulesNames = null;

            if (modules.getItemIds().size() > 0) {
                modulesNames = new HashSet<String>();
                for (Object module : modules.getItemIds()) {
                    modulesNames.add(((Module) module).getName());
                }
            }

            HashSet<String> flowNames = null;

            if (flows.getItemIds().size() > 0) {
                flowNames = new HashSet<String>();
                for (Object flow : flows.getItemIds()) {
                    flowNames.add(((Flow) flow).getName());
                }
            }

            HashSet<String> componentNames = null;

            if (components.getItemIds().size() > 0) {
                componentNames = new HashSet<String>();
                for (Object component : components.getItemIds()) {

                    componentNames.add("before " + ((Component) component).getName());
                    componentNames.add("after " + ((Component) component).getName());
                }
            }

            if (modulesNames == null && flowNames == null && componentNames == null
                    && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) {
                BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue());

                modulesNames = new HashSet<String>();

                for (BusinessStreamFlow flow : businessStream.getFlows()) {
                    modulesNames.add(flow.getFlow().getModule().getName());
                }
            }

            String errorCategory = null;

            // TODO Need to take a proper look at the wiretap search interface. We do not need to worry about paging search
            // results with Vaadin.
            PagedSearchResult<WiretapEvent> events = wiretapDao.findWiretapEvents(0, 10000, "timestamp", false,
                    modulesNames, flowNames, componentNames, eventId.getValue(), null, fromDate.getValue(),
                    toDate.getValue(), payloadContent.getValue());

            for (WiretapEvent<String> wiretapEvent : events.getPagedResults()) {
                Date date = new Date(wiretapEvent.getTimestamp());
                SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss");
                String timestamp = format.format(date);

                wiretapTable
                        .addItem(
                                new Object[] { wiretapEvent.getModuleName(), wiretapEvent.getFlowName(),
                                        wiretapEvent.getComponentName(),
                                        ((WiretapFlowEvent) wiretapEvent).getEventId(), timestamp },
                                wiretapEvent);
            }

            pbWindow.close();
        }
    });

    Button clearButton = new Button("Clear");
    clearButton.setStyleName(ValoTheme.BUTTON_SMALL);
    clearButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            modules.removeAllItems();
            flows.removeAllItems();
            components.removeAllItems();
        }
    });

    GridLayout layout = new GridLayout(1, 6);
    layout.setMargin(false);
    layout.setHeight(270, Unit.PIXELS);

    GridLayout listSelectLayout = new GridLayout(3, 1);
    listSelectLayout.setSpacing(true);
    listSelectLayout.setSizeFull();

    modules.setIcon(VaadinIcons.ARCHIVE);
    modules.addContainerProperty("Module Name", String.class, null);
    modules.addContainerProperty("", Button.class, null);
    modules.setSizeFull();
    modules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    modules.setDragMode(TableDragMode.ROW);
    modules.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable();

            if (t.getItemId() instanceof Module) {
                final Module module = (Module) t.getItemId();
                logger.info("sourceContainer.getText(): " + module.getName());

                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                // Add the delete functionality to each role that is added
                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        modules.removeItem(module);
                    }
                });

                modules.addItem(new Object[] { module.getName(), deleteButton }, module);

                for (final Flow flow : module.getFlows()) {
                    deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                    // Add the delete functionality to each role that is added
                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            flows.removeItem(flow);
                        }
                    });

                    flows.addItem(new Object[] { flow.getName(), deleteButton }, flow);

                    for (final Component component : flow.getComponents()) {
                        deleteButton = new Button();
                        deleteButton.setIcon(VaadinIcons.TRASH);
                        deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                        deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                        // Add the delete functionality to each role that is added
                        deleteButton.addClickListener(new Button.ClickListener() {
                            public void buttonClick(ClickEvent event) {
                                components.removeItem(component);
                            }
                        });

                        components.addItem(new Object[] { component.getName(), deleteButton }, component);
                    }
                }
            }

        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });

    listSelectLayout.addComponent(modules, 0, 0);

    flows.setIcon(VaadinIcons.AUTOMATION);
    flows.addContainerProperty("Flow Name", String.class, null);
    flows.addContainerProperty("", Button.class, null);
    flows.setSizeFull();
    flows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    flows.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable();

            if (t.getItemId() instanceof Flow) {
                final Flow flow = (Flow) t.getItemId();
                logger.info("sourceContainer.getText(): " + flow.getName());

                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                // Add the delete functionality to each role that is added
                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        flows.removeItem(flow);
                    }
                });

                flows.addItem(new Object[] { flow.getName(), deleteButton }, flow);

                for (final Component component : flow.getComponents()) {
                    deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                    // Add the delete functionality to each role that is added
                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            components.removeItem(component);
                        }
                    });

                    components.addItem(new Object[] { component.getName(), deleteButton }, component);
                }
            }

        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });

    listSelectLayout.addComponent(flows, 1, 0);

    components.setIcon(VaadinIcons.COG);
    components.setSizeFull();
    components.addContainerProperty("Component Name", String.class, null);
    components.addContainerProperty("", Button.class, null);
    components.setCellStyleGenerator(new IkasanCellStyleGenerator());
    components.setSizeFull();
    components.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    components.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable();

            if (t.getItemId() instanceof Component) {
                final Component component = (Component) t.getItemId();
                logger.info("sourceContainer.getText(): " + component.getName());

                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

                // Add the delete functionality to each role that is added
                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        components.removeItem(component);
                    }
                });

                components.addItem(new Object[] { component.getName(), deleteButton }, component);

            }

        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });
    listSelectLayout.addComponent(this.components, 2, 0);

    GridLayout dateSelectLayout = new GridLayout(2, 2);
    dateSelectLayout.setColumnExpandRatio(0, 0.25f);
    dateSelectLayout.setColumnExpandRatio(1, 0.75f);
    dateSelectLayout.setSizeFull();
    this.fromDate = new PopupDateField("From date");
    this.fromDate.setResolution(Resolution.MINUTE);
    this.fromDate.setValue(this.getMidnightToday());
    dateSelectLayout.addComponent(this.fromDate, 0, 0);
    this.toDate = new PopupDateField("To date");
    this.toDate.setResolution(Resolution.MINUTE);
    this.toDate.setValue(this.getTwentyThreeFixtyNineToday());
    dateSelectLayout.addComponent(this.toDate, 0, 1);

    this.eventId = new TextField("Event Id");
    this.eventId.setWidth("80%");
    this.payloadContent = new TextField("Payload Content");
    this.payloadContent.setWidth("80%");

    this.eventId.setNullSettingAllowed(true);
    this.payloadContent.setNullSettingAllowed(true);

    dateSelectLayout.addComponent(this.eventId, 1, 0);
    dateSelectLayout.addComponent(this.payloadContent, 1, 1);

    final VerticalSplitPanel vSplitPanel = new VerticalSplitPanel();
    vSplitPanel.setHeight("95%");

    GridLayout searchLayout = new GridLayout(2, 1);
    searchLayout.setSpacing(true);
    searchLayout.addComponent(searchButton, 0, 0);
    searchLayout.addComponent(clearButton, 1, 0);

    final Button hideFilterButton = new Button();
    hideFilterButton.setIcon(VaadinIcons.MINUS);
    hideFilterButton.setCaption("Hide Filter");
    hideFilterButton.setStyleName(ValoTheme.BUTTON_LINK);
    hideFilterButton.addStyleName(ValoTheme.BUTTON_SMALL);

    final Button showFilterButton = new Button();
    showFilterButton.setIcon(VaadinIcons.PLUS);
    showFilterButton.setCaption("Show Filter");
    showFilterButton.addStyleName(ValoTheme.BUTTON_LINK);
    showFilterButton.addStyleName(ValoTheme.BUTTON_SMALL);
    showFilterButton.setVisible(false);

    final HorizontalLayout hListSelectLayout = new HorizontalLayout();
    hListSelectLayout.setHeight(150, Unit.PIXELS);
    hListSelectLayout.setWidth("100%");
    hListSelectLayout.addComponent(listSelectLayout);

    final HorizontalLayout hDateSelectLayout = new HorizontalLayout();
    hDateSelectLayout.setHeight(80, Unit.PIXELS);
    hDateSelectLayout.setWidth("100%");
    hDateSelectLayout.addComponent(dateSelectLayout);

    final HorizontalLayout hSearchLayout = new HorizontalLayout();
    hSearchLayout.setHeight(30, Unit.PIXELS);
    hSearchLayout.setWidth("100%");
    hSearchLayout.addComponent(searchLayout);
    hSearchLayout.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER);

    hideFilterButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            hideFilterButton.setVisible(false);
            showFilterButton.setVisible(true);
            splitPosition = vSplitPanel.getSplitPosition();
            splitUnit = vSplitPanel.getSplitPositionUnit();
            vSplitPanel.setSplitPosition(0, Unit.PIXELS);
        }
    });

    showFilterButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            hideFilterButton.setVisible(true);
            showFilterButton.setVisible(false);
            vSplitPanel.setSplitPosition(splitPosition, splitUnit);
        }
    });

    GridLayout filterButtonLayout = new GridLayout(2, 1);
    filterButtonLayout.setHeight(25, Unit.PIXELS);
    filterButtonLayout.addComponent(hideFilterButton, 0, 0);
    filterButtonLayout.addComponent(showFilterButton, 1, 0);

    Label filterHintLabel = new Label();
    filterHintLabel.setCaptionAsHtml(true);
    filterHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Drag items from the topology tree to the tables below in order to narrow your search.");
    filterHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    filterHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);

    layout.addComponent(filterHintLabel);
    layout.addComponent(hListSelectLayout);
    layout.addComponent(hDateSelectLayout);
    layout.addComponent(hSearchLayout);
    layout.setSizeFull();

    Panel filterPanel = new Panel();
    filterPanel.setHeight(340, Unit.PIXELS);
    filterPanel.setWidth("100%");
    filterPanel.setContent(layout);
    filterPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);

    vSplitPanel.setFirstComponent(filterPanel);

    CssLayout hErrorTable = new CssLayout();
    hErrorTable.setSizeFull();
    hErrorTable.addComponent(this.wiretapTable);

    vSplitPanel.setSecondComponent(hErrorTable);
    vSplitPanel.setSplitPosition(350, Unit.PIXELS);

    GridLayout wrapper = new GridLayout(1, 2);
    wrapper.setRowExpandRatio(0, .01f);
    wrapper.setRowExpandRatio(1, .99f);
    wrapper.setSizeFull();
    wrapper.addComponent(filterButtonLayout);
    wrapper.setComponentAlignment(filterButtonLayout, Alignment.MIDDLE_RIGHT);
    wrapper.addComponent(vSplitPanel);

    return wrapper;
}

From source file:org.ikasan.dashboard.ui.topology.panel.TopologyViewPanel.java

License:BSD License

protected void init() {
    this.tabsheetPanel = new Panel();
    this.tabsheetPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    this.tabsheetPanel.setSizeFull();

    this.createModuleTreePanel();

    this.setWidth("100%");
    this.setHeight("100%");

    this.businessStreamCombo = new ComboBox();

    HorizontalSplitPanel hsplit = new HorizontalSplitPanel();
    hsplit.setStyleName(ValoTheme.SPLITPANEL_LARGE);

    HorizontalLayout leftLayout = new HorizontalLayout();
    leftLayout.setSizeFull();/* w  w w.  j  av a  2  s  . c  om*/
    leftLayout.setMargin(true);
    leftLayout.addComponent(this.topologyTreePanel);
    hsplit.setFirstComponent(leftLayout);
    HorizontalLayout rightLayout = new HorizontalLayout();
    rightLayout.setSizeFull();
    rightLayout.setMargin(true);
    rightLayout.addComponent(this.tabsheetPanel);
    hsplit.setSecondComponent(rightLayout);
    hsplit.setSplitPosition(30, Unit.PERCENTAGE);

    this.flowStates = this.topologyCache.getStateMap();

    this.setContent(hsplit);
}

From source file:org.ikasan.dashboard.ui.topology.panel.TopologyViewPanel.java

License:BSD License

protected void createModuleTreePanel() {
    this.topologyTreePanel = new Panel();
    this.topologyTreePanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    this.topologyTreePanel.setSizeFull();

    this.moduleTree = new Tree();
    this.moduleTree.setImmediate(true);
    this.moduleTree.setSizeFull();
    this.moduleTree.addActionHandler(this);
    this.moduleTree.setDragMode(TreeDragMode.NODE);
    this.moduleTree.setItemStyleGenerator(new ItemStyleGenerator() {
        @Override/*ww  w . java  2 s .  c  o  m*/
        public String getStyle(Tree source, Object itemId) {
            if (itemId instanceof Flow) {
                Flow flow = (Flow) itemId;

                String state = flowStates.get(flow.getModule().getName() + "-" + flow.getName());

                logger.info("State = " + state);

                if (state != null && state.equals(RUNNING)) {
                    return "greenicon";
                } else if (state != null && state.equals(RECOVERING)) {
                    return "orangeicon";
                } else if (state != null && state.equals(STOPPED)) {
                    return "redicon";
                } else if (state != null && state.equals(STOPPED_IN_ERROR)) {
                    return "redicon";
                } else if (state != null && state.equals(PAUSED)) {
                    return "indigoicon";
                }
            }

            return "";
        }
    });

    GridLayout layout = new GridLayout(1, 4);

    Label roleManagementLabel = new Label("Topology");
    roleManagementLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(roleManagementLabel, 0, 0);

    layout.setSpacing(true);
    layout.setWidth("100%");

    this.treeViewBusinessStreamCombo = new ComboBox("Business Stream");

    this.treeViewBusinessStreamCombo.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            if (event.getProperty() != null && event.getProperty().getValue() != null) {
                businessStream = (BusinessStream) event.getProperty().getValue();

                logger.info("Value changed to business stream: " + businessStream.getName());

                moduleTree.removeAllItems();

                final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService
                        .getCurrentRequest().getWrappedSession()
                        .getAttribute(DashboardSessionValueConstants.USER);

                if (authentication != null
                        && authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
                        && businessStream.getName().equals("All")) {
                    List<Server> servers = TopologyViewPanel.this.topologyService.getAllServers();

                    for (Server server : servers) {
                        Set<Module> modules = server.getModules();

                        TopologyViewPanel.this.moduleTree.addItem(server);
                        TopologyViewPanel.this.moduleTree.setItemCaption(server, server.getName());
                        TopologyViewPanel.this.moduleTree.setChildrenAllowed(server, true);
                        TopologyViewPanel.this.moduleTree.setItemIcon(server, VaadinIcons.SERVER);

                        for (Module module : modules) {
                            TopologyViewPanel.this.moduleTree.addItem(module);
                            TopologyViewPanel.this.moduleTree.setItemCaption(module, module.getName());
                            TopologyViewPanel.this.moduleTree.setParent(module, server);
                            TopologyViewPanel.this.moduleTree.setChildrenAllowed(module, true);
                            TopologyViewPanel.this.moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE);

                            Set<Flow> flows = module.getFlows();

                            for (Flow flow : flows) {
                                TopologyViewPanel.this.moduleTree.addItem(flow);
                                TopologyViewPanel.this.moduleTree.setItemCaption(flow, flow.getName());
                                TopologyViewPanel.this.moduleTree.setParent(flow, module);
                                TopologyViewPanel.this.moduleTree.setChildrenAllowed(flow, true);

                                TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION);

                                Set<Component> components = flow.getComponents();

                                for (Component component : components) {
                                    TopologyViewPanel.this.moduleTree.addItem(component);
                                    TopologyViewPanel.this.moduleTree.setParent(component, flow);
                                    TopologyViewPanel.this.moduleTree.setItemCaption(component,
                                            component.getName());
                                    TopologyViewPanel.this.moduleTree.setChildrenAllowed(component, false);

                                    if (component.isConfigurable()) {
                                        TopologyViewPanel.this.moduleTree.setItemIcon(component,
                                                VaadinIcons.COG);
                                    } else {
                                        TopologyViewPanel.this.moduleTree.setItemIcon(component,
                                                VaadinIcons.COG_O);
                                    }
                                }
                            }
                        }
                    }
                } else if (authentication != null
                        && !authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
                        && businessStream.getName().equals("All")) {
                    List<BusinessStream> businessStreams = topologyService.getAllBusinessStreams();

                    for (BusinessStream businessStream : businessStreams) {
                        if (authentication.canAccessLinkedItem(
                                PolicyLinkTypeConstants.BUSINESS_STREAM_LINK_TYPE, businessStream.getId())) {
                            for (BusinessStreamFlow bsFlow : businessStream.getFlows()) {
                                Server server = bsFlow.getFlow().getModule().getServer();
                                Module module = bsFlow.getFlow().getModule();
                                Flow flow = bsFlow.getFlow();

                                if (!moduleTree.containsId(server)) {
                                    moduleTree.addItem(server);
                                    moduleTree.setItemCaption(server, server.getName());
                                    moduleTree.setChildrenAllowed(server, true);
                                    moduleTree.setItemIcon(server, VaadinIcons.SERVER);
                                }

                                moduleTree.addItem(module);
                                moduleTree.setItemCaption(module, module.getName());
                                moduleTree.setParent(module, server);
                                moduleTree.setChildrenAllowed(module, true);
                                moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE);

                                moduleTree.addItem(flow);
                                moduleTree.setItemCaption(flow, flow.getName());
                                moduleTree.setParent(flow, module);
                                moduleTree.setChildrenAllowed(flow, true);

                                TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION);

                                Set<Component> components = flow.getComponents();

                                for (Component component : components) {
                                    moduleTree.addItem(component);
                                    moduleTree.setParent(component, flow);
                                    moduleTree.setItemCaption(component, component.getName());
                                    moduleTree.setChildrenAllowed(component, false);

                                    if (component.isConfigurable()) {
                                        TopologyViewPanel.this.moduleTree.setItemIcon(component,
                                                VaadinIcons.COG);
                                    } else {
                                        TopologyViewPanel.this.moduleTree.setItemIcon(component,
                                                VaadinIcons.COG_O);
                                    }
                                }
                            }
                        }
                    }
                } else {
                    for (BusinessStreamFlow bsFlow : businessStream.getFlows()) {
                        Server server = bsFlow.getFlow().getModule().getServer();
                        Module module = bsFlow.getFlow().getModule();
                        Flow flow = bsFlow.getFlow();

                        if (!moduleTree.containsId(server)) {
                            moduleTree.addItem(server);
                            moduleTree.setItemCaption(server, server.getName());
                            moduleTree.setChildrenAllowed(server, true);
                            moduleTree.setItemIcon(server, VaadinIcons.SERVER);
                        }

                        moduleTree.addItem(module);
                        moduleTree.setItemCaption(module, module.getName());
                        moduleTree.setParent(module, server);
                        moduleTree.setChildrenAllowed(module, true);
                        moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE);

                        moduleTree.addItem(flow);
                        moduleTree.setItemCaption(flow, flow.getName());
                        moduleTree.setParent(flow, module);
                        moduleTree.setChildrenAllowed(flow, true);

                        TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION);

                        Set<Component> components = flow.getComponents();

                        for (Component component : components) {
                            moduleTree.addItem(component);
                            moduleTree.setParent(component, flow);
                            moduleTree.setItemCaption(component, component.getName());
                            moduleTree.setChildrenAllowed(component, false);

                            if (component.isConfigurable()) {
                                TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG);
                            } else {
                                TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG_O);
                            }
                        }
                    }
                }
            }
        }
    });

    this.treeViewBusinessStreamCombo.setWidth("250px");
    layout.addComponent(this.treeViewBusinessStreamCombo);

    Button discoverButton = new Button("Discover");
    discoverButton.setStyleName(ValoTheme.BUTTON_SMALL);

    discoverButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                    .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

            try {
                topologyService.discover(authentication);
            } catch (DiscoveryException e) {
                Notification.show("An error occurred trying to auto discover modules: " + e.getMessage(),
                        Type.ERROR_MESSAGE);
            }

            Notification.show("Auto discovery complete!");
        }
    });

    Button refreshButton = new Button("Refresh");
    refreshButton.setStyleName(ValoTheme.BUTTON_SMALL);
    refreshButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            refreshTree();
        }
    });

    Button newServerButton = new Button("New Server");
    newServerButton.setStyleName(ValoTheme.BUTTON_SMALL);
    newServerButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().addWindow(new NewServerWindow(topologyService));
        }
    });

    GridLayout buttonLayout = new GridLayout(3, 1);
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(discoverButton);
    buttonLayout.addComponent(refreshButton);
    buttonLayout.addComponent(newServerButton);

    layout.addComponent(buttonLayout);
    layout.addComponent(this.moduleTree);

    this.topologyTreePanel.setContent(layout);
}

From source file:org.ikasan.dashboard.ui.topology.window.ErrorCategorisationWindow.java

License:BSD License

/**
  * Helper method to initialise this object.
  * /*from   w w  w  . j ava  2s . c  o  m*/
  * @param message
  */
protected void init() {
    setModal(true);
    setHeight("90%");
    setWidth("90%");

    this.existingCategorisedErrorsTable = new Table();
    this.existingCategorisedErrorsTable.setWidth("100%");
    this.existingCategorisedErrorsTable.setHeight(200, Unit.PIXELS);
    this.existingCategorisedErrorsTable.addContainerProperty("Module Name", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Module Name", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Flow Name", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Flow Name", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Component Name", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Component Name", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Action", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Action", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Error Category", Label.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Error Category", .1f);
    this.existingCategorisedErrorsTable.addContainerProperty("Error Message", String.class, null);
    this.existingCategorisedErrorsTable.setColumnExpandRatio("Error Message", .5f);

    this.existingCategorisedErrorsTable.addStyleName("wordwrap-table");
    this.existingCategorisedErrorsTable.addStyleName(ValoTheme.TABLE_NO_STRIPES);

    this.existingCategorisedErrorsTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
        @Override
        public String getStyle(Table source, Object itemId, Object propertyId) {

            ErrorCategorisationLink errorCategorisationLink = (ErrorCategorisationLink) itemId;

            if (propertyId == null) {
                // Styling for row         

                if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.TRIVIAL)) {
                    return "ikasan-green-small";
                } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.MAJOR)) {
                    return "ikasan-green-small";
                } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.CRITICAL)) {
                    return "ikasan-orange-small";
                } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                        .equals(ErrorCategorisation.BLOCKER)) {
                    return "ikasan-red-small";
                }
            }

            if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                    .equals(ErrorCategorisation.TRIVIAL)) {
                return "ikasan-green-small";
            } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                    .equals(ErrorCategorisation.MAJOR)) {
                return "ikasan-green-small";
            } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                    .equals(ErrorCategorisation.CRITICAL)) {
                return "ikasan-orange-small";
            } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory()
                    .equals(ErrorCategorisation.BLOCKER)) {
                return "ikasan-red-small";
            }

            return "ikasan-small";
        }
    });

    this.existingCategorisedErrorsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent itemClickEvent) {
            logger.info("table item slected: " + (ErrorCategorisationLink) itemClickEvent.getItemId());

            errorCategorisationLink = (ErrorCategorisationLink) itemClickEvent.getItemId();
            errorCategorisation = errorCategorisationLink.getErrorCategorisation();

            errorCategorisationItem = new BeanItem<ErrorCategorisation>(errorCategorisation);
            errorCategorisationLinkItem = new BeanItem<ErrorCategorisationLink>(errorCategorisationLink);

            moduleNameTextField
                    .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("moduleName"));
            flowNameTextField.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowName"));
            componentNameTextField
                    .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowElementName"));
            errorCategoryCombo.setPropertyDataSource(errorCategorisationItem.getItemProperty("errorCategory"));
            errorMessageTextArea
                    .setPropertyDataSource(errorCategorisationItem.getItemProperty("errorDescription"));
            actionCombo.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("action"));
            exceptionClassTextField
                    .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("exceptionClass"));

            errorMessageTextArea.markAsDirty();
            actionCombo.markAsDirty();
            errorCategoryCombo.markAsDirty();
            componentNameTextField.markAsDirty();
            flowNameTextField.markAsDirty();
            moduleNameTextField.markAsDirty();
        }
    });

    refreshExistingCategorisedErrorsTable();

    layout.setSizeFull();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setColumnExpandRatio(0, .25f);
    layout.setColumnExpandRatio(1, .75f);

    if (this.errorCategorisationLink == null) {
        clear();
    }

    Label configuredResourceIdLabel = new Label("Error Categorisation");
    configuredResourceIdLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(configuredResourceIdLabel, 0, 0, 1, 0);

    if (this.module == null && this.flow == null && this.component == null) {
        Label errorCategorisationHintLabel = new Label();
        errorCategorisationHintLabel.setCaptionAsHtml(true);
        errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
                + " You are creating an error categorisation for server wide errors. This categorisation will be applied"
                + " against errors that occur server wide, that do not have a more focused error categorisation.");
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL);

        layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1);
    } else if (this.flow == null && this.component == null) {
        Label errorCategorisationHintLabel = new Label();
        errorCategorisationHintLabel.setCaptionAsHtml(true);
        errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
                + " You are creating an error categorisation for module wide errors. This categorisation will be applied"
                + " against errors that occur within this module, that do not have a more focused error categorisation.");
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL);

        layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1);
    } else if (this.component == null) {
        Label errorCategorisationHintLabel = new Label();
        errorCategorisationHintLabel.setCaptionAsHtml(true);
        errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
                + " You are creating an error categorisation for flow wide errors. This categorisation will be applied"
                + " against errors that occur within this flow, that do not have a more focused error categorisation.");
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL);

        layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1);
    } else {
        Label errorCategorisationHintLabel = new Label();
        errorCategorisationHintLabel.setCaptionAsHtml(true);
        errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
                + " You are creating an error categorisation against a component. This is the most focused error categorisation"
                + " that can be applied. This categorisation will be applied against errors that occur on this component.");
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
        errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL);

        layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1);
    }

    if (this.module != null) {
        Label moduleNameLabel = new Label();
        moduleNameLabel.setContentMode(ContentMode.HTML);
        moduleNameLabel.setValue(VaadinIcons.ARCHIVE.getHtml() + " Module Name:");
        moduleNameLabel.setSizeUndefined();
        layout.addComponent(moduleNameLabel, 0, 2);
        layout.setComponentAlignment(moduleNameLabel, Alignment.MIDDLE_RIGHT);

        moduleNameTextField.setRequired(true);
        moduleNameTextField.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("moduleName"));
        moduleNameTextField.setReadOnly(true);
        moduleNameTextField.setWidth("80%");
        layout.addComponent(moduleNameTextField, 1, 2);
    }

    if (this.flow != null) {
        Label flowNameLabel = new Label();
        flowNameLabel.setContentMode(ContentMode.HTML);
        flowNameLabel.setValue(VaadinIcons.AUTOMATION.getHtml() + " Flow Name:");
        flowNameLabel.setSizeUndefined();
        layout.addComponent(flowNameLabel, 0, 3);
        layout.setComponentAlignment(flowNameLabel, Alignment.MIDDLE_RIGHT);

        flowNameTextField.setRequired(true);
        flowNameTextField.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowName"));
        flowNameTextField.setReadOnly(true);
        flowNameTextField.setWidth("80%");
        layout.addComponent(flowNameTextField, 1, 3);
    }

    if (this.component != null) {
        Label componentNameLabel = new Label();
        componentNameLabel.setContentMode(ContentMode.HTML);
        componentNameLabel.setValue(VaadinIcons.COG.getHtml() + " Component Name:");
        componentNameLabel.setSizeUndefined();
        layout.addComponent(componentNameLabel, 0, 4);
        layout.setComponentAlignment(componentNameLabel, Alignment.MIDDLE_RIGHT);

        componentNameTextField.setRequired(true);
        componentNameTextField
                .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowElementName"));
        componentNameTextField.setReadOnly(true);
        componentNameTextField.setWidth("80%");
        layout.addComponent(componentNameTextField, 1, 4);
    }

    Label exceptionClassLabel = new Label();
    exceptionClassLabel.setContentMode(ContentMode.HTML);
    exceptionClassLabel.setValue("Exception Class:");
    exceptionClassLabel.setSizeUndefined();
    layout.addComponent(exceptionClassLabel, 0, 5);
    layout.setComponentAlignment(exceptionClassLabel, Alignment.MIDDLE_RIGHT);

    this.exceptionClassTextField.setWidth("80%");
    exceptionClassTextField
            .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("exceptionClass"));
    layout.addComponent(exceptionClassTextField, 1, 5);

    Label actionLabel = new Label();
    actionLabel.setContentMode(ContentMode.HTML);
    actionLabel.setValue("Action:");
    actionLabel.setSizeUndefined();
    layout.addComponent(actionLabel, 0, 6);
    layout.setComponentAlignment(actionLabel, Alignment.MIDDLE_RIGHT);

    Label errorCategoryLabel = new Label("Error Category:");
    errorCategoryLabel.setSizeUndefined();
    layout.addComponent(errorCategoryLabel, 0, 7);
    layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_RIGHT);

    this.setupComboBoxesAndItems();

    Label errorMessageLabel = new Label("Error Message:");
    errorMessageLabel.setSizeUndefined();
    layout.addComponent(errorMessageLabel, 0, 8);
    layout.setComponentAlignment(errorMessageLabel, Alignment.TOP_RIGHT);

    errorMessageTextArea.addValidator(new StringLengthValidator(
            "You must define an error message between 1 and 2048 characters in length!", 1, 2048, false));
    errorMessageTextArea.setValidationVisible(false);
    errorMessageTextArea.setPropertyDataSource(errorCategorisationItem.getItemProperty("errorDescription"));
    errorMessageTextArea.setRequired(true);
    errorMessageTextArea.setWidth("650px");
    errorMessageTextArea.setRows(8);
    errorMessageTextArea.setRequiredError("An error message is required!");
    layout.addComponent(errorMessageTextArea, 1, 8);

    GridLayout buttonLayouts = new GridLayout(4, 1);
    buttonLayouts.setSpacing(true);

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                errorCategoryCombo.validate();
                errorMessageTextArea.validate();
                actionCombo.validate();
            } catch (InvalidValueException e) {
                errorCategoryCombo.setValidationVisible(true);
                errorMessageTextArea.setValidationVisible(true);
                actionCombo.setValidationVisible(true);

                errorCategoryCombo.markAsDirty();
                errorMessageTextArea.markAsDirty();
                actionCombo.markAsDirty();
                return;
            }

            try {
                errorCategorisationService.save(errorCategorisationItem.getBean());

                errorCategorisationLink.setErrorCategorisation(errorCategorisationItem.getBean());

                errorCategorisationService.save(errorCategorisationLink);
            } catch (Exception e) {
                if (e.getCause() instanceof ConstraintViolationException) {
                    Notification.show(
                            "An error occurred trying to save an error categorisation: Action type must be unique for a given node!",
                            Type.ERROR_MESSAGE);
                } else {
                    Notification.show(
                            "An error occurred trying to save an error categorisation: " + e.getMessage(),
                            Type.ERROR_MESSAGE);
                }
            }

            refreshExistingCategorisedErrorsTable();

            Notification.show("Saved!");
        }
    });

    Button clearButton = new Button("Clear");
    clearButton.setStyleName(ValoTheme.BUTTON_SMALL);
    clearButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            clear();
        }
    });

    Button deleteButton = new Button("Delete");
    deleteButton.setStyleName(ValoTheme.BUTTON_SMALL);
    deleteButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            ErrorCategorisation ec = errorCategorisationLink.getErrorCategorisation();

            errorCategorisationService.delete(errorCategorisationLink);
            errorCategorisationService.delete(ec);
            existingCategorisedErrorsTable.removeItem(errorCategorisationLink);

            clear();
        }
    });

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    buttonLayouts.addComponent(saveButton);
    buttonLayouts.addComponent(clearButton);
    buttonLayouts.addComponent(deleteButton);
    buttonLayouts.addComponent(cancelButton);

    layout.addComponent(buttonLayouts, 0, 9, 1, 9);
    layout.setComponentAlignment(buttonLayouts, Alignment.MIDDLE_CENTER);

    Label existingCategorisationLabel = new Label("Existing Error Categorisations");
    existingCategorisationLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(existingCategorisationLabel, 0, 10, 1, 10);

    Label uniquenessHintLabel = new Label();
    uniquenessHintLabel.setCaptionAsHtml(true);
    uniquenessHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " You can only create one error categorisation per Action type for a give node. If you attempt to create more you will receive an error when"
            + " trying to save.");
    uniquenessHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    uniquenessHintLabel.addStyleName(ValoTheme.LABEL_SMALL);
    layout.addComponent(uniquenessHintLabel, 0, 11, 1, 11);

    Label editHintLabel = new Label();
    editHintLabel.setCaptionAsHtml(true);
    editHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " You can can click on a row in the table below to edit an error categorisation.");
    editHintLabel.addStyleName(ValoTheme.LABEL_BOLD);
    editHintLabel.addStyleName(ValoTheme.LABEL_SMALL);
    layout.addComponent(editHintLabel, 0, 12, 1, 12);

    layout.addComponent(this.existingCategorisedErrorsTable, 0, 13, 1, 13);
    layout.setComponentAlignment(this.existingCategorisedErrorsTable, Alignment.MIDDLE_CENTER);

    Panel paramPanel = new Panel();
    paramPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    paramPanel.setWidth("100%");
    paramPanel.setContent(layout);

    GridLayout wrapper = new GridLayout();
    //      wrapper.setMargin(true);
    wrapper.setSizeFull();
    wrapper.addComponent(paramPanel);

    this.setContent(wrapper);
}

From source file:org.jumpmind.metl.ui.views.deploy.FlowSelectWindow.java

License:Open Source License

@SuppressWarnings({ "serial" })
public FlowSelectWindow(ApplicationContext context, String caption, String introText,
        boolean includeTestFlows) {
    super(caption);
    this.context = context;

    tree.setMultiSelect(true);/*w  w  w.j  a  v  a  2s .co m*/
    tree.addContainerProperty("name", String.class, "");
    tree.setItemCaptionPropertyId("name");
    tree.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    tree.addExpandListener(new ExpandListener() {
        public void nodeExpand(ExpandEvent event) {
            Object itemId = event.getItemId();
            if (itemId instanceof ProjectVersion) {
                addFlowsToVersion((ProjectVersion) itemId, includeTestFlows);
            }
        }
    });
    addProjects();

    setWidth(600.0f, Unit.PIXELS);
    setHeight(600.0f, Unit.PIXELS);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();
    layout.addComponent(new Label(introText));

    Panel scrollable = new Panel();
    scrollable.addStyleName(ValoTheme.PANEL_BORDERLESS);
    scrollable.addStyleName(ValoTheme.PANEL_SCROLL_INDICATOR);
    scrollable.setSizeFull();
    scrollable.setContent(tree);
    layout.addComponent(scrollable);
    layout.setExpandRatio(scrollable, 1.0f);
    addComponent(layout, 1);

    Button cancelButton = new Button("Cancel");
    Button selectButton = new Button("Select");
    addComponent(buildButtonFooter(cancelButton, selectButton));

    cancelButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    selectButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            Collection<FlowName> flowCollection = getFlowCollection(includeTestFlows);
            listener.selected(flowCollection);
            close();
        }
    });
}

From source file:org.jumpmind.metl.ui.views.design.TableColumnSelectWindow.java

License:Open Source License

public TableColumnSelectWindow(ApplicationContext context, Model model) {
    super("Import from Database into Model");
    this.context = context;
    this.model = model;

    setWidth(600.0f, Unit.PIXELS);/*from   w  w w  .  ja  va2  s .c  o m*/
    setHeight(600.0f, Unit.PIXELS);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();
    layout.addComponent(new Label("Select tables and columns to import into the model."));

    Panel scrollable = new Panel();
    scrollable.addStyleName(ValoTheme.PANEL_BORDERLESS);
    scrollable.addStyleName(ValoTheme.PANEL_SCROLL_INDICATOR);
    scrollable.setSizeFull();

    provider = new DbProvider(context);
    dbTree = new DbTree(provider, new DefaultSettingsProvider(context.getConfigDir()));
    scrollable.setContent(dbTree);

    layout.addComponent(scrollable);
    layout.setExpandRatio(scrollable, 1.0f);
    addComponent(layout, 1);

    Button refreshButton = new Button("Refresh");
    Button cancelButton = new Button("Cancel");
    Button selectButton = new Button("Import");
    addComponent(buildButtonFooter(refreshButton, cancelButton, selectButton));

    cancelButton.addClickListener(event -> close());
    selectButton.addClickListener(event -> select());
    refreshButton.addClickListener(event -> refresh());
}

From source file:org.lucidj.ui.gauss.GaussUI.java

License:Apache License

private void add_smart_tab(VerticalLayout container, String caption, Component contents) {
    String style_expanded = "ui-panel-caption-expanded";

    // Every panel is a glorified button disguised as accordion tab...
    final Button caption_button = new Button(caption);
    caption_button.setWidth(100, Unit.PERCENTAGE);
    container.addComponent(caption_button);
    caption_button.addStyleName("ui-panel-caption");
    caption_button.addStyleName(style_expanded);

    // ... with a panel for the contents and selective hide/show
    final Panel content_panel = new Panel();
    content_panel.setWidth(100, Unit.PERCENTAGE);
    content_panel.setContent(contents);/*  w w  w  .  j  a v a  2  s  .c  o m*/
    content_panel.addStyleName("ui-panel-contents");
    content_panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    container.addComponent(content_panel);

    caption_button.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            if (content_panel.isVisible()) {
                content_panel.setVisible(false);
                caption_button.removeStyleName(style_expanded);
            } else {
                content_panel.setVisible(true);
                caption_button.addStyleName(style_expanded);
            }
        }
    });
}

From source file:org.opencms.ui.dialogs.history.CmsHistoryDialog.java

License:Open Source License

/**
 * Opens the 'compare' view for the two selected versions of the resource.<p>
 *
 * @throws CmsException if something goes wrong
 */// w  w w .  j  av  a 2s . co m
public void tryCompare() throws CmsException {

    CmsObject cms = A_CmsUI.getCmsObject();
    CheckBox check1 = m_group1.getSelected();
    CheckBox check2 = m_group2.getSelected();
    if (!canCompare(check1, check2)) {
        Notification.show(
                CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_SELECT_TWO_DIFFERENT_VERSIONS_0));
    } else {
        CmsHistoryResourceBean bean1 = (CmsHistoryResourceBean) (check1.getData());
        CmsHistoryResourceBean bean2 = (CmsHistoryResourceBean) (check2.getData());
        VerticalLayout diffContainer = new VerticalLayout();
        diffContainer.setSpacing(true);
        for (I_CmsDiffProvider diff : m_diffs) {
            Optional<Component> optionalDiff = diff.diff(cms, bean1, bean2);
            if (optionalDiff.isPresent()) {
                diffContainer.addComponent(optionalDiff.get());
            }
        }
        Panel panel = new Panel();
        panel.setSizeFull();
        diffContainer.setWidth("100%");
        diffContainer.setMargin(true);
        panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
        panel.setContent(diffContainer);
        openChildDialog(CmsHistoryDialog.this, panel,
                CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_COMPARE_0));
    }

}

From source file:org.opencms.ui.dialogs.history.diff.CmsShowVersionButtons.java

License:Open Source License

/**
 * @see org.opencms.ui.dialogs.history.diff.I_CmsDiffProvider#diff(org.opencms.file.CmsObject, org.opencms.gwt.shared.CmsHistoryResourceBean, org.opencms.gwt.shared.CmsHistoryResourceBean)
 *//* www  .j a v a 2  s  .  com*/
public Optional<Component> diff(CmsObject cms, CmsHistoryResourceBean v1, CmsHistoryResourceBean v2) {

    Panel panel = new Panel("");
    panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    HorizontalLayout hl = new HorizontalLayout();
    panel.setContent(hl);
    hl.addComponent(createButton(cms, v1));
    hl.addComponent(createButton(cms, v2));
    VerticalLayout outerContainer = new VerticalLayout();
    outerContainer.addComponent(hl);
    outerContainer.setComponentAlignment(hl, Alignment.MIDDLE_RIGHT);
    outerContainer.setMargin(true);
    hl.setSpacing(true);
    return Optional.fromNullable((Component) outerContainer);
}

From source file:org.tylproject.vaadin.addon.fields.drilldown.DrillDownWindow.java

License:Apache License

public Layout makeLayout(ZoomField<T> field) {

    btnClose.setStyleName(ValoTheme.BUTTON_PRIMARY);
    content.addStyleName(ValoTheme.PANEL_BORDERLESS);

    Component dialogContents = field.getZoomDialog().getDialogContents();

    content.setContent(dialogContents);//from  w  w w .j a  v a  2 s  .  co m
    content.setSizeFull();

    buttonBar.setStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    buttonBar.setWidth("100%");
    buttonBar.setSpacing(true);
    buttonBar.setExpandRatio(spacer, 1);

    rootLayout.setSizeFull();
    rootLayout.setExpandRatio(content, 1);
    rootLayout.setMargin(new MarginInfo(true, false, true, false));

    return rootLayout;
}