org.eclipse.core.runtime.IProgressMonitor Java Examples

The following examples show how to use org.eclipse.core.runtime.IProgressMonitor. 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: UnlockResourcesCommand.java    From APICloud-Studio with 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 #2
Source File: CreateAppEngineFlexWtpProject.java    From google-cloud-eclipse with 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 File: IDEOpenSampleReportAction.java    From birt with 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 #4
Source File: IResourcesSetupUtil.java    From xtext-eclipse with 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 #5
Source File: TexlipseProjectCreationOperation.java    From texlipse with 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 #6
Source File: ModulesManagerWithBuild.java    From Pydev with 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 #7
Source File: LazyCommonViewerContentProvider.java    From elexis-3-core with 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 #8
Source File: BirtWizardUtil.java    From birt with 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 #9
Source File: ProjectFactory.java    From xtext-eclipse with 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 #10
Source File: ExternalResourceManager.java    From xds-ide with 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 #11
Source File: SARLRuntime.java    From sarl with 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 #12
Source File: RadlCreator.java    From RADL with 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 #13
Source File: APKInstallJob.java    From Flashtool with 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 #14
Source File: BuilderParticipant.java    From xtext-eclipse with 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 #15
Source File: ChangeUtilities.java    From gwt-eclipse-plugin with 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 #16
Source File: UpdateDialog.java    From offspring with MIT License 5 votes vote down vote up
private void scheduleJob() {
  updateJob = createUpdateJob();
  Job.getJobManager().setProgressProvider(new ProgressProvider() {

    @Override
    public IProgressMonitor createMonitor(Job job) {
      return monitor;
    }
  });
  updateJob.schedule();
}
 
Example #17
Source File: GenconfEditor.java    From M2Doc with 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 #18
Source File: CordovaProjectCLITest.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testAdditionalEnvProperties() throws CoreException{
	CordovaProjectCLI mockCLI = getMockCLI();
	IProcess mockProcess = mock(IProcess.class);
	IStreamsProxy2 mockStreams  = mock(IStreamsProxy2.class);
	setupMocks(mockCLI, mockProcess, mockStreams);
	ArgumentCaptor<ILaunchConfiguration> confCaptor = ArgumentCaptor.forClass(ILaunchConfiguration.class);
	mockCLI.prepare(new NullProgressMonitor(), "android");
	verify(mockCLI).startShell(any(IStreamListener.class), any(IProgressMonitor.class), confCaptor.capture());
	Map<String,String> attr = confCaptor.getValue().getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String,String>)null);
	assertEquals(EnvironmentPropsExt.ENV_VALUE, attr.get(EnvironmentPropsExt.ENV_KEY));
}
 
Example #19
Source File: RenamePackageChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void isValid(RefactoringStatus result, IPackageFragment pack, IProgressMonitor pm) throws JavaModelException {
	ICompilationUnit[] units= pack.getCompilationUnits();
	pm.beginTask("", units.length); //$NON-NLS-1$
	for (int i= 0; i < units.length; i++) {
		pm.subTask(Messages.format(RefactoringCoreMessages.RenamePackageChange_checking_change, JavaElementLabels.getElementLabel(pack, JavaElementLabels.ALL_DEFAULT)));
		checkIfModifiable(result, units[i].getResource(), VALIDATE_NOT_READ_ONLY | VALIDATE_NOT_DIRTY);
		pm.worked(1);
	}
	pm.done();
}
 
Example #20
Source File: ProjectBuilder.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public boolean handleResource ( final IResourceDelta delta, final IResource resource, final ComposedAdapterFactory adapterFactory, final Set<String> extensions, final IProgressMonitor monitor )
{
    logger.debug ( "Handle resource - file: {}", resource );

    if ( resource instanceof IProject )
    {
        return isInterestingProject ( (IProject)resource );
    }

    if ( resource instanceof IFolder )
    {
        return true;
    }

    if ( resource instanceof IFile )
    {
        final IFile file = (IFile)resource;
        if ( !isModelFile ( file, extensions ) )
        {
            return false;
        }

        if ( delta == null || delta.getKind () != IResourceDelta.REMOVED )
        {
            validateFile ( file, adapterFactory, monitor );
        }
    }
    return false;
}
 
Example #21
Source File: GlobalizeEditor.java    From neoscada with 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 #22
Source File: ClientTester.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void appendContents(InputStream source, boolean force,
		boolean keepHistory, IProgressMonitor monitor)
				throws CoreException {
	// TODO Auto-generated method stub

}
 
Example #23
Source File: LTTngControlService.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void enableSyscalls(String sessionName, String channelName, List<String> syscallNames, IProgressMonitor monitor) throws ExecutionException {

    ICommandInput command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_EVENT);

    boolean isAllSyscalls = ALL_EVENTS.equals(syscallNames);

    if (isAllSyscalls || (syscallNames == null) || (syscallNames.isEmpty())) {
        command.add(LTTngControlServiceConstants.OPTION_ALL);
    } else {
        command.add(toCsv(syscallNames));
    }

    command.add(LTTngControlServiceConstants.OPTION_KERNEL);

    command.add(LTTngControlServiceConstants.OPTION_SESSION);
    command.add(sessionName);

    if (channelName != null) {
        command.add(LTTngControlServiceConstants.OPTION_CHANNEL);
        command.add(channelName);
    }

    command.add(LTTngControlServiceConstants.OPTION_SYSCALL);

    executeCommand(command, monitor);
}
 
Example #24
Source File: RepositoryService.java    From ADT_Frontend with MIT License 5 votes vote down vote up
@Override
public IAbapObjects cloneRepository(String url, String branch, String targetPackage, String transportRequest, String user,
		String password,
		IProgressMonitor monitor) {
	IRestResource restResource = AdtRestResourceFactory.createRestResourceFactory().createResourceWithStatelessSession(this.uri,
			this.destinationId);

	IContentHandler<IRepository> requestContentHandlerV1 = new RepositoryContentHandlerV1();
	restResource.addContentHandler(requestContentHandlerV1);

	IRepository repository = AbapgitrepositoriesFactoryImpl.eINSTANCE.createRepository();
	repository.setUrl(url);
	repository.setPackage(targetPackage);
	repository.setBranchName(branch);

	if (user != null && !user.isEmpty()) {
		repository.setRemoteUser(user);
	}

	if (password != null && !password.isEmpty()) {
		repository.setRemotePassword(password);
	}

	repository.setTransportRequest(transportRequest);
	repository.setPackage(targetPackage);

	IAdtCompatibleRestResourceFilter compatibilityFilter = AdtCompatibleRestResourceFilterFactory.createFilter(new IContentHandler[0]);

	IContentHandler<IAbapObjects> responseContentHandlerV1 = new AbapObjectContentHandlerV1();
	restResource.addContentHandler(responseContentHandlerV1);

	IAdtCompatibleRestResourceFilter responseCompatibilityFilter = AdtCompatibleRestResourceFilterFactory
			.createFilter(new IContentHandler[0]);

	restResource.addResponseFilter(responseCompatibilityFilter);
	restResource.addRequestFilter(compatibilityFilter);

	return restResource.post(monitor, IAbapObjects.class, repository);
}
 
Example #25
Source File: StaticHTMLViewer.java    From birt with 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 );
}
 
Example #26
Source File: TreeSelectionDialog.java    From Pydev with 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 #27
Source File: JDTTypeHierarchyManagerTest.java    From bonita-studio with 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 #28
Source File: SetPropertyValueOperation.java    From gef with 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 #29
Source File: AbstractStateSystemTimeGraphView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void zoomByTime(final ITmfStateSystem ss, final List<TimeGraphEntry> entryList, final List<ILinkEvent> links, final List<IMarkerEvent> markers,
        long startTime, long endTime, long resolution, final @NonNull IProgressMonitor monitor) {
    final long start = Math.max(startTime, ss.getStartTime());
    final long end = Math.min(endTime, ss.getCurrentEndTime());
    final boolean fullRange = getZoomStartTime() <= getStartTime() && getZoomEndTime() >= getEndTime();
    if (end < start) {
        return;
    }

    ViewFilterDialog timeEventFilterDialog = getViewFilterDialog();
    boolean isFilterActive = timeEventFilterDialog != null && timeEventFilterDialog.isFilterActive();
    getTimeGraphViewer().setTimeEventFilterApplied(isFilterActive);

    boolean hasSavedFilter = timeEventFilterDialog != null && timeEventFilterDialog.hasActiveSavedFilters();
    getTimeGraphViewer().setSavedFilterStatus(hasSavedFilter);

    if (fullRange) {
        redraw();
    }
    @NonNull Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = generateRegexPredicate();
    Sampling sampling = new Sampling(getZoomStartTime(), getZoomEndTime(), predicates, getResolution());
    Iterable<@NonNull TimeGraphEntry> incorrectSample = Iterables.filter(fVisibleEntries, entry -> !sampling.equals(entry.getSampling()));
    /* Only keep entries that are a member or child of the ss entry list */
    Iterable<@NonNull TimeGraphEntry> entries = Iterables.filter(incorrectSample, entry -> isMember(entry, entryList));
    // set gaps to null when there is no active filter
    Map<TimeGraphEntry, List<ITimeEvent>> gaps = isFilterActive ? new HashMap<>() : null;
    doZoom(ss, links, markers, resolution, monitor, start, end, sampling, entries, predicates, gaps);

    if (isFilterActive && gaps != null && !gaps.isEmpty()) {
        doBgSearch(ss, BG_SEARCH_RESOLUTION, monitor, gaps, predicates);
    }
}
 
Example #30
Source File: CreateAppEngineFlexWtpProject.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Override
public void addAppEngineFacet(IFacetedProject newProject, IProgressMonitor monitor)
    throws CoreException {
  SubMonitor subMonitor = SubMonitor.convert(monitor,
      Messages.getString("add.appengine.flex.war.facet"), 100);

  AppEngineFlexWarFacet.installAppEngineFacet(
      newProject, true /* installDependentFacets */, subMonitor.newChild(100));
}