Example usage for com.vaadin.ui Button setData

List of usage examples for com.vaadin.ui Button setData

Introduction

In this page you can find the example usage for com.vaadin.ui Button setData.

Prototype

public void setData(Object data) 

Source Link

Document

Sets the data object, that can be used for any application specific data.

Usage

From source file:org.ikasan.dashboard.ui.mappingconfiguration.component.MappingConfigurationConfigurationValuesTable.java

License:BSD License

/**
 * Method to help populate the table with values associated with the MappingConfiguration.
 * //w ww .jav  a 2s  . com
 * @param mappingConfiguration
 */
public void populateTable(final MappingConfiguration mappingConfiguration) {
    this.mappingConfiguration = mappingConfiguration;

    Set<SourceConfigurationValue> sourceConfigurationValues = mappingConfiguration
            .getSourceConfigurationValues();

    super.removeAllItems();

    Iterator<SourceConfigurationValue> sourceConfigurationValueItr = sourceConfigurationValues.iterator();

    ArrayList<SourceConfigurationValue> usedSourceConfigurationValues = new ArrayList<SourceConfigurationValue>();

    ArrayList<SourceConfigurationValue> groupedSourceSystemValues = new ArrayList<SourceConfigurationValue>();

    while (sourceConfigurationValueItr.hasNext()) {
        SourceConfigurationValue value = sourceConfigurationValueItr.next();

        VerticalLayout tableCellLayout = new VerticalLayout();

        for (int i = 0; i < this.mappingConfiguration.getNumberOfParams(); i++) {
            if (!usedSourceConfigurationValues.contains(value)) {
                groupedSourceSystemValues.add(value);

                BeanItem<SourceConfigurationValue> item = new BeanItem<SourceConfigurationValue>(value);
                final TextField tf = new TextField(item.getItemProperty("sourceSystemValue"));
                tf.setWidth(300, Unit.PIXELS);

                tableCellLayout.addComponent(tf);
                tf.setReadOnly(true);
                usedSourceConfigurationValues.add(value);

                Iterator<SourceConfigurationValue> partnerSourceConfigurationValueItr = sourceConfigurationValues
                        .iterator();

                while (partnerSourceConfigurationValueItr.hasNext()) {
                    SourceConfigurationValue partnerSourceConfigurationValue = partnerSourceConfigurationValueItr
                            .next();

                    if (partnerSourceConfigurationValue.getSourceConfigGroupId() != null
                            && !usedSourceConfigurationValues.contains(partnerSourceConfigurationValue)
                            && partnerSourceConfigurationValue.getId().compareTo(value.getId()) != 0
                            && partnerSourceConfigurationValue.getSourceConfigGroupId()
                                    .compareTo(value.getSourceConfigGroupId()) == 0) {
                        groupedSourceSystemValues.add(partnerSourceConfigurationValue);
                        item = new BeanItem<SourceConfigurationValue>(partnerSourceConfigurationValue);
                        final TextField stf = new TextField(item.getItemProperty("sourceSystemValue"));
                        stf.setWidth(300, Unit.PIXELS);

                        tableCellLayout.addComponent(stf);
                        stf.setReadOnly(true);
                        usedSourceConfigurationValues.add(partnerSourceConfigurationValue);
                    }
                }

                TargetConfigurationValue targetConfigurationValue = value.getTargetConfigurationValue();
                BeanItem<TargetConfigurationValue> targetConfigurationItem = new BeanItem<TargetConfigurationValue>(
                        targetConfigurationValue);
                final TextField targetConfigurationTextField = new TextField(
                        targetConfigurationItem.getItemProperty("targetSystemValue"));
                targetConfigurationTextField.setReadOnly(true);
                targetConfigurationTextField.setWidth(300, Unit.PIXELS);

                final DeleteRowAction action = new DeleteRowAction(groupedSourceSystemValues,
                        this.mappingConfiguration, this, this.mappingConfigurationService,
                        this.systemEventService);

                final Button deleteButton = new Button("Delete");
                deleteButton.setData(value);
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                deleteButton.setDescription("Delete this record");
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        IkasanMessageDialog dialog = new IkasanMessageDialog("Delete record",
                                "This mapping configuration record will be permanently removed. "
                                        + "Are you sure you wish to proceed?.",
                                action);

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

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

                if (authentication != null
                        && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
                                || authentication.hasGrantedAuthority(SecurityConstants.EDIT_MAPPING_AUTHORITY))
                        || authentication.canAccessLinkedItem(
                                PolicyLinkTypeConstants.MAPPING_CONFIGURATION_LINK_TYPE,
                                mappingConfiguration.getId())) {
                    deleteButton.setVisible(true);
                } else {
                    deleteButton.setVisible(false);
                }

                this.addItem(new Object[] { tableCellLayout, targetConfigurationTextField, deleteButton },
                        value);

                groupedSourceSystemValues = new ArrayList<SourceConfigurationValue>();
            }
        }

    }
}

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

License:BSD License

public Layout createBusinessStreamLayout() {
    this.businessStreamTable = new Table();
    this.businessStreamTable.addContainerProperty("Server Name", String.class, null);
    this.businessStreamTable.addContainerProperty("Module Name", String.class, null);
    this.businessStreamTable.addContainerProperty("Flow Name", String.class, null);
    this.businessStreamTable.addContainerProperty("", Button.class, null);
    this.businessStreamTable.setWidth("100%");
    this.businessStreamTable.setHeight(600, Unit.PIXELS);
    this.businessStreamTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator());
    this.businessStreamTable.setDragMode(TableDragMode.ROW);
    this.businessStreamTable.setDropHandler(new DropHandler() {
        @Override//from  w w w  . ja v a 2 s .  c o  m
        public void drop(final DragAndDropEvent dropEvent) {
            final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                    .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

            if (authentication != null
                    && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication
                            .hasGrantedAuthority(SecurityConstants.MODIFY_BUSINESS_STREAM_AUTHORITY))) {
                Notification.show("You do not have the privilege to modify a business stream.");
                return;
            }

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

            if (t.getItemId() instanceof Flow) {
                final Flow flow = (Flow) t.getItemId();

                final BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue();
                BusinessStreamFlowKey key = new BusinessStreamFlowKey();
                key.setBusinessStreamId(businessStream.getId());
                key.setFlowId(flow.getId());
                final BusinessStreamFlow businessStreamFlow = new BusinessStreamFlow(key);
                businessStreamFlow.setFlow(flow);
                businessStreamFlow.setOrder(businessStreamTable.getItemIds().size());

                if (!businessStream.getFlows().contains(businessStreamFlow)) {
                    businessStream.getFlows().add(businessStreamFlow);

                    topologyService.saveBusinessStream(businessStream);

                    Button deleteButton = new Button();
                    Resource deleteIcon = VaadinIcons.TRASH;
                    deleteButton.setIcon(deleteIcon);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.setDescription("Delete the flow from the business stream.");

                    deleteButton.setData(businessStreamFlow);

                    // Add the delete functionality to each role that is added
                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            businessStream.getFlows().remove(businessStreamFlow);

                            topologyService.deleteBusinessStreamFlow(businessStreamFlow);
                            topologyService.saveBusinessStream(businessStream);

                            businessStreamTable.removeItem(businessStreamFlow.getFlow());
                        }
                    });

                    businessStreamTable
                            .addItem(
                                    new Object[] { flow.getModule().getServer().getName(),
                                            flow.getModule().getName(), flow.getName(), deleteButton },
                                    businessStreamFlow);
                }
            } else if (t.getItemId() instanceof Module) {
                final Module sourceContainer = (Module) t.getItemId();

                for (Flow flow : sourceContainer.getFlows()) {

                    final BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue();
                    BusinessStreamFlowKey key = new BusinessStreamFlowKey();
                    key.setBusinessStreamId(businessStream.getId());
                    key.setFlowId(flow.getId());
                    final BusinessStreamFlow businessStreamFlow = new BusinessStreamFlow(key);
                    businessStreamFlow.setFlow(flow);
                    businessStreamFlow.setOrder(businessStreamTable.getItemIds().size());

                    if (!businessStream.getFlows().contains(businessStreamFlow)) {
                        businessStream.getFlows().add(businessStreamFlow);

                        topologyService.saveBusinessStream(businessStream);

                        Button deleteButton = new Button();
                        Resource deleteIcon = VaadinIcons.TRASH;

                        deleteButton.setIcon(deleteIcon);
                        deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                        deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                        deleteButton.setDescription("Delete the flow from the business stream.");
                        deleteButton.setData(businessStreamFlow);

                        // Add the delete functionality to each role that is added
                        deleteButton.addClickListener(new Button.ClickListener() {
                            public void buttonClick(ClickEvent event) {
                                businessStream.getFlows().remove(businessStreamFlow);

                                topologyService.deleteBusinessStreamFlow(businessStreamFlow);
                                topologyService.saveBusinessStream(businessStream);

                                businessStreamTable.removeItem(businessStreamFlow.getFlow());
                            }
                        });

                        businessStreamTable.addItem(
                                new Object[] { flow.getModule().getServer().getName(),
                                        flow.getModule().getName(), flow.getName(), deleteButton },
                                businessStreamFlow);
                    }
                }
            } else {
                Notification.show("Only modules or flows can be dragged to this table.");
            }
        }

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

    GridLayout layout = new GridLayout(1, 6);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    Label tableDropHintLabel = new Label();
    tableDropHintLabel.setCaptionAsHtml(true);
    tableDropHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Drag modules or flows from the topology tree to the table below to build a business stream.");
    tableDropHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    tableDropHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);

    layout.addComponent(tableDropHintLabel);

    GridLayout controlsLayout = new GridLayout(3, 3);
    controlsLayout.setColumnExpandRatio(0, .05f);
    controlsLayout.setColumnExpandRatio(1, .65f);
    controlsLayout.setColumnExpandRatio(2, .3f);

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

    Label newBusinessStreamLabel = new Label("New Business Stream:");
    newBusinessStreamLabel.setSizeUndefined();
    controlsLayout.addComponent(newBusinessStreamLabel, 0, 0);
    controlsLayout.setComponentAlignment(newBusinessStreamLabel, Alignment.MIDDLE_RIGHT);

    Button newButton = new Button();
    newButton.setIcon(VaadinIcons.PLUS);
    newButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    newButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    newButton.setDescription("Create a new business stream.");
    newButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final NewBusinessStreamWindow newBusinessStreamWindow = new NewBusinessStreamWindow();
            UI.getCurrent().addWindow(newBusinessStreamWindow);

            newBusinessStreamWindow.addCloseListener(new Window.CloseListener() {
                // inline close-listener
                public void windowClose(CloseEvent e) {
                    topologyService.saveBusinessStream(newBusinessStreamWindow.getBusinessStream());

                    businessStreamCombo.addItem(newBusinessStreamWindow.getBusinessStream());
                    businessStreamCombo.setItemCaption(newBusinessStreamWindow.getBusinessStream(),
                            newBusinessStreamWindow.getBusinessStream().getName());

                    businessStreamCombo.select(newBusinessStreamWindow.getBusinessStream());

                    businessStreamTable.removeAllItems();
                }
            });
        }
    });

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

    if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
            && !authentication.hasGrantedAuthority(SecurityConstants.CREATE_BUSINESS_STREAM_AUTHORITY))) {
        newButton.setVisible(false);
    }

    controlsLayout.addComponent(newButton, 1, 0);

    Label businessStreamLabel = new Label("Business Stream:");
    businessStreamLabel.setSizeUndefined();

    final TextArea descriptionTextArea = new TextArea();
    descriptionTextArea.setReadOnly(true);

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

                descriptionTextArea.setReadOnly(false);
                descriptionTextArea.setValue(businessStream.getDescription());
                descriptionTextArea.setReadOnly(true);

                businessStreamTable.removeAllItems();

                for (final BusinessStreamFlow businessStreamFlow : businessStream.getFlows()) {
                    logger.info("Adding flow: " + businessStreamFlow);
                    Button deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.setDescription("Delete the flow from the business stream.");

                    // Add the delete functionality to each role that is added
                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            businessStream.getFlows().remove(businessStreamFlow);

                            topologyService.deleteBusinessStreamFlow(businessStreamFlow);
                            topologyService.saveBusinessStream(businessStream);

                            businessStreamTable.removeItem(businessStreamFlow.getFlow());
                        }
                    });

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

                    if (authentication != null
                            && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
                                    && !authentication.hasGrantedAuthority(
                                            SecurityConstants.MODIFY_BUSINESS_STREAM_AUTHORITY))) {
                        deleteButton.setVisible(false);
                    }

                    businessStreamTable.addItem(
                            new Object[] { businessStreamFlow.getFlow().getModule().getServer().getName(),
                                    businessStreamFlow.getFlow().getName(),
                                    businessStreamFlow.getFlow().getName(), deleteButton },
                            businessStreamFlow);
                }
            }
        }
    });
    businessStreamCombo.setWidth("100%");

    controlsLayout.addComponent(businessStreamLabel, 0, 1);
    controlsLayout.setComponentAlignment(businessStreamLabel, Alignment.MIDDLE_RIGHT);
    controlsLayout.addComponent(businessStreamCombo, 1, 1);

    Button deleteButton = new Button();
    deleteButton.setIcon(VaadinIcons.TRASH);
    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    deleteButton.setDescription("Delete the selected business stream.");
    deleteButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Collection<BusinessStreamFlow> businessStreamFlows = (Collection<BusinessStreamFlow>) businessStreamTable
                    .getItemIds();

            for (BusinessStreamFlow businessStreamFlow : businessStreamFlows) {
                topologyService.deleteBusinessStreamFlow(businessStreamFlow);
            }

            BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue();

            topologyService.deleteBusinessStream(businessStream);

            businessStreamTable.removeAllItems();

            List<BusinessStream> businessStreams = topologyService.getAllBusinessStreams();

            businessStreamCombo.removeItem(businessStream);

            descriptionTextArea.setValue("");
        }
    });

    if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
            && !authentication.hasGrantedAuthority(SecurityConstants.DELETE_BUSINESS_STREAM_AUTHORITY))) {
        deleteButton.setVisible(false);
    }

    controlsLayout.addComponent(deleteButton, 2, 1);

    Label descriptionLabel = new Label("Description:");
    descriptionLabel.setSizeUndefined();

    descriptionTextArea.setRows(4);
    descriptionTextArea.setWidth("100%");
    controlsLayout.addComponent(descriptionLabel, 0, 2);
    controlsLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT);
    controlsLayout.addComponent(descriptionTextArea, 1, 2);

    layout.addComponent(controlsLayout);
    layout.addComponent(this.businessStreamTable);

    return layout;
}

From source file:org.lucidj.iconlist.renderer.IconListRenderer.java

License:Apache License

private AbstractComponent create_icon(Map<String, Object> component) {
    String icon_title = (String) component.get("iconTitle");

    if (icon_title == null) {
        icon_title = "No title";
    }/*from  ww  w.j  a v  a2 s. c o  m*/

    Resource icon_resource = iconHelper.getIcon((String) component.get("iconUrl"), 32);

    Button button_icon = new Button(icon_title);
    button_icon.setIcon(icon_resource);
    button_icon.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    button_icon.addStyleName(ValoTheme.BUTTON_SMALL);
    button_icon.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
    button_icon.addStyleName("x-icon-button");
    button_icon.addStyleName("icon-size-32");
    button_icon.addClickListener(this);
    button_icon.setWidthUndefined();
    button_caption_wrap(button_icon);

    // Put the component in a D&D wrapper and allow dragging it
    final DragAndDropWrapper icon_dd_wrap = new DragAndDropWrapper(button_icon);
    icon_dd_wrap.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT);

    // Set the wrapper to wrap tightly around the component
    icon_dd_wrap.setSizeUndefined();
    icon_dd_wrap.setData(component);

    // Set ID for drag-drop AND on the Label for double-click
    if (component.containsKey("entryId")) {
        String entryId = (String) component.get("entryId");
        icon_dd_wrap.setId(entryId);
        button_icon.setId(entryId);
    }

    // Component data is the map itself
    button_icon.setData(component);

    // Remember this association
    component_to_vaadin.put(component, icon_dd_wrap);
    return (icon_dd_wrap);
}

From source file:org.milleni.dunning.ui.customer.CustomerListDetailPanel.java

License:Apache License

protected void addDunningProcessMaster(List<DunningProcessMaster> dngPrcsMasterList) {

    if (dunningProcessHeader != null) {
        mainPanel.removeComponent(dunningProcessHeader);
    }/*from w w w.j  av  a  2 s.c o m*/
    dunningProcessHeader = new Label(i18nManager.getMessage(Constants.CUSTOMER_DUNNING_PROCESSES));
    dunningProcessHeader.addStyleName(ExplorerLayout.STYLE_H3);
    dunningProcessHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    dunningProcessHeader.addStyleName(ExplorerLayout.STYLE_NO_LINE);

    addDetailComponent(dunningProcessHeader);

    if (dunningProcessLayout != null) {
        mainPanel.removeComponent(dunningProcessLayout);
    }

    dunningProcessLayout = new HorizontalLayout();
    dunningProcessLayout.setSpacing(true);
    dunningProcessLayout.setWidth(100, UNITS_PERCENTAGE);
    addDetailComponent(dunningProcessLayout);

    // dunningProcessLayout.addComponent(tasksHeader);

    duningProcessTable = new Table();
    duningProcessTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST);
    duningProcessTable.setWidth(100, UNITS_PERCENTAGE);
    duningProcessTable.setHeight(250, UNITS_PIXELS);
    duningProcessTable.setEditable(false);
    duningProcessTable.setImmediate(true);
    duningProcessTable.setSelectable(true);
    duningProcessTable.setNullSelectionAllowed(false);
    duningProcessTable.setSortDisabled(true);
    // duningProcessTable.setSizeFull();

    if (dngPrcsMasterList.size() > 0) {

        duningProcessTable.addContainerProperty("bpmProcessId", Button.class, null,
                i18nManager.getMessage(Constants.DUNNING_BPM_RPOCESS_ID), null, Table.ALIGN_LEFT);
        duningProcessTable.addContainerProperty("startDate", Date.class, null,
                i18nManager.getMessage(Constants.DUNNING_START_DATE), null, Table.ALIGN_LEFT);
        duningProcessTable.addContainerProperty("status", String.class, null,
                i18nManager.getMessage(Constants.CUSTOMER_STATUS), null, Table.ALIGN_LEFT);
        duningProcessTable.addContainerProperty("nextStep", String.class, null,
                i18nManager.getMessage(Constants.DUNNING_NEXT_STEP), null, Table.ALIGN_LEFT);
        duningProcessTable.addContainerProperty("nextStepDate", Date.class, null,
                i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE), null, Table.ALIGN_LEFT);
        duningProcessTable.addContainerProperty("currentDebit", String.class, null,
                i18nManager.getMessage(Constants.DUNNING_CURRENT_DEBIT), null, Table.ALIGN_LEFT);

        dunningProcessLayout.addComponent(duningProcessTable);

        for (DunningProcessMaster dnngPMaster : dngPrcsMasterList) {
            Item item = duningProcessTable.addItem(dnngPMaster);

            Button detailsField = new Button(dnngPMaster.getBpmProcessId());
            detailsField.setData(dnngPMaster.getBpmProcessId());
            detailsField.addListener(new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    String processId = (String) event.getButton().getData();
                    ExplorerApp.get().getViewManager().showPopupWindow(new ProcessDetailPopupWindow(processId));
                }
            });
            item.getItemProperty("bpmProcessId").setValue(detailsField);
            // item.getItemProperty("bpmProcessId").setValue(dnngPMaster.getBpmProcessId());
            item.getItemProperty("startDate").setValue(dnngPMaster.getCreateDate());

            String masterStatusDesc = "";
            if (StringUtils.hasLength(dnngPMaster.getStatusDesc()))
                masterStatusDesc = "(" + dnngPMaster.getStatusDesc() + ")";
            item.getItemProperty("status").setValue(dnngPMaster.getStatus().getStatusText() + masterStatusDesc);
            item.getItemProperty("currentDebit").setValue(
                    String.valueOf(dnngPMaster.getCurrentDebit() != null ? dnngPMaster.getCurrentDebit() : ""));
            item.getItemProperty("nextStepDate").setValue(dnngPMaster.getNextStepExecutionDate());
            if (dnngPMaster.getNextStepId() != null)
                item.getItemProperty("nextStep").setValue(dnngPMaster.getNextStepId().getStepText());
            duningProcessTable.addContainerProperty("nextStep", String.class, null,
                    i18nManager.getMessage(Constants.DUNNING_NEXT_STEP), null, Table.ALIGN_LEFT);
            duningProcessTable.addContainerProperty("nextStepDate", Date.class, null,
                    i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE), null, Table.ALIGN_LEFT);

        }
        duningProcessTable.setPageLength(duningProcessTable.size());
        duningProcessTable.addListener(new Property.ValueChangeListener() {
            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {
                DunningProcessMaster item = (DunningProcessMaster) event.getProperty().getValue();

                if (item != null) {
                    if (dunningProcessLayout != null && processStepTable != null)
                        dunningProcessLayout.removeComponent(processStepTable);

                    List<DunningProcessDetail> dunningProcessDetails = dunningProcessDetailRepository
                            .findDunningProcessDetails(item.getProcessId());
                    processStepTable = new DunningStepTableComponent(dunningProcessDetails);
                    dunningProcessLayout.addComponent(processStepTable);
                }
            }
        });
        processStepTable = new DunningStepTableComponent(
                dngPrcsMasterList.get(0).getDunningProcessDetailCollection());
        dunningProcessLayout.addComponent(processStepTable);

    } else {
        // No tasks
        noTasksLabel = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_NO_TASKS));
        dunningProcessLayout.addComponent(noTasksLabel);
    }
}

From source file:org.milleni.dunning.ui.customer.CustomerTableListItem.java

License:Apache License

public CustomerTableListItem(Customer customer) {
    addItemProperty("id", new ObjectProperty<Long>(customer.getCustomerId(), Long.class));
    addItemProperty("name", new ObjectProperty<String>(customer.getCustomerName(), String.class));
    addItemProperty("customerGroup",
            new ObjectProperty<String>(
                    customer.getCustomerGroup() != null ? customer.getCustomerGroup().getGroupName() : "",
                    String.class));
    addItemProperty("customerType", new ObjectProperty<String>(
            customer.getCustomerType() != null ? customer.getCustomerType().getTypeName() : "", String.class));
    addItemProperty("status", new ObjectProperty<String>(customer.getStatus(), String.class));

    Button detailsField = new Button("Fatura");
    detailsField.setData(customer.getCustomerId());
    detailsField.addListener(new Button.ClickListener() {

        @Override/* ww  w  . java 2s .com*/
        public void buttonClick(ClickEvent event) {
            Long customerId = (Long) event.getButton().getData();
            ExplorerApp.get().getViewManager().showPopupWindow(new InvoiceDetailPopupWindow(customerId));
        }
    });
    addItemProperty("invoicePopup", new ObjectProperty<Button>(detailsField, Button.class));
}

From source file:org.milleni.dunning.ui.customer.form.CustomerDetailPopupWindow.java

License:Apache License

protected void addDunningProcessMaster(List<DunningProcessMaster> dngPrcsMasterList) {

    dunningProcessLayout = new HorizontalLayout();
    dunningProcessLayout.setSpacing(true);
    dunningProcessLayout.setWidth(100, UNITS_PERCENTAGE);

    duningProcessTable = new Table();
    duningProcessTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST);
    duningProcessTable.setWidth(100, UNITS_PERCENTAGE);
    duningProcessTable.setHeight(250, UNITS_PIXELS);
    duningProcessTable.setEditable(false);
    duningProcessTable.setImmediate(true);
    duningProcessTable.setSelectable(true);
    duningProcessTable.setNullSelectionAllowed(false);
    duningProcessTable.setSortDisabled(true);
    // duningProcessTable.setSizeFull();

    if (dngPrcsMasterList.size() > 0) {

        duningProcessTable.addContainerProperty("bpmProcessId", Button.class, null,
                i18nManager.getMessage(Constants.DUNNING_BPM_RPOCESS_ID), null, Table.ALIGN_LEFT);
        duningProcessTable.addContainerProperty("status", String.class, null,
                i18nManager.getMessage(Constants.CUSTOMER_STATUS), null, Table.ALIGN_LEFT);
        duningProcessTable.addContainerProperty("startDate", Date.class, null,
                i18nManager.getMessage(Constants.DUNNING_START_DATE), null, Table.ALIGN_LEFT);
        duningProcessTable.addContainerProperty("currentDebit", String.class, null,
                i18nManager.getMessage(Constants.DUNNING_CURRENT_DEBIT), null, Table.ALIGN_LEFT);

        dunningProcessLayout.addComponent(duningProcessTable);

        for (DunningProcessMaster dnngPMaster : dngPrcsMasterList) {

            dnngPMaster = DaoHelper.initializeAndUnproxy(dnngPMaster);
            Item item = duningProcessTable.addItem(dnngPMaster);

            Button detailsField = new Button(dnngPMaster.getBpmProcessId());
            detailsField.setData(dnngPMaster.getBpmProcessId());
            detailsField.addListener(new Button.ClickListener() {

                @Override/*from  w  w w .  ja v  a 2s . c  o  m*/
                public void buttonClick(ClickEvent event) {
                    String processId = (String) event.getButton().getData();
                    ExplorerApp.get().getViewManager().showPopupWindow(new ProcessDetailPopupWindow(processId));
                }
            });
            item.getItemProperty("bpmProcessId").setValue(detailsField);
            // item.getItemProperty("bpmProcessId").setValue(dnngPMaster.getBpmProcessId());
            item.getItemProperty("startDate").setValue(dnngPMaster.getCreateDate());

            String masterStatusDesc = "";
            if (StringUtils.hasLength(dnngPMaster.getStatusDesc()))
                masterStatusDesc = "(" + dnngPMaster.getStatusDesc() + ")";
            item.getItemProperty("status").setValue(dnngPMaster.getStatus().getStatusText() + masterStatusDesc);
            item.getItemProperty("currentDebit").setValue(
                    String.valueOf(dnngPMaster.getCurrentDebit() != null ? dnngPMaster.getCurrentDebit() : ""));
        }
        duningProcessTable.setPageLength(duningProcessTable.size());
        duningProcessTable.addListener(new Property.ValueChangeListener() {
            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {
                DunningProcessMaster item = (DunningProcessMaster) event.getProperty().getValue();

                if (item != null) {
                    if (dunningProcessLayout != null && processStepTable != null)
                        dunningProcessLayout.removeComponent(processStepTable);

                    List<DunningProcessDetail> dunningProcessDetails = dunningProcessDetailRepository
                            .findDunningProcessDetails(item.getProcessId());
                    processStepTable = new DunningStepTableComponent(dunningProcessDetails);
                    dunningProcessLayout.addComponent(processStepTable);
                }
            }
        });
        processStepTable = new DunningStepTableComponent(
                dngPrcsMasterList.get(0).getDunningProcessDetailCollection());
        dunningProcessLayout.addComponent(processStepTable);
    }

}

From source file:org.milleni.dunning.ui.dpdetail.DunningProcessDetailTableListItem.java

License:Apache License

public DunningProcessDetailTableListItem(DunningProcessDetail dpDetail) {
    this.dpDetail = dpDetail;
    Button detailsField = new Button(dpDetail.getProcessId().getBpmProcessId());
    detailsField.setData(dpDetail.getProcessId().getBpmProcessId());
    detailsField.addListener(new Button.ClickListener() {

        @Override/* w w  w.  j  a  v a2 s. co  m*/
        public void buttonClick(ClickEvent event) {
            String processId = (String) event.getButton().getData();
            ExplorerApp.get().getViewManager().showPopupWindow(new ProcessDetailPopupWindow(processId));
        }
    });

    Embedded embed = null;
    if (dpDetail.getStatus() != null && Constants.SUCCESS.equals(dpDetail.getStatus().getId())) {
        embed = new Embedded(null, Images.TASK_FINISHED_22);
    } else {
        embed = new Embedded(null, Images.TASK_22);
    }

    String customerName = "";
    String customerStatus = "";
    String masterStatus = "";
    String startDebit = "";
    String currentDebit = "";
    Date dunningInvoiceDate = null;
    Date dunningInvoiceDueDate = null;

    DunningProcessMaster dpm = dpDetail.getProcessId();
    if (dpm != null) {
        Customer customer = dpm.getCustomerId();
        if (customer != null) {
            customerName = customer.getCustomerName();
            customerStatus = customer.getStatus();
        }
        masterStatus = dpm.getStatus() != null ? dpm.getStatus().getStatusText() : "";
        startDebit = dpm.getCurrentDebit() != null ? dpm.getCurrentDebit().toString() : "";
        currentDebit = customer.getCurrentDebit() != null ? customer.getCurrentDebit().toString() : "";
        dunningInvoiceDate = dpm.getDunningInvoiceId() != null ? dpm.getDunningInvoiceId().getInvoiceDate()
                : null;
        dunningInvoiceDueDate = dpm.getDunningInvoiceId() != null
                ? dpm.getDunningInvoiceId().getInvoiceDueDate()
                : null;
    }

    addItemProperty("finished", new ObjectProperty<Embedded>(embed, Embedded.class));
    addItemProperty("name",
            new ObjectProperty<String>(
                    dpDetail.getProcessStepId() != null ? dpDetail.getProcessStepId().getStepText() : "",
                    String.class));
    addItemProperty("startDate", new ObjectProperty<Date>(dpDetail.getCreateDate(), Date.class));
    addItemProperty("endDate", new ObjectProperty<Date>(dpDetail.getStatusDate(), Date.class));
    addItemProperty("status", new ObjectProperty<String>(
            dpDetail.getStatus() != null ? dpDetail.getStatus().getStatusText() : "", String.class));
    addItemProperty("customerId",
            new ObjectProperty<String>(
                    (dpDetail.getProcessId() != null && dpDetail.getProcessId().getCustomerId() != null)
                            ? dpDetail.getProcessId().getCustomerId().getCustomerId()
                            : "",
                    String.class));
    addItemProperty("startDebit", new ObjectProperty<String>(startDebit, String.class));

    addItemProperty("customerName", new ObjectProperty<String>(customerName, String.class));
    addItemProperty("customerStatus", new ObjectProperty<String>(customerStatus, String.class));
    addItemProperty("masterStatus", new ObjectProperty<String>(masterStatus, String.class));
    addItemProperty("dunningInvoiceDate", new ObjectProperty<Date>(dunningInvoiceDate, Date.class));
    addItemProperty("dunningInvoiceDueDate", new ObjectProperty<Date>(dunningInvoiceDueDate, Date.class));
    addItemProperty("currentDebit", new ObjectProperty<String>(currentDebit, String.class));

}

From source file:org.milleni.dunning.ui.dpmaster.DunningProcessTableListItem.java

License:Apache License

public DunningProcessTableListItem(DunningProcessMaster dnngPMaster) {
    this.dnngProcessMaster = dnngPMaster;
    Button detailsField = new Button(dnngPMaster.getBpmProcessId());
    detailsField.setData(dnngPMaster.getBpmProcessId());
    detailsField.addListener(new Button.ClickListener() {

        @Override//www .  j  ava  2 s  .co m
        public void buttonClick(ClickEvent event) {
            String processId = (String) event.getButton().getData();
            ExplorerApp.get().getViewManager().showPopupWindow(new ProcessDetailPopupWindow(processId));
        }
    });
    addItemProperty("bpmProcessId", new ObjectProperty<Button>(detailsField, Button.class));
    addItemProperty("currentStep",
            new ObjectProperty<String>(
                    dnngPMaster.getCurrentStepId() != null ? dnngPMaster.getCurrentStepId().getStepText() : "",
                    String.class));
    addItemProperty("lastStep", new ObjectProperty<String>(
            dnngPMaster.getProcessLastStepId() != null ? dnngPMaster.getProcessLastStepId().getStepText() : "",
            String.class));
    addItemProperty("nextStep",
            new ObjectProperty<String>(
                    dnngPMaster.getNextStepId() != null ? dnngPMaster.getNextStepId().getStepText() : "",
                    String.class));
    addItemProperty("startDate", new ObjectProperty<Date>(dnngPMaster.getCreateDate(), Date.class));
    addItemProperty("nextStepDate",
            new ObjectProperty<Date>(dnngPMaster.getNextStepExecutionDate(), Date.class));
    addItemProperty("status",
            new ObjectProperty<String>(dnngPMaster.getStatus().getStatusText(), String.class));
    addItemProperty("statusDesc", new ObjectProperty<String>(dnngPMaster.getStatusDesc(), String.class));
    addItemProperty("customerId",
            new ObjectProperty<String>(dnngPMaster.getCustomerId().getCustomerId(), String.class));
    addItemProperty("startDebit", new ObjectProperty<String>(
            dnngPMaster.getCurrentDebit() != null ? dnngPMaster.getCurrentDebit() : "", String.class));
    addItemProperty("currentDebit",
            new ObjectProperty<String>(dnngPMaster.getCustomerId().getCurrentDebit() != null
                    ? dnngPMaster.getCustomerId().getCurrentDebit()
                    : "", String.class));
    addItemProperty("dunningInvoiceDate",
            new ObjectProperty<String>((dnngPMaster.getDunningInvoiceId() != null
                    && dnngPMaster.getDunningInvoiceId().getInvoiceDate() != null)
                            ? dateFormat.format(dnngPMaster.getDunningInvoiceId().getInvoiceDate())
                            : "",
                    String.class));
    addItemProperty("dunningInvoiceDueDate",
            new ObjectProperty<String>((dnngPMaster.getDunningInvoiceId() != null
                    && dnngPMaster.getDunningInvoiceId().getInvoiceDueDate() != null)
                            ? dateFormat.format(dnngPMaster.getDunningInvoiceId().getInvoiceDueDate())
                            : "",
                    String.class));
    addItemProperty("customerStatus", new ObjectProperty<String>(
            dnngPMaster.getCustomerId() != null ? dnngPMaster.getCustomerId().getStatus() : "", String.class));
}

From source file:org.opencms.ui.apps.CmsFileExplorer.java

License:Open Source License

/**
 * Sets the current path info.<p>/*from  w  w  w  .j  a  v  a2  s .c  o m*/
 *
 * @param path the path
 */
private void setPathInfo(String path) {

    m_infoPath.setValue(path);

    // generate the path bread crumb
    m_crumbs.removeAllComponents();
    int i = path.indexOf("/");
    String openPath = "";
    while (i >= 0) {
        String fragment = path.substring(0, i + 1);
        openPath += fragment;
        path = path.substring(i + 1);
        i = path.indexOf("/");
        Button crumb = new Button(fragment, m_crumbListener);
        crumb.setData(openPath);
        crumb.addStyleName(ValoTheme.BUTTON_LINK);
        m_crumbs.addComponent(crumb);
    }
}

From source file:org.processbase.ui.core.template.DefaultConfirmDialogFactory.java

License:Open Source License

public ConfirmDialog create(final String caption, final String message, final String okCaption,
        final String cancelCaption) {

    // Create a confirm dialog
    final ConfirmDialog confirm = new ConfirmDialog();
    confirm.setCaption(caption != null ? caption : DEFAULT_CAPTION);

    // Close listener implementation
    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {
            confirm.setConfirmed(false);
            if (confirm.getListener() != null) {
                confirm.getListener().onClose(confirm);
            }// w  w  w. j a va2 s.  c o  m
        }
    });

    // Create content
    VerticalLayout c = (VerticalLayout) confirm.getContent();
    c.setSizeFull();
    c.setSpacing(true);

    // Panel for scrolling lengthty messages.
    Panel scroll = new Panel(new VerticalLayout());
    scroll.setScrollable(true);
    c.addComponent(scroll);
    scroll.setWidth("100%");
    scroll.setHeight("100%");
    scroll.setStyleName(Reindeer.PANEL_LIGHT);
    c.setExpandRatio(scroll, 1f);

    // Always HTML, but escape
    Label text = new Label("", Label.CONTENT_RAW);
    scroll.addComponent(text);
    confirm.setMessageLabel(text);
    confirm.setMessage(message);

    HorizontalLayout buttons = new HorizontalLayout();
    c.addComponent(buttons);
    buttons.setSpacing(true);

    buttons.setHeight(format(BUTTON_HEIGHT) + "em");
    buttons.setWidth("100%");
    Label spacer = new Label("");
    buttons.addComponent(spacer);
    spacer.setWidth("100%");
    buttons.setExpandRatio(spacer, 1f);

    final Button cancel = new Button(cancelCaption != null ? cancelCaption : DEFAULT_CANCEL_CAPTION);
    cancel.setData(false);
    cancel.setClickShortcut(KeyCode.ESCAPE, null);
    buttons.addComponent(cancel);
    buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT);
    confirm.setCancelButton(cancel);

    final Button ok = new Button(okCaption != null ? okCaption : DEFAULT_OK_CAPTION);
    ok.setData(true);
    ok.setClickShortcut(KeyCode.ENTER, null);
    ok.setStyleName(Reindeer.BUTTON_DEFAULT);
    ok.focus();
    buttons.addComponent(ok);
    buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT);
    confirm.setOkButton(ok);

    // Create a listener for buttons
    Button.ClickListener cb = new Button.ClickListener() {
        private static final long serialVersionUID = 3525060915814334881L;

        public void buttonClick(ClickEvent event) {
            // Copy the button date to window for passing through either
            // "OK" or "CANCEL"
            confirm.setConfirmed(event.getButton() == ok);

            // This has to be invoked as the window.close
            // event is not fired when removed.
            if (confirm.getListener() != null) {
                confirm.getListener().onClose(confirm);
            }
            confirm.close();

        }

    };
    cancel.addListener(cb);
    ok.addListener(cb);

    // Approximate the size of the dialog
    double[] dim = getDialogDimensions(message, ConfirmDialog.CONTENT_TEXT_WITH_NEWLINES);
    confirm.setWidth(format(dim[0]) + "em");
    confirm.setHeight(format(dim[1]) + "em");
    confirm.setResizable(false);

    return confirm;
}