Search in sources :

Example 86 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class PerfCore method refreshView.

public static void refreshView(final String title) {
    Display.getDefault().syncExec(() -> {
        try {
            PerfProfileView view = (PerfProfileView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
            view.setContentDescription(title);
            view.refreshModel();
        } catch (PartInitException e) {
            logException(e);
        }
    });
}
Also used : PerfProfileView(org.eclipse.linuxtools.internal.perf.ui.PerfProfileView) PartInitException(org.eclipse.ui.PartInitException)

Example 87 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class PerfSaveSessionHandler method saveData.

@Override
public IPath saveData(String filename) {
    // get paths
    IPath newDataLoc = getNewDataLocation(filename, DATA_EXT);
    IPath defaultDataLoc = PerfPlugin.getDefault().getPerfProfileData();
    URI newDataLocURI = null;
    URI defaultDataLocURI = null;
    // get files
    IRemoteFileProxy proxy = null;
    try {
        newDataLocURI = new URI(newDataLoc.toPortableString());
        defaultDataLocURI = new URI(defaultDataLoc.toPortableString());
        proxy = RemoteProxyManager.getInstance().getFileProxy(newDataLocURI);
    } catch (URISyntaxException e) {
        openErroDialog(Messages.MsgProxyError, Messages.MsgProxyError, newDataLoc.lastSegment());
    } catch (CoreException e) {
        openErroDialog(Messages.MsgProxyError, Messages.MsgProxyError, newDataLoc.lastSegment());
    }
    IFileStore newDataFileStore = proxy.getResource(newDataLocURI.getPath());
    IFileStore defaultDataFileStore = proxy.getResource(defaultDataLocURI.getPath());
    if (canSave(newDataLoc)) {
        // copy default data into new location
        try {
            defaultDataFileStore.copy(newDataFileStore, EFS.OVERWRITE, null);
            PerfPlugin.getDefault().setPerfProfileData(newDataLoc);
            try {
                PerfProfileView view = (PerfProfileView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
                view.setContentDescription(newDataLoc.toOSString());
            } catch (PartInitException e) {
            // fail silently
            }
            IFileInfo info = newDataFileStore.fetchInfo();
            info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true);
            newDataFileStore.putInfo(info, EFS.SET_ATTRIBUTES, null);
            return newDataLoc;
        } catch (CoreException e) {
            openErroDialog(Messages.PerfSaveSession_failure_title, Messages.PerfSaveSession_failure_msg, newDataLoc.lastSegment());
        }
    }
    return null;
}
Also used : PerfProfileView(org.eclipse.linuxtools.internal.perf.ui.PerfProfileView) IFileInfo(org.eclipse.core.filesystem.IFileInfo) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) IRemoteFileProxy(org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy) IFileStore(org.eclipse.core.filesystem.IFileStore) URISyntaxException(java.net.URISyntaxException) PartInitException(org.eclipse.ui.PartInitException) URI(java.net.URI)

Example 88 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class STLink2SourceSupport method openFileImpl.

private static boolean openFileImpl(IProject project, IPath sourceLoc, int lineNumber) {
    if (sourceLoc == null || "??".equals(sourceLoc.toString())) {
        // $NON-NLS-1$
        return false;
    }
    try {
        IEditorInput editorInput = getEditorInput(sourceLoc, project);
        IWorkbenchPage p = CUIPlugin.getActivePage();
        if (p != null) {
            if (editorInput == null) {
                p.openEditor(new STCSourceNotFoundEditorInput(project, sourceLoc, lineNumber), STCSourceNotFoundEditor.ID, true);
            } else {
                IEditorPart editor = p.openEditor(editorInput, CUIPlugin.EDITOR_ID, true);
                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);
                        IWorkbenchPage page = editor.getSite().getPage();
                        page.activate(editor);
                        return true;
                    } catch (BadLocationException x) {
                    // ignore
                    }
                }
            }
        }
    } catch (PartInitException e) {
    }
    return false;
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 89 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class OprofileViewDoubleClickListener method doubleClick.

@Override
public void doubleClick(DoubleClickEvent event) {
    TreeViewer tv = (TreeViewer) event.getSource();
    TreeSelection tsl = (TreeSelection) tv.getSelection();
    IUiModelElement element = (IUiModelElement) tsl.getFirstElement();
    try {
        if (element instanceof UiModelEvent) {
        // UiModelEvent event = (UiModelEvent)element;
        } else if (element instanceof UiModelSession) {
        /* moved into an action menu */
        } else if (element instanceof UiModelImage) {
        // UiModelImage image = (UiModelImage)element;
        } else if (element instanceof UiModelSymbol) {
            final UiModelSymbol symbol = (UiModelSymbol) element;
            final String fileName = symbol.getFileName();
            int line = symbol.getLineNumber();
            ProfileUIUtils.openEditorAndSelect(fileName, line);
        } else if (element instanceof UiModelSample) {
            // jump to line number in the appropriate file
            UiModelSample sample = (UiModelSample) element;
            int line = sample.getLine();
            // get file name from the parent sample
            final String fileName = sample.getFile();
            ProfileUIUtils.openEditorAndSelect(fileName, line, getProject());
        }
    } catch (BadLocationException e1) {
        e1.printStackTrace();
    } catch (PartInitException e2) {
        e2.printStackTrace();
    } catch (CoreException e) {
        e.printStackTrace();
    }
}
Also used : UiModelSample(org.eclipse.linuxtools.oprofile.ui.model.UiModelSample) UiModelEvent(org.eclipse.linuxtools.oprofile.ui.model.UiModelEvent) IUiModelElement(org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement) TreeViewer(org.eclipse.jface.viewers.TreeViewer) UiModelSession(org.eclipse.linuxtools.oprofile.ui.model.UiModelSession) CoreException(org.eclipse.core.runtime.CoreException) TreeSelection(org.eclipse.jface.viewers.TreeSelection) PartInitException(org.eclipse.ui.PartInitException) UiModelImage(org.eclipse.linuxtools.oprofile.ui.model.UiModelImage) UiModelSymbol(org.eclipse.linuxtools.oprofile.ui.model.UiModelSymbol) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 90 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class MassifViewPart method displayChart.

private void displayChart(final ChartEditorInput chartInput) {
    Display.getDefault().syncExec(() -> {
        try {
            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            page.openEditor(chartInput, MassifPlugin.EDITOR_ID);
        } catch (PartInitException e) {
            e.printStackTrace();
        }
    });
    saveChartAction.setChart(chartInput.getChart().getChartControl(), chartInput.getName());
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

PartInitException (org.eclipse.ui.PartInitException)720 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)300 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)177 IFile (org.eclipse.core.resources.IFile)146 IEditorPart (org.eclipse.ui.IEditorPart)141 CoreException (org.eclipse.core.runtime.CoreException)94 FileEditorInput (org.eclipse.ui.part.FileEditorInput)88 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)82 IEditorInput (org.eclipse.ui.IEditorInput)74 ISelection (org.eclipse.jface.viewers.ISelection)62 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)60 IResource (org.eclipse.core.resources.IResource)59 IEditorReference (org.eclipse.ui.IEditorReference)53 IViewPart (org.eclipse.ui.IViewPart)53 IOException (java.io.IOException)42 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)41 Point (org.eclipse.swt.graphics.Point)40 IWorkbench (org.eclipse.ui.IWorkbench)40 Path (org.eclipse.core.runtime.Path)39 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)39