~ubuntu-branches/ubuntu/vivid/eclipse-linuxtools/vivid-proposed

« back to all changes in this revision

Viewing changes to perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfSaveStatsHandler.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam, Jakub Adam, tony mancill
  • Date: 2014-10-11 11:44:05 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20141011114405-yazjvxfzzhmi5sgj
Tags: 3.1.0-1
[ Jakub Adam ]
* New upstream release (Closes: #761524).
* Refreshed d/patches.
* Don't build removed feature org.eclipse.linuxtools.tools.launch
  - merged into org.eclipse.linuxtools.profiling.
* Use javac target 1.7.
* Build new feature org.eclipse.linuxtools.dataviewers.feature
  - required by Valgrind integration.
* Build-depend on eclipse-remote-services-api and eclipse-cdt-autotools.
* Bump Standards-Version to 3.9.6.
* Override incompatible-java-bytecode-format - linuxtools needs Java 7.
* Remove unused codeless-jar override.

[ tony mancill ]
* Tweak short package description to make lintian happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 */
32
32
public class PerfSaveStatsHandler extends AbstractSaveDataHandler {
33
33
 
34
 
        public static String DATA_EXT = "stat"; //$NON-NLS-1$
35
 
 
36
 
        @Override
37
 
        public IPath saveData(String filename) {
38
 
                IPath newDataLoc = getNewDataLocation(filename, DATA_EXT);
39
 
                IPerfData statData = PerfPlugin.getDefault().getStatData();
40
 
                BufferedWriter writer = null;
41
 
                OutputStreamWriter osw = null;
42
 
                URI newDataLocURI = null;
43
 
 
44
 
                try {
45
 
                        IRemoteFileProxy proxy = null;
46
 
                        newDataLocURI = new URI(newDataLoc.toPortableString());
47
 
                        proxy = RemoteProxyManager.getInstance().getFileProxy(newDataLocURI);
48
 
                        IFileStore newDataFileStore = proxy.getResource(newDataLocURI.getPath());
49
 
                        osw = new OutputStreamWriter(newDataFileStore.openOutputStream(EFS.NONE, null));
50
 
                        writer = new BufferedWriter(osw);
51
 
                        writer.write(statData.getPerfData());
52
 
                        IFileInfo info = newDataFileStore.fetchInfo();
53
 
                        info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true);
54
 
                        newDataFileStore.putInfo(info, EFS.SET_ATTRIBUTES, null);
55
 
                        return newDataLoc;
56
 
                } catch (IOException e) {
57
 
                        openErroDialog(Messages.PerfSaveStat_error_title,
58
 
                                        Messages.PerfSaveStat_error_msg,
59
 
                                        newDataLoc.lastSegment());
60
 
                } catch (CoreException e) {
61
 
                        openErroDialog(Messages.PerfSaveStat_error_title,
62
 
                                        Messages.PerfSaveStat_error_msg,
63
 
                                        newDataLoc.lastSegment());
64
 
                } catch (URISyntaxException e) {
65
 
                        openErroDialog(Messages.PerfSaveStat_error_title,
66
 
                                        Messages.PerfSaveStat_error_msg,
67
 
                                        newDataLoc.lastSegment());
68
 
                } finally {
69
 
                        closeResource(writer);
70
 
                }
71
 
                return null;
72
 
        }
73
 
 
74
 
        @Override
75
 
        public boolean verifyData() {
76
 
                IPerfData statData = PerfPlugin.getDefault().getStatData();
77
 
                return statData != null && statData.getPerfData() != null;
78
 
        }
 
34
    public static String DATA_EXT = "stat"; //$NON-NLS-1$
 
35
 
 
36
    @Override
 
37
    public IPath saveData(String filename) {
 
38
        IPath newDataLoc = getNewDataLocation(filename, DATA_EXT);
 
39
        IPerfData statData = PerfPlugin.getDefault().getStatData();
 
40
        BufferedWriter writer = null;
 
41
        OutputStreamWriter osw = null;
 
42
        URI newDataLocURI = null;
 
43
 
 
44
        try {
 
45
            IRemoteFileProxy proxy = null;
 
46
            newDataLocURI = new URI(newDataLoc.toPortableString());
 
47
            proxy = RemoteProxyManager.getInstance().getFileProxy(newDataLocURI);
 
48
            IFileStore newDataFileStore = proxy.getResource(newDataLocURI.getPath());
 
49
            osw = new OutputStreamWriter(newDataFileStore.openOutputStream(EFS.NONE, null));
 
50
            writer = new BufferedWriter(osw);
 
51
            writer.write(statData.getPerfData());
 
52
            IFileInfo info = newDataFileStore.fetchInfo();
 
53
            info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true);
 
54
            newDataFileStore.putInfo(info, EFS.SET_ATTRIBUTES, null);
 
55
            return newDataLoc;
 
56
        } catch (IOException|CoreException|URISyntaxException e) {
 
57
            openErroDialog(Messages.PerfSaveStat_error_title,
 
58
                    Messages.PerfSaveStat_error_msg,
 
59
                    newDataLoc.lastSegment());
 
60
        } finally {
 
61
            closeResource(writer);
 
62
        }
 
63
        return null;
 
64
    }
 
65
 
 
66
    @Override
 
67
    public boolean verifyData() {
 
68
        IPerfData statData = PerfPlugin.getDefault().getStatData();
 
69
        return statData != null && statData.getPerfData() != null;
 
70
    }
79
71
 
80
72
}