Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.WorkspaceJob


   */
  private IProject createIProject(String name, final java.net.URI hdfsURI) {
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IProject project = workspace.getRoot().getProject(name);
    final IProjectDescription pd = workspace.newProjectDescription(name);
      WorkspaceJob operation = new WorkspaceJob("Adding HDFS Location") {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
        monitor.beginTask("Creating Project", 100);
        try {
          pd.setLocationURI(hdfsURI);
          project.create(pd, new SubProgressMonitor(monitor, 70));
          project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 30));
          RepositoryProvider.map(project, HDFSTeamRepositoryProvider.ID);
          return Status.OK_STATUS;
        } catch (final CoreException e) {
          logger.error("error found in creating HDFS site", e);
          Display.getDefault().syncExec(new Runnable(){
            public void run(){
              MessageDialog.openError(Display.getDefault().getActiveShell(),
                  "HDFS Error", "Unable to create HDFS site :"+e.getMessage());
            }
          });
          deleteServer(getServer(hdfsURI.toString()));
          return e.getStatus();
        } finally {
          monitor.done();
        }
      }
       };
    operation.setPriority(Job.LONG);
    operation.setUser(true);
    operation.setRule(project);
    operation.schedule();
    return project;
  }
View Full Code Here


            @Override
            public void run() {
                final IStatus[] errorStatus = new IStatus[1];
                errorStatus[0] = Status.OK_STATUS;
                final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus);
                WorkspaceJob job = new WorkspaceJob("refresh") { //$NON-NLS-1$

                    @SuppressWarnings("synthetic-access")
                    @Override
                    public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                        try {
                            op.run(monitor);
                            if (shell != null && !shell.isDisposed()) {
                                shell.getDisplay().asyncExec(new Runnable() {
                                    @Override
                                    public void run() {
                                        StructuredViewer viewer = getActionSite().getStructuredViewer();
                                        if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
                                            viewer.refresh();
                                        }
                                    }
                                });
                            }
                        } catch (InvocationTargetException e) {
                            String msg = NLS.bind(Messages.ToolRefreshActionProvider_invocationTargetExceptionMessage, getClass().getName(), e.getTargetException());
                            throw new CoreException(new Status(IStatus.ERROR, ToolPlugin.PLUGIN_ID, IStatus.ERROR, msg, e
                                    .getTargetException()));
                        } catch (InterruptedException e) {
                            return Status.CANCEL_STATUS;
                        }
                        return errorStatus[0];
                    }

                };
                ISchedulingRule rule = op.getRule();
                if (rule != null) {
                    job.setRule(rule);
                }
                job.setUser(true);
                job.schedule();
            }
        };
        refreshAction.setDisabledImageDescriptor(getImageDescriptor("icons/refresh_nav_disabled.gif"));//$NON-NLS-1$
        refreshAction.setImageDescriptor(getImageDescriptor("icons/refresh_nav_enabled.gif"));//$NON-NLS-1$
        refreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH);
View Full Code Here

     */
    public static void buildAllMavenProjectsinWorkspace()
    {
        final IProject[] mavenProjects = MavenManager.getMavenProjectManager().getWorkspaceProjects();

        WorkspaceJob job = new WorkspaceJob( "Building Maven Projects in Workspace" )
        {
            public IStatus runInWorkspace( IProgressMonitor monitor )
                throws CoreException
            {
                for ( int i = 0; i < mavenProjects.length; i++ )
                {
                    mavenProjects[i].build( IncrementalProjectBuilder.FULL_BUILD, monitor );
                }
                return Status.OK_STATUS;
            }
        };
        job.setUser( true );
        job.setRule( ResourcesPlugin.getWorkspace().getRoot() );
        job.schedule();
    }
View Full Code Here

   */
  public void release() {
   
    synchronized (fLock) {
      if (fCompilationUnit != null) {
        Job discarder = new WorkspaceJob(fClassname) {
          public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            try {
              if (DEBUG) {
                System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$
                System.out.println("(-) JSPTranslation [" + this + "] discarding CompilationUnit: " + fCompilationUnit); //$NON-NLS-1$ //$NON-NLS-2$
                System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$
              }
              fCompilationUnit.discardWorkingCopy();
            }
            catch (JavaModelException e) {
              // we're done w/ it anyway
            }
            return Status.OK_STATUS;
          }
        };
        discarder.schedule();
      }
    }
  }
View Full Code Here

        }

    }
    private void runOnWorkspaceJob(final boolean forceRefresh, final Runnable runAfter)
    {
      WorkspaceJob refreshJob = new WorkspaceJob(NLS.bind(Messages
                .getString("JSPModelProcessor.0"), _file)) { //$NON-NLS-1$
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor)
                    throws CoreException
            {
                RefreshRunnable runnable = new RefreshRunnable(forceRefresh);
                runnable.run(monitor);
                return Status.OK_STATUS;
            }
        };
        refreshJob.setSystem(true);
        refreshJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
        if (runAfter != null)
        {
            refreshJob.addJobChangeListener(new JobChangeAdapter()
            {
                @Override
                public void done(final IJobChangeEvent event)
                {
                    runAfter.run();
                }
            });
        }
        refreshJob.schedule();
    }
View Full Code Here

        }

    }
    private void runOnWorkspaceJob(final boolean forceRefresh, final Runnable runAfter)
    {
      WorkspaceJob refreshJob = new WorkspaceJob(NLS.bind(Messages
                .getString("JSPModelProcessor.0"), _file)) { //$NON-NLS-1$
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor)
                    throws CoreException
            {
                RefreshRunnable runnable = new RefreshRunnable(forceRefresh);
                runnable.run(monitor);
                return Status.OK_STATUS;
            }
        };
        refreshJob.setSystem(true);
        refreshJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
        if (runAfter != null)
        {
            refreshJob.addJobChangeListener(new JobChangeAdapter()
            {
                @Override
                public void done(final IJobChangeEvent event)
                {
                    runAfter.run();
                }
            });
        }
        refreshJob.schedule();
    }
View Full Code Here

   */
  public void release() {
   
    synchronized (fLock) {
      if (fCompilationUnit != null) {
        Job discarder = new WorkspaceJob(fClassname) {
          public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            try {
              if (DEBUG) {
                System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$
                System.out.println("(-) JSPTranslation [" + this + "] discarding CompilationUnit: " + fCompilationUnit); //$NON-NLS-1$ //$NON-NLS-2$
                System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$
              }
              fCompilationUnit.discardWorkingCopy();
            }
            catch (JavaModelException e) {
              // we're done w/ it anyway
            }
            return Status.OK_STATUS;
          }
        };
        discarder.schedule();
      }
    }
  }
View Full Code Here

      }
    };
    m_delta.accept(visitor);
    // run "Clean" job for found projects
    if (!projectsToBuild.isEmpty()) {
      WorkspaceJob cleanJob = new WorkspaceJob("GWT project rebuild") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
          for (IProject project : projectsToBuild) {
            project.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor());
          }
          return Status.OK_STATUS;
        }
      };
      cleanJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
      cleanJob.setUser(true);
      cleanJob.schedule();
    }
  }
View Full Code Here

    if (filename == null) {
      return;
    }
   
   
    Job job = new WorkspaceJob("Generate architecture graph") {
      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        monitor.beginTask("Loading architecture", IProgressMonitor.UNKNOWN);
       
        ArchitectureMappingModel model = null;
        try {
          model = ArchitectureMappingCache.getArchitectureMappingModel(project);
          if (model == null) {
            return Status.CANCEL_STATUS;
          }
        } catch (ArchMapperException e) {
          showErrorAsync("Error reading architecture: "+ e.getMessage());
          e.printStackTrace();
          return Status.CANCEL_STATUS;
        }
       
        monitor.beginTask("Generating graph definition file", IProgressMonitor.UNKNOWN);
       
        String def = new DotGraphExporter().getDotGraphDefinition(model.getArchitecture());
       
        File out = new File(filename);
        try {
          FileWriter writer = new FileWriter(out);
          writer.write(def);
          writer.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
       
        return Status.OK_STATUS;
      }
    };
   
    job.setUser(true);
    job.schedule();
    job.addJobChangeListener(new JobChangeAdapter() {
      @Override
      public void done(IJobChangeEvent event) {
        Display.getDefault().asyncExec(new Runnable() {
          public void run() {
            MessageDialog.openInformation(window.getShell(), "Finished",
View Full Code Here

    if (project == null) {
      Logger.log(ERROR, "Error finishing create-project installation. Could not obtain project from workspace: " + projectName);
      return;
    }
   
    new WorkspaceJob("Refreshing " + projectName) {
      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
        project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
        return Status.OK_STATUS;
      }
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.WorkspaceJob

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.