Example usage for com.vaadin.ui Button addListener

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

Introduction

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

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

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   www.  j a  v a 2  s. com
                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.DunningProcessDetailListDetailPanel.java

License:Apache License

protected void initInstancesTable() {

    dpDetailTable = new Table() {
        @Override//w  w w . j av a 2s  .  c o  m
        public boolean handleError(ComponentErrorEvent error) {

            return false;
        }

        @Override
        public void changeVariables(Object source, Map<String, Object> variables) {
            // TODO Auto-generated method stub
            try {
                super.changeVariables(source, variables);
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
            }
        }

    };

    dpDetailTable.setWidth(100, UNITS_PERCENTAGE);
    dpDetailTable.setHeight(600, UNITS_PIXELS);
    dpDetailTable.setEditable(false);
    dpDetailTable.setImmediate(true);
    dpDetailTable.setSelectable(true);
    dpDetailTable.setNullSelectionAllowed(false);
    dpDetailTable.setSortDisabled(true);

    container = new LazyLoadingContainer(lazyLoadingQuery, 50);
    container.setTableSizeActionListener(this);
    dpDetailTable.setContainerDataSource(container);

    dpDetailTable.addContainerProperty("finished", Component.class, null, "", null, Table.ALIGN_CENTER);
    dpDetailTable.setColumnWidth("finished", 22);
    dpDetailTable.addContainerProperty("name", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_CURRENT_STEP), null, Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("startDate", Date.class, null,
            i18nManager.getMessage(Constants.DUNNING_START_DATE), null, Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("endDate", Date.class, null,
            i18nManager.getMessage(Constants.DUNNING_END_DATE), null, Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("status", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_STATUS), null, Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("customerId", String.class, null,
            i18nManager.getMessage(Constants.CUSTOMER_ID), null, Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("customerName", String.class, null,
            i18nManager.getMessage(Constants.CUSTOMER_NAME), null, Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("customerStatus", String.class, null, "Musteri Durumu", null,
            Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("masterStatus", String.class, null, "Surec Durumu", null,
            Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("startDebit", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_CURRENT_DEBIT), null, Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("currentDebit", String.class, null,
            i18nManager.getMessage(Constants.CUSTOMER_DEBIT), null, Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("dunningInvoiceDate", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_INVOICE_DATE), null, Table.ALIGN_LEFT);
    dpDetailTable.addContainerProperty("dunningInvoiceDueDate", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_INVOICE_SOT), null, Table.ALIGN_LEFT);

    dpDetailTable.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            DunningProcessDetailTableListItem item = (DunningProcessDetailTableListItem) dpDetailTable
                    .getItem(event.getProperty().getValue());

            if (item != null) {
                if (dunningProcessDetailLogLayout != null && stepLogTable != null)
                    dunningProcessDetailLogLayout.removeComponent(stepLogTable);
                stepLogTable = new DunningStepLogTableComponent(
                        dunningProcessDetailRepository.getDunningProcessDetailLog(item.getDpDetail()));
                stepLogTable.setHeight(150, UNITS_PIXELS);
                dunningProcessDetailLogLayout.addComponent(stepLogTable);
            }
        }
    });

    final ThemeResource export = new ThemeResource("../images/table-excel.png");
    final Button excelExportButton = new Button();
    excelExportButton.setIcon(export);
    excelExportButton.setStyleName(BaseTheme.BUTTON_LINK);
    instancesHeader.addComponent(excelExportButton);
    initInstancesTitle(instancesHeader);
    instancesLayout.addComponent(dpDetailTable);

    excelExportButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        public void buttonClick(final ClickEvent event) {
            excelExport = new ExcelExport(dpDetailTable);
            container.setBatchSize(100000);
            excelExport.excludeCollapsedColumns();
            excelExport.setDisplayTotals(false);
            excelExport.setRowHeaders(true);
            excelExport.setDoubleDataFormat("0.00");
            excelExport.setExcelFormatOfProperty("konto", "0");
            excelExport.export();
            container.setBatchSize(50);
        }
    });

}

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  ww.j ava2 s.  c om
        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.DunningProcessListDetailPanel.java

License:Apache License

protected void initInstancesTable() {

    dpMasterTable = new Table() {
        @Override/*  w  w  w. j  a  v  a  2  s. co m*/
        public boolean handleError(ComponentErrorEvent error) {

            return false;
        }

        @Override
        public void changeVariables(Object source, Map<String, Object> variables) {
            // TODO Auto-generated method stub
            try {
                super.changeVariables(source, variables);
            } catch (Exception ex) {

            }
        }

    };

    dpMasterTable.setWidth(100, UNITS_PERCENTAGE);
    dpMasterTable.setHeight(250, UNITS_PIXELS);
    dpMasterTable.setEditable(false);
    dpMasterTable.setImmediate(true);
    dpMasterTable.setSelectable(true);
    dpMasterTable.setNullSelectionAllowed(false);
    dpMasterTable.setSortDisabled(true);

    container = new LazyLoadingContainer(lazyLoadingQuery, 50);
    container.setTableSizeActionListener(this);
    dpMasterTable.setContainerDataSource(container);

    dpMasterTable.addContainerProperty("bpmProcessId", Button.class, null,
            i18nManager.getMessage(Constants.DUNNING_BPM_RPOCESS_ID), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("customerId", Date.class, null,
            i18nManager.getMessage(Constants.CUSTOMER_ID), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("currentStep", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_CURRENT_STEP), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("lastStep", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_LAST_STEP), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("nextStep", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_NEXT_STEP), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("startDate", Date.class, null,
            i18nManager.getMessage(Constants.DUNNING_START_DATE), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("nextStepDate", Date.class, null,
            i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("status", String.class, null,
            i18nManager.getMessage(Constants.CUSTOMER_STATUS), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("startDebit", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_CURRENT_DEBIT), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("currentDebit", String.class, null,
            i18nManager.getMessage(Constants.CUSTOMER_DEBIT), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("dunningInvoiceDate", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_INVOICE_DATE), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("dunningInvoiceDueDate", String.class, null,
            i18nManager.getMessage(Constants.DUNNING_INVOICE_SOT), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("statusDesc", String.class, null,
            i18nManager.getMessage(Constants.CUSTOMER_STATUS), null, Table.ALIGN_LEFT);
    dpMasterTable.addContainerProperty("customerStatus", String.class, null,
            i18nManager.getMessage(Constants.CUSTOMER_STATUS), null, Table.ALIGN_LEFT);

    dpMasterTable.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            DunningProcessTableListItem item = (DunningProcessTableListItem) dpMasterTable
                    .getItem(event.getProperty().getValue());

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

                List<DunningProcessDetail> dunningProcessDetails = dunningProcessDetailRepository
                        .findDunningProcessDetails(item.getDnngProcessMaster().getProcessId());
                processStepTable = new DunningStepTableComponent(dunningProcessDetails);
                processStepTable.setHeight(200, UNITS_PIXELS);

                detailHeader = new HorizontalLayout();
                detailHeader.setSpacing(true);
                detailHeader.setWidth(100, UNITS_PERCENTAGE);
                detailHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
                dunningProcessDetailLayout.addComponent(detailHeader);

                instancesLabel = new Label(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEPS));
                instancesLabel.addStyleName(ExplorerLayout.STYLE_H3);
                detailHeader.addComponent(instancesLabel);

                dunningProcessDetailLayout.addComponent(processStepTable);

                processStepTable.addListener(new Property.ValueChangeListener() {
                    private static final long serialVersionUID = 1L;

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

                        if (item != null) {
                            if (dunningProcessDetailLogLayout != null && stepLogTable != null)
                                dunningProcessDetailLogLayout.removeComponent(stepLogTable);

                            stepLogTable = new DunningStepLogTableComponent(
                                    item.getDunningProcessDetailLogsCollection());
                            stepLogTable.setHeight(150, UNITS_PIXELS);
                            dunningProcessDetailLogLayout.addComponent(stepLogTable);
                        }
                    }
                });

            }
        }
    });

    final ThemeResource export = new ThemeResource("../images/table-excel.png");
    final Button excelExportButton = new Button();
    excelExportButton.setIcon(export);
    excelExportButton.setStyleName(BaseTheme.BUTTON_LINK);
    instancesHeader.addComponent(excelExportButton);
    initInstancesTitle(instancesHeader);
    instancesLayout.addComponent(dpMasterTable);

    excelExportButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        public void buttonClick(final ClickEvent event) {
            excelExport = new ExcelExport(dpMasterTable);
            container.setBatchSize(100000);
            excelExport.excludeCollapsedColumns();
            excelExport.setDisplayTotals(false);
            excelExport.setRowHeaders(true);
            CellStyle cs = excelExport.getTitleStyle();
            cs.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index);
            excelExport.setTitleStyle(cs);
            excelExport.setDoubleDataFormat("0.00");
            excelExport.setExcelFormatOfProperty("konto", "0");
            excelExport.export();
            container.setBatchSize(50);
        }
    });

}

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//  w w w .  j av a 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.milleni.dunning.ui.prcstart.BulkDunningProcessFinishPanel.java

License:Apache License

protected void initSettingsProperties() {
    panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);//from   w  ww . j av a  2 s .  c  o m
    detailLayout.setMargin(true, true, true, false);
    detailLayout.addComponent(panelLayout);

    // Database type
    Label reason = new Label("Dunning Surecini Bitirmek Icin Aciklama Giriniz.");
    panelLayout.addComponent(reason);

    textAreaReason = new TextArea("");
    textAreaReason.setRequired(true);
    textAreaReason.setEnabled(true);
    textAreaReason.setRows(2);
    textAreaReason.setColumns(50);
    textAreaReason.setMaxLength(150);
    panelLayout.addComponent(textAreaReason);

    textArea = new TextArea("");
    textArea.setRequired(true);
    textArea.setEnabled(true);
    textArea.setRows(10);
    textArea.setColumns(50);
    panelLayout.addComponent(textArea);

    Button claimButton = new Button("Dunning Sureci Sonlandr");
    claimButton.setIcon(Images.EXECUTE);
    claimButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            String customerIds = (String) textArea.getValue();
            String reason = loggedInUser.getFullName() + " " + (String) textAreaReason.getValue();
            String[] customerIdArray = customerIds.split("\n");
            List<Long> customerIdList = new ArrayList<Long>();

            DunningProcessMasterRepository dpmRepository = DaoHelper.getInstance()
                    .getDunningProcessMasterRepository();
            DunningProcessService dpmService = DaoHelper.getInstance().getDunningProcessService();

            for (String strCustomerId : customerIdArray) {
                strCustomerId = strCustomerId.trim();
                if (StringUtils.hasText(strCustomerId)) {
                    try {
                        customerIdList.add(Long.parseLong(strCustomerId));
                    } catch (Exception ex) {
                        throw new RuntimeException(
                                strCustomerId + " musteri no yanlis formatta " + ex.getMessage());
                    }
                }
            }

            for (Long customerId : customerIdList) {
                List<DunningProcessMaster> dpmList = dpmRepository.findDunningProcessMastersByStatus(customerId,
                        Constants.RUNNING);
                if (dpmList != null && dpmList.size() > 0) {

                    if (dpmList.size() > 1)
                        throw new RuntimeException(
                                customerId + " musterinin birden fazla dunning sureci var. Kontrol ediniz.");

                    DunningProcessMaster dpm = dpmList.get(0);
                    String processInctanceId = dpm.getBpmProcessId();
                    try {
                        runtimeService.deleteProcessInstance(processInctanceId, null);
                        dpm.setStatus(dpmRepository.getProcessStatus(Constants.MANUAL_FINISHED));
                        dpm.setStatusDesc(reason);
                        dpmService.saveDunningProcessMaster(dpm);
                        List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery()
                                .processDefinitionKey(Constants.FL95_SuspendToActive)
                                .variableValueEquals("customerId", customerId).list();
                        if (processInstances != null && processInstances.size() > 0) {
                            for (ProcessInstance processInstance : processInstances) {
                                runtimeService.deleteProcessInstance(processInstance.getId(), null);
                            }
                        }
                    } catch (Exception ex) {
                        throw new RuntimeException(
                                customerId + " musterinin processi silinirken hata olustu." + ex.getMessage());
                    }
                }
            }

            textArea.setValue("");
        }
    });

    panelLayout.addComponent(claimButton);
}

From source file:org.milleni.dunning.ui.prcstart.BulkDunningProcessStartPanel.java

License:Apache License

protected void initSettingsProperties() {
    panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);/*from w  w w .  j  a  v  a  2  s. c o m*/
    detailLayout.setMargin(true, true, true, false);
    detailLayout.addComponent(panelLayout);

    processDate = new DateField("Sre Balama Zaman");
    panelLayout.addComponent(processDate);
    // Database type

    textArea = new TextArea("");
    textArea.setRequired(true);
    textArea.setEnabled(true);
    textArea.setRows(10);
    textArea.setColumns(50);
    check = new CheckBox("Gn gemi stepi yapma");
    panelLayout.addComponent(check);
    panelLayout.addComponent(textArea);

    Button claimButton = new Button("Balat");
    claimButton.setIcon(Images.EXECUTE);
    claimButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            String customerIds = (String) textArea.getValue();
            Date processDateValue = (Date) processDate.getValue();

            boolean startStepFirst = false;
            if ((Boolean) check.getValue()) {
                startStepFirst = true;
            }

            String[] customerIdArray = customerIds.split("\n");
            List<Long> customerIdList = new ArrayList<Long>();
            for (String strCustomerId : customerIdArray) {
                strCustomerId = strCustomerId.trim();
                if (StringUtils.hasText(strCustomerId)) {
                    customerIdList.add(Long.parseLong(strCustomerId));
                }
            }

            for (Long customerId : customerIdList) {
                Map<String, Object> variables = new HashMap<String, Object>();
                variables.put(Constants.customerId, customerId);
                if (loggedInUser != null)
                    variables.put(Constants.user, loggedInUser.getFullName());
                if (startStepFirst)
                    variables.put(Constants.firstStepNext, true);
                if (processDateValue != null)
                    variables.put(Constants.processStartDate, processDateValue);
                runtimeService.startProcessInstanceByKey(Constants.FL100_DunningProcessInitializer, variables);
            }
            textArea.setValue("");
        }
    });

    panelLayout.addComponent(claimButton);
}

From source file:org.milleni.dunning.ui.prcstart.CompleteFinansTaskPanel.java

License:Apache License

protected void initSettingsProperties() {
    panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);/*  ww w .  j a  v  a 2  s . c o  m*/
    detailLayout.setMargin(true, true, true, false);
    detailLayout.addComponent(panelLayout);

    // Database type

    textArea = new TextArea("");
    textArea.setRequired(true);
    textArea.setEnabled(true);
    textArea.setRows(10);
    textArea.setColumns(50);

    textAreaFinansNot = new TextArea("");
    textAreaFinansNot.setRequired(true);
    textAreaFinansNot.setEnabled(true);
    textAreaFinansNot.setRows(2);
    textAreaFinansNot.setColumns(50);
    textAreaFinansNot.setMaxLength(150);

    panelLayout.addComponent(yasalOrTakipCombo);
    Label lblFinansNot = new Label("Finans Notu");
    lblFinansNot.setSizeUndefined();
    lblFinansNot.addStyleName(Reindeer.LABEL_H2);
    panelLayout.addComponent(lblFinansNot);
    panelLayout.addComponent(textAreaFinansNot);

    Label lblCustomer = new Label("Musteriler");
    lblCustomer.setSizeUndefined();
    lblCustomer.addStyleName(Reindeer.LABEL_H2);
    panelLayout.addComponent(lblCustomer);
    panelLayout.addComponent(textArea);

    Button claimButton = new Button("Tasklari Tamamla");
    claimButton.setIcon(Images.EXECUTE);
    claimButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            String customerIds = (String) textArea.getValue();
            boolean takipDisi = (yasalOrTakipCombo.getValue() != null
                    && takipDisiBirak.equals(yasalOrTakipCombo.getValue())) ? true : false;

            String finansNotu = textAreaFinansNot.getValue() != null ? textAreaFinansNot.getValue().toString()
                    : null;

            String[] customerIdArray = customerIds.split("\n");
            List<Long> customerIdList = new ArrayList<Long>();
            for (String strCustomerId : customerIdArray) {
                strCustomerId = strCustomerId.trim();
                if (StringUtils.hasText(strCustomerId)) {
                    customerIdList.add(Long.parseLong(strCustomerId));
                }
            }

            for (Long customerId : customerIdList) {
                Map<String, Object> variables = new HashMap<String, Object>();
                variables.put(Constants.customerId, customerId);
                if (loggedInUser != null)
                    variables.put(Constants.user, loggedInUser.getFullName());

                if (takipDisi)
                    variables.put(Constants.taskStatusFinans, Constants.takipDisiBirak);

                if (StringUtils.hasText(finansNotu))
                    variables.put("finansNotu", finansNotu);

                ProcessInstance instance = runtimeService.createProcessInstanceQuery()
                        .variableValueEquals("customerId", customerId).singleResult();
                Task task = taskService.createTaskQuery().taskDefinitionKeyLike("%taskYasal%")
                        .processInstanceId(instance.getProcessInstanceId()).singleResult();
                taskService.complete(task.getId(), variables);
                //runtimeService.startProcessInstanceByKey(Constants.FL100_DunningProcessInitializer,variables);
            }
            textArea.setValue("");
        }
    });

    panelLayout.addComponent(claimButton);

}

From source file:org.milleni.dunning.ui.prcstart.DunningProcessTimingOperationsPanel.java

License:Apache License

protected void initSettingsProperties() {
    detailLayout.setMargin(true, true, true, false);
    panelLayout = new VerticalLayout();
    detailLayout.addComponent(panelLayout);

    queryActionLayout = createHorizontalLayout();
    panelLayout.addComponent(queryActionLayout);

    queryLayout = new VerticalLayout();
    queryLayout.setSpacing(true);/*from w w w.  j  a  v a2  s . co  m*/
    actionLayout = new VerticalLayout();
    actionLayout.setSpacing(true);
    queryActionLayout.addComponent(queryLayout);
    queryActionLayout.addComponent(actionLayout);

    panelLayout.setSpacing(true);

    queryLayout.addComponent(policyCombo);
    queryLayout.addComponent(stepCombo);

    queryLayout.addComponent(nextStepDateStart);
    queryLayout.addComponent(nextStepDateEnd);

    Button claimButton = new Button("Balat");

    final Button changeExecDate = new Button("Degistir.");

    lblEntityCount = new Label("Kayit Sayisi");
    lblEntityCount.addStyleName(ExplorerLayout.STYLE_H3);
    lblEntityCount.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);

    changeExecDate.setIcon(Images.EXECUTE);
    claimButton.setIcon(Images.EXECUTE);
    claimButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            int entityCount = DaoHelper.getInstance().getDunningProcessMasterRepository()
                    .listNextStepDunningProcessCount(selectedDunningPolicy.getPolicyId(),
                            selectedProcessStep.getStepId(), (Date) nextStepDateStart.getValue(),
                            (Date) nextStepDateEnd.getValue());
            lblEntityCount.setValue(entityCount);
            if (entityCount > 0) {
                actionLayout.addComponent(nextStepCombo);
                actionLayout.addComponent(executionDate);
                actionLayout.addComponent(changeExecDate);
            } else {
                actionLayout.removeComponent(nextStepCombo);
                actionLayout.removeComponent(executionDate);
                actionLayout.removeComponent(changeExecDate);
            }
        }
    });

    changeExecDate.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            try {
                String userName = "username";
                if (loggedInUser != null)
                    userName = loggedInUser.getFullName();

                Integer count = 0;
                int xx = DaoHelper.getInstance().getDunningProcessMasterRepository().updateDunningProcessSteps(
                        selectedDunningPolicy.getPolicyId(), selectedProcessStep.getStepId(),
                        (Date) nextStepDateStart.getValue(), (Date) nextStepDateEnd.getValue(),
                        (Date) executionDate.getValue(), nextSelectedProcessStep.getStepId(), count, userName);
                notificationManager.showInformationNotification(Messages.DUNNING_STEPCHANGE_SUCCESS, xx);
                //DaoHelper.getInstance().getDunningProcessMasterRepository().updateDunningProcessSteps();
                actionLayout.removeComponent(nextStepCombo);
                actionLayout.removeComponent(executionDate);
                actionLayout.removeComponent(changeExecDate);
            } catch (Exception ex) {
                notificationManager.showErrorNotification("Hata", "" + ex.getMessage());
            }
        }
    });
    queryLayout.addComponent(claimButton);

    queryLayout.addComponent(lblEntityCount);

}

From source file:org.milleni.dunning.ui.prcstart.StepSelectStartDunningProcessPanel.java

License:Apache License

protected void initSettingsProperties() {
    panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);//from   ww w .j  ava  2 s.com
    detailLayout.setMargin(true, true, true, false);
    detailLayout.addComponent(panelLayout);

    processDate = new DateField("Sre Balama Zaman");
    panelLayout.addComponent(processDate);
    // Database type

    textArea = new TextArea("");
    textArea.setRequired(true);
    textArea.setEnabled(true);
    textArea.setRows(10);
    textArea.setColumns(50);
    check = new CheckBox("Gn gemi stepi yapma");

    panelLayout.addComponent(policyCombo);
    panelLayout.addComponent(stepCombo);
    panelLayout.addComponent(textArea);

    Button claimButton = new Button("Balat");
    claimButton.setIcon(Images.EXECUTE);
    claimButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            if (selectedProcessStep == null)
                throw new RuntimeException("Adm bo olamaz");
            String customerIds = (String) textArea.getValue();
            Date processDateValue = (Date) processDate.getValue();

            String[] customerIdArray = customerIds.split("\n");
            List<Long> customerIdList = new ArrayList<Long>();
            for (String strCustomerId : customerIdArray) {
                strCustomerId = strCustomerId.trim();
                if (StringUtils.hasText(strCustomerId)) {
                    customerIdList.add(Long.parseLong(strCustomerId));
                }
            }

            for (Long customerId : customerIdList) {
                Map<String, Object> variables = new HashMap<String, Object>();
                variables.put(Constants.customerId, customerId);
                if (loggedInUser != null)
                    variables.put(Constants.user, loggedInUser.getFullName());
                if (processDateValue != null)
                    variables.put(Constants.processStartDate, processDateValue);

                if (selectedProcessStep != null) {
                    variables.put(Constants.userSelectedProcessStep, selectedProcessStep.getStepId());
                }
                runtimeService.startProcessInstanceByKey(Constants.FL100_DunningProcessInitializer, variables);
            }
            textArea.setValue("");
        }
    });

    panelLayout.addComponent(claimButton);

}