Package org.eclipse.core.runtime.jobs

Examples of org.eclipse.core.runtime.jobs.Job


      final CloudFoundryApplicationModule appModule = getExistingApplication();
      if (appModule != null && saveManifest != null && !saveManifest.isDisposed()) {
        if (MessageDialog.openConfirm(saveManifest.getShell(),
            Messages.ApplicationDetailsPart_TEXT_SAVE_MANIFEST,
            Messages.ApplicationDetailsPart_TEXT_SAVE_MANIFEST_BODY)) {
          Job job = new Job(NLS.bind(Messages.ApplicationDetailsPart_JOB_WRITE,
              appModule.getDeployedApplicationName())) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {

              try {
                // Update the bound service mappings so they
                // point
                // to
                // the updated services
                serverBehaviour.refreshApplicationBoundServices(appModule, monitor);

                ManifestParser parser = new ManifestParser(appModule, cloudServer);
                parser.write(monitor, null);
              }
              catch (CoreException ce) {
                errorStatus[0] = ce.getStatus();
                return errorStatus[0];
              }
              return Status.OK_STATUS;
            }
          };
          job.schedule();
        }
      }
      else {
        errorStatus[0] = CloudFoundryPlugin
            .getErrorStatus(Messages.ApplicationDetailsPart_ERROR_WRITE_TO_MANIFEST);
View Full Code Here


      setToolTipText(Messages.ProjectExplorerMenuFactory_LABEL_CONVERT_TOOLTIP);
      setEnabled(true);
    }

    public void run() {
      Job job = new Job(Messages.ProjectExplorerMenuFactory_JOB_ENABLE) {

        protected IStatus run(IProgressMonitor monitor) {

          new StandaloneFacetHandler(project).addFacet(monitor);
          return Status.OK_STATUS;
        }
      };

      job.setSystem(false);
      job.schedule();
    }
View Full Code Here

      setToolTipText(Messages.ProjectExplorerMenuFactory_LABEL_REMOVE_TOOLTIP);
      setEnabled(true);
    }

    public void run() {
      Job job = new Job(Messages.ProjectExplorerMenuFactory_JOB_DISABLE) {

        protected IStatus run(IProgressMonitor monitor) {

          new StandaloneFacetHandler(project).removeFacet();
          return Status.OK_STATUS;
        }
      };

      job.setSystem(false);
      job.schedule();
    }
View Full Code Here

        return false;
    }

    private void registerResourceListeners()
    {
        Job job = new Job("Initialising sigil resource listeners")
        {
            @Override
            protected IStatus run(IProgressMonitor monitor)
            {
                ResourcesPlugin.getWorkspace().addResourceChangeListener(
                    new ProjectResourceListener(projectManager),
                    ProjectResourceListener.EVENT_MASKS);
                return Status.OK_STATUS;
            }
        };
        job.setSystem(true);
        job.schedule();
    }
View Full Code Here

    public void run()
    {
        final Shell shell = findDisplay().getActiveShell();

        Job job = new Job("Resolving dependencies")
        {
            @Override
            protected IStatus run(IProgressMonitor monitor)
            {
                monitor.beginTask("", IProgressMonitor.UNKNOWN);

                List<IPackageImport> imports = JavaHelper.findRequiredImports(project,
                    monitor);

                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
               
                if (imports.isEmpty())
                {
                    info(shell, "No new dependencies found");
                }
                else
                {
                    Collections.sort(imports, new Comparator<IPackageImport>()
                    {
                        public int compare(IPackageImport o1, IPackageImport o2)
                        {
                            int i = o1.getPackageName().compareTo(o2.getPackageName());

                            // shouldn't get more than one import for same package
                            // but may as well sort if do...
                            if (i == 0)
                            {
                                i = o1.getVersions().getFloor().compareTo(
                                    o2.getVersions().getFloor());
                            }

                            return i;
                        }
                    });

                    final ResourceReviewDialog<IPackageImport> dialog = new ResourceReviewDialog<IPackageImport>(
                        shell, "Review New Dependencies", imports);
                    shell.getDisplay().asyncExec(new Runnable()
                    {
                        public void run()
                        {
                            if (!review || dialog.open() == Window.OK)
                            {
                                WorkspaceModifyOperation op = new WorkspaceModifyOperation()
                                {
                                    @Override
                                    protected void execute(IProgressMonitor monitor)
                                        throws CoreException
                                    {
                                        for (IPackageImport pi : dialog.getResources())
                                        {
                                            project.getBundle().getBundleInfo().addImport(
                                                pi);
                                        }

                                        project.save(monitor);
                                    }
                                };

                                SigilUI.runWorkspaceOperation(op, shell);
                            }
                        }
                    });
                }

                return Status.OK_STATUS;
            }
        };

        job.schedule();

        IProgressService p = PlatformUI.getWorkbench().getProgressService();
        p.showInDialog(shell, job);
    }
View Full Code Here

    @Override
    public void run()
    {
        final Shell shell = findDisplay().getActiveShell();

        Job job = new Job("Resolving imports")
        {

            @Override
            protected IStatus run(IProgressMonitor monitor)
            {
                Collection<IModelElement> unused = JavaHelper.findUnusedReferences(
                    project, monitor);

                if (monitor.isCanceled()) return Status.CANCEL_STATUS;
               
                if (unused.isEmpty())
                {
                    info(shell, "No unused references found");
                }
                else
                {
                    final ResourceReviewDialog<IModelElement> dialog = new ResourceReviewDialog<IModelElement>(
                        shell, "Review Unused Imports", unused);

                    shell.getDisplay().asyncExec(new Runnable()
                    {
                        public void run()
                        {
                            if (dialog.open() == Window.OK)
                            {
                                WorkspaceModifyOperation op = new WorkspaceModifyOperation()
                                {
                                    @Override
                                    protected void execute(IProgressMonitor monitor)
                                        throws CoreException
                                    {
                                        for (IModelElement e : dialog.getResources())
                                        {
                                            if (!project.getBundle().getBundleInfo().removeChild(
                                                e))
                                            {
                                                SigilCore.error("Failed to remove " + e);
                                            }
                                        }

                                        project.save(monitor);
                                    }
                                };

                                SigilUI.runWorkspaceOperation(op, shell);
                            }
                        }
                    });
                }

                return Status.OK_STATUS;
            }
        };

        job.schedule();

        IProgressService p = PlatformUI.getWorkbench().getProgressService();
        p.showInDialog(shell, job);
    }
View Full Code Here

        {
            ArrayList<Job> jobs = new ArrayList<Job>(background.size());
            for (Map.Entry<String, IJobRunnable> e : background.entrySet())
            {
                final IJobRunnable run = e.getValue();
                Job job = new Job(e.getKey())
                {
                    @Override
                    protected IStatus run(IProgressMonitor monitor)
                    {
                        return run.run(monitor);
                    }
                };
                job.schedule();
            }

            return jobs.toArray(new Job[jobs.size()]);
        }
    }
View Full Code Here

        }
       
        buf.insert(0, "Repository Path: ");
        repoPath.setText(buf.toString());

        job = new Job("Resolving " + element)
        {
            @Override
            protected IStatus run(IProgressMonitor progress)
            {
                try
View Full Code Here

                    {
                        exports.put(export.getPackageName(), export);
                    }
                }
            });
        Job findExportsJob = new Job("Find exports")
        {
            protected IStatus run(IProgressMonitor monitor)
            {
                return exportFinder.run(monitor);
            }
        };
        findExportsJob.setUser(true);
        findExportsJob.schedule();

        // Find imports from Java source
        Job findImportsJob = new Job("Find imports")
        {
            protected IStatus run(IProgressMonitor monitor)
            {
                IJavaProject javaProject = getProjectModel().getJavaModel();
                try
                {
                    IPackageFragment[] packages = javaProject.getPackageFragments();
                    for (IPackageFragment pkg : packages)
                    {
                        ICompilationUnit[] compilationUnits = pkg.getCompilationUnits();
                        for (ICompilationUnit compilationUnit : compilationUnits)
                        {
                            IImportDeclaration[] importDecls = compilationUnit.getImports();
                            for (IImportDeclaration importDecl : importDecls)
                            {
                                imports.add(getPackageName(importDecl));
                            }
                        }
                    }
                    return Status.OK_STATUS;
                }
                catch (JavaModelException e)
                {
                    return new Status(IStatus.ERROR, SigilUI.PLUGIN_ID, 0,
                        "Error finding imports", e);
                }
            }
        };
        findImportsJob.setUser(true);
        findImportsJob.schedule();

        // Wait for both jobs to complete
        try
        {
            findImportsJob.join();
            findExportsJob.join();
        }
        catch (InterruptedException e)
        {
            // Aborted, just do nothing
View Full Code Here

    }

    private static void log(final String message)
    {
        // do this in background to avoid deadlock with ui
        Job job = new Job("log")
        {
            @Override
            protected IStatus run(IProgressMonitor arg0)
            {
                BuildConsole console = findConsole();
                MessageConsoleStream stream = console.getMessageStream();
                stream.println(message);
                return Status.OK_STATUS;
            }
        };
        job.schedule();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.jobs.Job

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.