Search in sources :

Example 1 with IPerfData

use of org.eclipse.linuxtools.internal.perf.IPerfData in project linuxtools by eclipse.

the class PerfSaveStatsHandler method saveData.

@Override
public IPath saveData(String filename) {
    IPath newDataLoc = getNewDataLocation(filename, DATA_EXT);
    IPerfData statData = PerfPlugin.getDefault().getStatData();
    BufferedWriter writer = null;
    OutputStreamWriter osw = null;
    try {
        IRemoteFileProxy proxy = null;
        proxy = RemoteProxyManager.getInstance().getFileProxy(getWorkingDirURI());
        if (proxy == null) {
            openErroDialog(Messages.PerfSaveStat_error_title, Messages.PerfSaveStat_error_msg, newDataLoc.lastSegment());
            return null;
        }
        IFileStore newDataFileStore = proxy.getResource(newDataLoc.toOSString());
        osw = new OutputStreamWriter(newDataFileStore.openOutputStream(EFS.NONE, null));
        writer = new BufferedWriter(osw);
        writer.write(statData.getPerfData());
        closeResource(writer);
        IFileInfo info = newDataFileStore.fetchInfo();
        info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true);
        newDataFileStore.putInfo(info, EFS.SET_ATTRIBUTES, null);
        return newDataLoc;
    } catch (IOException | CoreException e) {
        openErroDialog(Messages.PerfSaveStat_error_title, Messages.PerfSaveStat_error_msg, newDataLoc.lastSegment());
    } finally {
        closeResource(writer);
    }
    return null;
}
Also used : IPerfData(org.eclipse.linuxtools.internal.perf.IPerfData) 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) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 2 with IPerfData

use of org.eclipse.linuxtools.internal.perf.IPerfData in project linuxtools by eclipse.

the class PerfStatDataOpenHandler method open.

@Override
public void open(IPath file) {
    File statFile = file.toFile();
    try (BufferedReader fileReader = new BufferedReader(new FileReader(statFile))) {
        final StringBuilder contents = new StringBuilder();
        final StringBuilder title = new StringBuilder();
        String line;
        // read file contents
        while ((line = fileReader.readLine()) != null) {
            // set data title
            if (title.length() == 0 && line.contains(TITLE_EXCERPT)) {
                title.append(line);
            }
            contents.append(line);
            // $NON-NLS-1$
            contents.append("\n");
        }
        // construct basic title if none was found in the file
        if (title.length() == 0) {
            title.append(NLS.bind(Messages.PerfEditorLauncher_stat_title, statFile.getName()));
        }
        final String timestamp = DateFormat.getInstance().format(new Date(statFile.lastModified()));
        PerfPlugin.getDefault().setStatData(new IPerfData() {

            @Override
            public String getTitle() {
                // $NON-NLS-1$ //$NON-NLS-2$
                return title.toString() + " (" + timestamp + ")";
            }

            @Override
            public String getPerfData() {
                return contents.toString();
            }
        });
        StatView.refreshView();
    } catch (FileNotFoundException e) {
        PerfPlugin.getDefault().openError(e, NLS.bind(Messages.PerfEditorLauncher_file_dne_error, statFile.getName()));
    } catch (IOException e) {
        PerfPlugin.getDefault().openError(e, NLS.bind(Messages.PerfEditorLauncher_file_read_error, statFile.getName()));
    }
}
Also used : IPerfData(org.eclipse.linuxtools.internal.perf.IPerfData) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) IOException(java.io.IOException) File(java.io.File) Date(java.sql.Date)

Example 3 with IPerfData

use of org.eclipse.linuxtools.internal.perf.IPerfData in project linuxtools by eclipse.

the class StatView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    parent.setLayoutData(new GridLayout(1, true));
    text = new StyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    text.setEditable(false);
    IPerfData data = PerfPlugin.getDefault().getStatData();
    if (data != null) {
        setStyledText(data.getPerfData());
        setContentDescription(data.getTitle());
    }
}
Also used : IPerfData(org.eclipse.linuxtools.internal.perf.IPerfData) GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText)

Example 4 with IPerfData

use of org.eclipse.linuxtools.internal.perf.IPerfData in project linuxtools by eclipse.

the class SourceDisassemblyView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    parent.setLayoutData(new GridLayout(1, true));
    text = new StyledText(parent, SWT.WRAP | SWT.V_SCROLL);
    text.setEditable(false);
    IPerfData data = PerfPlugin.getDefault().getSourceDisassemblyData();
    if (data != null) {
        setStyledText(data.getPerfData());
        setContentDescription(data.getTitle());
        setupFindDialog();
    }
}
Also used : IPerfData(org.eclipse.linuxtools.internal.perf.IPerfData) GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText)

Example 5 with IPerfData

use of org.eclipse.linuxtools.internal.perf.IPerfData in project linuxtools by eclipse.

the class StatView method updateData.

/**
 * Update to most recent statistics data.
 */
private void updateData() {
    IPerfData data = PerfPlugin.getDefault().getStatData();
    if (data != null) {
        setStyledText(data.getPerfData());
        setContentDescription(data.getTitle());
    }
}
Also used : IPerfData(org.eclipse.linuxtools.internal.perf.IPerfData)

Aggregations

IPerfData (org.eclipse.linuxtools.internal.perf.IPerfData)5 IOException (java.io.IOException)2 StyledText (org.eclipse.swt.custom.StyledText)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Date (java.sql.Date)1 IFileInfo (org.eclipse.core.filesystem.IFileInfo)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IRemoteFileProxy (org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy)1