Search in sources :

Example 1 with TaskSummariesModel

use of com.salaboy.jbpm5.dev.guide.tablemodel.TaskSummariesModel in project jBPM5-Developer-Guide by Salaboy.

the class TasksListUI method selectTaskForm.

//GEN-LAST:event_refreshjButtonActionPerformed
private void selectTaskForm(JTable target, int row) {
    long taskId = ((TaskSummariesModel) target.getModel()).getTaskId(row);
    String taskName = ((TaskSummariesModel) target.getModel()).getTaskName(row);
    String selectedUser = (String) selectedUserjComboBox.getItemAt(selectedUserjComboBox.getSelectedIndex());
    System.out.println("Selected User: " + selectedUser);
    Class clazz = taskForms.get(taskName);
    if (clazz == null) {
        //no custom form for this task. Let's see if there is a default
        //form defined.
        clazz = taskForms.get("*");
        if (clazz == null) {
            JOptionPane.showMessageDialog(this, "No form defined for '" + taskName + " and not default (*) form is configured.", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
    Constructor constructor = null;
    try {
        constructor = clazz.getConstructor(LocalTaskService.class, long.class, String.class);
    } catch (NoSuchMethodException ex) {
        Logger.getLogger(TasksListUI.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(TasksListUI.class.getName()).log(Level.SEVERE, null, ex);
    }
    JPanel taskForm = null;
    try {
        taskForm = (JPanel) constructor.newInstance(localTaskService, taskId, selectedUser);
    } catch (InstantiationException ex) {
        Logger.getLogger(TasksListUI.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(TasksListUI.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalArgumentException ex) {
        Logger.getLogger(TasksListUI.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InvocationTargetException ex) {
        Logger.getLogger(TasksListUI.class.getName()).log(Level.SEVERE, null, ex);
    }
    //new MyTaskFormJPanel(localTaskService, taskId, selectedUser);
    tasklistsjTabbedPane.add(taskForm);
    tasklistsjTabbedPane.setSelectedComponent(taskForm);
    openedTaskForms.put(taskId, taskForm);
}
Also used : MySimpleTaskFormJPanel(com.salaboy.jbpm5.dev.guide.taskform.MySimpleTaskFormJPanel) JPanel(javax.swing.JPanel) Constructor(java.lang.reflect.Constructor) LocalTaskService(org.jbpm.task.service.local.LocalTaskService) InvocationTargetException(java.lang.reflect.InvocationTargetException) DetailedTaskSummariesModel(com.salaboy.jbpm5.dev.guide.tablemodel.DetailedTaskSummariesModel) SimpleTaskSummariesModel(com.salaboy.jbpm5.dev.guide.tablemodel.SimpleTaskSummariesModel) TaskSummariesModel(com.salaboy.jbpm5.dev.guide.tablemodel.TaskSummariesModel)

Aggregations

DetailedTaskSummariesModel (com.salaboy.jbpm5.dev.guide.tablemodel.DetailedTaskSummariesModel)1 SimpleTaskSummariesModel (com.salaboy.jbpm5.dev.guide.tablemodel.SimpleTaskSummariesModel)1 TaskSummariesModel (com.salaboy.jbpm5.dev.guide.tablemodel.TaskSummariesModel)1 MySimpleTaskFormJPanel (com.salaboy.jbpm5.dev.guide.taskform.MySimpleTaskFormJPanel)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 JPanel (javax.swing.JPanel)1 LocalTaskService (org.jbpm.task.service.local.LocalTaskService)1