@Override
  protected void doRun() {
    RepositoryNode routineNode = getCurrentRepositoryNode();

    if (isToolbar()) {
      if (routineNode != null && routineNode.getContentType() != ERepositoryObjectType.PIG_UDF) {
        routineNode = null;
      }
      if (routineNode == null) {
        routineNode = getRepositoryNodeForDefault(ERepositoryObjectType.PIG_UDF);
      }
    }
    RepositoryNode node = null;
    IPath path = null;
    if (!isToolbar()) {
      ISelection selection = getSelection();
      Object obj = ((IStructuredSelection) selection).getFirstElement();
      node = (RepositoryNode) obj;
      path = RepositoryNodeUtilities.getPath(node);
    }

    NewPigudfWizard routineWizard = new NewPigudfWizard(path);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), routineWizard);

    if (dlg.open() == Window.OK) {

      try {
        openRoutineEditor(routineWizard.getPigudf(), false);
      } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
      } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.Action#run()
   */
  @Override
  protected void doRun() {
    if (repositoryNode == null) {
      repositoryNode = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    }
    RoutineItem routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();

    // Property updatedProperty = null;
    // try {
    // updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(
    // new Project(ProjectManager.getInstance().getProject(routineItem)),
    // routineItem.getProperty().getId())
    // .getProperty();
    //
    // // repositoryNode.getObject().setProperty(updatedProperty);
    // } catch (PersistenceException e) {
    // ExceptionHandler.process(e);
    // }
    // routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();

    try {
      openRoutineEditor(routineItem, false);
      refresh(repositoryNode);
      CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
      CorePlugin.getDefault().getRunProcessService().updateLibraries(new HashSet<String>(), null);
    } catch (PartInitException e) {
      MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
      MessageBoxExceptionHandler.process(e);
    }
  }
예제 #3
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.Action#run()
   */
  protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();

    RepositoryNode node = (RepositoryNode) obj;
    CamelProcessItem processItem = (CamelProcessItem) node.getObject().getProperty().getItem();

    IWorkbenchPage page = getActivePage();

    try {
      CamelProcessEditorInput fileEditorInput =
          new CamelProcessEditorInput(processItem, true, null, true);
      checkUnLoadedNodeForProcess(fileEditorInput);
      IEditorPart editorPart = page.findEditor(fileEditorInput);

      if (editorPart == null) {
        fileEditorInput.setRepositoryNode(node);
        page.openEditor(fileEditorInput, CamelMultiPageTalendEditor.ID, true);
      } else {
        page.activate(editorPart);
      }
    } catch (PartInitException e) {
      MessageBoxExceptionHandler.process(e);
    } catch (PersistenceException e) {
      MessageBoxExceptionHandler.process(e);
    }
  }
 private boolean refreshNewJob() {
   if (alreadyEditedByUser) {
     return false;
   }
   IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
   try {
     repositoryFactory.save(getProperty(), this.originaleObjectLabel, this.originalVersion);
     ExpressionPersistance.getInstance()
         .jobNameChanged(originaleObjectLabel, repoObject.getLabel());
     ProxyRepositoryFactory.getInstance()
         .saveProject(ProjectManager.getInstance().getCurrentProject());
     return true;
   } catch (PersistenceException e) {
     MessageBoxExceptionHandler.process(e);
     return false;
   }
 }
예제 #5
0
  @Override
  public boolean performFinish() {
    final String destinationValue = mainPage.getDestinationValue();
    // TESB-7319: add confirm dialog
    if (new File(destinationValue).exists()) {
      boolean openQuestion =
          MessageDialog.openQuestion(
              getShell(),
              Messages.ServiceExportWizard_destinationExistTitle,
              Messages.ServiceExportWizard_destinationExistMessage);
      if (!openQuestion) {
        return false;
      }
    }
    // END TESB-7319

    Map<ExportChoice, Object> exportChoiceMap = mainPage.getExportChoiceMap();
    try {
      if (mainPage.isAddMavenScript()) {
        ServiceExportWithMavenManager mavenManager =
            new ServiceExportWithMavenManager(
                exportChoiceMap,
                IContext.DEFAULT,
                JobScriptsManager.LAUNCHER_ALL,
                IProcessor.NO_STATISTICS,
                IProcessor.NO_TRACES);
        IRunnableWithProgress action =
            new ExportServiceWithMavenAction(
                mavenManager, exportChoiceMap, serviceItem, destinationValue);
        getContainer().run(false, true, action);
      } else {
        IRunnableWithProgress action =
            new ExportServiceAction(serviceItem, destinationValue, exportChoiceMap);
        getContainer().run(true, true, action);
      }

      mainPage.finish();
    } catch (InvocationTargetException e) {
      MessageBoxExceptionHandler.process(e.getCause(), getShell());
      return false;
    } catch (InterruptedException e) {
      return false;
    }
    return true;
  }
  private void openedByBrowser(Item item, URL url) {
    if (url == null || item == null) {
      return;
    }

    WebBrowserEditorInput input = new WebBrowserEditorInput(url);
    // add for bug TDI-21189 at 2012-6-8,that a document exist is only opened one time in studio
    try {
      IWorkbenchPage page = getActivePage();
      IEditorReference[] iEditorReference = page.getEditorReferences();
      for (IEditorReference editors : iEditorReference) {
        if (WebBrowserEditor.WEB_BROWSER_EDITOR_ID.equals(editors.getId())) {
          IEditorPart iEditorPart = editors.getEditor(true);
          if (iEditorPart != null && iEditorPart instanceof WebBrowserEditor) {
            WebBrowserEditorInput webBrowserEditorInput =
                (WebBrowserEditorInput) iEditorPart.getEditorInput();
            if (webBrowserEditorInput != null && url.equals(webBrowserEditorInput.getURL())) {
              // page.activate(iEditorPart);
              iEditorPart.init(iEditorPart.getEditorSite(), webBrowserEditorInput);
              DocumentationUtil.setPartItemId(
                  (WebBrowserEditor) iEditorPart,
                  item.getProperty().getId(),
                  ERepositoryObjectType.getItemType(item));
              return;
            }
          }
        }
      }
      input.setName(item.getProperty().getLabel());
      input.setToolTipText(
          item.getProperty().getLabel() + " " + item.getProperty().getVersion()); // $NON-NLS-1$
      IEditorPart editorPart = page.openEditor(input, WebBrowserEditor.WEB_BROWSER_EDITOR_ID);
      if (editorPart != null && editorPart instanceof WebBrowserEditor) {
        DocumentationUtil.setPartItemId(
            (WebBrowserEditor) editorPart,
            item.getProperty().getId(),
            ERepositoryObjectType.getItemType(item));
      }
    } catch (PartInitException e) {
      MessageBoxExceptionHandler.process(e);
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.wizard.Wizard#performFinish()
   */
  @Override
  public boolean performFinish() {
    if (mainPage.isCreateNewVersionJob()) {

      IWorkspaceRunnable runnable =
          new IWorkspaceRunnable() {

            public void run(final IProgressMonitor monitor) throws CoreException {
              if (!alreadyEditedByUser) {
                getProperty().setVersion(mainPage.getNewVersion());
                refreshNewJob();
                try {
                  ProxyRepositoryFactory.getInstance()
                      .saveProject(ProjectManager.getInstance().getCurrentProject());
                } catch (Exception e) {
                  ExceptionHandler.process(e);
                }
              }

              try {
                ProxyRepositoryFactory.getInstance().lock(repoObject);
              } catch (PersistenceException e) {
                ExceptionHandler.process(e);
              } catch (LoginException e) {
                ExceptionHandler.process(e);
              }

              boolean locked =
                  repoObject.getRepositoryStatus().equals(ERepositoryStatus.LOCK_BY_USER);
              openAnotherVersion((RepositoryNode) repoObject.getRepositoryNode(), !locked);
              try {
                ProxyRepositoryFactory.getInstance()
                    .saveProject(ProjectManager.getInstance().getCurrentProject());
              } catch (Exception e) {
                ExceptionHandler.process(e);
              }
            }
          };
      IWorkspace workspace = ResourcesPlugin.getWorkspace();
      try {
        ISchedulingRule schedulingRule = workspace.getRoot();
        // the update the project files need to be done in the workspace
        // runnable to avoid all notification
        // of changes before the end of the modifications.
        workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, null);
      } catch (CoreException e) {
        MessageBoxExceptionHandler.process(e);
      }
    } else {
      StructuredSelection selection = (StructuredSelection) mainPage.getSelection();
      RepositoryNode node = (RepositoryNode) selection.getFirstElement();
      boolean lastVersion = node.getObject().getVersion().equals(repoObject.getVersion());
      repoObject.getProperty().setVersion(originalVersion);
      if (lastVersion) {
        lockObject(repoObject);
      }
      ERepositoryStatus status = node.getObject().getRepositoryStatus();
      boolean isLocked = false;
      if (status == ERepositoryStatus.LOCK_BY_USER) {
        isLocked = true;
      }

      // Only latest version can be editted
      openAnotherVersion(node, !lastVersion || !isLocked);
    }
    return true;
  }