use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class ChartEditor method showView.
/**
* Shows the Valgrind view in the active page and gives it focus.
*/
private void showView() {
Display.getDefault().syncExec(() -> {
try {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
activePage.showView(IValgrindToolView.VIEW_ID);
} catch (PartInitException e) {
e.printStackTrace();
}
});
}
use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class SpecfileFormEditor method addPages.
@Override
protected void addPages() {
try {
int index = addPage(editor, getEditorInput());
setPageText(index, Messages.SpecfileFormEditor_0);
Specfile specfile = editor.getSpecfile();
FormPage mainPackage = new MainPackagePage(this, specfile);
addPage(0, mainPackage);
addPage(1, new RpmSectionPage(this, specfile, RpmSections.PREP_SECTION));
addPage(2, new RpmSectionPage(this, specfile, RpmSections.BUILD_SECTION));
addPage(3, new RpmSectionPage(this, specfile, RpmSections.INSTALL_SECTION));
} catch (PartInitException e) {
//
}
}
use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class SourcesFileHyperlink method open.
/**
* Tries to open the given file name looking for it in the current directory
* and in ../SOURCES.
*
* @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
*/
@Override
public void open() {
IContainer container = original.getParent();
IResource resourceToOpen = container.findMember(fileName);
if (resourceToOpen == null) {
IResource sourcesFolder = container.getParent().findMember(// $NON-NLS-1$
"SOURCES");
resourceToOpen = ((IFolder) sourcesFolder).getFile(fileName);
}
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
if (resourceToOpen.getType() == IResource.FILE) {
IDE.openEditor(page, (IFile) resourceToOpen);
}
} catch (PartInitException e) {
SpecfileLog.logError(e);
}
}
use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class CovView method displayCovResults.
public static void displayCovResults(String binaryPath, String gcda) {
try {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile binary = root.getFileForLocation(new Path(binaryPath));
IProject project = null;
if (binary != null) {
project = binary.getProject();
}
// parse and process coverage data
CovManager cvrgeMnger = new CovManager(binaryPath, project);
List<String> gcdaPaths = cvrgeMnger.getGCDALocations();
cvrgeMnger.processCovFiles(gcdaPaths, gcda);
// generate model for view
cvrgeMnger.fillGcovView();
// load an Eclipse view
Date date = new Date(0);
Date dateCandidate;
for (String file : gcdaPaths) {
dateCandidate = new Date(new File(file).lastModified());
if (dateCandidate.after(date)) {
date = dateCandidate;
}
}
String timestamp = DateFormat.getInstance().format(date);
PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
try {
displayCovResults(cvrgeMnger, timestamp);
} catch (PartInitException e) {
reportError(e);
}
});
} catch (InterruptedException | IOException | CoreException e) {
reportError(e);
}
}
use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class OpenSourceFileAction method openAnnotatedSourceFile.
public static void openAnnotatedSourceFile(IProject project, IFile binary, SourceFile sourceFile, IPath realLocation, int lineNumber) {
PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
IWorkbenchPage page = CUIPlugin.getActivePage();
if (page != null) {
IFileStore fs = getFileStore(project, realLocation);
if (fs == null && !realLocation.isAbsolute() && binary != null) {
IPath p = binary.getProjectRelativePath().removeLastSegments(1);
fs = getFileStore(project, p.append(realLocation));
}
if (fs == null) {
try {
page.openEditor(new STAnnotatedSourceNotFoundEditorInput(project, sourceFile, realLocation, lineNumber), STAnnotatedSourceNotFoundEditor.ID, true);
} catch (PartInitException e) {
Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.OpenSourceFileAction_open_error, e);
Activator.getDefault().getLog().log(s);
}
} else {
try {
IEditorPart editor = IDE.openEditorOnFileStore(page, fs);
if (lineNumber > 0 && editor instanceof ITextEditor) {
IDocumentProvider provider = ((ITextEditor) editor).getDocumentProvider();
IDocument document = provider.getDocument(editor.getEditorInput());
try {
int start = document.getLineOffset(lineNumber - 1);
((ITextEditor) editor).selectAndReveal(start, 0);
} catch (BadLocationException e) {
// ignore
}
IWorkbenchPage p = editor.getSite().getPage();
p.activate(editor);
}
} catch (PartInitException e) {
Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.OpenSourceFileAction_open_error, e);
Activator.getDefault().getLog().log(s);
}
}
}
});
}
Aggregations