⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workflow_flowtree.java

📁 用java实现的工作流
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
          tree.setRowHeight(25);
          String filename = path0 + (String) cell.getUserObject() +
              ".gxl";
          file = new File(filename);

          if (file.isFile() && file.exists()) {
            fr = new workflow_FileImportGXL(filename);
            try {
              workflow_GraphEd gdx = new workflow_GraphEd("");
              gdx.newgraph(gdx.graph);
              wtp.addTab( (String) cell.getUserObject(), gdx);
              fr.parseGXLFileInto(filename, gdx.graph);
            }
            catch (Exception ex) {
              // JOptionPane.showMessageDialog(null, "显示未提交流程图异常" );
              System.out.println(ex);
            }
          }
          else {
            fr = new workflow_FileImportGXL(path2 +
                                            (String) cell.getUserObject() +
                                            ".actioned"
                                            );
            try {

              workflow_GraphEd gdx = new workflow_GraphEd("");
              gdx.newgraph(gdx.graph);
              wtp.addTab(cell.getUserObject().toString(), gdx);
              fr.parseGXLFileInto(path2 +
                                  (String) cell.getUserObject() +
                                  ".actioned"
                                  , gdx.graph);
            }
            catch (Exception ex) {
              JOptionPane.showMessageDialog(null, "显示已经提交流程图异常" + ex);
              // System.out.println("显示已经提交流程图异常" + ex);
            }
          }
          tree.setRowHeight(25);
        }
      });

    }

    ////////////将已经提交入库的流程图进行运行状态标记////////////////////

    if (!tree.isSelectionEmpty() && cell.getParent().toString().equals("已提交工作流")) {
      menu.addSeparator();
      menu.add(new AbstractAction("开始运行该流程") {
        public void actionPerformed(ActionEvent e) {

          tree.setRowHeight(25);

          // 调用运行激活流程方法
          java.util.Date date = new java.util.Date();
          currentDateTime = wudt.getCurrentDate(date);
          smn = new workflow_StepMain(cell.getUserObject().toString());
          if (JOptionPane.showConfirmDialog(null, "是否开始运行该流程?") == 0) {
            if (smn.start_flow(cell.getUserObject().toString(), currentDateTime)) {
              JOptionPane.showMessageDialog(null, "该流程的状态已经被设置为开始运行");
            }

            /////修改已经设置为开始运行的节点状态////
            DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode) tree.
                getLastSelectedPathComponent();
            if (selectNode.isLeaf()) {
              selectNode.add(new DefaultMutableTreeNode("流程状态监控"));
            }
            createnode2(cell.toString());
            tree.updateUI();
            tree.setRowHeight(25);
            tree.updateUI();
            tree.setRowHeight(25);

          }
        }
      });

    }


    if (!tree.isSelectionEmpty() && cell.getParent().toString().equals("已提交工作流")) {
      menu.addSeparator();
      menu.add(new AbstractAction("终止运行该流程") {
        public void actionPerformed(ActionEvent e) {

          tree.setRowHeight(25);

          ///// 调用运行激活流程方法////
          if (JOptionPane.showConfirmDialog(null, "是否终止运行该流程?") == 0) {
            smn = new workflow_StepMain(cell.getUserObject().toString());
            if (smn.suspend_flow(cell.getUserObject().toString())) {
              JOptionPane.showMessageDialog(null, "该流程已经被停止运行");
            }

            //    smn.
            DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode) tree.
                getLastSelectedPathComponent();
            if (!selectNode.isLeaf()) {
              selectNode.removeAllChildren();
            }
            tree.setRowHeight(25);
            tree.updateUI();
            tree.setRowHeight(25);

          }
        }
      });

    }
///////////////////调用workflow_RTCView()类显示流程图的运行状态///////////////
/*
  目前使用的是静态流程图的还原显示方法调用,通过监测数据库中的节点的状态来表示
  图中的节点ICON..

*/
    if (!tree.isSelectionEmpty() && cell.getParent().toString().equals("已提交工作流")) {
      menu.addSeparator();
      menu.add(new AbstractAction("查看流程运行状态") {
        public void actionPerformed(ActionEvent e) {

          try {

            workflow_GraphEd gdx = new workflow_GraphEd("disable");
            gdx.newgraph(gdx.graph);
            gdx.graph.setEditable(false);
            gdx.graph.setDragEnabled(false);
            gdx.graph.setDropEnabled(false);
            gdx.graph.setConnectable(false);
            gdx.graph.setMoveable(false);
            gdx.graph.setCloneable(false);
            gdx.graph.setFocusable(false);
            gdx.graph.setGridEnabled(true);
            gdx.graph.setPortsVisible(false);
            gdx.graph.setDisconnectOnMove(false);
            gdx.graph.setAntiAliased(true);
            gdx.graph.setBendable(false);

            wtp.addTab(cell.getUserObject().toString() + "的处理状态", gdx);
            wrtc.parseGXLFileInto_RTC(path2 +
                                      (String) cell.getUserObject() +
                                      ".actioned"
                                      , gdx.graph,
                                      cell.getUserObject().toString());
          }
          catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "查看流程运行状态异常" + ex);
            // System.out.println("显示已经提交流程图异常" + ex);
          }

        }
      });

    }
/////////////////////////////删除流程图//////////////////////////////////
    if (!tree.isSelectionEmpty() && cell.getParent().toString().equals("未提交工作流")) {
      menu.addSeparator();
      menu.add(new AbstractAction("删除未提交流程图") {
        public void actionPerformed(ActionEvent e) {
          if (JOptionPane.showConfirmDialog(null, "是否删除该流程图?") == 0) {
            cell.removeFromParent();
            tree.setRowHeight(25);
            tree.updateUI();
            file = new File(path0 + (String) cell.getUserObject() +
                            ".gxl");
            if (file.isFile() && file.exists()) {
              file.delete();

            }
            tree.setRowHeight(25);
          }
        }
      });
    }
/////////////////////////编辑已经入库的流程图的活动属性/////////////////
    if (!tree.isSelectionEmpty() && cell.getParent().toString().equals("已提交工作流")) {
      menu.addSeparator();
      menu.add(new AbstractAction("编辑流程活动属性") {
        public void actionPerformed(ActionEvent e) {
          waa = new workflow_AddStepActive(wul, cell.getUserObject().toString());
          waa.setTitle("为" + cell.getUserObject().toString() + "添加活动属性");
          waa.setSize(400, 335);
          waa.setLocationRelativeTo(null);
          //   waa.setDefaultCloseOperation(waa.EXIT_ON_CLOSE);
          waa.show();

        }
      });
    }

    return menu;
  }
// 串行化方法,保存树型目录的状态和数据,方便下次运行的时候显示以前保留的状态
/////////////////  写文件////////////////////////
  public void serializableNode(DefaultMutableTreeNode node) {
    try {
      java.io.FileOutputStream objfile = new java.io.FileOutputStream(
          "FLOWTREE.OBJ");
      java.io.ObjectOutputStream p = new java.io.ObjectOutputStream(objfile);
      p.writeObject(node);
      p.flush();
      objfile.close();
    }
    catch (java.io.IOException e) {
      System.out.println(e.toString());
    }

  }

///////////////////// 串行方法读文件///////////////////////

  public DefaultMutableTreeNode readNode() {

    FileInputStream objfile = null;
    try {
      objfile = new java.io.FileInputStream("FLOWTREE.OBJ");
      ObjectInputStream q = new ObjectInputStream(objfile);
      root = (DefaultMutableTreeNode) q.readObject();
    }
    catch (Exception e) {
      //   System.out.println(e);
      //   JOptionPane.showMessageDialog(null,"系统第一次运行");
      root = new DefaultMutableTreeNode(depname1 + "工作流列表");
      node1 = new DefaultMutableTreeNode("未提交工作流");
      node2 = new DefaultMutableTreeNode("已提交工作流");
      node3 = new DefaultMutableTreeNode("正在运行的流程");
      node4 = new DefaultMutableTreeNode("运行完毕的流程");
      root.add(node1);
      root.add(node2);
      root.add(node3);
      root.add(node4);

    }
    return root;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -