32
32
public class PerfSaveStatsHandler extends AbstractSaveDataHandler {
34
public static String DATA_EXT = "stat"; //$NON-NLS-1$
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;
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);
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());
69
closeResource(writer);
75
public boolean verifyData() {
76
IPerfData statData = PerfPlugin.getDefault().getStatData();
77
return statData != null && statData.getPerfData() != null;
34
public static String DATA_EXT = "stat"; //$NON-NLS-1$
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;
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);
56
} catch (IOException|CoreException|URISyntaxException e) {
57
openErroDialog(Messages.PerfSaveStat_error_title,
58
Messages.PerfSaveStat_error_msg,
59
newDataLoc.lastSegment());
61
closeResource(writer);
67
public boolean verifyData() {
68
IPerfData statData = PerfPlugin.getDefault().getStatData();
69
return statData != null && statData.getPerfData() != null;