Package org.uengine.kernel

Examples of org.uengine.kernel.SwitchActivity


     
      ProcessDefinition sampleProcDef = new ProcessDefinition();
      sampleProcDef = (ProcessDefinition) GlobalContext.deserialize(new FileInputStream(args[0]), ProcessDefinition.class);
      ActivityDesigner actDesigner = sampleProcDef.createDesigner();
     
      SwitchActivity switchAct = new SwitchActivity();
      switchAct.addChildActivity(new HumanActivity());
      switchAct.addChildActivity(new HumanActivity());
     
      JPanel panel = new JPanel(new BorderLayout());
      Component switchDesigner = switchAct.createDesigner().getComponent();
      panel.add("Center", switchDesigner);
      panel.setPreferredSize(new Dimension(300,200));
      JFrame frame = new JFrame();
      frame.getContentPane().setLayout(new BorderLayout());
      frame.getContentPane().add("Center", panel);
View Full Code Here


      ComplexActivity firstBlock = resultingBlock; 
     
      Vector insertedActivities = new Vector(); //for undo
     
      if (isXOR()) { //Switch block
        innerBlock = new SwitchActivity();

      } else //All block
        //System.out.println("in all");
        innerBlock = new AllActivity();
       
View Full Code Here

    Component comp = super.boxComponent(designer);
   
    JPanel compPanel = new ProxyPanel(new BorderLayout(0,0));

    final int where = getChildDesigners().size();
    final SwitchActivity switchActivity = (SwitchActivity)getActivity();
    Condition[] conditions = switchActivity.getConditions();
    String conditionDescription;// = "condition" + where;
   
    if(conditions!=null && conditions.length>where){
      conditionDescription = conditions[where].toString();
      switchActivity.setExtendedAttribute("conditionDescriptions_" + where, conditionDescription);
    }else{
      conditionDescription = "condition" + where;
    }
   
    final JPanel conditionLabelPanel = new ProxyPanel(new BorderLayout());
    final JLabel conditionLabel = new JLabel(conditionDescription);

    conditionLabelPanel.add("Center", conditionLabel);
    conditionLabel.addMouseListener(new MouseAdapter(){

      public void mouseClicked(MouseEvent arg0) {
        conditionLabelPanel.removeAll();
        final JTextField labelEditor = new JTextField();
        labelEditor.setText(conditionLabel.getText());
        conditionLabelPanel.add("Center", labelEditor);
       
        final ActionListener onEditDone = new ActionListener(){
          public void actionPerformed(ActionEvent arg0) {
           
            Condition theCondition = null;
           
            int where = switchActivity.getChildActivities().indexOf(designer.getActivity());
            Condition[] conditions = switchActivity.getConditions();
            if(conditions!=null && conditions.length > where){
              theCondition = conditions[where];
            }

            String conditionDescription = labelEditor.getText();
           
            if(theCondition!=null){
              if(conditionDescription==null || conditionDescription.trim().length()==0){
                conditionDescription = theCondition.toString();
              }else{
                theCondition.getDescription().setText(conditionDescription);
              }
            }
           
            conditionLabel.setText(conditionDescription);
            conditionLabelPanel.removeAll();
            conditionLabelPanel.add("Center", conditionLabel);
            conditionLabelPanel.revalidate();
           
            switchActivity.setExtendedAttribute("conditionDescriptions_" + where, conditionDescription);
          }
        };
       
        labelEditor.addFocusListener(new FocusListener(){
          public void focusGained(FocusEvent arg0) {
          }
          public void focusLost(FocusEvent arg0) {
            onEditDone.actionPerformed(null);           
          }
        });
       
        labelEditor.addActionListener(onEditDone);
       
        conditionLabelPanel.revalidate();
      }
     
    });
   
    switchActivity.addProperyChangeListener(
      new PropertyChangeListener(){
        public void propertyChange(PropertyChangeEvent pce){
          if(pce.getPropertyName().equals("conditions")){
            try{
              int where = switchActivity.getChildActivities().indexOf(designer.getActivity());
              Condition[] conditions = (Condition[])pce.getNewValue()
              conditionLabel.setText(conditions[where].toString());
            }catch(Exception e){
            }
          }
View Full Code Here

*/
  
public class SwitchActivityAdapter implements Adapter{
 
  public Object convert(Object src, java.util.Hashtable keyedContext) throws Exception{
    SwitchActivity srcAct = (SwitchActivity)src;

    tSwitch destAct = new tSwitch();
    destAct.setname_Attribute(new XNCName(srcAct.getName().getText().replace(' ', '_')));
   
    Vector childActivities = srcAct.getChildActivities();
    int i=0;
    for(Enumeration enumeration = childActivities.elements(); enumeration.hasMoreElements();){
      Object item = (Object)enumeration.nextElement();
      Adapter adpt = ProcessDefinitionAdapter.getAdapter(item.getClass());
      if(adpt==null){
        continue;
      }
             
      activity actGrp_ = (activity)adpt.convert(item, keyedContext);
     
      Condition condition = srcAct.getConditions()[i];
      if(condition instanceof Otherwise){
        tActivityContainer actContainer = new tActivityContainer();
        actContainer.setactivity_Group(actGrp_);
        destAct.setotherwise(actContainer);
      }else{
View Full Code Here

  }

  public void setActivity(Activity activity, String propertyName) {
    editingActivity = activity;
    if(editingActivity!=null && editingActivity instanceof SwitchActivity){
      SwitchActivity switchActivity = (SwitchActivity)editingActivity;
      switchActivity.addProperyChangeListener(this);
      propertyChange(new PropertyChangeEvent(switchActivity, "extendedAttribute", null, null));
    }
   
    table.setProcessDefinition(activity.getProcessDefinition());
  }
View Full Code Here

    table.setProcessDefinition(activity.getProcessDefinition());
  }

  public void propertyChange(PropertyChangeEvent pce) {   
    if(editingActivity!=null && editingActivity instanceof SwitchActivity && pce.getPropertyName().equals("extendedAttribute")){
      SwitchActivity switchActivity = (SwitchActivity)editingActivity;

      Map extAttrs = ((SwitchActivity)editingActivity).getExtendedAttributes();
     
      String[] conditionNames = new String[switchActivity.getChildActivities().size()];
      for(int i=0; i<switchActivity.getChildActivities().size(); i++){
        String attrKey = "conditionDescriptions_" + i;
        String conditionDescription = null;
        if(extAttrs!=null && extAttrs.containsKey(attrKey)){
          conditionDescription = (String)extAttrs.get(attrKey);
        }
       
        if(conditionDescription == null){
          if(switchActivity.getConditions()!=null && switchActivity.getConditions().length > i){
            conditionDescription = switchActivity.getConditions()[i].toString();
          }
        }
       
        conditionNames[i] = (conditionDescription !=null ? conditionDescription : ("condition" + i));
      }
View Full Code Here

 
  public void setInstance(Instance rec, String fieldName) {
    if(rec!=null && rec instanceof ObjectInstance){
      editingActivity = (Activity)((ObjectInstance)rec).getObject();
      if(editingActivity!=null && editingActivity instanceof SwitchActivity){
        SwitchActivity switchActivity = (SwitchActivity)editingActivity;
        Map extAttrs = ((SwitchActivity)editingActivity).getExtendedAttributes();
       
        String[] conditionNames = new String[switchActivity.getChildActivities().size()];
        for(int i=0; i<switchActivity.getChildActivities().size(); i++){
          String conditionDescription = (String)extAttrs.get("conditionDescription_" + i);
          conditionNames[i] = (conditionDescription !=null ? conditionDescription : ("condition" + i));
        }
       
        table.setConditionNames(conditionNames);
View Full Code Here

  public void afterComplete(Activity activity, ProcessInstance instance)
    throws Exception {

    if(!(activity instanceof SwitchActivity)) return;
   
    SwitchActivity switchActivity = (SwitchActivity)activity;
    int selectionPath = switchActivity.getCurrentStep(instance);
    Long procDefId = new Long(switchActivity.getProcessDefinition().getBelongingDefinitionId());
    Long pathNo = new Long(selectionPath);

    boolean isNew = false;
    long occurrence=0;
    long total=0;

    Long[] occurrenceAndTotal = getOccurrenceAndTotal(switchActivity, selectionPath);
    if(occurrenceAndTotal==null){
      isNew = true;
    }else{
      occurrence=occurrenceAndTotal[0].longValue();
      total=occurrenceAndTotal[1].longValue();
    }
   
    occurrence++;
   
    String sql = (isNew?
    "insert into BPM_AUDIT_PRBLTY(ProcDefId, TracingTag, PathNo, Occurrence) values (?ProcDefId, ?TracingTag, ?PathNo, ?Occurrence)":
    "update BPM_AUDIT_PRBLTY set Occurrence=?Occurrence where (ProcDefId = ?ProcDefId and TracingTag = ?TracingTag and PathNo = ?PathNo)"
    );
    
    BPM_AUDIT_PRBLTY newProbability = (BPM_AUDIT_PRBLTY)GenericDAO.createDAOImpl(
      DefaultConnectionFactory.create(),
      sql,
      BPM_AUDIT_PRBLTY.class
    );
   
    newProbability.setProcDefId(procDefId);
    newProbability.setTracingTag(switchActivity.getTracingTag());
    newProbability.setPathNo(pathNo);
    newProbability.setOccurrence(new Long(occurrence));
   
    newProbability.insert();   
  }
View Full Code Here

      act = new HumanActivity();
      act.setName("set the right person");
      ((HumanActivity) act).setRole(role2);     
      def.addChildActivity(act);
     
      cAct1 = new SwitchActivity();
      cAct1.setName("switch1");
      def.addChildActivity(cAct1);{
        cAct2 = new SequenceActivity();
        cAct1.addChildActivity(cAct2);{
          act = new HumanActivity();
View Full Code Here

 
  protected String getLabel(int i, Activity activity, ProcessInstance instance, Map options){
    try{
      String locale = (String)options.get("locale");
     
      SwitchActivity switchActivity = (SwitchActivity)activity;
     
      boolean isVertical = options.containsKey("vertical");
      boolean isSelected = false;
      if(instance!=null /*&& instance.isRunning(activity.getTracingTag())*/) {
        Activity currChild = (Activity) switchActivity.getChildActivities().get(i);
        if (!instance.getStatus().equals(Activity.STATUS_RUNNING)) {
          if (currChild instanceof ComplexActivity) {
            while (currChild instanceof ComplexActivity) {
              currChild = (Activity) ((ComplexActivity) currChild).getChildActivities().get(0);
            }
View Full Code Here

TOP

Related Classes of org.uengine.kernel.SwitchActivity

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.