org.eclipse.core.resources.IWorkspaceRunnable Java Examples

The following examples show how to use org.eclipse.core.resources.IWorkspaceRunnable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PoolNotificationListener.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected IWorkspaceRunnable handlePoolRemoved(final ProcessConfigurationRepositoryStore processConfStore,
        final DiagramRepositoryStore diagramStore) {
    return new IWorkspaceRunnable() {

        @Override
        public void run(final IProgressMonitor arg0) throws CoreException {
            final Set<String> poolIds = diagramStore.getAllProcessIds();
            for (final IRepositoryFileStore file : processConfStore.getChildren()) {
                String id = file.getName();
                id = id.substring(0, id.lastIndexOf("."));
                if (!poolIds.contains(id)) {
                    file.delete();
                }
            }
        }
    };

}
 
Example #2
Source File: DiagnosticsCommand.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static void refreshDiagnostics(final ICompilationUnit target) {
	final JavaClientConnection connection = JavaLanguageServerPlugin.getInstance().getClientConnection();
	if (connection == null) {
		JavaLanguageServerPlugin.logError("The client connection doesn't exist.");
		return;
	}

	try {
		ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
			@Override
			public void run(IProgressMonitor monitor) throws CoreException {
				List<ICompilationUnit> units = getNonProjectCompilationUnits(target, monitor);
				for (ICompilationUnit unit : units) {
					publishDiagnostics(connection, unit, monitor);
				}
			}
		}, new NullProgressMonitor());
	} catch (CoreException e) {
		JavaLanguageServerPlugin.logException("Refresh Diagnostics for non-project Java files", e);
	}
}
 
Example #3
Source File: Storage2UriMapperJavaImpl.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private void doInitializeCache() throws CoreException {
	if(!isInitialized) {
		IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
			@Override
			public void run(IProgressMonitor monitor) throws CoreException {
				if(!isInitialized) {
					for(IProject project: workspace.getRoot().getProjects()) {
						if(project.isAccessible() && JavaProject.hasJavaNature(project)) {
							IJavaProject javaProject = JavaCore.create(project);
							updateCache(javaProject);
						}
					}
					isInitialized = true;
				}
			}
		};
		// while the tree is locked, workspace.run may not be used but we are sure that we do already
		// hold the workspace lock - save to just run the action code
		if (workspace.isTreeLocked()) {
			runnable.run(null);
		} else {
			workspace.run(runnable, null, IWorkspace.AVOID_UPDATE, null);
		}
	}
}
 
Example #4
Source File: SaveHelper.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public void saveEditors(final IRenameElementContext context) {
	new DisplayRunnable() {
		@Override
		protected void run() throws Exception {
			workspace.run(new IWorkspaceRunnable() {
				@Override
				public void run(IProgressMonitor monitor) throws CoreException {
					IWorkbenchPage workbenchPage = getWorkbenchPage(context);
					if (prefs.isSaveAllBeforeRefactoring()) 
						workbenchPage.saveAllEditors(false);
					else
						saveDeclaringEditor(context, workbenchPage);
				}
			}, new NullProgressMonitor());
		}
	}.syncExec();
	syncUtil.waitForBuild(null);
}
 
Example #5
Source File: TestsPdeAbapGitStagingUtil.java    From ADT_Frontend with MIT License 6 votes vote down vote up
protected IProject createDummyAbapProject(String projectName) throws CoreException{
	String destinationId = projectName;
	
	IDestinationDataWritable data = AdtDestinationDataFactory.newDestinationData(destinationId);
	data.setUser("TEST_DUMMY_USER"); 
	data.setClient("777"); 
	data.setLanguage("DE"); 
	data.setPassword("TEST_DUMMY_PW"); 
	
	String projectDestinationId = AdtProjectServiceFactory.createProjectService().createDestinationId(projectName);
	final IDestinationData destinationData = data.getReadOnlyClone(projectDestinationId);
	
	final IAbapProjectService abapProjectService = AdtProjectServiceFactory.createProjectService();
	//IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	final AbapProject[] projects = new AbapProject[1];
	workspace.run(new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			projects[0] = (AbapProject) abapProjectService.createAbapProject(projectName, destinationData, monitor);
		}
	}, new NullProgressMonitor());
	return projects[0].getProject();
}
 
Example #6
Source File: AbstractSyntaxProjectsManagerBasedTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
protected List<IProject> importProjects(Collection<String> paths, boolean deleteExistingFiles) throws Exception {
	final List<IPath> roots = new ArrayList<>();
	for (String path : paths) {
		File file = copyFiles(path, deleteExistingFiles);
		roots.add(Path.fromOSString(file.getAbsolutePath()));
	}
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			projectsManager.initializeProjects(roots, monitor);
		}
	};
	JavaCore.run(runnable, null, monitor);
	JobHelpers.waitForWorkspaceJobsToComplete(monitor);
	return Arrays.asList(ProjectUtils.getAllProjects());
}
 
Example #7
Source File: AbstractInvisibleProjectBasedTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
protected IProject importRootFolder(IPath rootPath, String triggerFile) throws Exception {
	if (StringUtils.isNotBlank(triggerFile)) {
		IPath triggerFilePath = rootPath.append(triggerFile);
		Preferences preferences = preferenceManager.getPreferences();
		preferences.setTriggerFiles(Arrays.asList(triggerFilePath));
	}
	final List<IPath> roots = Arrays.asList(rootPath);
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			projectsManager.initializeProjects(roots, monitor);
		}
	};
	JavaCore.run(runnable, null, monitor);
	waitForBackgroundJobs();
	String invisibleProjectName = ProjectUtils.getWorkspaceInvisibleProjectName(rootPath);
	return ResourcesPlugin.getWorkspace().getRoot().getProject(invisibleProjectName);
}
 
Example #8
Source File: AbstractProjectsManagerBasedTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
protected List<IProject> importProjects(Collection<String> paths, boolean deleteExistingFiles) throws Exception {
	final List<IPath> roots = new ArrayList<>();
	for (String path : paths) {
		File file = copyFiles(path, deleteExistingFiles);
		roots.add(Path.fromOSString(file.getAbsolutePath()));
	}
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			projectsManager.initializeProjects(roots, monitor);
		}
	};
	JavaCore.run(runnable, null, monitor);
	waitForBackgroundJobs();
	return WorkspaceHelper.getAllProjects();
}
 
Example #9
Source File: DotGraphView.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private IWorkspaceRunnable updateGraphRunnable(final File f) {
	if (!listenToDotContent
			&& !hasDotFileExtension(f.getAbsolutePath().toString())) {
		return null;
	}
	IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
		@Override
		public void run(final IProgressMonitor monitor)
				throws CoreException {
			if (updateGraph(f)) {
				currentFile = f;
			}
		}
	};
	return workspaceRunnable;
}
 
Example #10
Source File: JavaProjectHelper.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Removes all files in the project and sets the given classpath
 *
 * @param jproject
 *            The project to clear
 * @param entries
 *            The default class path to set
 * @throws CoreException
 *             Clearing the project failed
 */
public static void clear(final IJavaProject jproject, final IClasspathEntry[] entries) throws CoreException {
    performDummySearch();

    IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
        @Override
        public void run(IProgressMonitor monitor) throws CoreException {
            jproject.setRawClasspath(entries, null);

            IResource[] resources = jproject.getProject().members();
            for (int i = 0; i < resources.length; i++) {
                if (!resources[i].getName().startsWith(".")) {
                    resources[i].delete(true, null);
                }
            }
        }
    };
    ResourcesPlugin.getWorkspace().run(runnable, null);
}
 
Example #11
Source File: DialogPackageExplorer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
   * Set the selection and focus to the list of elements
   * @param elements the object to be selected and displayed
   */
  public void setSelection(final List<?> elements) {
      if (elements == null || elements.size() == 0)
          return;
try {
       ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
       	public void run(IProgressMonitor monitor) throws CoreException {
       		fPackageViewer.refresh();
               IStructuredSelection selection= new StructuredSelection(elements);
               fPackageViewer.setSelection(selection, true);
               fPackageViewer.getTree().setFocus();

               if (elements.size() == 1 && elements.get(0) instanceof IJavaProject)
                   fPackageViewer.expandToLevel(elements.get(0), 1);
           }
       }, ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
      } catch (CoreException e) {
       JavaPlugin.log(e);
      }
  }
 
Example #12
Source File: HybridMobileEngineTests.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testRemoveEngineUsingName() throws CoreException {
	final HybridMobileEngine[] engines = new HybridMobileEngine[2];
	engines[0] = new HybridMobileEngine("android", "6.0.0", null);
	engines[1] = new HybridMobileEngine("ios", "4.4.0", null);
	manager.updateEngines(engines);
	JobUtils.waitForIdle();

	// Run on a IWorkspaceRunnable because it needs to sync with the udpateEngines
	// call.
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			manager.removeEngine(engines[0].getName(), monitor, true);
			Widget w = WidgetModel.getModel(testproject.hybridProject()).getWidgetForRead();
			assertEquals(1, w.getEngines().size());
			assertEquals(1, manager.getEngines().length);
			checkEnginesPersistedCorrectly(new HybridMobileEngine[] { engines[1] });
		}
	};
	IWorkspace ws = ResourcesPlugin.getWorkspace();
	ISchedulingRule rule = ws.getRuleFactory().modifyRule(testproject.getProject());
	ws.run(runnable, rule, 0, new NullProgressMonitor());
}
 
Example #13
Source File: HybridMobileEngineTests.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testRemoveEngine() throws CoreException {
	final HybridMobileEngine[] engines = new HybridMobileEngine[2];
	engines[0] = new HybridMobileEngine("android", "6.0.0", null);
	engines[1] = new HybridMobileEngine("ios", "4.4.0", null);
	manager.updateEngines(engines);
	JobUtils.waitForIdle();

	// Run on a IWorkspaceRunnable because it needs to sync with the udpateEngines
	// call.
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			manager.removeEngine(engines[0], monitor, true);
			Widget w = WidgetModel.getModel(testproject.hybridProject()).getWidgetForRead();
			assertEquals(1, w.getEngines().size());
			checkEnginesPersistedCorrectly(new HybridMobileEngine[] { engines[1] });
		}
	};
	IWorkspace ws = ResourcesPlugin.getWorkspace();
	ISchedulingRule rule = ws.getRuleFactory().modifyRule(testproject.getProject());
	ws.run(runnable, rule, 0, new NullProgressMonitor());
}
 
Example #14
Source File: PythonBreakpointPage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Store the breakpoint properties.
 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
 */
@Override
public boolean performOk() {
    IWorkspaceRunnable wr = new IWorkspaceRunnable() {
        @Override
        public void run(IProgressMonitor monitor) throws CoreException {
            PyBreakpoint breakpoint = getBreakpoint();
            boolean delOnCancel = breakpoint.getMarker().getAttribute(ATTR_DELETE_ON_CANCEL) != null;
            if (delOnCancel) {
                // if this breakpoint is being created, remove the "delete on cancel" attribute
                // and register with the breakpoint manager
                breakpoint.getMarker().setAttribute(ATTR_DELETE_ON_CANCEL, (String) null);
                breakpoint.setRegistered(true);
            }
            doStore();
        }
    };
    try {
        ResourcesPlugin.getWorkspace().run(wr, null, 0, null);
    } catch (CoreException e) {
        PydevDebugPlugin.errorDialog("An exception occurred while saving breakpoint properties.", e); //$NON-NLS-1$
        PydevDebugPlugin.log(IStatus.ERROR, e.getLocalizedMessage(), e);
    }
    return super.performOk();
}
 
Example #15
Source File: LangProjectWizardTest.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
@After
public void tearDown() throws Exception {
	// Should undo all wizard actions
	ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			IProject project = EclipseUtils.getWorkspaceRoot().getProject(NEWPROJNAME);
			if(project.exists()) {
				project.delete(true, monitor);
			}
		}
	}, null);
	
	if(wizDialog != null) {
		wizDialog.close();
	}
}
 
Example #16
Source File: FileProcessOutputSink.java    From tlaplus with MIT License 6 votes vote down vote up
public synchronized void appendText(final String text)
{
    try
    {
        ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
            public void run(IProgressMonitor monitor) throws CoreException
            {
                // System.out.print(Thread.currentThread().getId() + " : " + message);
                outFile.appendContents(new ByteArrayInputStream(text.getBytes()), IResource.FORCE, monitor);
            }
        }, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());

        // if the console output is active, print to it
    } catch (CoreException e)
    {
        TLCActivator.logError("Error writing the TLC process output file for " + model.getName(), e);
    }

}
 
Example #17
Source File: ToolMarkersHelper.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
public void doAddErrorMarkers(Iterable<ToolSourceMessage> buildErrors, Location rootPath, IProgressMonitor pm)
		throws CoreException {
	documents.clear();
	
	ResourceUtils.getWorkspace().run(new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			for(ToolSourceMessage buildError : buildErrors) {
				if(pm.isCanceled()) {
					return;
				}
				addErrorMarkers(buildError, rootPath);
			}
		}
	}, ResourceUtils.getWorkspaceRoot(), IWorkspace.AVOID_UPDATE, pm);
}
 
Example #18
Source File: ProblemMarkerUpdater.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
protected void updateProblemMarkers() throws CoreException {
	// Review if this can run outside lock
	IFile[] files = ResourceUtils.getWorkspaceRoot().findFilesForLocationURI(location.toUri());
	if(files.length == 0) {
		return;
	}
	
	final IFile file = files[0];
	
	ResourceUtils.getWorkspace().run(new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			try {
				doCreateProblemMarkers(file);
			} catch(OperationCancellation e) {
				return;
			}
		}
	}, file, IWorkspace.AVOID_UPDATE, null);
}
 
Example #19
Source File: ResourceUtils.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
public static void connectResourceListener(IResourceChangeListener listener, 
		RunnableX<CoreException> initialUpdate, ISchedulingRule opRule, IOwner owner) {
	try {
		getWorkspace().run(new IWorkspaceRunnable() {
			@Override
			public void run(IProgressMonitor monitor) throws CoreException {
				getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
				initialUpdate.run();
			}
		}, opRule, IWorkspace.AVOID_UPDATE, null);
		
	} catch (CoreException ce) {
		EclipseCore.logStatus(ce);
		// This really should not happen, but still try to recover by registering the listener.
		getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
	}
	owner.bind(() -> ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener));
}
 
Example #20
Source File: TestsPdeAbapGitRepositoriesUtil.java    From ADT_Frontend with MIT License 6 votes vote down vote up
protected IProject createDummyAbapProject() throws CoreException{
	String projectName = "ABAPGIT_TEST_PROJECT";
	String destinationId = "ABAPGIT_TEST_PROJECT";
	
	IDestinationDataWritable data = AdtDestinationDataFactory.newDestinationData(destinationId);
	data.setUser("TEST_DUMMY_USER"); 
	data.setClient("777"); 
	data.setLanguage("DE"); 
	data.setPassword("TEST_DUMMY_PW"); 
	
	String projectDestinationId = AdtProjectServiceFactory.createProjectService().createDestinationId(projectName);
	final IDestinationData destinationData = data.getReadOnlyClone(projectDestinationId);
	
	final IAbapProjectService abapProjectService = AdtProjectServiceFactory.createProjectService();
	//IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	final AbapProject[] projects = new AbapProject[1];
	workspace.run(new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			projects[0] = (AbapProject) abapProjectService.createAbapProject(projectName, destinationData, monitor);
		}
	}, new NullProgressMonitor());
	return projects[0].getProject();
}
 
Example #21
Source File: BaseDocumentLifeCycleHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public void didSave(DidSaveTextDocumentParams params) {
	ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
	try {
		JobHelpers.waitForJobs(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, new NullProgressMonitor());
		ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
			@Override
			public void run(IProgressMonitor monitor) throws CoreException {
				handleSaved(params);
			}
		}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
	} catch (CoreException e) {
		JavaLanguageServerPlugin.logException("Handle document save ", e);
	}
}
 
Example #22
Source File: ExternalFileAnnotationModel.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void deleteMarkers(final IMarker[] markers) throws CoreException
{
	ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable()
	{
		public void run(IProgressMonitor monitor) throws CoreException
		{
			for (int i = 0; i < markers.length; ++i)
			{
				markers[i].delete();
			}
		}
	}, null, IWorkspace.AVOID_UPDATE, null);
}
 
Example #23
Source File: AddResourcesToClientBundleAction.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void addResourcesToClientBundle(IType clientBundle,
    List<ClientBundleResource> resources) throws CoreException {
  IWorkspaceRunnable op = new AddResourcesJob(clientBundle, resources);
  // Need to lock on the package fragment since we might have to create new
  // CssResource subtypes in addition to the ClientBundle interface.
  ISchedulingRule lock = clientBundle.getPackageFragment().getResource();
  ResourcesPlugin.getWorkspace().run(op, lock, IWorkspace.AVOID_UPDATE, null);
}
 
Example #24
Source File: SynchronizerSyncInfoCache.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void flushPendingStatuses()
{
	if (accessor.isFlushFeasible())
	{
		try {
			ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
				public void run(IProgressMonitor monitor) {
					accessor.flushPendingCacheWrites();
				}
			}, null);
		} catch (CoreException e) {
			SVNProviderPlugin.log(SVNException.wrapException(e));
		}
	}
}
 
Example #25
Source File: SVNHistoryPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private IAction getGetContentsAction() {
  if(getContentsAction == null) {
    getContentsAction = getContextMenuAction(Policy.bind("HistoryView.getContentsAction"), new IWorkspaceRunnable() { //$NON-NLS-1$
          public void run(IProgressMonitor monitor) throws CoreException {
            ISelection selection = getSelection();
            if( !(selection instanceof IStructuredSelection))
              return;
            IStructuredSelection ss = (IStructuredSelection) selection;
            ISVNRemoteFile remoteFile = (ISVNRemoteFile) getLogEntry(ss).getRemoteResource();
            monitor.beginTask(null, 100);
            try {
              if(remoteFile != null) {
                if(confirmOverwrite()) {
              	if (remoteFile instanceof RemoteResource) {
              		if (resource != null) {
              			ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
              			((RemoteResource)remoteFile).setPegRevision(localResource.getRevision());
              		} else {
              			((RemoteResource)remoteFile).setPegRevision(SVNRevision.HEAD);
              		}
              	}
                  InputStream in = ((IResourceVariant) remoteFile).getStorage(new SubProgressMonitor(monitor, 50))
                      .getContents();
                  IFile file = (IFile) resource;
                  file.setContents(in, false, true, new SubProgressMonitor(monitor, 50));
                }
              }
            } catch(TeamException e) {
              throw new CoreException(e.getStatus());
            } finally {
              monitor.done();
            }
          }
        });
    PlatformUI.getWorkbench().getHelpSystem().setHelp(getContentsAction, IHelpContextIds.GET_FILE_CONTENTS_ACTION);
  }
  return getContentsAction;
}
 
Example #26
Source File: DynamicValidationStateChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
	final Change[] result= new Change[1];
	IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
		public void run(IProgressMonitor monitor) throws CoreException {
			result[0]= DynamicValidationStateChange.super.perform(monitor);
		}
	};
	JavaCore.run(runnable, fSchedulingRule, pm);
	return result[0];
}
 
Example #27
Source File: GenerateHashCodeEqualsAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
IWorkspaceRunnable createOperation(Object[] selectedBindings, CodeGenerationSettings settings, boolean regenerate, IJavaElement type, IJavaElement elementPosition) {
	final IVariableBinding[] selectedVariableBindings= Arrays.asList(selectedBindings).toArray(new IVariableBinding[0]);
	HashCodeEqualsGenerationSettings hashCodeEqualsGenerationSettings= (HashCodeEqualsGenerationSettings)settings;
	GenerateHashCodeEqualsOperation operation= new GenerateHashCodeEqualsOperation(fTypeBinding, selectedVariableBindings, fUnit, elementPosition, settings,
			hashCodeEqualsGenerationSettings.useInstanceOf, regenerate, true, false);
	operation.setUseBlocksForThen(hashCodeEqualsGenerationSettings.useBlocks);
	return operation;
}
 
Example #28
Source File: RefreshAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run(final IStructuredSelection selection) {
	IWorkspaceRunnable operation= new IWorkspaceRunnable() {
		public void run(IProgressMonitor monitor) throws CoreException {
			performRefresh(selection, monitor);
		}
	};
	new WorkbenchRunnableAdapter(operation).runAsUserJob(ActionMessages.RefreshAction_refresh_operation_label, null);
}
 
Example #29
Source File: ReferenceRefresher.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void refreshUiXml(final IFile uiXmlFile) {
  try {
    // Lock it
    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
      public void run(IProgressMonitor monitor) throws CoreException {
        refreshUiXmlUnsafe(uiXmlFile);
      }
    }, uiXmlFile, 0, null);
  } catch (CoreException e) {
    GWTPluginLog.logError(e, "Could not refresh {0}.",
        uiXmlFile.getLocation().toOSString());
  }
}
 
Example #30
Source File: JavaCompilerPropertyPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
 */
@Override
public boolean performOk() {
	if (fIsValidElement && fIgnoreOptionalProblemsField.isSelected() != isIgnoringOptionalProblems()) {
		String newValue= fIgnoreOptionalProblemsField.isSelected() ? "true" : null; //$NON-NLS-1$
		fElement.setAttribute(IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, newValue);
		IWorkspaceRunnable runnable= getRunnable(getShell(), fProject, fElement.getClasspathEntry());
		WorkbenchRunnableAdapter op= new WorkbenchRunnableAdapter(runnable);
		op.runAsUserJob(PreferencesMessages.BuildPathsPropertyPage_job_title, null);
	}
	return true;
}