Search in sources :

Example 1 with ChecklistContextConstraint

use of org.jbpm.examples.checklist.ChecklistContextConstraint in project jbpm by kiegroup.

the class DefaultChecklistManager method getTasks.

public List<ChecklistItem> getTasks(long processInstanceId, List<ChecklistContextConstraint> contexts) {
    List<ChecklistItem> items = getTasks(processInstanceId);
    List<ChecklistItem> results = new ArrayList<ChecklistItem>();
    for (ChecklistItem item : items) {
        if (contexts != null) {
            for (ChecklistContextConstraint context : contexts) {
                if (!context.acceptsTask(item)) {
                    break;
                }
            }
        }
        results.add(item);
    }
    return results;
}
Also used : ChecklistItem(org.jbpm.examples.checklist.ChecklistItem) ArrayList(java.util.ArrayList) ChecklistContextConstraint(org.jbpm.examples.checklist.ChecklistContextConstraint)

Example 2 with ChecklistContextConstraint

use of org.jbpm.examples.checklist.ChecklistContextConstraint in project jbpm by kiegroup.

the class ChecklistUI method refresh.

private void refresh() {
    Long processInstanceId = getSelectedProcessInstance();
    if (processInstanceId != null) {
        List<ChecklistContextConstraint> contexts = null;
        items = checklistManager.getTasks(processInstanceId, contexts);
    } else {
        items = new ArrayList<ChecklistItem>();
    }
    DefaultTableModel tableModel = new DefaultTableModel(items.size(), 5);
    for (int i = 0; i < items.size(); i++) {
        ChecklistItem item = items.get(i);
        String orderingNb = item.getOrderingNb();
        if (orderingNb == null) {
            orderingNb = "";
        } else if (orderingNb.endsWith("+")) {
            orderingNb = "*";
        }
        tableModel.setValueAt(item.getStatus(), i, 0);
        tableModel.setValueAt("(" + orderingNb + ")", i, 1);
        tableModel.setValueAt(item.getName(), i, 2);
        tableModel.setValueAt(item.getType(), i, 3);
        tableModel.setValueAt(item.getActors(), i, 4);
    // tableModel.setValueAt(item.getPriority(), i, 4);
    }
    itemTable.setModel(tableModel);
    itemTable.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() {

        private static final long serialVersionUID = 6L;

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            JLabel label = new JLabel();
            if (value != null) {
                label.setHorizontalAlignment(JLabel.CENTER);
                switch((Status) value) {
                    case Completed:
                        label.setIcon(ICONS[0]);
                        break;
                    case Aborted:
                        label.setIcon(ICONS[2]);
                        break;
                    case InProgress:
                        label.setIcon(ICONS[1]);
                        break;
                    case Created:
                        label.setIcon(ICONS[1]);
                        break;
                    case Reserved:
                        label.setIcon(ICONS[1]);
                        break;
                    case Ready:
                        label.setIcon(ICONS[1]);
                        break;
                    case Optional:
                        label.setIcon(ICONS[3]);
                        break;
                    case Pending:
                        break;
                    default:
                        break;
                }
            }
            return label;
        }
    });
    itemTable.getColumnModel().getColumn(3).setCellRenderer(new DefaultTableCellRenderer() {

        private static final long serialVersionUID = 6L;

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            JLabel label = new JLabel();
            label.setHorizontalAlignment(JLabel.CENTER);
            if (value != null) {
                String s = (String) value;
                if ("HumanTaskNode".equals(s)) {
                    label.setIcon(TYPE_ICONS[0]);
                } else if ("ActionNode".equals(s)) {
                    label.setIcon(TYPE_ICONS[1]);
                } else if ("SubProcessNode".equals(s)) {
                    label.setIcon(TYPE_ICONS[2]);
                } else if ("WorkItemNode".equals(s)) {
                    label.setIcon(TYPE_ICONS[3]);
                }
            }
            return label;
        }
    });
    itemTable.getColumnModel().getColumn(0).setPreferredWidth(32);
    itemTable.getColumnModel().getColumn(0).setMaxWidth(32);
    itemTable.getColumnModel().getColumn(1).setPreferredWidth(40);
    itemTable.getColumnModel().getColumn(2).setPreferredWidth(230);
    itemTable.getColumnModel().getColumn(3).setPreferredWidth(32);
    itemTable.getColumnModel().getColumn(3).setMaxWidth(32);
    itemTable.getColumnModel().getColumn(4).setPreferredWidth(120);
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) JLabel(javax.swing.JLabel) ChecklistContextConstraint(org.jbpm.examples.checklist.ChecklistContextConstraint) ChecklistContextConstraint(org.jbpm.examples.checklist.ChecklistContextConstraint) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JTable(javax.swing.JTable) ChecklistItem(org.jbpm.examples.checklist.ChecklistItem) Component(java.awt.Component)

Aggregations

ChecklistContextConstraint (org.jbpm.examples.checklist.ChecklistContextConstraint)2 ChecklistItem (org.jbpm.examples.checklist.ChecklistItem)2 Component (java.awt.Component)1 ArrayList (java.util.ArrayList)1 JLabel (javax.swing.JLabel)1 JTable (javax.swing.JTable)1 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1