Package reportgen.ren.report.userinput

Examples of reportgen.ren.report.userinput.UserInput


        JPanel parent = this;
        int errorIndex = 0;
        while(it.hasNext()) {
            Component comp = null;
            KnockModelListener knockModel = null;
            UserInput userInput = it.next();
            errors.add(null);

            if(userInput instanceof UserInputEditable) {
                //еденичное значение
                UserInputEditable uie = (UserInputEditable) userInput;
                if(uie.getValue() instanceof Boolean) {
                    //булевое
                    JCheckBox check = new JCheckBox("Да", (Boolean)uie.getValue());
                    comp = check;
                    CheckBoxActionListener model = new CheckBoxActionListener(uie, errorIndex);
                    knockModel = model;
                    check.addActionListener(model);

                } else if(uie.getValue() instanceof Date) {
                    JDateChooser dc = new JDateChooser((Date)uie.getValue());
                    comp = dc;
                    DateListener model = new DateListener(uie, errorIndex);
                    knockModel = model;
                    dc.getDateEditor().addPropertyChangeListener(model);

                } else {
                    //не булевое - целое, вещественное, строка
                    JTextArea ta = new JTextArea(uie.getValue().toString());
                    comp = ta;
                    TxtFieldDocumentListener model = new TxtFieldDocumentListener(uie, errorIndex);
                    knockModel = model;
                    ta.getDocument().addDocumentListener(model);
                }

            } else if(userInput instanceof UserInputSelect) {
                //выбор из множества
                UserInputSelect uis = (UserInputSelect) userInput;
                ArrayList<Integer> selectedRows = uis.getSelected();
                if(uis.getActiveRows().isSingle()) {
                    //единичный выбор
                    JComboBox combo = new JComboBox(uis.getOptions().toArray());
                    if(selectedRows == null
                            || selectedRows.size() != 1) {
                        combo.setSelectedIndex(-1);
                        uis.setSelected(null);
                    } else {
                        combo.setSelectedIndex(selectedRows.get(0));
                    }
                    comp = combo;
                    ComboItemListener model = new ComboItemListener(uis, errorIndex);
                    knockModel = model;
                    combo.addItemListener(model);
                } else {
                    //множественный выбор
                    JList list = new JList(uis.getOptions().toArray());
                    if(selectedRows == null
                            || selectedRows.size() == 0) {
                        list.setSelectedIndex(-1);
                        uis.setSelected(null);
                    } else {
                        for(Integer row: selectedRows) {
                            list.getSelectionModel().addSelectionInterval(row, row);
                        }
                    }
                    comp = list;
                    ListBoxSelectionListener model = new ListBoxSelectionListener(uis, errorIndex);
                    knockModel = model;
                    list.addListSelectionListener(model);
                }
            } else {
                JLabel label = new JLabel("Unknown value");
                label.setBorder(BorderFactory.createEtchedBorder());
                comp = label;
            }


            JPanel titlePane = new JPanel(new BorderLayout(5, 5));
            JLabel title = new JLabel(userInput.getTitle());
            titlePane.add(title, BorderLayout.CENTER);
            JCheckBox enableCheck = new JCheckBox("");
            if(!userInput.isCanBeOmitted()) {
                enableCheck.setEnabled(false);
                enableCheck.setSelected(true);
            } else {
                enableCheck.setSelected(false);
                enableCheck.addActionListener(new CheckBoxListener(comp, userInput,
                        errorIndex, knockModel));
                comp.setEnabled(false);
                userInput.clearSelection();
            }
            titlePane.add(enableCheck, BorderLayout.WEST);

            JPanel head = new JPanel(new BorderLayout(5, 5));
            head.add(titlePane, BorderLayout.NORTH);
View Full Code Here


        //Проверка входных параметров, все они должн  быть назначены
        ItemSelectorEditable<QueryInputValue> it = report.getInputs();
        for(int i=0; i<it.size(); i++) {
            QueryInputValue qiv = it.get(i);
            if(!qiv.isConstant()) {
                UserInput ui = input.getUserInput(QueryInputValue.TAG + "@" + qiv.getSelectTitle());
                if(ui == null) {
                    throw new ReportException("Отсутствует обязательный входной параметр: '"
                            + qiv.getSelectTitle() + "'");
                }
                qiv.setUserInput(ui);
            }
        }

        //проверка подотчетов
        ItemSelectorEditable<QueryExecuterSub> subreports = report.getSubReports();
        for(int i=0; i<subreports.size(); i++) {
            QueryExecuterSub subreport = subreports.get(i);
            UserInputSelect val = subreport.getResultInputValue();
            if(val == null) {
                //не требует результатов (константный отчет)
                continue;
            }

            UserInput ui = input.getUserInput(subreport.getReportId() + "@" + val.getTitle());
            if(ui == null) {
                throw new ReportException("Отсутствует обязательный входной параметр: '" + val.getTitle() + "'");
            } else if(ui instanceof UserInputSelect) {
                subreport.setResultUserInput((UserInputSelect) ui);
            } else {
View Full Code Here

TOP

Related Classes of reportgen.ren.report.userinput.UserInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.