Java Code Examples for org.eclipse.core.runtime.IProgressMonitor

The following examples show how to use org.eclipse.core.runtime.IProgressMonitor. These examples are extracted from open source projects. 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 Project: texlipse   Author: eclipse   File: TexlipseProjectCreationOperation.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create the project directory.
 * If the user has specified an external project location,
 * the project is created with a custom description for the location.
 * 
 * @param project project
 * @param monitor progress monitor
 * @throws CoreException
 */
private void createProject(IProject project, IProgressMonitor monitor)
        throws CoreException {

    monitor.subTask(TexlipsePlugin.getResourceString("projectWizardProgressDirectory"));
    
    if (!project.exists()) {
        if (attributes.getProjectLocation() != null) {
            IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
            IPath projectPath = new Path(attributes.getProjectLocation());
            IStatus stat = ResourcesPlugin.getWorkspace().validateProjectLocation(project, projectPath);
            if (stat.getSeverity() != IStatus.OK) {
                // should not happen. the location should have been checked in the wizard page
                throw new CoreException(stat);
            }
            desc.setLocation(projectPath);
            project.create(desc, monitor);
        } else {
            project.create(monitor);
        }
    }
    if (!project.isOpen()) {
        project.open(monitor);
    }
}
 
Example #2
Source Project: google-cloud-eclipse   Author: GoogleCloudPlatform   File: CreateAppEngineFlexWtpProject.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void addAdditionalDependencies(IProject newProject, AppEngineProjectConfig config,
    IProgressMonitor monitor) throws CoreException {
  super.addAdditionalDependencies(newProject, config, monitor);

  if (config.getUseMaven()) {
    return;
  }

  SubMonitor subMonitor = SubMonitor.convert(monitor, 100);

  // Create a lib folder
  IFolder libFolder = newProject.getFolder("lib"); //$NON-NLS-1$
  if (!libFolder.exists()) {
    libFolder.create(true, true, subMonitor.newChild(10));
  }

  // Download the dependencies from maven
  subMonitor.setWorkRemaining(SERVLET_DEPENDENCIES.size() + 10);
  for (MavenCoordinates dependency : SERVLET_DEPENDENCIES) {
    installArtifact(dependency, libFolder, subMonitor.newChild(1));
  }

  addDependenciesToClasspath(newProject, libFolder, subMonitor.newChild(10));
}
 
Example #3
Source Project: birt   Author: eclipse   File: BirtWizardUtil.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * extract zip file and import files into project
 * 
 * @param srcZipFile
 * @param destPath
 * @param monitor
 * @param query
 * @throws CoreException
 */
private static void importFilesFromZip( ZipFile srcZipFile, IPath destPath,
		IProgressMonitor monitor, IOverwriteQuery query )
		throws CoreException
{
	try
	{
		ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(
				srcZipFile );
		List list = prepareFileList( structureProvider, structureProvider
				.getRoot( ), null );
		ImportOperation op = new ImportOperation( destPath,
				structureProvider.getRoot( ), structureProvider, query,
				list );
		op.run( monitor );
	}
	catch ( Exception e )
	{
		String message = srcZipFile.getName( ) + ": " + e.getMessage( ); //$NON-NLS-1$
		Logger.logException( e );
		throw BirtCoreException.getException( message, e );
	}
}
 
Example #4
Source Project: elexis-3-core   Author: elexis   File: LazyCommonViewerContentProvider.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected void asyncReload(){
	Job job = Job.create(getJobName(), new ICoreRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException{
			loadedElements = getElements(null);
			Display.getDefault().asyncExec(() -> {
				// virtual table ...
				AbstractTableViewer viewer =
					(AbstractTableViewer) commonViewer.getViewerWidget();
				if (viewer != null && !viewer.getControl().isDisposed()) {
					viewer.setItemCount(loadedElements.length);
				}
				// trigger viewer refresh
				commonViewer.notify(Message.update);
			});
		}
	});
	job.setPriority(Job.SHORT);
	job.schedule();
}
 
Example #5
Source Project: xds-ide   Author: excelsior-oss   File: ExternalResourceManager.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private static final Collection<IStatus> linkExternalDirectories(IProject p, Collection<File> externalDirectories, IProgressMonitor monitor) throws CoreException {
	monitor.beginTask(Messages.ExternalResourceManager_LinkingExternalFiles, externalDirectories.size());
	
	Collection<IStatus> linkStatuses = new ArrayList<>();
	
	recreateExternalsFolder(p.getName(), monitor);
	IFolder externalsFolder = p.getFolder(SpecialFolderNames.VIRTUAL_MOUNT_ROOT_DIR_NAME);
	Path projectPath = new Path(ResourceUtils.getAbsolutePath(p));
	
	try{
		for (File dir : externalDirectories) {
			boolean isInsideProject = projectPath.isPrefixOf(new Path(dir.getAbsolutePath()));
			if (dir.isDirectory() && !isInsideProject) {
				linkStatuses.add(linkDirectory(p, externalsFolder, dir, monitor, true));
				monitor.worked(1);
			}
		}
	}
	finally{
		monitor.done();
	}
	
	return linkStatuses;
}
 
Example #6
Source Project: xtext-eclipse   Author: eclipse   File: BuilderParticipant.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void delete(IResource resource, OutputConfiguration config, EclipseResourceFileSystemAccess2 access,
		IProgressMonitor monitor) throws CoreException {
	if (monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	if (resource instanceof IContainer) {
		IContainer container = (IContainer) resource;
		for (IResource child : container.members()) {
			delete(child, config, access, monitor);
		}
		container.delete(IResource.FORCE | IResource.KEEP_HISTORY, monitor);
	} else if (resource instanceof IFile) {
		IFile file = (IFile) resource;
		access.deleteFile(file, config.getName(), monitor);
	} else {
		resource.delete(IResource.FORCE | IResource.KEEP_HISTORY, monitor);
	}
}
 
Example #7
Source Project: gwt-eclipse-plugin   Author: gwt-plugins   File: ChangeUtilities.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a {@link Change} from the given {@link Refactoring}.
 * 
 * @param errorLevel the error level for the condition checking which should
 *          cause the change creation to fail
 * 
 * @return a non-null {@link Change}
 * @throws RefactoringException if there was a problem creating the change
 */
public static Change createChange(IWorkspace workspace, IProgressMonitor pm,
    Refactoring refactoring, int errorLevel) throws RefactoringException {
  CreateChangeOperation createChangeOperation = ChangeUtilities.createCreateChangeOperation(
      refactoring, errorLevel);
  try {
    workspace.run(createChangeOperation, pm);

    RefactoringStatus status = createChangeOperation.getConditionCheckingStatus();
    if (status.getSeverity() >= errorLevel) {
      // Could not create the change, throw an exception with the failure
      // status message
      throw new RefactoringException(
          status.getMessageMatchingSeverity(status.getSeverity()));
    }
  } catch (CoreException e) {
    throw new RefactoringException(e);
  }

  return createChangeOperation.getChange();
}
 
Example #8
Source Project: Flashtool   Author: Androxyde   File: APKInstallJob.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected IStatus run(IProgressMonitor monitor) {
 	try {
File files = new File(instpath);
File[] chld = files.listFiles(new APKFilter());
LogProgress.initProgress(chld.length);
for(int i = 0; i < chld.length; i++){
	if (chld[i].getName().toUpperCase().endsWith(".APK"))
		AdbUtility.install(chld[i].getPath());
	LogProgress.updateProgress();
}
LogProgress.initProgress(0);
logger.info("APK Installation finished");
return Status.OK_STATUS;
 	}
 	catch (Exception e) {
 		e.printStackTrace();
 		logger.error(e.getMessage());
 		LogProgress.initProgress(0);
 		return Status.CANCEL_STATUS;
 	}
 }
 
Example #9
Source Project: RADL   Author: restful-api-description-language   File: RadlCreator.java    License: Apache License 2.0 6 votes vote down vote up
public IFile createRadlFile(String folderName, String serviceName, IProgressMonitor monitor,
    IWorkspaceRoot root) throws CoreException {
  IFolder folder = root.getFolder(new Path(folderName));
  if (!folder.exists()) {
    ensureFolder(monitor, folder);
  }
  final IFile result = folder.getFile(serviceNameToFileName(serviceName));
  try (InputStream stream = getRadlSkeleton(serviceName)) {
    if (result.exists()) {
      result.setContents(stream, true, true, monitor);
    } else {
      result.create(stream, true, monitor);
    }
  } catch (IOException e) { // NOPMD EmptyCatchBlock
  }
  IProjectNature nature = new RadlNature();
  nature.setProject(folder.getProject());
  nature.configure();
  return result;
}
 
Example #10
Source Project: sarl   Author: sarl   File: SARLRuntime.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the listing of currently installed SREs as a single XML file.
 *
 * @param monitor monitor on the XML building.
 * @return an XML representation of all of the currently installed SREs.
 * @throws CoreException if trying to compute the XML for the SRE state encounters a problem.
 */
public static String getSREsAsXML(IProgressMonitor monitor) throws CoreException {
	initializeSREs();
	try {
		final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		final DocumentBuilder builder = factory.newDocumentBuilder();
		final Document xmldocument = builder.newDocument();
		final Element rootElement = getXml(xmldocument);
		xmldocument.appendChild(rootElement);
		final TransformerFactory transFactory = TransformerFactory.newInstance();
		final Transformer trans = transFactory.newTransformer();
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
			final DOMSource source = new DOMSource(xmldocument);
			final PrintWriter flot = new PrintWriter(baos);
			final StreamResult xmlStream = new StreamResult(flot);
			trans.transform(source, xmlStream);
			return new String(baos.toByteArray());
		}
	} catch (Throwable e) {
		throw new CoreException(SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, e));
	}
}
 
Example #11
Source Project: xtext-eclipse   Author: eclipse   File: ProjectFactory.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected IFile createFile(final String name, final IContainer container, final String content,
		final IProgressMonitor progressMonitor) {
	final IFile file = container.getFile(new Path(name));
	createRecursive(file.getParent());
	SubMonitor subMonitor = SubMonitor.convert(progressMonitor, 1);
	try {
		final InputStream stream = new ByteArrayInputStream(content.getBytes(file.getCharset()));
		if (file.exists()) {
			logger.debug("Overwriting content of '" + file.getFullPath() + "'");
			file.setContents(stream, true, true, subMonitor.newChild(1));
		} else {
			file.create(stream, true, subMonitor.newChild(1));
		}
		stream.close();
	} catch (final Exception e) {
		logger.error(e.getMessage(), e);
	} finally {
		subMonitor.done();
	}
	return file;
}
 
Example #12
Source Project: APICloud-Studio   Author: apicloudcom   File: UnlockResourcesCommand.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void run(IProgressMonitor monitor) throws SVNException {
      final ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
      
      final File[] resourceFiles = new File[resources.length];
      for (int i = 0; i < resources.length;i++)
          resourceFiles[i] = resources[i].getLocation().toFile(); 
      
      try {
          monitor.beginTask(null, 100);
          
          svnClient.addNotifyListener(operationResourceCollector);
          
          OperationManager.getInstance().beginOperation(svnClient);

          svnClient.unlock(resourceFiles, force);
      } catch (SVNClientException e) {
          throw SVNException.wrapException(e);
      } finally {
      	Set<IResource> operationResources = operationResourceCollector.getOperationResources();
          OperationManager.getInstance().endOperation(true, operationResources);
          svnClient.removeNotifyListener(operationResourceCollector);
          root.getRepository().returnSVNClient(svnClient);
          monitor.done();
      }
}
 
Example #13
Source Project: Pydev   Author: fabioz   File: ModulesManagerWithBuild.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * removes all the modules that have the module starting with the name of the module from
 * the specified file.
 */
private void removeModulesBelow(File file, IProject project, IProgressMonitor monitor) {
    if (file == null) {
        return;
    }

    String absolutePath = FileUtils.getFileAbsolutePath(file);
    List<ModulesKey> toRem = new ArrayList<ModulesKey>();

    synchronized (modulesKeysLock) {

        for (ModulesKey key : modulesKeys.keySet()) {
            if (key.file != null && FileUtils.getFileAbsolutePath(key.file).startsWith(absolutePath)) {
                toRem.add(key);
            }
        }

        removeThem(toRem);
    }
}
 
Example #14
Source Project: xtext-eclipse   Author: eclipse   File: IResourcesSetupUtil.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public static void setReference(final IProject from, final IProject to)
		throws CoreException, InvocationTargetException,
		InterruptedException {
	new WorkspaceModifyOperation() {

		@Override
		protected void execute(IProgressMonitor monitor)
				throws CoreException, InvocationTargetException,
				InterruptedException {
			IProjectDescription projectDescription = from.getDescription();
			IProject[] projects = projectDescription
					.getReferencedProjects();
			IProject[] newProjects = new IProject[projects.length + 1];
			System.arraycopy(projects, 0, newProjects, 0, projects.length);
			newProjects[projects.length] = to;
			projectDescription.setReferencedProjects(newProjects);
			from.setDescription(projectDescription, monitor());
		}
	}.run(monitor());
}
 
Example #15
Source Project: birt   Author: eclipse   File: IDEOpenSampleReportAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void refreshReportProject( final IProject project )
{
	WorkspaceModifyOperation op = new WorkspaceModifyOperation( ) {

		protected void execute( IProgressMonitor monitor )
				throws CoreException
		{
			project.refreshLocal( IResource.DEPTH_INFINITE, monitor );
		}
	};

	try
	{
		new ProgressMonitorDialog( composite.getShell( ) ).run( false,
				true,
				op );
	}
	catch ( Exception e )
	{
		ExceptionUtil.handle( e );
	}
}
 
Example #16
Source Project: Pydev   Author: fabioz   File: TreeSelectionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected void setFilter(String text, IProgressMonitor monitor, boolean updateFilterMatcher) {
    synchronized (lock) {
        if (monitor.isCanceled()) {
            return;
        }

        if (updateFilterMatcher) {
            //just so that subclasses may already treat it.
            if (fFilterMatcher.lastPattern.equals(text)) {
                //no actual change...
                return;
            }
            fFilterMatcher.setFilter(text);
            if (monitor.isCanceled()) {
                return;
            }
        }

        TreeViewer treeViewer = getTreeViewer();
        Tree tree = treeViewer.getTree();
        tree.setRedraw(false);
        tree.getParent().setRedraw(false);
        try {
            if (monitor.isCanceled()) {
                return;
            }
            treeViewer.refresh();
            if (monitor.isCanceled()) {
                return;
            }
            treeViewer.expandAll();
        } finally {
            tree.setRedraw(true);
            tree.getParent().setRedraw(true);
        }
    }
}
 
Example #17
Source Project: google-cloud-eclipse   Author: GoogleCloudPlatform   File: DataflowMavenModel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the Dataflow Dependency of this model to the LATEST version value.
 */
@Deprecated
public void trackDataflowDependency(IProgressMonitor monitor) throws CoreException {
  try {
    editPom(
        new SetDataflowDependencyVersion(
            VersionRange.createFromVersion(Artifact.LATEST_VERSION)));
  } catch (IOException e) {
    throw new CoreException(new Status(Status.ERROR, DataflowCorePlugin.PLUGIN_ID,
        "Exception when trying to track Dataflow Dependency", e));
  }
}
 
Example #18
Source Project: bonita-studio   Author: bonitasoft   File: StartSignalEventCreateCommand.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void doConfigure(StartSignalEvent newElement, IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
	ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
	configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
	configureRequest.addParameters(getRequest().getParameters());
	ICommand configureCommand = elementType.getEditCommand(configureRequest);
	if (configureCommand != null && configureCommand.canExecute()) {
		configureCommand.execute(monitor, info);
	}
}
 
Example #19
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	IntermediateCatchTimerEvent newElement = ProcessFactory.eINSTANCE.createIntermediateCatchTimerEvent();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_IntermediateCatchTimerEvent_3017(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #20
Source Project: APICloud-Studio   Author: apicloudcom   File: GenerateDiffFileSynchronizeOperation.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	SyncInfoSet syncSet = getSyncInfoSet();
	final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
	Iterator iter = projectSyncInfos.keySet().iterator();
	final IProject project = (IProject) iter.next();
	SVNTeamProvider provider = (SVNTeamProvider)RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
	monitor.beginTask(null, projectSyncInfos.size() * 100);
	run(provider, syncSet, Policy.subMonitorFor(monitor,100));
	monitor.done();
}
 
Example #21
Source Project: sarl   Author: sarl   File: SarlBatchCompiler.java    License: Apache License 2.0 5 votes vote down vote up
/** Check the compiler configuration; and logs errors.
 *
 * @param progress monitor of the progress of the compilation.
 * @return success status. Replies <code>false</code> if the operation is canceled.
 */
protected boolean checkConfiguration(IProgressMonitor progress) {
	assert progress != null;
	progress.subTask(Messages.SarlBatchCompiler_55);
	final File output = getOutputPath();
	if (getLogger().isLoggable(Level.FINEST)) {
		getLogger().finest(MessageFormat.format(Messages.SarlBatchCompiler_35, output));
	}
	if (output == null) {
		reportInternalError(Messages.SarlBatchCompiler_36);
		return false;
	}
	progress.subTask(Messages.SarlBatchCompiler_56);
	for (final File sourcePath : getSourcePaths()) {
		if (progress.isCanceled()) {
			return false;
		}
		try {
			if (getLogger().isLoggable(Level.FINEST)) {
				getLogger().finest(MessageFormat.format(Messages.SarlBatchCompiler_37, sourcePath));
			}
			if (isContainedIn(output.getCanonicalFile(), sourcePath.getCanonicalFile())) {
				reportInternalError(Messages.SarlBatchCompiler_10, output, sourcePath);
				return false;
			}
		} catch (IOException e) {
			reportInternalError(Messages.SarlBatchCompiler_11, e);
		}
	}
	return true;
}
 
Example #22
Source Project: uml2solidity   Author: UrsZeidler   File: InstalledSolidityCompilerPreferencePage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected void search() {
	DirectoryDialog directoryDialog = new DirectoryDialog(getShell());
	directoryDialog.setText("search solc ");
	String open = directoryDialog.open();

	final File file = new File(open);
	final Set<SolC> list = new HashSet<SolC>();

	IRunnableWithProgress withProgress = new IRunnableWithProgress() {

		@Override
		public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
			monitor.beginTask("file:" + file.getAbsolutePath(), IProgressMonitor.UNKNOWN);
			searchAndAdd(file, list, monitor);
			monitor.done();
		}
	};

	try {
		new ProgressMonitorDialog(getShell()).run(true, true, withProgress);
		installedSolCs.addAll(list);
		fCompilerList.setInput(installedSolCs.toArray());
	} catch (InvocationTargetException | InterruptedException e) {
		Activator.logError("", e);
	}

}
 
Example #23
Source Project: neoscada   Author: eclipse   File: ConfigurationEditorInput.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void performLoad ( final IProgressMonitor monitor )
{
    final LoadJob job = load ();
    job.addJobChangeListener ( new JobChangeAdapter () {
        @Override
        public void done ( final IJobChangeEvent event )
        {
            handleSetResult ( job.getConfiguration () );
        }
    } );
    job.setProgressGroup ( monitor, 2 );
    job.schedule ();
}
 
Example #24
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: ChangeSignatureProcessor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private Map<ICompilationUnit, Set<IType>> createNamedSubclassMapping(IProgressMonitor pm) throws JavaModelException{
	IType[] subclasses= getCachedTypeHierarchy(new SubProgressMonitor(pm, 1)).getSubclasses(fMethod.getDeclaringType());
	Map<ICompilationUnit, Set<IType>> result= new HashMap<ICompilationUnit, Set<IType>>();
	for (int i= 0; i < subclasses.length; i++) {
		IType subclass= subclasses[i];
		if (subclass.isAnonymous())
			continue;
		ICompilationUnit cu= subclass.getCompilationUnit();
		if (! result.containsKey(cu))
			result.put(cu, new HashSet<IType>());
		result.get(cu).add(subclass);
	}
	return result;
}
 
Example #25
Source Project: APICloud-Studio   Author: apicloudcom   File: SVNRepositoryLocation.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void validateConnection(IProgressMonitor monitor) throws SVNException {
	ISVNClientAdapter svnClient = getSVNClient();
	try {
		// we try to get the list of directories and files using the connection
		ISVNInfo info = svnClient.getInfo(getUrl());
	    repositoryRootUrl = info.getRepository();
	} catch (SVNClientException e) {
		// If the validation failed, dispose of any cached info
		dispose();
		throw SVNException.wrapException(e);
	}
}
 
Example #26
Source Project: pentaho-kettle   Author: pentaho   File: TextFileInputCSVImportProgressDialogTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
  shell = mock( Shell.class );
  meta = mock( CsvInputMeta.class );
  transMeta = mock( TransMeta.class );
  monitor = mock( IProgressMonitor.class );
}
 
Example #27
Source Project: gef   Author: eclipse   File: SetPropertyValueOperation.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	/*
	 * Fix for bug #54250 IPropertySource.isPropertySet(String) returns
	 * false both when there is no default value, and when there is a
	 * default value and the property is set to that value. To correctly
	 * determine if a reset should be done during undo, we compare the
	 * return value of isPropertySet(String) before and after
	 * setPropertyValue(...) is invoked. If they are different (it must have
	 * been false before and true after -- it cannot be the other way
	 * around), then that means we need to reset.
	 */
	boolean wasPropertySet = propertySource.isPropertySet(propertyId);
	oldValue = unwrapValue(propertySource.getPropertyValue(propertyId));

	// set value of property to new value or reset the value, if specified
	if (newValue == DEFAULT_VALUE) {
		propertySource.resetPropertyValue(propertyId);
	} else {
		propertySource.setPropertyValue(propertyId, unwrapValue(newValue));
	}

	// check if property was set to its default value before (so it will
	// have to be resetted during undo); note that if the new value is
	// DEFAULT_VALUE the old value may not have been the default value as
	// well, as the command would not be executable in this case.
	if (propertySource instanceof IPropertySource2) {
		if (!wasPropertySet && ((IPropertySource2) propertySource)
				.isPropertyResettable(propertyId)) {
			oldValue = DEFAULT_VALUE;
		}
	} else {
		if (!wasPropertySet && propertySource.isPropertySet(propertyId)) {
			oldValue = DEFAULT_VALUE;
		}
	}
	// TODO: infer a proper status
	return Status.OK_STATUS;
}
 
Example #28
Source Project: bonita-studio   Author: bonitasoft   File: JDTTypeHierarchyManagerTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testGetTypeHierarchy() throws JavaModelException {
    final JDTTypeHierarchyManager jdtTypeHierarchyManager = new JDTTypeHierarchyManager();
    final JDTTypeHierarchyManager spy = spy(jdtTypeHierarchyManager);
    assertThat(spy.getTypeHierarchy(type)).isEqualTo(typeHierarchy);
    assertThat(spy.getTypeHierarchy(type)).isEqualTo(typeHierarchy);
    assertThat(spy.getTypeHierarchy(type)).isEqualTo(typeHierarchy);
    verify(type, times(1)).newTypeHierarchy(any(IProgressMonitor.class));
}
 
Example #29
Source Project: neoscada   Author: eclipse   File: GlobalizeEditor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void doSaveAs ( URI uri, IEditorInput editorInput )
{
    ( editingDomain.getResourceSet ().getResources ().get ( 0 ) ).setURI ( uri );
    setInputWithNotify ( editorInput );
    setPartName ( editorInput.getName () );
    IProgressMonitor progressMonitor = getActionBars ().getStatusLineManager () != null ? getActionBars ().getStatusLineManager ().getProgressMonitor () : new NullProgressMonitor ();
    doSave ( progressMonitor );
}
 
Example #30
Source Project: birt   Author: eclipse   File: StaticHTMLViewer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void getParamValuesJob( RenderJobRule jobRule )
{
	Job getParameterJob = new AbstractUIJob( "Collecting parameters", //$NON-NLS-1$
			this.reportDesignFile ) {

		public void work( IProgressMonitor monitor )
		{
			monitor.subTask( "Collecting parameters" ); //$NON-NLS-1$
			getParameterValues( inputParameters );
		}
	};
	getParameterJob.setSystem( true );
	RenderJobRunner.runRenderJob( getParameterJob, jobRule );
}