public static void executeImportModels(
      final EditorInputEMF alternative, final Resource[] resources, final boolean copy) {

    WorkspaceJob job =
        new WorkspaceJob("Copying models into alternative") {

          @Override
          public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {

            monitor.beginTask("Importing models into alternative", 6 * resources.length);

            if (copy) {
              ExplorerProjectPaths.copyEMFResources(alternative.getResource(), resources, monitor);
            }

            for (Resource resource : resources) {
              IFile f = ExplorerProjectPaths.getFileFromEmfResource(resource);
              alternative.addSubResource(f);
            }

            return new Status(IStatus.OK, Activator.PLUGIN_ID, "Copying models done.");
          }
        };

    job.setUser(true);
    job.schedule();
  }
Exemplo n.º 2
0
  /** do not call from within a job */
  protected void reevaluateFileChecks(final Set<CLRAnnotatedSourceFile> files) {
    final HashSet<ITypingCheck> checks = new HashSet<ITypingCheck>(knownChecks);
    WorkspaceJob op =
        new WorkspaceJob("Reevaluate Typing") {

          @Override
          public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {

            Map<IProject, Collection<CLRAnnotatedSourceFile>> groupedFiles = groupByProject(files);
            for (Entry<IProject, Collection<CLRAnnotatedSourceFile>> fileGroup :
                groupedFiles.entrySet()) {

              List<ITypingProvider> typingProviders =
                  TypingExtensionManager.getInstance().getTypingProviders(fileGroup.getKey());
              for (ITypingProvider typingProvider : typingProviders) {
                typingProvider.prepareReevaluation(fileGroup.getValue(), monitor);
              }
            }
            // TODO currently pretty inefficient. should store
            // association
            // of checks to projects or files more directly
            for (ITypingCheck check : checks) {
              if (files.contains(check.getFile()))
                evaluateChecks(
                    Collections.singleton(check),
                    check.getFile().getResource().getProject(),
                    monitor);
            }
            return Status.OK_STATUS;
          }
        };
    op.setUser(true);
    op.schedule();
  }
  public static void executeCreateModels(
      final EditorInputEMF alternative, final ModelType[] types) {

    WorkspaceJob job =
        new WorkspaceJob("Creating new models") {

          @Override
          public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {

            monitor.beginTask("Creating new models", 2 * types.length + 1);

            ResourceSet modelResSet = new ResourceSetImpl();
            ResourceSet diagramResSet = new ResourceSetImpl();

            ModelUtils.createModels(
                modelResSet, diagramResSet, alternative.getResource(), types, monitor);
            for (Resource res : modelResSet.getResources()) {
              alternative.addSubResource(ExplorerProjectPaths.getFileFromEmfResource(res));
            }

            monitor.subTask("Saving alternative");
            alternative.save();
            monitor.worked(1);

            // IFile repFile = ExplorerProjectPaths.getNonexistingSubFile(alternative.getResource(),
            // "model", ModelType.REPRESENTATIONS.getFileExtension());
            // ResourceUtils.createSystemDiagramRepresentation((SystemImpl)alternative.getModelRootObject(ModelType.SYSTEM.getToolchainFileID()), repFile, modelResSet);

            return new Status(IStatus.OK, Activator.PLUGIN_ID, "Creating new models done.");
          }
        };

    job.setUser(true);
    job.schedule();
  }
Exemplo n.º 4
0
  /** do not call from within a job */
  protected void reevaluateProjectChecks(final IProject project) {
    final HashSet<ITypingCheck> checks = new HashSet<ITypingCheck>(knownChecks);
    WorkspaceJob op =
        new WorkspaceJob("Reevaluate Typing") {

          @Override
          public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            List<ITypingProvider> typingProviders =
                TypingExtensionManager.getInstance().getTypingProviders(project);
            for (ITypingProvider typingProvider : typingProviders) {
              typingProvider.prepareReevaluationAll(monitor);
            }

            // TODO currently pretty inefficient. should store association
            // of checks to projects or files more directly
            LinkedList<ITypingCheck> toCheck = new LinkedList<ITypingCheck>();
            for (ITypingCheck check : checks) {
              if (check.getFile().getResource().getProject() == project) toCheck.add(check);
            }
            evaluateChecks(toCheck, project, monitor);

            return Status.OK_STATUS;
          }
        };
    op.setUser(true);
    op.schedule();
  }
Exemplo n.º 5
0
  public static void runTestCase(final IStructuredSelection selection, final Mode mode) {
    final WorkspaceJob job =
        new WorkspaceJob("Launching Robot Tests") {

          @Override
          public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {

            final Map<IResource, List<String>> resourcesMapping = new HashMap<>();

            final List<RobotCase> selectedTestCases =
                Selections.getElements(selection, RobotCase.class);
            for (final RobotCase robotCase : selectedTestCases) {
              final IResource suiteFile = robotCase.getSuiteFile().getFile();
              if (!resourcesMapping.containsKey(suiteFile)) {
                resourcesMapping.put(suiteFile, new ArrayList<String>());
              }
              resourcesMapping.get(suiteFile).add(robotCase.getName());
            }
            RobotLaunchConfiguration.createLaunchConfigurationForSelectedTestCases(resourcesMapping)
                .launch(mode.launchMgrName, monitor);

            return Status.OK_STATUS;
          }
        };
    job.setUser(false);
    job.schedule();
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.wizard.Wizard#performFinish()
   */
  @Override
  public boolean performFinish() {
    if (mainPage.getContainerFullPath().append(mainPage.getFileName()).getFileExtension() == null) {
      mainPage.setFileName(
          mainPage.getFileName() + '.' + GlobalParser.SUPPORTED_TTCN3_EXTENSIONS[1]);
    }
    final IFile newModule = mainPage.createNewFile();
    if (newModule != null) {
      try {
        if (optionsPage.isExcludeFromBuildSelected()) {
          newModule.setPersistentProperty(
              new QualifiedName(
                  FileBuildPropertyData.QUALIFIER,
                  FileBuildPropertyData.EXCLUDE_FROM_BUILD_PROPERTY),
              TRUE);
        }

        ProjectFileHandler pfHandler = new ProjectFileHandler(newModule.getProject());
        pfHandler.saveProjectSettings();
        newModule.touch(new NullProgressMonitor());

        WorkspaceJob refreshJob =
            new WorkspaceJob("Refreshing built resources") {
              @Override
              public IStatus runInWorkspace(final IProgressMonitor monitor) {
                boolean proceedingOK = SymbolicLinkHandler.createSymlinks(newModule);
                if (proceedingOK) {
                  proceedingOK = TITANBuilder.removeExecutable(newModule.getProject());
                }
                if (proceedingOK) {
                  proceedingOK = TITANBuilder.removeMakefile(newModule.getProject());
                }
                if (proceedingOK) {
                  TITANBuilder.invokeBuild(newModule.getProject());
                }

                return Status.OK_STATUS;
              }
            };
        refreshJob.setPriority(Job.LONG);
        refreshJob.setUser(false);
        refreshJob.setSystem(true);
        refreshJob.setProperty(
            IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
        refreshJob.schedule();

        selectAndRevealNewModule(newModule);
      } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
      }
    }
    return true;
  }
  private void show() {
    final IServerInternal server =
        (IServerInternal)
            ((SimpleUserNode) viewer.getTreeSelection().getFirstElement()).getRealObject();
    final RelationDataLoader dataLoader = new RelationDataLoader();
    WorkspaceJob loadDataAndShowWizardJob =
        new WorkspaceJob("Loading relations from server '" + server.getName() + "'") {
          @Override
          public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            final List<RelationData> relationData = dataLoader.loadData(server, monitor);
            if (!dataLoader.isCanceled()) {
              Collections.sort(relationData);

              monitor.done();
              Display.getDefault()
                  .syncExec(
                      new Runnable() {
                        public void run() {
                          if (relationData.size() > 0) {
                            LoadRelationsWizard loadRelationsWizard =
                                new LoadRelationsWizard(relationData);
                            loadRelationsWizard.init(
                                PlatformUI.getWorkbench(), viewer.getTreeSelection());

                            WizardDialog dialog =
                                new WizardDialog(
                                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                    loadRelationsWizard);
                            dialog.create();
                            dialog.open();
                          } else {
                            MessageDialog.openInformation(
                                Display.getDefault().getActiveShell(),
                                "Load relations",
                                "No relation was found in server '" + server.getName() + "'.");
                          }
                        }
                      });
              return Status.OK_STATUS;
            } else {
              return Status.CANCEL_STATUS;
            }
          }

          @Override
          protected void canceling() {
            dataLoader.setCanceled(true);
          }
        };

    loadDataAndShowWizardJob.setUser(true);
    loadDataAndShowWizardJob.schedule();
  }
Exemplo n.º 8
0
  /** do not call from within a job */
  public void recheckFiles(List<CLRAnnotatedSourceFile> files) {
    HashMap<IProject, List<CLRAnnotatedSourceFile>> orderedFiles =
        new HashMap<IProject, List<CLRAnnotatedSourceFile>>();
    for (CLRAnnotatedSourceFile file : files) {
      List<CLRAnnotatedSourceFile> projectFiles = orderedFiles.get(file.getResource().getProject());
      if (projectFiles == null) {
        projectFiles = new ArrayList<CLRAnnotatedSourceFile>();
        orderedFiles.put(file.getResource().getProject(), projectFiles);
      }
      projectFiles.add(file);
    }

    for (Entry<IProject, List<CLRAnnotatedSourceFile>> fileSet : orderedFiles.entrySet()) {
      WorkspaceJob op = new TypecheckFilesJob(fileSet.getKey(), fileSet.getValue(), this);
      op.setUser(true);
      op.schedule();
    }
  }
Exemplo n.º 9
0
 /** do not call from within a job */
 public void recheckProjects(IProject[] projects) {
   WorkspaceJob op = new TypecheckProjectJob(projects, this);
   op.setUser(true);
   op.schedule();
 }