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;
}
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()));
}
}
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());
}
}
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();
}
}
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());
}
}
Aggregations