Anonymous avatar Anonymous committed a06d3f7

Initial import from SourceForge

Comments (0)

Files changed (7)

src/designer/com/opensymphony/workflow/designer/UIFactory.java

+package com.opensymphony.workflow.designer;
+
+import java.awt.event.ActionListener;
+import javax.swing.*;
+
+import com.jgoodies.forms.builder.ButtonBarBuilder;
+
+/**
+ * @author Hani Suleiman (hani@formicary.net)
+ * Date: May 21, 2003
+ * Time: 9:46:11 PM
+ */
+public class UIFactory
+{
+  public static JPanel getTableButtonBar(ActionListener listener, String prefix)
+  {
+    if(prefix==null) prefix = "";
+    JButton[] buttons = new JButton[3];
+    JButton add = new JButton("Add");
+    add.setActionCommand(prefix + "add");
+    buttons[0] = add;
+    add.addActionListener(listener);
+    JButton remove = new JButton("Remove");
+    remove.setActionCommand(prefix + "remove");
+    remove.addActionListener(listener);
+    buttons[1] = remove;
+    JButton props = new JButton("Properties...");
+    props.setActionCommand(prefix + "properties");
+    props.addActionListener(listener);
+    buttons[2] = props;
+    JPanel panel = new JPanel();
+    ButtonBarBuilder builder = new ButtonBarBuilder(panel);
+    builder.addGriddedGrowingButtons(buttons);
+    return panel;
+  }
+}

src/designer/com/opensymphony/workflow/designer/actions/ImportWorkflow.java

+package com.opensymphony.workflow.designer.actions;
+
+import java.awt.event.ActionEvent;
+import java.awt.*;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import javax.swing.*;
+
+import com.opensymphony.workflow.designer.event.WorkspaceListener;
+import com.opensymphony.workflow.designer.event.WorkspaceEvent;
+import com.opensymphony.workflow.designer.Utils;
+import com.opensymphony.workflow.designer.WorkflowDesigner;
+import com.opensymphony.workflow.loader.Workspace;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Hani Suleiman (hani@formicary.net)
+ * Date: May 21, 2003
+ * Time: 12:55:51 AM
+ */
+public class ImportWorkflow extends AbstractAction implements WorkspaceListener
+{
+  private static final Log log = LogFactory.getLog(ImportWorkflow.class);
+
+  private Workspace currentWorkspace;
+
+  public ImportWorkflow()
+  {
+    setEnabled(false);
+    putValue(SHORT_DESCRIPTION, "Import a workflow");
+    putValue(NAME, "Import workflow");
+    putValue(LONG_DESCRIPTION, "Import a workflow definition file into the current workspace");
+  }
+
+  public void actionPerformed(ActionEvent e)
+  {
+    File file = Utils.promptUserForFile((Component)e.getSource(), JFileChooser.FILES_AND_DIRECTORIES, false, ".xml", "XML Workflow Files");
+    if(file!=null)
+    {
+      try
+      {
+        if(currentWorkspace.getLocation()==null)
+        {
+          JOptionPane.showMessageDialog((Component)e.getSource(), "Please save this workspace before importing workflows into it", "Warning", JOptionPane.WARNING_MESSAGE);
+          return;
+        }
+        FileOutputStream out = new FileOutputStream(new File(currentWorkspace.getLocation().getParentFile(), file.getName()));
+        FileInputStream in = new FileInputStream(file);
+
+        byte[] buff = new byte[4096];
+        int nch;
+        while((nch = in.read(buff, 0, buff.length)) != -1)
+        {
+          out.write(buff, 0, nch);
+        }
+        out.flush();
+        out.close();
+        String name = file.getName();
+        currentWorkspace.importDescriptor(name.substring(0, name.lastIndexOf('.')), new FileInputStream(file));
+        WorkflowDesigner.INSTANCE.navigator().setWorkspace(currentWorkspace);
+      }
+      catch(Exception t)
+      {
+        log.error("Error importing descriptor", t);
+      }
+    }
+  }
+
+  public void workspaceChanged(WorkspaceEvent event)
+  {
+    if(event.getId()==WorkspaceEvent.WORKSPACE_OPENED)
+    {
+      setEnabled(true);
+      currentWorkspace = event.getWorkspace();
+    }
+    else
+    {
+      setEnabled(false);
+      currentWorkspace = null;
+    }
+  }
+}

src/designer/com/opensymphony/workflow/designer/editor/JoinEditor.java

+package com.opensymphony.workflow.designer.editor;
+
+import javax.swing.*;
+
+import com.opensymphony.workflow.designer.model.ConditionsTableModel;
+import com.opensymphony.workflow.designer.JoinCell;
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.builder.PanelBuilder;
+
+public class JoinEditor extends DetailPanel
+{
+  private JTextField id = new JTextField(12);
+  private ConditionsTableModel conditionsModel = new ConditionsTableModel();
+  private JComboBox conditionTypes = new JComboBox(new String[]{"OR", "AND"});
+
+  public JoinEditor()
+  {
+  }
+
+  protected void initComponents()
+  {
+    FormLayout layout = new FormLayout("2dlu, max(30dlu;pref), 2dlu, pref:grow, 4dlu", "pref, 2dlu, pref, 2dlu, pref, 3dlu, pref, 2dlu, 60dlu, 2dlu");
+    PanelBuilder builder = new PanelBuilder(this, layout);
+    CellConstraints cc = new CellConstraints();
+    builder.addSeparator("Info", cc.xywh(2, 1, 4, 1));
+    builder.addLabel("ID", cc.xy(2, 3));
+    builder.add(id, cc.xy(4, 3));
+    builder.addLabel("Condition Type", cc.xy(2, 5));
+    builder.add(conditionTypes, cc.xy(4, 5));
+    builder.addSeparator("Conditions", cc.xywh(2, 7, 3, 1));
+    JTable actionsTable = new JTable(conditionsModel);
+    builder.add(new JScrollPane(actionsTable), cc.xywh(2, 9, 3, 1));
+  }
+
+  public String getTitle()
+  {
+    return "Join #" + id.getText();
+  }
+
+  protected void updateView()
+  {
+    JoinCell cell = (JoinCell)getCell();
+    id.setText(Integer.toString(cell.getId(), 10));
+    String type= cell.getJoinDescriptor().getConditionType();
+    if(type==null)
+    {
+      conditionTypes.setSelectedIndex(-1);
+    }
+    else
+    {
+      conditionTypes.setSelectedItem(type);
+    }
+    conditionsModel.setList(cell.getJoinDescriptor().getConditions());
+  }
+}

src/designer/com/opensymphony/workflow/designer/editor/SplitEditor.java

+package com.opensymphony.workflow.designer.editor;
+
+import javax.swing.*;
+
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.builder.PanelBuilder;
+import com.opensymphony.workflow.designer.SplitCell;
+import com.opensymphony.workflow.designer.model.ResultsTableModel;
+
+public class SplitEditor extends DetailPanel
+{
+  private JTextField id = new JTextField(12);
+  private ResultsTableModel resultsModel = new ResultsTableModel();
+
+  public SplitEditor()
+  {
+  }
+
+  protected void initComponents()
+  {
+    FormLayout layout = new FormLayout("2dlu, max(30dlu;pref), 2dlu, pref:grow, 4dlu", "pref, 2dlu, pref, 3dlu, pref, 2dlu, 60dlu, 2dlu");
+    PanelBuilder builder = new PanelBuilder(this, layout);
+    CellConstraints cc = new CellConstraints();
+    builder.addSeparator("Info", cc.xywh(2, 1, 4, 1));
+    builder.addLabel("ID", cc.xy(2, 3));
+    builder.add(id, cc.xy(4, 3));
+    builder.addSeparator("Results", cc.xywh(2, 5, 3, 1));
+    JTable actionsTable = new JTable(resultsModel);
+    builder.add(new JScrollPane(actionsTable), cc.xywh(2, 7, 3, 1));
+  }
+
+  public String getTitle()
+  {
+    return "Split #" + id.getText();
+  }
+
+  protected void updateView()
+  {
+    SplitCell cell = (SplitCell)getCell();
+    id.setText(Integer.toString(cell.getId(), 10));
+    resultsModel.setList(cell.getSplitDescriptor().getResults());
+  }
+}

src/designer/com/opensymphony/workflow/designer/editor/StepEditor.java

+package com.opensymphony.workflow.designer.editor;
+
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import javax.swing.*;
+
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.builder.PanelBuilder;
+import com.opensymphony.workflow.designer.StepCell;
+import com.opensymphony.workflow.designer.UIFactory;
+import com.opensymphony.workflow.designer.model.ActionsTableModel;
+import com.opensymphony.workflow.designer.model.PermissionsTableModel;
+import com.opensymphony.workflow.loader.StepDescriptor;
+import com.opensymphony.workflow.loader.PermissionDescriptor;
+
+public class StepEditor extends DetailPanel implements ActionListener
+{
+  private JTextField id = new JTextField(12);
+  private JTextField name = new JTextField(12);
+  private ActionsTableModel actionsModel = new ActionsTableModel();
+  private PermissionsTableModel permissionsModel = new PermissionsTableModel();
+  private JTable permissionsTable;
+  private JTable actionsTable;
+
+  public StepEditor()
+  {
+  }
+
+  protected void initComponents()
+  {
+    FormLayout layout = new FormLayout("2dlu, max(30dlu;pref), 2dlu, pref:grow, 4dlu", "pref, 2dlu, pref, 2dlu, pref, 4dlu, " + //next is 7 - actions separator
+                                                                                  "pref, 2dlu, 50dlu, pref, 2dlu, pref, 2dlu, 50dlu, pref, 2dlu");
+    PanelBuilder builder = new PanelBuilder(this, layout);
+    CellConstraints cc = new CellConstraints();
+    builder.addSeparator("Info", cc.xywh(2, 1, 3, 1));
+    builder.addLabel("ID", cc.xy(2, 3));
+    builder.add(id, cc.xy(4, 3));
+    builder.addLabel("Name", cc.xy(2, 5));
+    builder.add(name, cc.xy(4, 5));
+
+    builder.addSeparator("Actions", cc.xywh(2, 7, 3, 1));
+    actionsTable = new JTable(actionsModel);
+    builder.add(new JScrollPane(actionsTable), cc.xywh(2, 9, 3, 1));
+    builder.add(UIFactory.getTableButtonBar(this, "action"), cc.xywh(2, 10, 3, 1));
+
+    builder.addSeparator("Permissions", cc.xywh(2, 12, 3, 1));
+    permissionsTable = new JTable(permissionsModel);
+    builder.add(new JScrollPane(permissionsTable), cc.xywh(2, 14, 3, 1));
+    builder.add(UIFactory.getTableButtonBar(this, "permission"), cc.xywh(2, 15, 3, 1));
+  }
+
+  public void actionPerformed(ActionEvent e)
+  {
+    String command = e.getActionCommand();
+    if(command.equals("actionadd"))
+    {
+
+    }
+    else if(command.equals("actionremove"))
+    {
+      int[] selected = actionsTable.getSelectedRows();
+      for(int i=0;i<selected.length;i++)
+      {
+        actionsModel.remove(selected[i]);
+      }
+    }
+    else if(command.equals("actionproperties"))
+    {
+
+    }
+    else if(command.equals("permissionadd"))
+    {
+      //PermissionDescriptor descriptor = new PermissionDescriptor();
+      //descriptor.setId("0");
+      //permissionsModel.add(descriptor);
+    }
+    else if(command.equals("permissionremove"))
+    {
+      int[] selected = permissionsTable.getSelectedRows();
+      for(int i=0;i<selected.length;i++)
+      {
+        permissionsModel.remove(selected[i]);
+      }
+    }
+    else if(command.equals("permissionproperties"))
+    {
+
+    }
+  }
+
+  public String getTitle()
+  {
+    return "Step #" + id.getText();
+  }
+
+  protected void viewClosed()
+  {
+    if(permissionsTable.isEditing())
+    {
+      permissionsTable.getCellEditor().stopCellEditing();
+    }
+    if(actionsTable.isEditing())
+    {
+      actionsTable.getCellEditor().stopCellEditing();
+    }
+  }
+
+  protected void updateView()
+  {
+    StepCell cell = (StepCell)getCell();
+    StepDescriptor descriptor = cell.getDescriptor();
+    name.setText(cell.getName());
+    id.setText(String.valueOf(cell.getId()));
+    actionsModel.setList(descriptor.getActions());
+    permissionsModel.setList(descriptor.getPermissions());
+    actionsTable.getSelectionModel().clearSelection();
+    permissionsTable.getSelectionModel().clearSelection();
+  }
+}

src/designer/com/opensymphony/workflow/designer/model/ActionsTableModel.java

+package com.opensymphony.workflow.designer.model;
+
+import com.opensymphony.workflow.loader.ActionDescriptor;
+
+/**
+ * @author Hani Suleiman (hani@formicary.net)
+ * Date: May 20, 2003
+ * Time: 11:04:16 AM
+ */
+public class ActionsTableModel extends ListTableModel
+{
+  private String[] header = new String[]{"id", "name", "view", "auto"};
+
+  public ActionsTableModel()
+  {
+  }
+
+  public boolean isCellEditable(int rowIndex, int columnIndex)
+  {
+    return columnIndex!=0;
+  }
+
+  public int getColumnCount()
+  {
+    return header.length;
+  }
+
+  public void setValueAt(Object aValue, int rowIndex, int columnIndex)
+  {
+    ActionDescriptor action = (ActionDescriptor)list.get(rowIndex);
+    switch(columnIndex)
+    {
+      case 0:
+        if(aValue!=null)
+        action.setId(((Integer)aValue).intValue());
+        break;
+      case 1:
+        if(aValue!=null)
+          action.setName(aValue.toString());
+        break;
+      case 2:
+        action.setView(aValue!=null ? aValue.toString() : null);
+        break;
+      case 3:
+        action.setAutoExecute(((Boolean)aValue).booleanValue());
+        break;
+    }
+  }
+
+  public String getColumnName(int column)
+  {
+    return header[column];
+  }
+
+  public Class getColumnClass(int columnIndex)
+  {
+    switch(columnIndex)
+    {
+      case 0:
+        return Integer.class;
+      case 1:
+      case 2:
+        return String.class;
+      case 3:
+        return Boolean.class;
+      default:
+        return String.class;
+    }
+  }
+
+  public Object getValueAt(int rowIndex, int columnIndex)
+  {
+    ActionDescriptor action = (ActionDescriptor)list.get(rowIndex);
+    switch(columnIndex)
+    {
+      case 0:
+        return new Integer(action.getId());
+      case 1:
+        return action.getName();
+      case 2:
+        return action.getView()!=null ? action.getView() : "";
+      case 3:
+        return action.getAutoExecute() ? Boolean.TRUE : Boolean.FALSE;
+      default:
+        return "";
+    }
+  }
+}

src/designer/com/opensymphony/workflow/designer/model/ListTableModel.java

+package com.opensymphony.workflow.designer.model;
+
+import java.util.List;
+import java.util.ArrayList;
+import javax.swing.table.AbstractTableModel;
+
+/**
+ * @author Hani Suleiman (hani@formicary.net)
+ * Date: May 21, 2003
+ * Time: 10:20:51 PM
+ */
+public abstract class ListTableModel extends AbstractTableModel
+{
+  protected List list = new ArrayList();
+
+  public int getRowCount()
+  {
+    return list==null ? 0 : list.size();
+  }
+
+  public void setList(List l)
+  {
+    this.list = l;
+    fireTableDataChanged();
+  }
+
+  public void add(Object item)
+  {
+    list.add(item);
+    fireTableRowsInserted(list.size(), list.size());
+  }
+
+  public void remove(int index)
+  {
+    list.remove(index);
+    fireTableRowsDeleted(index, index);
+  }
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.