use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class GcovTest method testGcovSummaryByLaunch.
@Test
public void testGcovSummaryByLaunch() {
display.syncExec(() -> {
try {
CommonNavigator vc = (CommonNavigator) window.getActivePage().showView(ProjectExplorer.VIEW_ID);
vc.selectReveal(new StructuredSelection(project.getFile(getBinName())));
Menu menu = new MenuManager().createContextMenu(vc.getCommonViewer().getControl());
new ProfileContextualLaunchAction(menu);
for (MenuItem item : menu.getItems()) {
if (item.getText().endsWith("Profile Code Coverage")) {
((ActionContributionItem) item.getData()).getAction().run();
break;
}
}
} catch (PartInitException e1) {
Assert.fail("Cannot show Project Explorer.");
}
try {
window.getActivePage().showView("org.eclipse.linuxtools.gcov.view");
} catch (PartInitException e2) {
Assert.fail("Cannot show GCov View.");
}
});
// Wait for the build job to finish (note: DebugUIPlugin doesn't put launch jobs in a family)
Job[] jobs = Job.getJobManager().find(null);
for (Job job : jobs) {
if (job.getName().contains("Gcov")) {
try {
job.join();
} catch (InterruptedException e) {
}
break;
}
}
}
use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class OpenFileHandler method runActions.
private void runActions(File file) {
successful = false;
IFileStore fileStore = EFS.getLocalFileSystem().getStore(file.toURI());
IWorkbenchPage page = window.getActivePage();
try {
IDE.openEditorOnFileStore(page, fileStore);
successful = true;
} catch (PartInitException e) {
ErrorDialog.openError(window.getShell(), // $NON-NLS-1$
Localization.getString("OpenFileHandler.Problem"), // $NON-NLS-1$
Localization.getString("OpenFileHandler.ProblemMessage"), new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID, e.getMessage(), e));
}
}
use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class CreaterepoResourceChangeListener method closeEditors.
/**
* Close the editors thats resource has been affected by a change in the
* workspace. E.g. if an editor's project has been closed/deleted, close the
* editor.
*/
private void closeEditors() {
IWorkbench workbench = PlatformUI.getWorkbench();
IResource repomdFile = project.getRepoFile();
// deleted, or the file was deleted. If so, close the editor of the file.
if (!repomdFile.exists()) {
for (IWorkbenchPage page : workbench.getActiveWorkbenchWindow().getPages()) {
for (IEditorReference ref : page.getEditorReferences()) {
try {
// get the resource from the editor part and exit the editor if
// it is within the project(s) being closed/deleted
IResource resource = ResourceUtil.getResource(ref.getEditorInput());
if (ref.getId().equals(RepoFormEditor.EDITOR_ID) && resource.getProject().equals(project.getProject())) {
page.closeEditor(ref.getEditor(false), false);
}
} catch (PartInitException e) {
Activator.logError(Messages.CreaterepoResourceChangeListener_errorGettingResource, e);
}
}
}
}
}
use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class CreaterepoWizard method createProject.
/**
* Create a createrepo project that contains an empty content folder and
* a quickly initialized .repo file with the mandatory options.
*
* @param monitor The progress monitor.
*/
private void createProject(IProgressMonitor monitor) {
try {
String fileName = pageTwo.getRepositoryID().concat("." + // $NON-NLS-1$
ICreaterepoConstants.REPO_FILE_EXTENSION);
// create the project
IProject project = CreaterepoProjectCreator.create(pageOne.getProjectName(), pageOne.getLocationPath(), fileName, monitor);
// get a handle on the content folder
IFolder folder = project.getFolder(ICreaterepoConstants.CONTENT_FOLDER);
if (!folder.exists()) {
folder.create(false, true, monitor);
}
// get a handle on the .repo file
final IFile file = project.getFile(fileName);
final String repoFileContents = initializeRepoContents(pageTwo.getRepositoryID(), pageTwo.getRepositoryName(), pageTwo.getRepositoryURL());
InputStream stream = new ByteArrayInputStream(repoFileContents.getBytes());
if (file.exists()) {
file.setContents(stream, true, true, monitor);
} else {
file.create(stream, true, monitor);
}
monitor.worked(1);
monitor.setTaskName(Messages.CreaterepoWizard_openFileOnCreation);
getShell().getDisplay().asyncExec(() -> {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IDE.openEditor(page, file, true);
} catch (PartInitException e) {
Activator.logError(Messages.CreaterepoWizard_errorOpeningNewlyCreatedFile, e);
}
});
monitor.worked(1);
} catch (CoreException e) {
Activator.logError(Messages.CreaterepoWizard_errorCreatingProject, e);
}
}
use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class ARpmlintResolution method getEditor.
/**
* Returns the SpecfileEditor for the given IMarker if any.
*
* @param marker The marker to use for retrieving the editor.
* @return The IEditorPart this marker is from or null.
*/
protected IEditorPart getEditor(IMarker marker) {
// Open or activate the editor.
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart part;
try {
part = IDE.openEditor(page, marker);
} catch (PartInitException e) {
RpmlintLog.logError(e);
return null;
}
return part;
}
Aggregations