Package org.uengine.kernel

Examples of org.uengine.kernel.FormActivity


       
       
       
        //TODO: 1. 서버에 있는 Form html을 읽어서 file로 저장.
        //FIXME: production 버전을 갖고 와야함
        FormActivity formActivity = (FormActivity) getActivity();
        HtmlFormContext formContext = (HtmlFormContext) formActivity.getVariableForHtmlFormContext().getDefaultValue();
       
        String formDefID[] = formContext.getFormDefId().split("@");


        openedForm = new OpenedForm();
        openedForm.formDefVerId = formDefID[1];
        openedForm.formName = formDefID[0].replaceAll("[\\[||\\]]","");
        openedForm.launcher = launcher; //may result huge memory resident in the static variable "openedForms"
       
        String fileName = openedForm.formName + ".jsp";
        String tempFilePath = System.getProperty("temp.path", "C:\\uengine\\");

        File newFile = new File(tempFilePath);
        if(!newFile.exists()){
          newFile.mkdirs();
        }
       
        tempFilePath = tempFilePath + File.separatorChar + fileName;

        openedForm.localFilePath = tempFilePath;
   
        InputStream is;
        try {
          is = ProcessDesigner.getInstance().getClientProxy().showFormDefinitionWithVersionId(formDefID[1]);
          File outFile = new File(tempFilePath);
          BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outFile));
          /*if(is!=null){
            byte [] buf = new byte[1024];
            int len;
            while ((len = is.read(buf)) > 0) {
              bos.write(buf, 0, len);
            }
            is.close();
              }
          bos.close();*/
         
          if(is!=null)
            org.uengine.util.UEngineUtil.copyStream(is, bos);
         
          openedForm.lastModified = outFile.lastModified();
          //openedForm.
         
        } catch (Exception e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
        String tool = System.getProperty("form.editor", "notepad");
       
        //review: this command will work only in Windows
        launcher.run(
          "cmd /c \"" + tool + "\" " + tempFilePath
        );
       
        openedForms.put(openedForm.formName, openedForm);
       
        // keep only one window listener for all the form designers there
        if(windowsFocusListener==null){
          windowsFocusListener = new WindowFocusListener(){

              public void windowGainedFocus(WindowEvent e) {
               
                try {

                  final Type deployOrNot = new Type("Select forms to deploy");
                  final Instance deployInstance = deployOrNot.createInstance();

                  new ForLoop(){

                    public void logic(Object target) {
                      OpenedForm openedForm = (OpenedForm) target;
                     
                      File file = new File(openedForm.localFilePath);
                      if(openedForm.lastModified != file.lastModified()){
                        deployOrNot.addFieldDescriptor(new FieldDescriptor(openedForm.formName, Boolean.class, null, null));
                        deployInstance.setFieldValue(openedForm.formName, true);
                        openedForm.lastModified = file.lastModified();
                      }
                    }
                   
                  }.run(openedForms);
                 
                  if(deployOrNot.getFieldDescriptors()==null || deployOrNot.getFieldDescriptors().length == 0) return;
                 
                  InputForm inputForm = new InputForm(deployOrNot){
                    public void onSaveOK(final Instance rec, JDialog dialog) {

                      dialog.dispose();
                     
                      SwingUtilities.invokeLater(new Runnable(){

                        public void run() {
                          new ProgressDialog("Deploy", ProcessDesigner.getInstance()){

                            public void run() throws Exception {
                              FieldDescriptor[] fds = deployOrNot.getFieldDescriptors();

                              for(int i=0; i<deployOrNot.getFieldDescriptors().length; i++){
                               
                                String fieldName = fds[i].getName();
                                Boolean value = (Boolean)rec.getFieldValue(fieldName);
                                if(value.booleanValue()){
                                  OpenedForm of = (OpenedForm) openedForms.get(fieldName);
                                  deployForm(of);
                                }
                              }
                            }
                           
                          }.show();
                        }
                       
                      });
                     
                    }

                    public void onUpdateOK(Instance rec, JDialog dialog) {
                      onUpdateOK(rec, dialog);
                    }
                  };
                 
                  inputForm.setInstance(deployInstance);
                 
                  inputForm.postInputDialog(ProcessDesigner.getInstance(), "Deploy", "Deploy");
                 
                } catch (Exception e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                }
              }

              public void windowLostFocus(WindowEvent e) {
                // TODO Auto-generated method stub
               
              }

          };
         
          ProcessDesigner.getInstance().addWindowFocusListener(windowsFocusListener);
        }
       
      }
     
    });
   
    previewForm.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e) {
        FormActivity formActivity = (FormActivity) getActivity();
        HtmlFormContext formContext = (HtmlFormContext) formActivity.getVariableForHtmlFormContext().getDefaultValue();
        String[] formDefID = formContext.getFormDefId().split("@");
        String host = ProcessDesigner.getInstance().getClientProxy().getHttpClient().getHost();
        int port = ProcessDesigner.getInstance().getClientProxy().getHttpClient().getPort();
        ProcessDesigner.getInstance().openNativeBrowser("http://" + host + ":" + port + GlobalContext.WEB_CONTEXT_ROOT + "/processmanager/previewFormDefinition.jsp?defVerId=" + formDefID[1]);
      }     
View Full Code Here


import org.uengine.kernel.SubProcessActivity;

public class FormActivityViewer extends DefaultActivityViewer {

  public StringBuffer getActivityPropertyString(Activity activity,ProcessInstance instance, Map options) throws Exception {
    FormActivity formActivity = (FormActivity) activity;
   
    StringBuffer formActivityPropertyString = super.getActivityPropertyString(activity, instance, options);
    String formDefinitionId = ((HtmlFormContext)formActivity.getVariableForHtmlFormContext().getDefaultValue()).getFormDefId();
   
    formActivityPropertyString.append("formDefinitionId=").append(formDefinitionId).append(",");
   
    String[] taskId = formActivity.getTaskIds(instance);
    if(taskId !=null)
      formActivityPropertyString.append("taskId=").append(taskId[0]).append(",");
   
    return formActivityPropertyString;
  }
View Full Code Here

    }

  public void afterComplete(Activity activity, ProcessInstance instance)
      throws Exception {
    if(activity instanceof FormActivity){
      FormActivity formActivity = (FormActivity)activity;
     
      String fileSystemPath = ProcessDefinitionFactory.DEFINITION_ROOT;
      Serializable value =formActivity.getVariableForHtmlFormContext().get(instance, "");
     
      BufferedInputStream bufferIs = null;
      FileOutputStream os = null;
      try{
        if(value instanceof HtmlFormContext){
View Full Code Here

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

    if(activity instanceof FormActivity){
      FormActivity formActivity = (FormActivity)activity;

      String defaultDrive = "x://";
      String defaultFolder = "uengine_inst";
     
      File f = null;
View Full Code Here

TOP

Related Classes of org.uengine.kernel.FormActivity

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.