org.eclipse.core.runtime.NullProgressMonitor Java Examples

The following examples show how to use org.eclipse.core.runtime.NullProgressMonitor. 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: AbstractWorkbenchTestCase.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
protected static void configureInterpreters() {
    if (!interpretersConfigured) {
        interpretersConfigured = true;
        InterpreterInfo.configurePathsCallback = new ICallback<Boolean, Tuple<List<String>, List<String>>>() {
            @Override
            public Boolean call(Tuple<List<String>, List<String>> arg) {
                return Boolean.TRUE;
            }
        };
        IEclipsePreferences node = PydevPrefs.getEclipsePreferences();
        InterpreterManagersAPI.setJythonInterpreterManager(new JythonInterpreterManager(node));
        InterpreterManagersAPI.setPythonInterpreterManager(new PythonInterpreterManager(node));

        ProjectModulesManager.IN_TESTS = true;

        NullProgressMonitor monitor = new NullProgressMonitor();

        createJythonInterpreterManager(monitor);
        createPythonInterpreterManager(monitor);
    }
}
 
Example #2
Source File: ImportOrganizeTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private void addFilesFromJar(IJavaProject javaProject, File jarFile, String encoding) throws InvocationTargetException, CoreException, IOException {
	IFolder src = (IFolder) fSourceFolder.getResource();
	File targetFile = src.getLocation().toFile();
	try (JarFile file = new JarFile(jarFile)) {
		for (JarEntry entry : Collections.list(file.entries())) {
			if (entry.isDirectory()) {
				continue;
			}
			try (InputStream in = file.getInputStream(entry); Reader reader = new InputStreamReader(in, encoding)) {
				File outFile = new File(targetFile, entry.getName());
				outFile.getParentFile().mkdirs();
				try (OutputStream out = new FileOutputStream(outFile); Writer writer = new OutputStreamWriter(out, encoding)) {
					IOUtils.copy(reader, writer);
				}
			}
		}
	}
	javaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}
 
Example #3
Source File: OpenNestedGraphOnDoubleClickHandler.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void click(MouseEvent event) {
	if (event.getClickCount() == 2) {
		// double click, so open nested graph, if it exists
		final Graph nestedGraph = getHost().getContent().getNestedGraph();
		if (nestedGraph != null) {
			IViewer viewer = getHost().getRoot().getViewer();
			try {
				// navigate to nested graph
				viewer.getDomain().execute(new NavigateOperation(viewer, nestedGraph, true),
						new NullProgressMonitor());
			} catch (ExecutionException e) {
				throw new RuntimeException(e);
			}
		}
	}
}
 
Example #4
Source File: XtextGrammarQuickfixProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private void assertAndApplySingleResolution(XtextEditor xtextEditor, String issueCode, int issueDataCount, String resolutionLabel,
		boolean isCleanAfterApply) {
	IXtextDocument document = xtextEditor.getDocument();
	List<Issue> issues = getIssues(document);
	assertFalse(issues.toString(), issues.isEmpty());
	Issue issue = issues.iterator().next();
	assertEquals(issueCode, issue.getCode());
	assertNotNull(issue.getData());
	assertEquals(issueDataCount, issue.getData().length);
	List<IssueResolution> resolutions = issueResolutionProvider.getResolutions(issue);

	assertEquals(1, resolutions.size());
	IssueResolution resolution = resolutions.iterator().next();
	assertEquals(resolutionLabel, resolution.getLabel());
	try {
		resolution.apply();
		assertEquals(getIssues(document).toString(), isCleanAfterApply, getIssues(document).isEmpty());
	} finally {
		// Save xtextEditor in any case. Otherwise test will stuck,
		// because the "save changed resource dialog" waits for user input.
		xtextEditor.doSave(new NullProgressMonitor());
	}
}
 
Example #5
Source File: ProjectTemplate.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public IStatus apply(final IProject project, boolean promptForOverwrite)
{
	IInputStreamTransformer transform = new TemplateSubstitutionTransformer(project);
	File zipFile = new File(getDirectory(), getLocation());
	try
	{
		return ZipUtil.extract(zipFile, project.getLocation().toFile(),
				promptForOverwrite ? ZipUtil.Conflict.PROMPT : ZipUtil.Conflict.OVERWRITE, transform,
				new NullProgressMonitor());
	}
	catch (IOException e)
	{
		return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, MessageFormat.format(
				"IOException reading zipfile {0}", zipFile.getAbsolutePath()), e); //$NON-NLS-1$
	}
}
 
Example #6
Source File: ImportUtil.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static IProject importExistingMavenProjects(IPath path, String projectName) throws Exception {
	File root = path.toFile();
	String location = path.toOSString();
	MavenModelManager modelManager = MavenPlugin.getMavenModelManager();
	LocalProjectScanner scanner = new LocalProjectScanner(root, location, false, modelManager);
	scanner.run(new NullProgressMonitor());
	List<MavenProjectInfo> infos = new ArrayList<MavenProjectInfo>();
	infos.addAll(scanner.getProjects());
	for(MavenProjectInfo info : scanner.getProjects()){
		infos.addAll(info.getProjects());
	}
	ImportMavenProjectsJob job = new ImportMavenProjectsJob(infos, new ArrayList<IWorkingSet>(), new ProjectImportConfiguration());
	job.setRule(MavenPlugin.getProjectConfigurationManager().getRule());
	job.schedule();
	IProject project = waitForProject(projectName);
	return project;
}
 
Example #7
Source File: ImportedProjectNamePluginTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Tests the following project name configuration.
 *
 * <pre>
 * File System: 	file-other-system
 * Package.json: 	file-system
 * Eclipse: 		file-system
 * </pre>
 */
@Test
public void testDifferentFileSystemName() throws CoreException {
	// workspace setup
	final IProject testProject = ProjectTestsUtils.createProjectWithLocation(projectsRoot,
			"file-other-system", "file-system");
	configureProjectWithXtext(testProject);
	waitForAutoBuild();

	// obtain package.json resource
	final IResource packageJsonResource = testProject.findMember(IN4JSProject.PACKAGE_JSON);

	// assert project name markers
	assertHasMarker(packageJsonResource, IssueCodes.PKGJ_PACKAGE_NAME_MISMATCH);
	assertHasNoMarker(packageJsonResource, IssueCodes.PKGJ_PROJECT_NAME_ECLIPSE_MISMATCH);

	// tear down
	testProject.delete(false, true, new NullProgressMonitor());
}
 
Example #8
Source File: Auditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private IDocument connectFileBuffer(IResource resource) {

      if (!(resource instanceof IFile)) {
        return null;
      }

      IDocument document = null;

      try {
        IPath path = resource.getFullPath();
        mFileBufferManager.connect(path, new NullProgressMonitor());

        mConnectedFileBufferPaths.add(path);
        document = mFileBufferManager.getTextFileBuffer(path).getDocument();
      } catch (CoreException e) {
        CheckstyleLog.log(e);
      }
      return document;
    }
 
Example #9
Source File: BundleJavaProcessor.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
@Override
public void generatePom(int option) {
    super.generatePom(option);
    if (option == TalendProcessOptionConstants.GENERATE_IS_MAINJOB) {
        try {
            IRepositoryObject repositoryObject = new RepositoryObject(getProperty());

            // Fix TESB-22660: Avoide to operate repo viewer before it open
            if (PlatformUI.isWorkbenchRunning()) {
                RepositorySeekerManager.getInstance().searchRepoViewNode(getProperty().getId(), false);
            }

            IRunnableWithProgress action = new JavaCamelJobScriptsExportWSAction(repositoryObject, getProperty().getVersion(),
                    "", false);
            action.run(new NullProgressMonitor());
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
}
 
Example #10
Source File: ProjectCacheInvalidationPluginTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Performs the given {@code updateOperation} on the loaded AST of the given {@code packageJsonFile} and saves it to
 * disk.
 */
private void updatePackageJsonFile(IFile packageJsonFile, Consumer<JSONObject> updateOperation)
		throws CoreException {
	final IProject project = packageJsonFile.getProject();
	final ResourceSet resourceSet = resourceSetProvider.get(project);

	// read and parse package.json contents
	final String path = packageJsonFile.getFullPath().toString();
	final URI uri = URI.createPlatformResourceURI(path, true);
	final Resource resource = resourceSet.getResource(uri, true);

	final JSONObject root = PackageJSONTestUtils.getPackageJSONRoot(resource);
	updateOperation.accept(root);

	try {
		resource.save(null);
	} catch (IOException e) {
		throw new WrappedException("Failed to save package.json resource at " + resource.getURI().toString() + ".",
				e);
	}
	packageJsonFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
}
 
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: OriginalEditorSelector.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private SearchResult findTypesBySimpleName(String simpleTypeName, final boolean searchForSources) {
	final SearchResult result = new SearchResult();
	try {
		new SearchEngine().searchAllTypeNames(null, 0, // match all package names
				simpleTypeName.toCharArray(), SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
					IJavaSearchConstants.TYPE,
					SearchEngine.createWorkspaceScope(),
					new TypeNameMatchRequestor() {
						@Override
						public void acceptTypeNameMatch(TypeNameMatch match) {
							IPackageFragmentRoot fragmentRoot = match.getPackageFragmentRoot();
							boolean externalLib = fragmentRoot.isArchive() || fragmentRoot.isExternal();
							if (externalLib ^ searchForSources) {
								result.foundTypes.add(match.getType());
							}
						}
					}, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, // wait for the jdt index to be ready
					new NullProgressMonitor());
	} catch (JavaModelException e) {
		logger.error(e.getMessage(), e);
	}
	return result;
}
 
Example #13
Source File: ContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static IProject createPluginProject(String name) throws CoreException {
	Injector injector = XtendActivator.getInstance().getInjector("org.eclipse.xtend.core.Xtend");
	PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class);
	projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
	projectFactory.setProjectName(name);
	projectFactory.setProjectDefaultCharset(StandardCharsets.ISO_8859_1.name());
	projectFactory.addFolders(Collections.singletonList("src"));
	projectFactory.addBuilderIds(
		JavaCore.BUILDER_ID, 
		"org.eclipse.pde.ManifestBuilder",
		"org.eclipse.pde.SchemaBuilder",
		XtextProjectHelper.BUILDER_ID);
	projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID);
	projectFactory.addRequiredBundles(Lists.newArrayList(
			"org.eclipse.xtext.xbase.lib",
			"org.eclipse.xtend.lib"));
	IProject result = projectFactory.createProject(new NullProgressMonitor(), null);
	JavaProjectSetupUtil.makeJava8Compliant(JavaCore.create(result));
	return result;
}
 
Example #14
Source File: ASTRewriteCorrectionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
	super.addEdits(document, editRoot);
	ASTRewrite rewrite= getRewrite();
	if (rewrite != null) {
		try {
			TextEdit edit= rewrite.rewriteAST();
			editRoot.addChild(edit);
		} catch (IllegalArgumentException e) {
			throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, e));
		}
	}
	if (fImportRewrite != null) {
		editRoot.addChild(fImportRewrite.rewriteImports(new NullProgressMonitor()));
	}
}
 
Example #15
Source File: IDEBUG_856_PluginTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks whether the external refreshing does not cause deadlock due to incorrect workspace checkpoints and
 * incorrect job family configuration.
 */
@Test
public void testMultipleExternalRefresh() throws Exception {
	// initial load to trigger cloning
	libManager.synchronizeNpms(new NullProgressMonitor());

	LOG.info("------------------------------------------------------------");
	for (int i = 1; i <= ITERATION_COUNT; i++) {
		LOG.info("Iteration " + i + " of " + ITERATION_COUNT + ".");
		libManager.synchronizeNpms(new NullProgressMonitor());
		// schedule second reload to see if they deadlock
		libManager.synchronizeNpms(new NullProgressMonitor());
		LOG.info("waiting for build.");
		waitForAutoBuild();
	}
	LOG.info("------------------------------------------------------------");
}
 
Example #16
Source File: AbstractConfigurationEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void setInput ( final IEditorInput input )
{
    final ConfigurationEditorInput configurationInput = (ConfigurationEditorInput)input;

    if ( !this.nested )
    {
        configurationInput.performLoad ( new NullProgressMonitor () );
    }

    this.dirtyValue = configurationInput.getDirtyValue ();
    this.dirtyValue.addValueChangeListener ( new IValueChangeListener () {

        @Override
        public void handleValueChange ( final ValueChangeEvent event )
        {
            firePropertyChange ( IEditorPart.PROP_DIRTY );
        }
    } );

    super.setInput ( input );
}
 
Example #17
Source File: GroovyConnectorIT.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_groovy_connector_configuration_be_converted_at_export() throws Exception {
    RepositoryAccessor repositoryAccessor = new RepositoryAccessor();
    repositoryAccessor.init();
    final ImportBosArchiveOperation op = new ImportBosArchiveOperation(repositoryAccessor);
    final URL fileURL1 = FileLocator
            .toFileURL(TestDatabaseConnectorResulset.class.getResource("GroovyConnectorTest-1.0.bos")); //$NON-NLS-1$
    op.setArchiveFile(FileLocator.toFileURL(fileURL1).getFile());
    op.setCurrentRepository(repositoryAccessor.getCurrentRepository());
    op.run(new NullProgressMonitor());
    for (final IRepositoryFileStore fStore : op.getFileStoresToOpen()) {
        fStore.open();
    }
    final MainProcess mainProcess = (MainProcess) op.getFileStoresToOpen().get(0).getContent();

    final RunProcessCommand runProcessCommand = new RunProcessCommand(true);
    final Status status = (Status) runProcessCommand
            .execute(ProcessSelector.createExecutionEvent((AbstractProcess) mainProcess.getElements().get(0)));
    assertThat(status.isOK()).isTrue();

}
 
Example #18
Source File: JReFrameworker.java    From JReFrameworker with MIT License 6 votes vote down vote up
private static IJavaProject createProject(String projectName, IPath projectPath, IProject project, IProgressMonitor monitor) throws CoreException {
	IProjectDescription projectDescription = project.getWorkspace().newProjectDescription(project.getName());
	URI location = getProjectLocation(projectName, projectPath);
	projectDescription.setLocationURI(location);
	
	// make this a JReFrameworker project
	projectDescription.setNatureIds(new String[] { JReFrameworkerNature.NATURE_ID, JavaCore.NATURE_ID });

	// build first with Java compiler then JReFramewoker bytecode operations
	BuildCommand javaBuildCommand = new BuildCommand();
	javaBuildCommand.setBuilderName(JavaCore.BUILDER_ID);
	BuildCommand jrefBuildCommand = new BuildCommand();
	jrefBuildCommand.setBuilderName(JReFrameworkerBuilder.BUILDER_ID);
	projectDescription.setBuildSpec(new ICommand[]{ javaBuildCommand, jrefBuildCommand});

	// create and open the Eclipse project
	project.create(projectDescription, null);
	IJavaProject jProject = JavaCore.create(project);
	project.open(new NullProgressMonitor());
	return jProject;
}
 
Example #19
Source File: SpecTest.java    From tlaplus with MIT License 6 votes vote down vote up
private void createDelete(final String specName, boolean forget) throws IOException, CoreException {
	// Create...
	final File tempFile = File.createTempFile(specName, TLAConstants.Files.TLA_EXTENSION);
	final Spec spec = Spec.createNewSpec("TestCreateDeleteSpec", tempFile.getAbsolutePath(), false, new NullProgressMonitor());
	final IProject project = spec.getProject();
	
	final WorkspaceSpecManager wsm = new WorkspaceSpecManager(new NullProgressMonitor());
	wsm.removeSpec(spec, new NullProgressMonitor(), forget);
	
	// Make sure that the project has been deleted.
	assertFalse(project.exists());
	final IWorkspace ws = ResourcesPlugin.getWorkspace();
	for (final IProject aProject : ws.getRoot().getProjects()) {
		assertNotSame(project.getName(), aProject.getName());
	}
	
	Spec mostRecentlyOpenedSpec = wsm.getMostRecentlyOpenedSpec();
	assertNull(mostRecentlyOpenedSpec != null ? mostRecentlyOpenedSpec.getName() : "", mostRecentlyOpenedSpec);
}
 
Example #20
Source File: DirtyStateEditorSupportIntegrationTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void pushKey(char c, int k) throws Exception {
	String textBefore = editor.getDocument().get();
	Event event = new Event();
	event.type = SWT.KeyDown;
	event.character = c;
	event.keyCode = k;
	myDisplay.post(event);
	syncUtil.yieldToQueuedDisplayJobs(new NullProgressMonitor());
	Event event2 = new Event();
	event2.type = SWT.KeyUp;
	event2.character = c;
	event2.keyCode = k;
	myDisplay.post(event2);
	int maxTries = 10;
	while (maxTries-- > 0) {
		if (!Objects.equal(editor.getDocument().get(), textBefore)) {
			syncUtil.waitForReconciler(editor);
			return;
		}
		Thread.sleep(10);
		syncUtil.yieldToQueuedDisplayJobs(new NullProgressMonitor());
	}
	Assert.fail("Document didn't change on keystroke");
}
 
Example #21
Source File: SVNSynchronizeParticipant.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
	if (event.getProperty().equals(ISVNCoreConstants.PREF_IGNORE_HIDDEN_CHANGES)) {
		if (getResources() != null) {
			refresh(getResources(), new NullProgressMonitor());		
			reset();
		}
	}
}
 
Example #22
Source File: RefactorProposalUtility.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static CUCorrectionProposal getExtractVariableProposal(CodeActionParams params, IInvocationContext context, boolean problemsAtLocation, Map formatterOptions, boolean returnAsCommand) throws CoreException {
	final ICompilationUnit cu = context.getCompilationUnit();
	ExtractTempRefactoring extractTempRefactoringSelectedOnly = new ExtractTempRefactoring(context.getASTRoot(), context.getSelectionOffset(), context.getSelectionLength(), formatterOptions);
	extractTempRefactoringSelectedOnly.setReplaceAllOccurrences(false);
	if (extractTempRefactoringSelectedOnly.checkInitialConditions(new NullProgressMonitor()).isOK()) {
		String label = CorrectionMessages.QuickAssistProcessor_extract_to_local_description;
		int relevance;
		if (context.getSelectionLength() == 0) {
			relevance = IProposalRelevance.EXTRACT_LOCAL_ZERO_SELECTION;
		} else if (problemsAtLocation) {
			relevance = IProposalRelevance.EXTRACT_LOCAL_ERROR;
		} else {
			relevance = IProposalRelevance.EXTRACT_LOCAL;
		}

		if (returnAsCommand) {
			return new CUCorrectionCommandProposal(label, JavaCodeActionKind.REFACTOR_EXTRACT_VARIABLE, cu, relevance, APPLY_REFACTORING_COMMAND_ID, Arrays.asList(EXTRACT_VARIABLE_COMMAND, params));
		}

		LinkedProposalModelCore linkedProposalModel = new LinkedProposalModelCore();
		extractTempRefactoringSelectedOnly.setLinkedProposalModel(linkedProposalModel);
		extractTempRefactoringSelectedOnly.setCheckResultForCompileProblems(false);
		RefactoringCorrectionProposal proposal = new RefactoringCorrectionProposal(label, JavaCodeActionKind.REFACTOR_EXTRACT_VARIABLE, cu, extractTempRefactoringSelectedOnly, relevance) {
			@Override
			protected void init(Refactoring refactoring) throws CoreException {
				ExtractTempRefactoring etr = (ExtractTempRefactoring) refactoring;
				etr.setTempName(etr.guessTempName()); // expensive
			}
		};
		proposal.setLinkedProposalModel(linkedProposalModel);
		return proposal;
	}

	return null;
}
 
Example #23
Source File: XLIFFEditorImplWithNatTable.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 返回与此编辑器相关的进度监视器。
 * @return 与此编辑器相关的进度监视器
 */
protected IProgressMonitor getProgressMonitor() {
	IProgressMonitor pm = null;
	IStatusLineManager manager = getStatusLineManager();
	if (manager != null)
		pm = manager.getProgressMonitor();
	return pm != null ? pm : new NullProgressMonitor();
}
 
Example #24
Source File: FlexMavenPackagedProjectStagingDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testWaitUntilLaunchTerminates_normalExit()
    throws DebugException, InterruptedException {
  IProcess process = mock(IProcess.class);
  when(process.getExitValue()).thenReturn(0);

  ILaunch launch = mock(ILaunch.class);
  when(launch.isTerminated()).thenReturn(true);
  when(launch.getProcesses()).thenReturn(new IProcess[] {process, process});

  boolean normalExit = FlexMavenPackagedProjectStagingDelegate.waitUntilLaunchTerminates(
      launch, new NullProgressMonitor());
  assertTrue(normalExit);
}
 
Example #25
Source File: LTTngControlServiceTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Test
@Ignore
public void testGetSessionWithLive() {
    try {
        fShell.setScenario(SCEN_GET_SESSION_WITH_LIVE);

        // Verify Session (snapshot session, non-live)
        ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
        assertNotNull(session);
        assertEquals("mysession", session.getName());
        assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
        assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
        assertFalse(session.isLive());

        // Verify Session (regular session, non-live)
        session = fService.getSession("mysession1", new NullProgressMonitor());
        assertNotNull(session);
        assertEquals("mysession1", session.getName());
        assertEquals("/home/user/lttng-traces/mysession1-20120129-084256", session.getSessionPath());
        assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
        assertFalse(session.isLive());

        // Verify Session (regular session, live)
        session = fService.getSession("mysession2", new NullProgressMonitor());
        assertNotNull(session);
        assertEquals("mysession2", session.getName());
        assertEquals("tcp4://172.0.0.1:5342/ [data: 5343]", session.getSessionPath());
        assertEquals("net://127.0.0.1", session.getLiveUrl());
        assertEquals(Integer.valueOf(5344), session.getLivePort());
        assertEquals(1000000, session.getLiveDelay());
        assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
        assertTrue(session.isLive());

    } catch (ExecutionException e) {
        fail(e.toString());
    }
}
 
Example #26
Source File: PostAttachmentCommand.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void execute() throws CoreException, IOException, MalformedURLException {
    Logger log = Logger.getLogger(this.getClass().getName());
    if(log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "executing PostTaskDataCommand for task: {0}", task.getTaskId()); // NOI18N
    }
    AbstractTaskAttachmentHandler taskAttachmentHandler = repositoryConnector.getTaskAttachmentHandler();
    if (!taskAttachmentHandler.canPostContent(taskRepository, task)) {
        throw new IOException("Cannot post attachment for task with id: " + task.getTaskId());
    }
    taskAttachmentHandler.postContent(taskRepository, task, taskAttachmentSource, comment, attAttribute, new NullProgressMonitor());
}
 
Example #27
Source File: TestRunConfiguration.java    From corrosion with Eclipse Public License 2.0 5 votes vote down vote up
private static void confirmErrorPopup(ILaunchConfiguration configuration) throws CoreException {
	configuration.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
	new DisplayHelper() {
		@Override
		protected boolean condition() {
			return getErrorPopup() != null;
		}
	}.waitForCondition(Display.getDefault(), 15000);

	assertNotNull(getErrorPopup());
}
 
Example #28
Source File: SelectAllProjectExplorer_PluginUITest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Tries to close the project with the given name.
 */
private void closeProject(String projectName) {
	IN4JSEclipseProject n4jsProject = eclipseN4jsCore.findProject(URI.createPlatformResourceURI(projectName, true))
			.orNull();
	if (null == n4jsProject) {
		throw new IllegalArgumentException("Could not find project with name '" + projectName + "'");
	}
	try {
		n4jsProject.getProject().close(new NullProgressMonitor());
	} catch (CoreException e) {
		throw new IllegalArgumentException(
				"Could not close project with name '" + projectName + "': " + e.getMessage());
	}
}
 
Example #29
Source File: NewTypeScriptProjectWizard.java    From typescript.java with MIT License 5 votes vote down vote up
private IFile generateJsonFile(Object jsonObject, IPath path, IProject project) throws InvocationTargetException {
	Gson gson = new GsonBuilder().setPrettyPrinting().create();
	String content = gson.toJson(jsonObject);
	IFile file = project.getFile(path);
	try {
		if (file.exists()) {
			file.setContents(IOUtils.toInputStream(content), 1, new NullProgressMonitor());
		} else {
			file.create(IOUtils.toInputStream(content), 1, new NullProgressMonitor());
		}
	} catch (CoreException e) {
		throw new InvocationTargetException(e);
	}
	return file;
}
 
Example #30
Source File: RenameMethodUserInterfaceStarter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
	RenameVirtualMethodProcessor processor= (RenameVirtualMethodProcessor)refactoring.getAdapter(RenameVirtualMethodProcessor.class);
	if (processor != null) {
		RefactoringStatus status= processor.checkInitialConditions(new NullProgressMonitor());
		if (!status.hasFatalError()) {
			IMethod method= processor.getMethod();
			if (!method.equals(processor.getOriginalMethod())) {
				String message= null;
				if (method.getDeclaringType().isInterface()) {
					message= Messages.format(
						RefactoringCoreMessages.MethodChecks_implements,
						new String[]{
							JavaElementUtil.createMethodSignature(method),
							JavaElementLabels.getElementLabel(method.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)});
				} else {
					message= Messages.format(
						RefactoringCoreMessages.MethodChecks_overrides,
						new String[]{
							JavaElementUtil.createMethodSignature(method),
							JavaElementLabels.getElementLabel(method.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)});
				}
				message= Messages.format(
					ReorgMessages.RenameMethodUserInterfaceStarter_message,
					message);
				if (!MessageDialog.openQuestion(parent,
						ReorgMessages.RenameMethodUserInterfaceStarter_name,
						message)) {
					return false;
				}
			}
		}
	}
	return super.activate(refactoring, parent, saveMode);
}