private static void openURL(String strURL) {
   if (Program.launch(strURL)) {
     return;
   }
   URL openURL = null;
   try {
     openURL = new URL(strURL);
     PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(openURL);
   } catch (PartInitException e) {
     // if no default browser (like on linux), try to open directly with firefox.
     try {
       Runtime.getRuntime().exec("firefox " + openURL.toString()); // $NON-NLS-1$
     } catch (IOException e2) {
       if (PlatformUI.getWorkbench().getBrowserSupport().isInternalWebBrowserAvailable()) {
         IWebBrowser browser;
         try {
           browser =
               PlatformUI.getWorkbench()
                   .getBrowserSupport()
                   .createBrowser("registrationId"); // $NON-NLS-1$
           browser.openURL(openURL);
         } catch (PartInitException e1) {
           ExceptionHandler.process(e);
         }
       } else {
         ExceptionHandler.process(e);
       }
     }
   } catch (MalformedURLException e) {
     ExceptionHandler.process(e);
   }
 }
 private void lockObject(IRepositoryViewObject object) {
   IProxyRepositoryFactory repositoryFactory =
       CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
   try {
     repositoryFactory.lock(object);
   } catch (PersistenceException e) {
     ExceptionHandler.process(e);
   } catch (BusinessException e) {
     ExceptionHandler.process(e);
   }
 }
  public void buildNewJar() {
    try {
      String tmpFoler = getTmpFolder();
      // ZipToFile.unZipFile(zipFile, tmpFoler);
      // init jobFolder File
      initJobFolder();
      // bug 21473
      // change the .bat file & .sh file
      if (batFile != null) {
        changeScriptFile(batFile);
      }
      if (shFile != null) {
        changeScriptFile(shFile);
      }
      if (jobFolder == null) {
        return;
      }
      String newJarPath = jobFolder.getAbsolutePath() + "/" + CLASSPATH_JAR; // $NON-NLS-1$
      NewJarBuilder jarBuilder = new NewJarBuilder(tmpFoler, newJarPath);
      jarBuilder.buildJar();

      // delete non used jar files
      // deleteNonUsedJar();

    } catch (Exception e) {
      ExceptionHandler.process(e);
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see org.talend.core.ui.ILastVersionChecker#isLastVersion(org.talend.core.model.properties.Item)
  */
 public boolean isLastVersion(Item item) {
   if (item.getProperty() != null) {
     if (item.getProperty().getId() == null) {
       return true;
     }
     try {
       List<IRepositoryViewObject> allVersion =
           ProxyRepositoryFactory.getInstance().getAllVersion(item.getProperty().getId());
       if (allVersion != null && !allVersion.isEmpty()) {
         String lastVersion = VersionUtils.DEFAULT_VERSION;
         for (IRepositoryViewObject object : allVersion) {
           if (VersionUtils.compareTo(object.getVersion(), lastVersion) > 0) {
             lastVersion = object.getVersion();
           }
         }
         if (VersionUtils.compareTo(item.getProperty().getVersion(), lastVersion) == 0) {
           return true;
         }
       }
     } catch (PersistenceException e) {
       ExceptionHandler.process(e);
     }
   }
   return false;
 }
  @Override
  public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    String[] tmomCompNames = {"tMomInput", "tMomInputLoop", "tMomOutput"}; // $NON-NLS-1$

    IComponentConversion changeActiveMqDriverJarType =
        new IComponentConversion() {
          public void transform(NodeType node) {
            ElementParameterType mq_drivers =
                ComponentUtilities.getNodeProperty(node, PROPERTY_TO_REMOVE); // $NON-NLS-2$
            if (mq_drivers != null) {
              ComponentUtilities.removeNodeProperty(node, PROPERTY_TO_REMOVE);
            }
          }
        };

    for (String name : tmomCompNames) {
      IComponentFilter filter = new NameComponentFilter(name); // $NON-NLS-4$
      try {
        ModifyComponentsAction.searchAndModify(
            item,
            processType,
            filter,
            Arrays.<IComponentConversion>asList(changeActiveMqDriverJarType));
      } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
      }
    }

    return ExecutionResult.SUCCESS_NO_ALERT;
  }
  public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
      return ExecutionResult.NOTHING_TO_DO;
    }

    try {
      IComponentFilter filter1 = new NameComponentFilter("tFileInputCSV"); // $NON-NLS-1$

      IComponentConversion addProperty = new AddPropertyCSVOptionConversion();
      IComponentConversion renameComponent =
          new RenameComponentConversion("tFileInputDelimited"); // $NON-NLS-1$

      ModifyComponentsAction.searchAndModify(
          item,
          processType,
          filter1,
          Arrays.<IComponentConversion>asList(addProperty, renameComponent));

      return ExecutionResult.SUCCESS_WITH_ALERT;
    } catch (Exception e) {
      ExceptionHandler.process(e);
      return ExecutionResult.FAILURE;
    }
  }
Пример #7
0
  @Override
  public void createPartControl(Composite parent) {
    try {
      browser = new Browser(parent, SWT.NONE);
      browser.setText(StartingHelper.getHelper().getHtmlContent());
      browser.addLocationListener(new BrowserDynamicPartLocationListener());
      return;
    } catch (IOException e) {
      ExceptionHandler.process(e);
    } catch (Throwable t) {

      Exception ex =
          new Exception(
              "The internal web browser can not be access,the starting page won't be displayed");
      ExceptionHandler.process(ex);
    }
  }
 @Override
 public ExecutionResult execute(Item item) {
   try {
     replaceHostAndPort(item);
     return ExecutionResult.SUCCESS_NO_ALERT;
   } catch (Exception e) {
     ExceptionHandler.process(e);
     return ExecutionResult.FAILURE;
   }
 }
  /**
   * Gets all demo projects information.
   *
   * @return a list of <code>DemoProjectBean</code>
   */
  public static List<DemoProjectBean> getAllDemoProjects() {
    SAXReader reader = new SAXReader();
    Document doc = null;
    List<DemoProjectBean> demoProjectList = new ArrayList<DemoProjectBean>();
    DemoProjectBean demoProject = null;
    List<File> xmlFilePath = getXMLFilePath();
    for (int t = 0; t < xmlFilePath.size(); t++) {
      try {
        doc = reader.read(xmlFilePath.get(t));
      } catch (DocumentException e) {
        ExceptionHandler.process(e);
        return null;
      }

      Element demoProjectsInfo = doc.getRootElement();

      IBrandingService brandingService =
          (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
      String[] availableLanguages =
          brandingService.getBrandingConfiguration().getAvailableLanguages();

      for (Iterator<DemoProjectBean> i = demoProjectsInfo.elementIterator("project");
          i.hasNext(); ) { // $NON-NLS-1$
        Element demoProjectElement = (Element) i.next();
        demoProject = new DemoProjectBean();
        demoProject.setProjectName(demoProjectElement.attributeValue("name")); // $NON-NLS-1$
        String language = demoProjectElement.attributeValue("language"); // $NON-NLS-1$

        if (!ArrayUtils.contains(availableLanguages, language)) {
          // if the language is not available in current branding, don't display this demo project
          continue;
        }

        demoProject.setLanguage(ECodeLanguage.getCodeLanguage(language));
        String demoProjectFileType =
            demoProjectElement.attributeValue("demoProjectFileType"); // $NON-NLS-1$
        demoProject.setDemoProjectFileType(
            EDemoProjectFileType.getDemoProjectFileTypeName(demoProjectFileType));
        demoProject.setDemoProjectFilePath(
            demoProjectElement.attributeValue("demoFilePath")); // $NON-NLS-1$
        demoProject.setDescriptionFilePath(
            demoProjectElement.attributeValue("descriptionFilePath")); // $NON-NLS-1$
        // get the demo plugin Id
        demoProject.setPluginId(demoProjectElement.attributeValue("pluginId")); // $NON-NLS-1$
        if (demoProject.getProjectName().equals("ESBDEMOS")) {
          if (!PluginChecker.isPluginLoaded("org.talend.repository.services")) {
            continue;
          }
        }
        demoProjectList.add(demoProject);
      }
    }
    return demoProjectList;
  }
  /** qzhang Comment method "runPreviewCode". */
  public Process runPreviewCode() {
    getProcess();
    if (jobContextManager == null) {
      // proc.getContextManager().setListContext(component.getProcess().getContextManager().getListContext());
      proc.getContextManager()
          .setDefaultContext(component.getProcess().getContextManager().getDefaultContext());
    } else {
      // proc.getContextManager().setListContext(jobContextManager.getListContext());
      proc.getContextManager().setDefaultContext(jobContextManager.getDefaultContext());
    }
    // IContext context2 = new org.talend.core.model.context.JobContext(PREVIEW);
    // if (UIManager.isJavaProject()) {
    // List<IContextParameter> params = new ArrayList<IContextParameter>();
    // JobContextParameter contextParameter = new JobContextParameter();
    // contextParameter.setContext(context2);
    // contextParameter.setName(PREVIEW);
    // contextParameter.setValue(PREVIEW);
    // contextParameter.setType("String");
    // params.add(contextParameter);
    // context2.setContextParameterList(params);
    // }

    // generate context files.
    IProcessor contextProcessor = ProcessorUtilities.getProcessor(proc, null);
    contextProcessor.setContext(proc.getContextManager().getDefaultContext());
    try {
      contextProcessor.cleanBeforeGenerate(TalendProcessOptionConstants.CLEAN_CONTEXTS);
      contextProcessor.generateContextCode();
    } catch (ProcessorException pe) {
      ExceptionHandler.process(pe);
    }

    IProcessor processor =
        ProcessorUtilities.getProcessor(proc, null, proc.getContextManager().getDefaultContext());
    try {
      return processor.run(IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, null);
    } catch (Exception e) {
      ExceptionHandler.process(e);
      return null;
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.Action#run()
   */
  public void run() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    try {
      page.showView(getViewId());

    } catch (PartInitException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      ExceptionHandler.process(e);
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.core.model.migration.TXMLMapChangeAllInOneValueMigrationTask
   * (org .talend.core.model.properties.Item)
   */
  @Override
  public ExecutionResult execute(Item item) {

    IProxyRepositoryFactory factory =
        CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
    ProcessType processType = getProcessType(item);
    boolean modified = false;

    if (processType != null) {
      for (Object obj : processType.getNode()) {
        NodeType nodeType = (NodeType) obj;
        if (nodeType.getComponentName().startsWith("tXMLMap")) {
          XmlMapData xmlMapdata = (XmlMapData) nodeType.getNodeData();
          EList<OutputXmlTree> outputTables = xmlMapdata.getOutputTrees();
          EList<InputXmlTree> inputTables = xmlMapdata.getInputTrees();
          boolean hasDocumentInTheMainInputTable = false;
          for (InputXmlTree inputTable : inputTables) {
            if (!(inputTable.isLookup())) {
              for (TreeNode inputEntry : inputTable.getNodes()) {
                if ("id_Document".equals(inputEntry.getType())) {
                  hasDocumentInTheMainInputTable = true;
                }
              }
            }
          }
          if (hasDocumentInTheMainInputTable) {
            for (OutputXmlTree outputTable : outputTables) {
              for (TreeNode outputEntry : outputTable.getNodes()) {
                if ("id_Document".equals(outputEntry.getType())) {
                  if (!outputTable.isAllInOne()) {
                    outputTable.setAllInOne(true);
                    modified = true;
                    break;
                  }
                }
              }
            }
          }
        }
      }
    }
    try {
      if (modified) {
        factory.save(item, true);
        return ExecutionResult.SUCCESS_WITH_ALERT;
      } else {
        return ExecutionResult.SUCCESS_NO_ALERT;
      }
    } catch (Exception e) {
      ExceptionHandler.process(e);
      return ExecutionResult.FAILURE;
    }
  }
Пример #13
0
 @Override
 public RootContainer<String, IRepositoryViewObject> getRootContainerFromType(
     Project project, ERepositoryObjectType type) {
   if (project == null || type == null) {
     return null;
   }
   try {
     return getObjectFromFolder(project, type, true);
   } catch (PersistenceException e) {
     ExceptionHandler.process(e);
   }
   return null;
 }
 public IEditorPart openEditor(IWorkbenchPage page, IFile file, Item item, boolean forceReadOnly) {
   try {
     IEditorDescriptor editorDesc = IDE.getEditorDescriptor(file);
     RepositoryEditorInput repositoryEditorInput = new RepositoryEditorInput(file, item);
     repositoryEditorInput.setReadOnly(forceReadOnly);
     repositoryEditorInput.setRepositoryNode(null);
     IEditorPart editorPart = IDE.openEditor(page, repositoryEditorInput, editorDesc.getId());
     editors.put(editorPart, repositoryEditorInput);
     return editorPart;
   } catch (PartInitException e) {
     // e.printStackTrace();
     ExceptionHandler.process(e);
   }
   return null;
 }
 /**
  * DOC mhelleboid Comment method "getTempFolder".
  *
  * @param project TODO
  * @return
  */
 private IPath getTempFolderPath(Project project) {
   IProject iProject;
   IFolder iFolder = null;
   try {
     iProject = ResourceModelHelper.getProject(project);
     iFolder = ResourceUtils.getFolder(iProject, RepositoryConstants.TEMP_DIRECTORY, false);
     if (!iFolder.exists()) {
       ResourceUtils.createFolder(iFolder);
     }
   } catch (PersistenceException e) {
     // e.printStackTrace();
     ExceptionHandler.process(e);
   }
   return iFolder.getFullPath();
 }
  @SuppressWarnings({"rawtypes", "unchecked"})
  private static Class<Item>[] retrieveClasses(IConfigurationElement parent) {
    IConfigurationElement[] children = parent.getChildren("Item"); // $NON-NLS-1$
    List<Class<Item>> list = new ArrayList<Class<Item>>();

    for (IConfigurationElement ce : children) {
      String className = ce.getAttribute("clazz"); // $NON-NLS-1$
      try {
        Class clazz = Class.forName(className);
        list.add(clazz);
      } catch (ClassNotFoundException e) {
        ExceptionHandler.process(e);
      }
    }
    return list.toArray(new Class[0]);
  }
 @Override
 public ExecutionResult execute(Item item) {
   ProcessType processType = getProcessType(item);
   if (getProject().getLanguage() == ECodeLanguage.JAVA && processType != null) {
     try {
       ModifyComponentsAction.searchAndRename(
           item, processType, "tBuffer", "tBufferOutput"); // $NON-NLS-1$ //$NON-NLS-2$
       return ExecutionResult.SUCCESS_WITH_ALERT;
     } catch (Exception e) {
       ExceptionHandler.process(e);
       return ExecutionResult.FAILURE;
     }
   } else {
     return ExecutionResult.NOTHING_TO_DO;
   }
 }
  /**
   * Gets the path of demo projects xml file.
   *
   * @return String
   */
  private static List<File> getXMLFilePath() {
    List<File> xmlListFile = new ArrayList<File>();
    String[] pluginIDs =
        new String[] {
          ResourcesPlugin.PLUGIN_ID,
          "org.talend.resources.perl", //$NON-NLS-1$
          ResourcesPlugin.TDQ_PLUGIN_ID,
          getMDMDemoPluginId()
        }; //$NON-NLS-1$

    for (int i = 0; i < pluginIDs.length; i++) {
      Bundle bundle = Platform.getBundle(pluginIDs[i]);
      if (bundle != null) {
        URL url = null;

        String fullPath = XML_FILE_PATH;
        if (ResourcesPlugin.TDQ_PLUGIN_ID.equals(pluginIDs[i])) {
          fullPath = PluginConstant.EMPTY_STRING;
        }
        URL fileUrl = FileLocator.find(bundle, new Path(fullPath), null);
        try {
          if (fileUrl != null) {
            url = FileLocator.toFileURL(fileUrl);
          }
        } catch (IOException e) {
          ExceptionHandler.process(e);
        }
        if (url == null) continue;
        File xmlFilePath = new File(url.getPath());
        if (xmlFilePath.exists()) {
          String files[] =
              xmlFilePath.list(
                  new FilenameFilter() {

                    public boolean accept(File arg0, String arg1) {
                      return XmlUtil.isXMLFile(arg1);
                    }
                  });
          for (String file : files) {
            File xml = new File(url.getPath() + "/" + file); // $NON-NLS-1$
            xmlListFile.add(xml);
          }
        }
      }
    }
    return xmlListFile;
  }
Пример #19
0
 /**
  * Get the absolute installation path of plugin.
  *
  * @param pluginId
  * @return the plugin path or an empty string when it's not found.
  */
 public static String getPluginInstallPath(String pluginId) {
   String pluginPath = "";
   try {
     boolean running = Platform.isRunning();
     if (!running) {
       return pluginPath;
     }
     URL url = FileLocator.resolve(Platform.getBundle(pluginId).getEntry("/")); // $NON-NLS-1$
     if (url == null) {
       return pluginPath;
     }
     pluginPath = url.getFile();
     String protoPath = url.getProtocol();
     if (pluginPath.startsWith("file:")) { // $NON-NLS-1$
       pluginPath = pluginPath.substring(pluginPath.indexOf("file:") + 6); // $NON-NLS-1$
     }
     if ("jar".equals(protoPath) && pluginPath.endsWith("!/")) { // $NON-NLS-1$ //$NON-NLS-2$
       pluginPath = pluginPath.substring(0, pluginPath.lastIndexOf("!/")); // $NON-NLS-1$
     }
   } catch (IOException e) {
     ExceptionHandler.process(e);
   }
   return pluginPath;
 }
  /**
   * yzhang Comment method "run".
   *
   * @param refresh
   * @param number
   * @return
   */
  public List<List<String>> run(final Button refresh, String number) {
    this.number = number;
    results.clear();
    IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
    try {
      progressService.runInUI(
          PlatformUI.getWorkbench().getProgressService(),
          new IRunnableWithProgress() {

            public void run(final IProgressMonitor monitor) {
              monitor.beginTask(
                  Messages.getString("RowGenPreivewCodeMain.Process.Generate"),
                  IProgressMonitor.UNKNOWN); // $NON-NLS-1$
              try {
                try {
                  process = runPreviewCode();
                  if (process == null) {
                    return;
                  }

                  StringBuffer out = new StringBuffer();
                  StringBuffer err = new StringBuffer();

                  createResultThread(process.getErrorStream(), err).start();
                  createResultThread(process.getInputStream(), out).start();

                  process.waitFor();

                  if (out.length() > 0) {
                    convert(out.toString());
                  }
                  if (err.length() > 0) {
                    String mainMsg =
                        Messages.getString("RowGenPreivewCodeMain.PerlRun.Error"); // $NON-NLS-1$
                    new ErrorDialogWidthDetailArea(
                        Display.getCurrent().getActiveShell(),
                        PluginUtils.PLUGIN_ID,
                        mainMsg,
                        Messages.getString(
                            "RowGenProcessMain.checkParameter", err.toString())); // $NON-NLS-1$
                  }
                } catch (Exception e) {
                  ExceptionHandler.process(e);
                  kill();
                }
              } finally {
                monitor.done();
                refresh.setText(
                    Messages.getString("RowGenPreivewCodeMain.PreviewBtn.Text")); // $NON-NLS-1$
              }
            }
          },
          null);

    } catch (Exception ex) {
      ExceptionHandler.process(ex);
    } finally {
      proc.reconnection();
    }
    return results;
  }
  @Override
  public ExecutionResult execute(Item item) {
    try {
      ProcessType processType = getProcessType(item);
      if (getProject().getLanguage() == ECodeLanguage.JAVA || processType == null) {

        return ExecutionResult.NOTHING_TO_DO;

      } else {

        List<String> namesList = new ArrayList<String>();

        for (Object o : processType.getNode()) {
          NodeType nt = (NodeType) o;
          namesList.add(ComponentUtilities.getNodeUniqueName(nt));
        }
        for (Object o : processType.getConnection()) {
          ConnectionType currentConnection = (ConnectionType) o;
          int lineStyle = currentConnection.getLineStyle();
          EConnectionType connectionType = EConnectionType.getTypeFromId(lineStyle);
          if (connectionType.hasConnectionCategory(EConnectionType.FLOW)) {
            namesList.add(currentConnection.getLabel());
          }
        }
        final String[] namesArrays = namesList.toArray(new String[0]);

        IComponentFilter filter1 =
            new IComponentFilter() {

              /*
               * (non-Javadoc)
               *
               * @see org.talend.core.model.components.filters.IComponentFilter#accept(org.talend.designer.core.model.utils.emf.talendfile.NodeType)
               */
              public boolean accept(NodeType node) {
                return true;
              }
            };

        IComponentConversion componentConversion =
            new IComponentConversion() {

              RefArraySyntaxReplacerForPerl parser = new RefArraySyntaxReplacerForPerl();

              /*
               * (non-Javadoc)
               *
               * @see org.talend.core.model.components.conversions.IComponentConversion#transform(org.talend.designer.core.model.utils.emf.talendfile.NodeType)
               */
              public void transform(NodeType node) {

                for (Object o : node.getElementParameter()) {
                  ElementParameterType pType = (ElementParameterType) o;
                  if (pType.getField().equals("TABLE")) { // $NON-NLS-1$
                    for (ElementValueType elementValue :
                        (List<ElementValueType>) pType.getElementValue()) {
                      elementValue.getValue();
                      String value = elementValue.getValue();
                      if (value != null) {
                        String newValue = parser.processReplacementOperations(value, namesArrays);
                        elementValue.setValue(newValue);
                      }
                    }
                  } else {
                    String value = pType.getValue();
                    if (value != null) {
                      String newValue = parser.processReplacementOperations(value, namesArrays);
                      pType.setValue(newValue);
                    }
                  }
                }
              }
            };

        ModifyComponentsAction.searchAndModify(
            item, processType, filter1, Arrays.<IComponentConversion>asList(componentConversion));

        return ExecutionResult.SUCCESS_WITH_ALERT;
      }
    } catch (Exception e) {
      ExceptionHandler.process(e);
      return ExecutionResult.FAILURE;
    }
  }
  public void run(String[] refreshTypes, final String pageToDispaly) {
    List typesToRefresh = null;

    if (refreshTypes == null || refreshTypes.length == 0) {
      typesToRefresh = new ArrayList();
      typesToRefresh.add(REFRESH_ALL);
    } else {
      typesToRefresh = Arrays.asList(refreshTypes);
    }

    if (typesToRefresh.contains(REFRESH_ALL) || typesToRefresh.contains(REFRESH_AVAILABLES)) {
      try {
        final RefreshJob job = new RefreshJob();
        job.addJobChangeListener(
            new JobChangeAdapter() {

              @Override
              public void done(final IJobChangeEvent event) {

                Display.getDefault()
                    .syncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            updateUI(job, event);
                            String toDisplay =
                                pageToDispaly == null
                                    ? ContentConstants.UL_LIST_AVAILABLE_EXTENSIONS
                                    : pageToDispaly;
                            ExchangeManager.getInstance()
                                .generateXHTMLPage(
                                    toDisplay,
                                    new String[] {ContentConstants.INSERT_EXTENSION_DATA});
                          }
                        });
              }
            });
        ExchangeUtils.scheduleUserJob(job);

      } catch (Exception e) {
        ExceptionHandler.process(e);
      }
    }

    // Show Installed Extensions
    if (typesToRefresh.contains(REFRESH_ALL) || typesToRefresh.contains(REFRESH_INSTALLED)) {
      try {
        final ShowInstalledExtensionsJob showInstalledJob = new ShowInstalledExtensionsJob();
        showInstalledJob.addJobChangeListener(
            new JobChangeAdapter() {

              @Override
              public void done(final IJobChangeEvent event) {

                Display.getDefault()
                    .syncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            updateInstalledUI(showInstalledJob, event);
                            ExchangeManager.getInstance()
                                .generateXHTMLPage(
                                    pageToDispaly,
                                    new String[] {ContentConstants.DOWNLOADEXTENSION_DATA});
                          }
                        });
              }
            });
        ExchangeUtils.scheduleUserJob(showInstalledJob);

      } catch (Exception e) {
        ExceptionHandler.process(e);
      }
    }

    // Show Contributed Extensions
    if (typesToRefresh.contains(REFRESH_ALL) || typesToRefresh.contains(REFRESH_MY_EXTENSIONS)) {
      try {
        final ShowContributedExtensionsJob showContributedJob = new ShowContributedExtensionsJob();
        showContributedJob.addJobChangeListener(
            new JobChangeAdapter() {

              @Override
              public void done(final IJobChangeEvent event) {

                Display.getDefault()
                    .syncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            updateContributedUI(showContributedJob, event);
                            ExchangeManager.getInstance()
                                .generateXHTMLPage(
                                    pageToDispaly,
                                    new String[] {ContentConstants.LIST_MY_EXTENSION});
                          }
                        });
              }
            });
        ExchangeUtils.scheduleUserJob(showContributedJob);

      } catch (Exception e) {
        ExceptionHandler.process(e);
      }
    }

    //
    getVersionRevisionsAndCategorys();
    // refreshHTML();

  }
  /** Constructs a new FileInputNode. */
  public FileInputDelimitedNode(
      String filename,
      String rowSep,
      String fieldSep,
      int limitRows,
      int headerRows,
      int footerRows,
      String escapeChar,
      String textEnclosure,
      boolean removeEmptyRow,
      boolean spitRecord,
      String encoding,
      EShadowProcessType fileType) {
    super("tFileInputDelimited"); // $NON-NLS-1$

    boolean csvoption = false;
    String languageName = LanguageManager.getCurrentLanguage().getName();
    switch (fileType) {
      case FILE_DELIMITED:
        csvoption = false;

        if (languageName.equals("perl")) { // $NON-NLS-1$
          int max =
              getColumnCount(
                  filename,
                  rowSep,
                  fieldSep,
                  limitRows,
                  headerRows,
                  escapeChar,
                  textEnclosure,
                  EShadowProcessType.FILE_DELIMITED);
          this.setColumnNumber(max);

        } else {

          int max = 0;
          try {

            max =
                FileInputDelimited.getMaxColumnCount(
                    trimParameter(filename),
                    trimParameter(encoding),
                    trimParameter(StringUtils.loadConvert(fieldSep, languageName)),
                    trimParameter(StringUtils.loadConvert(rowSep, languageName)),
                    true,
                    spitRecord,
                    headerRows,
                    limitRows);

          } catch (IOException e) {
            // e.printStackTrace();
            ExceptionHandler.process(e);
          }
          if (max > 0) {
            this.setColumnNumber(max);
          }
        }
        break;

      case FILE_CSV:
        csvoption = true;
        if (languageName.equals("perl")) { // $NON-NLS-1$
          int max =
              getColumnCount(
                  filename,
                  rowSep,
                  fieldSep,
                  limitRows,
                  headerRows,
                  escapeChar,
                  textEnclosure,
                  EShadowProcessType.FILE_CSV);
          this.setColumnNumber(max);
        } else {
          CSVFileColumnConnter cr = null;
          try {
            cr = new CSVFileColumnConnter();
            cr.setSeperator(
                trimParameter(StringUtils.loadConvert(fieldSep, languageName)).charAt(0));
            int columnCount = 0;
            columnCount =
                cr.countMaxColumnNumber(
                    new File(TalendTextUtils.removeQuotes(filename)), limitRows);
            if (columnCount > 0) {
              this.setColumnNumber(columnCount);
            }
          } catch (UnsupportedEncodingException e) {
            ExceptionHandler.process(e);
          } catch (FileNotFoundException e) {
            ExceptionHandler.process(e);
          } catch (IOException e) {
            ExceptionHandler.process(e);
          }
        }
        break;

      default:
        break;
    }

    String[] paramNames = null;

    if (!csvoption) {
      paramNames =
          new String[] {
            "FILENAME",
            "ROWSEPARATOR",
            "FIELDSEPARATOR",
            "LIMIT",
            "HEADER",
            "FOOTER", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                      // //$NON-NLS-6$
            "ESCAPE_CHAR",
            "TEXT_ENCLOSURE",
            "REMOVE_EMPTY_ROW",
            "ENCODING",
            "CSV_OPTION",
            "SPLITRECORD"
          }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    } else {
      paramNames =
          new String[] {
            "FILENAME",
            "CSVROWSEPARATOR",
            "FIELDSEPARATOR",
            "LIMIT",
            "HEADER",
            "FOOTER", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                      // //$NON-NLS-6$
            "ESCAPE_CHAR",
            "TEXT_ENCLOSURE",
            "REMOVE_EMPTY_ROW",
            "ENCODING",
            "CSV_OPTION",
            "SPLITRECORD"
          }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    }
    String[] paramValues =
        new String[] {
          filename,
          rowSep,
          fieldSep,
          Integer.toString(limitRows),
          Integer.toString(headerRows),
          Integer.toString(footerRows),
          escapeChar,
          textEnclosure,
          Boolean.toString(removeEmptyRow),
          encoding,
          Boolean.toString(csvoption),
          Boolean.toString(spitRecord)
        };

    IComponent component =
        ComponentsFactoryProvider.getInstance()
            .get(
                "tFileInputDelimited", //$NON-NLS-1$
                ComponentCategory.CATEGORY_4_DI.getName());
    this.setElementParameters(component.createElementParameters(this));
    for (int i = 0; i < paramNames.length; i++) {
      if (paramValues[i] != null) {
        IElementParameter param = this.getElementParameter(paramNames[i]);
        if (param != null) {
          param.setValue(paramValues[i]);
        }
      }
    }
  }
  @SuppressWarnings("unchecked")
  private static String getDisplayValue(final IElementParameter param) {
    Object value = param.getValue();

    if (value instanceof String) {

      if (param.getName().equals("PROCESS_TYPE_VERSION")
          && value.equals(RelationshipItemBuilder.LATEST_VERSION)) { // $NON-NLS-1$
        String jobId =
            (String)
                param
                    .getParentParameter()
                    .getChildParameters()
                    .get("PROCESS_TYPE_PROCESS")
                    .getValue(); //$NON-NLS-1$
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId);
        if (processItem == null) {
          return ""; //$NON-NLS-1$
        }
        return processItem.getProperty().getVersion();
      }
      if (param.getName().equals("PROCESS_TYPE_CONTEXT")) { // $NON-NLS-1$
        String jobId =
            (String)
                param
                    .getParentParameter()
                    .getChildParameters()
                    .get("PROCESS_TYPE_PROCESS")
                    .getValue(); //$NON-NLS-1$
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId);
        if (processItem == null) {
          return ""; //$NON-NLS-1$
        }
        // check if the selected context exists, if not, use the default context of the job.
        boolean contextExists = false;
        for (Object object : processItem.getProcess().getContext()) {
          if (object instanceof ContextType) {
            if (((ContextType) object).getName() != null
                && ((ContextType) object).getName().equals(value)) {
              contextExists = true;
              continue;
            }
          }
        }
        if (!contextExists) {
          return processItem.getProcess().getDefaultContext();
        }
        return (String) value;
      }
      // hywang add for 6484
      if ("SELECTED_FILE".equals(param.getRepositoryValue())) { // $NON-NLS-N$ //$NON-NLS-1$
        IElementParameter propertyParam =
            param
                .getElement()
                .getElementParameter(
                    "PROPERTY:REPOSITORY_PROPERTY_TYPE"); // $NON-NLS-N$ //$NON-NLS-1$
        if (propertyParam != null
            && propertyParam.getValue() != null
            && !propertyParam.getValue().equals("")) { // $NON-NLS-1$
          try {
            IRepositoryViewObject object =
                CoreRuntimePlugin.getInstance()
                    .getProxyRepositoryFactory()
                    .getLastVersion((String) propertyParam.getValue());
            if (object != null) {
              Item item = object.getProperty().getItem();
              String extension = null;

              String rule = ""; // $NON-NLS-1$
              String processLabelAndVersion = null;
              if (item instanceof RulesItem) {
                RulesItem rulesItem = (RulesItem) item;
                extension = rulesItem.getExtension();
                if (param.getElement() instanceof INode) {
                  INode node = (INode) param.getElement();
                  IProcess process = node.getProcess();
                  String jobLabel = process.getName();
                  String jobVersion = process.getVersion();
                  processLabelAndVersion =
                      JavaResourcesHelper.getJobFolderName(jobLabel, jobVersion);
                }

                rule =
                    "rules/final/"
                        + processLabelAndVersion
                        + "/"
                        + rulesItem.getProperty().getLabel() // $NON-NLS-1$ //$NON-NLS-2$
                        + rulesItem.getProperty().getVersion()
                        + extension;
              }
              return TalendQuoteUtils.addQuotes(rule);
            } else {
              return param.getValue().toString();
            }
          } catch (Exception e) {
            ExceptionHandler.process(e);
          }
        }
      }

      return (String) value;
    }
    if (param.getFieldType() == EParameterFieldType.RADIO
        || param.getFieldType() == EParameterFieldType.CHECK
        || param.getFieldType() == EParameterFieldType.AS400_CHECK) {
      if (value instanceof Boolean) {
        return ((Boolean) param.getValue()).toString();
      } else {
        return Boolean.FALSE.toString();
      }
    }

    if (param.getFieldType() == EParameterFieldType.TABLE) {
      List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue();
      String[] items = param.getListItemsDisplayCodeName();
      String stringValues = "{"; // $NON-NLS-1$
      for (int i = 0; i < tableValues.size(); i++) {
        Map<String, Object> lineValues = tableValues.get(i);
        stringValues += "["; // $NON-NLS-1$
        for (int j = 0; j < items.length; j++) {

          Object currentValue = lineValues.get(items[j]);
          if (currentValue instanceof Integer) {
            IElementParameter tmpParam = (IElementParameter) param.getListItemsValue()[j];
            if (tmpParam.getListItemsDisplayName().length != 0) {
              stringValues += tmpParam.getListItemsDisplayName()[(Integer) currentValue];
            }
          } else {
            stringValues += currentValue;
          }

          if (j != (items.length - 1)) {
            stringValues += ","; // $NON-NLS-1$
          }
        }
        stringValues += "]"; // $NON-NLS-1$
        if (i != (tableValues.size() - 1)) {
          stringValues += ","; // $NON-NLS-1$
        }
      }
      stringValues += "}"; // $NON-NLS-1$
      return stringValues;
    }

    return new String(""); // $NON-NLS-1$
  }
  private static void init() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] configurationElements =
        registry.getConfigurationElementsFor(
            "org.talend.core.runtime.repositoryComponent_provider"); //$NON-NLS-1$
    List<String> repositoryComponentNames = new ArrayList<String>();
    List<String> dndFilterIds = new ArrayList<String>();
    List<String> componentIds = new ArrayList<String>();

    for (int i = 0; i < configurationElements.length; i++) {
      IConfigurationElement element = configurationElements[i];
      if (element.getName().equals("ExtensionFilter")) { // $NON-NLS-1$
        //
        List<String> filterAttrs =
            getFilterAttrs(
                element,
                "RepositoryComponentFilter", //$NON-NLS-1$
                "repositoryComponentName"); //$NON-NLS-1$
        repositoryComponentNames.addAll(filterAttrs);

        //
        filterAttrs =
            getFilterAttrs(
                element,
                "DragAndDropFilterFilter", //$NON-NLS-1$
                "dndFilterId"); //$NON-NLS-1$
        dndFilterIds.addAll(filterAttrs);

        //
        filterAttrs =
            getFilterAttrs(
                element,
                "SortedComponentFilter", //$NON-NLS-1$
                "componentId"); //$NON-NLS-1$
        componentIds.addAll(filterAttrs);
      }
    }

    for (int i = 0; i < configurationElements.length; i++) {
      IConfigurationElement element = configurationElements[i];
      if (element.getName().equals("RepositoryComponent")) { // $NON-NLS-1$
        String name = element.getAttribute("name"); // $NON-NLS-1$
        if (repositoryComponentNames.contains(name)) {
          continue; // filter
        }
        String type = element.getAttribute("type"); // $NON-NLS-1$
        boolean withSchema =
            Boolean.parseBoolean(element.getAttribute("withSchema")); // $NON-NLS-1$
        String input = element.getAttribute("input"); // $NON-NLS-1$
        String output = element.getAttribute("output"); // $NON-NLS-1$
        String def = element.getAttribute("default"); // $NON-NLS-1$

        IRepositoryComponentAgent agent = null;
        if (element.getAttribute("agent") != null) { // $NON-NLS-1$
          try {
            Object object = element.createExecutableExtension("agent"); // $NON-NLS-1$
            if (object != null && (object instanceof IRepositoryComponentAgent)) {
              agent = (IRepositoryComponentAgent) object;
            }
          } catch (Exception e) {
            //
          }
        }

        RepositoryComponentSetting setting = new RepositoryComponentSetting();
        setting.setName(name);
        setting.setRepositoryType(type);
        setting.setWithSchema(withSchema);
        setting.setInputComponent(input);
        setting.setOutputComponent(output);
        setting.setDefaultComponent(def);
        setting.setClasses(retrieveClasses(element));
        setting.setDbTypes(retrieveDBTypes(element));
        setting.setAgent(agent);

        repComponentSettings.add(setting);
      } else if (element.getName().equals("DragAndDropFilter")) { // $NON-NLS-1$
        String id = element.getAttribute("id"); // $NON-NLS-1$
        if (dndFilterIds.contains(id)) {
          continue; // filter
        }
        String name = element.getAttribute("name"); // $NON-NLS-1$
        int level = parserLevel(element.getAttribute("level")); // $NON-NLS-1$
        IRepositoryComponentDndFilter filter = null;
        try {
          Object object = element.createExecutableExtension("clazz"); // $NON-NLS-1$
          if (object == null || !(object instanceof IRepositoryComponentDndFilter)) {
            throw new IllegalArgumentException("the argument of clazz is wrong"); // $NON-NLS-1$
          }
          filter = (IRepositoryComponentDndFilter) object;
        } catch (Exception e) {
          ExceptionHandler.process(e);
        }

        RepositoryComponentDndFilterSetting dndSetting = new RepositoryComponentDndFilterSetting();

        dndSetting.setId(id);
        dndSetting.setName(name);
        dndSetting.setLevel(level);
        dndSetting.setFilter(filter);

        repComponentDndFilterSettings.add(dndSetting);
      } else if (element.getName().equals("SortedComponents")) { // $NON-NLS-1$

        retrieveSortedComponent(
            componentIds, sortedComponentSetting, element, "Component"); // $NON-NLS-1$
        retrieveSortedComponent(
            componentIds,
            specialSortedComponentSetting,
            element,
            "SpecialComponent"); //$NON-NLS-1$
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.Action#run()
   */
  protected void doRun() {
    RepositoryNode node =
        (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();

    final Item item = node.getObject().getProperty().getItem();
    if (item == null) {
      return;
    }
    String initialFileName = null;
    String initialExtension = null;
    if (item instanceof DocumentationItem) {
      DocumentationItem documentationItem = (DocumentationItem) item;
      initialFileName = documentationItem.getName();
      if (documentationItem.getExtension() != null) {
        initialExtension = documentationItem.getExtension();
      }
    } else if (item instanceof LinkDocumentationItem) { // link documenation
      LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;

      if (!LinkUtils.validateLink(linkDocItem.getLink())) {
        MessageDialog.openError(
            Display.getCurrent().getActiveShell(),
            Messages.getString("ExtractDocumentationAction.fileErrorTitle"), // $NON-NLS-1$
            Messages.getString("ExtractDocumentationAction.fileErrorMessages")); // $NON-NLS-1$
        return;
      }

      initialFileName = linkDocItem.getName();
      if (linkDocItem.getExtension() != null) {
        initialExtension = linkDocItem.getExtension();
      }
    }
    if (initialFileName != null) {
      FileDialog fileDlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);

      if (initialExtension != null) {
        initialFileName = initialFileName + LinkUtils.DOT + initialExtension; // $NON-NLS-1$
        fileDlg.setFilterExtensions(
            new String[] {"*." + initialExtension, "*.*"}); // $NON-NLS-1$ //$NON-NLS-2$
      }
      fileDlg.setFileName(initialFileName);
      String filename = fileDlg.open();
      if (filename != null) {
        final File file = new File(filename);

        ProgressDialog progressDialog =
            new ProgressDialog(Display.getCurrent().getActiveShell()) {

              @Override
              public void run(IProgressMonitor monitor)
                  throws InvocationTargetException, InterruptedException {
                try {
                  if (item instanceof DocumentationItem) {
                    DocumentationItem documentationItem = (DocumentationItem) item;
                    documentationItem.getContent().setInnerContentToFile(file);
                  } else if (item instanceof LinkDocumentationItem) { // link documenation
                    LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
                    ByteArray byteArray = LinkDocumentationHelper.getLinkItemContent(linkDocItem);
                    if (byteArray != null) {
                      byteArray.setInnerContentToFile(file);
                    }
                  }

                } catch (IOException ioe) {
                  MessageBoxExceptionHandler.process(ioe);
                }
              }
            };
        try {
          progressDialog.executeProcess();
        } catch (InvocationTargetException e) {
          ExceptionHandler.process(e);
        } catch (InterruptedException e) {
          // Nothing to do
        }
      }
    }
  }
  @Override
  public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    String[] oracleCompNames = {
      "tOracleBulkExec",
      "tOracleClose",
      "tOracleCommit",
      "tOracleConnection",
      "tOracleInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
      "tOracleOutput",
      "tOracleOutputBulk",
      "tOracleOutputBulkExec",
      "tOracleRollback",
      "tOracleRow",
      "tOracleSCD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                    // //$NON-NLS-6$
      "tOracleSCDELT",
      "tOracleSP",
      "tOracleTableList",
      "tAmazonOracleClose",
      "tAmazonOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
      "tAmazonOracleConnection",
      "tAmazonOracleInput",
      "tAmazonOracleOutput",
      "tAmazonOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
      "tAmazonOracleRow",
      "tMondrianInput",
      "tCreateTable",
      "tOracleInvalidRows", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
      "tOracleValidRows",
      "tELTOracleMap",
      "tOracleCDC",
      "tOracleSCDELT"
    }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

    IComponentConversion changeOracleDriverJarType =
        new IComponentConversion() {

          public void transform(NodeType node) {
            ElementParameterType dbVersion =
                ComponentUtilities.getNodeProperty(node, "DB_VERSION"); // $NON-NLS-1$
            if (dbVersion != null) {
              String jarValue = dbVersion.getValue();
              if ("ojdbc6.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$
                dbVersion.setValue("ORACLE_11-6"); // $NON-NLS-1$
              } else if ("ojdbc5.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$
                dbVersion.setValue("ORACLE_11"); // $NON-NLS-1$
              } else if ("ojdbc14.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$
                dbVersion.setValue("ORACLE_10"); // $NON-NLS-1$
              } else if ("ojdbc14-9i.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$
                dbVersion.setValue("ORACLE_9"); // $NON-NLS-1$
              } else if ("ojdbc12.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$
                dbVersion.setValue("ORACLE_8"); // $NON-NLS-1$
              }
            }
          }
        };

    for (String name : oracleCompNames) {
      IComponentFilter filter = new NameComponentFilter(name);

      try {
        ModifyComponentsAction.searchAndModify(
            item,
            processType,
            filter,
            Arrays.<IComponentConversion>asList(changeOracleDriverJarType));
      } catch (PersistenceException e) {
        // TODO Auto-generated catch block
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
      }
    }

    return ExecutionResult.SUCCESS_NO_ALERT;
  }
  /**
   * change .sh & .bat file's contents
   *
   * @throws FileNotFoundException
   */
  private void changeScriptFile(File file) {
    // change batFile
    BufferedReader br = null;
    BufferedWriter bw = null;
    try {
      br = new BufferedReader(new FileReader(file));
      StringBuffer changedContent = new StringBuffer();

      // write all the lines before the java command
      String line = br.readLine();
      while (line != null
          && !line.contains("java")) { // $NON-NLS-N$  hywang modify for 6484 //$NON-NLS-1$
        changedContent.append(line + "\n"); // $NON-NLS-1$
        line = br.readLine();
      }
      if (line == null) line = "";
      // get java command line
      String line1 = line.trim();
      String[] strs = line1.split("\\s"); // $NON-NLS-1$
      int pos = -1;
      for (int i = 0; i < strs.length; i++) {
        if ("-cp".equalsIgnoreCase(strs[i])
            || "-classpath".equalsIgnoreCase(strs[i])) { // $NON-NLS-1$ //$NON-NLS-2$
          pos = i;
        }
      }
      if (pos != -1) {
        if (file.getName().endsWith(".sh")) { // $NON-NLS-1$
          strs[pos + 1] = CLASSPATH_JAR + ":"; // $NON-NLS-1$
        }
        if (file.getName().endsWith(".bat")) { // $NON-NLS-1$
          // bug 21473
          needModuleJarStrs = strs[pos + 1];
          strs[pos + 1] = CLASSPATH_JAR + ";"; // $NON-NLS-1$
        }
      }

      for (String s : strs) {
        changedContent.append(s).append(" "); // $NON-NLS-1$
      }
      // see bug 7181. add addition lines
      String line2 = br.readLine();
      while (line2 != null) {
        changedContent.append(('\n')).append(line2); // $NON-NLS-1$
        line2 = br.readLine();
      }
      bw = new BufferedWriter(new FileWriter(file));
      // rewrite the changed content to file
      bw.write(changedContent.toString());
      bw.flush();
      // br.close();
      // bw.close();
    } catch (Exception e) {
      ExceptionHandler.process(e);
    } finally {
      if (br != null) {
        try {
          br.close();
        } catch (IOException e) {
          ExceptionHandler.process(e);
        }
      }
      if (bw != null) {
        try {
          bw.close();
        } catch (IOException e) {
          ExceptionHandler.process(e);
        }
      }
    }
  }
  @Override
  public void run() {
    SaveAsBusinessModelWizard businessModelWizard = new SaveAsBusinessModelWizard(editorPart);

    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), businessModelWizard);
    if (dlg.open() == Window.OK) {

      try {

        BusinessProcessItem businessProcessItem = businessModelWizard.getBusinessProcessItem();

        IRepositoryNode repositoryNode =
            RepositoryNodeUtilities.getRepositoryNode(
                businessProcessItem.getProperty().getId(), false);

        // because step1, the fresh will unload the resource(EMF), so, assign a new one...
        businessProcessItem =
            (BusinessProcessItem) repositoryNode.getObject().getProperty().getItem();

        IWorkbenchPage page = getActivePage();

        DiagramResourceManager diagramResourceManager =
            new DiagramResourceManager(page, new NullProgressMonitor());
        IFile file = businessModelWizard.getTempFile();
        // Set readonly to false since created job will always be editable.
        RepositoryEditorInput newBusinessModelEditorInput =
            new RepositoryEditorInput(file, businessProcessItem);

        newBusinessModelEditorInput.setRepositoryNode(repositoryNode);

        // here really do the normal save as function
        IDocumentProvider provider =
            ((BusinessDiagramEditor) this.editorPart).getDocumentProvider();

        provider.aboutToChange(newBusinessModelEditorInput);
        provider.saveDocument(
            null,
            newBusinessModelEditorInput,
            provider.getDocument(this.editorPart.getEditorInput()),
            true);
        provider.changed(newBusinessModelEditorInput);

        // copy back from the *.business_diagram file to *.item file.
        // @see:BusinessDiagramEditor.doSave(IProgressMonitor progressMonitor)
        diagramResourceManager.updateFromResource(
            businessProcessItem, newBusinessModelEditorInput.getFile());

        // notice: here, must save it, save the item to disk, otherwise close the editor
        // without any modification, there won't save the
        // model again, so, will lost the graphic when reopen it.
        ProxyRepositoryFactory.getInstance().save(businessProcessItem);

        // close the old editor
        page.closeEditor(this.editorPart, false);

        // open the new editor, because at the same time, there will update the
        // jobSetting/componentSetting view
        IEditorPart openEditor =
            page.openEditor(newBusinessModelEditorInput, BusinessDiagramEditor.ID, true);

      } catch (Exception e) {
        MessageDialog.openError(
            Display.getCurrent().getActiveShell(),
            "Error",
            "Business model could not be saved" + " : " + e.getMessage());
        ExceptionHandler.process(e);
      }
    }
  }
  private int getColumnCount(
      String filename,
      String rowSep,
      String fieldSep,
      int limitRows,
      int headerRows,
      String escapeChar,
      String textEnclosure,
      EShadowProcessType fileType) {

    File config =
        new File(
            CorePlugin.getDefault()
                    .getPreferenceStore()
                    .getString(ITalendCorePrefConstants.FILE_PATH_TEMP)
                + "/conf.pl"); //$NON-NLS-1$
    if (config.exists()) {
      config.delete();
    }
    String modulepath = LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.PERL);
    FileWriter filewriter;
    String str = "0"; // $NON-NLS-1$
    File resultFile =
        new File(
            CorePlugin.getDefault()
                    .getPreferenceStore()
                    .getString(ITalendCorePrefConstants.FILE_PATH_TEMP)
                + "/result.txt"); //$NON-NLS-1$

    if (resultFile.exists()) {
      resultFile.delete();
    }

    try {
      filewriter = new FileWriter(config, true);
      switch (fileType) {
        case FILE_DELIMITED:
          filewriter.write("$conf{filename} = " + filename + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{row_separator} = " + rowSep + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{field_separator} = " + fieldSep + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{header} = " + headerRows + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{limit} = " + limitRows + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{result_file} =\'"
                  + resultFile.toString()
                  + "\';"); //$NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{type} = \'delimited\';"); // $NON-NLS-1$
          break;
        case FILE_CSV:
          filewriter.write("$conf{filename} = " + filename + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{row_separator} = " + rowSep + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{field_separator} = " + fieldSep + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{escape_char} = " + escapeChar + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{text_enclosure} = " + textEnclosure + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{header} = " + headerRows + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{limit} = " + limitRows + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{result_file} =\'"
                  + resultFile.toString()
                  + "\';"); //$NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{type} = \'CSV\';"); // $NON-NLS-1$
          break;
        default:
          break;
      }

      filewriter.close();
      modulepath = modulepath + "/column_counter_delimited.pl"; // $NON-NLS-1$
      StringBuffer out = new StringBuffer();
      StringBuffer err = new StringBuffer();

      IRunProcessService service =
          (IRunProcessService)
              GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
      service.perlExec(
          out,
          err,
          new Path(modulepath),
          null,
          Level.DEBUG,
          "",
          null,
          -1,
          -1,
          new String[] {
            "--conf=" //$NON-NLS-1$ //$NON-NLS-2$
                + config
          });

      FileReader filereader = new FileReader(resultFile);
      BufferedReader reader = new BufferedReader(filereader);
      str = reader.readLine();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      ExceptionHandler.process(e);
    } catch (ProcessorException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      ExceptionHandler.process(e);
    }
    return Integer.parseInt(str);
  }