private void create() { String s = (String) JOptionPane.showInputDialog( this, "Select Checklist Template:", "Select Template", JOptionPane.PLAIN_MESSAGE, null, new Object[] {"None", "Business Trip", "Sample1"}, "None"); if (s == null) { return; } String processId = null; if ("Sample1".equals(s)) { processId = "org.jbpm.examples.checklist.sample1"; } else if ("Business Trip".equals(s)) { processId = "org.jbpm.examples.checklist.travel"; } long processInstanceId = checklistManager.createContext(processId, getActorId()); String contextName = processInstanceId + ""; contexts.addItem(contextName); contexts.setSelectedItem(contextName); refresh(); }
private void createNewItem() { if (getSelectedProcessInstance() != null) { CreateItemDialog dialog = new CreateItemDialog(this, getActorId()); dialog.setVisible(true); String name = dialog.getItemName(); if (name != null) { ChecklistItem item = getSelectedItem(); String orderingNb = null; if (item != null) { orderingNb = item.getOrderingNb() + "+"; } else { orderingNb = items.get(items.size() - 1).getOrderingNb() + "+"; } String[] actors = null; String actorIds = dialog.getActors(); if (actorIds.trim().length() == 0) { actors = new String[0]; } else { actors = actorIds.split(","); } String[] groups = null; String groupIds = dialog.getGroups(); if (groupIds.trim().length() == 0) { groups = new String[0]; } else { groups = groupIds.split(","); } checklistManager.addTask( dialog.getActors(), actors, groups, name, orderingNb, getSelectedProcessInstance()); refresh(); } } }
private void create() { long processInstanceId = checklistManager.createContext("org.jbpm.examples.checklist.sample1"); String contextName = processInstanceId + ""; contexts.addItem(contextName); contexts.setSelectedItem(contextName); 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); }