aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2013-03-04 18:10:18 (EST)
committerRoland Grunberg2013-03-06 16:14:03 (EST)
commit35f4b3945cbee8659339a785ddd81b938821508d (patch)
tree6eaf675149f4d54f887ae65deaa238c5c0d1362d
parent1343e1f4d33d9e45b247c54458041729a9a7827d (diff)
downloadorg.eclipse.linuxtools-35f4b3945cbee8659339a785ddd81b938821508d.zip
org.eclipse.linuxtools-35f4b3945cbee8659339a785ddd81b938821508d.tar.gz
org.eclipse.linuxtools-35f4b3945cbee8659339a785ddd81b938821508d.tar.bz2
Add support for saving perf stat sessions.refs/changes/61/10861/7
* Created abstract class to handle common functionality of save commands. * Refactored PerfSaveSessionHandler to make use of abstract class. * Reimplemeted PerfSaveSessionHandler to copy data file instead of renaming. * Implemented tests for covering saving functionality. Change-Id: I4da01e98f83232841d2d1b1b1ada639544ecfd2f Reviewed-on: https://git.eclipse.org/r/10861 Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/AllPerfTests.java1
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/SaveSessionTest.java131
-rw-r--r--perf/org.eclipse.linuxtools.perf/plugin.xml15
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/AbstractSaveDataHandler.java163
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/Messages.java10
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfSaveSessionHandler.java118
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfSaveStatsHandler.java60
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/messages.properties10
8 files changed, 443 insertions, 65 deletions
diff --git a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/AllPerfTests.java b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/AllPerfTests.java
index 35b1b33..550a82b 100644
--- a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/AllPerfTests.java
+++ b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/AllPerfTests.java
@@ -31,6 +31,7 @@ public class AllPerfTests {
suite.addTestSuite(LaunchTabsTest.class);
suite.addTestSuite(ModelTest.class);
suite.addTestSuite(DataManipulatorTest.class);
+ suite.addTestSuite(SaveSessionTest.class);
if (RUN_PERF) {
suite.addTestSuite(LaunchTest.class);
diff --git a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/SaveSessionTest.java b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/SaveSessionTest.java
new file mode 100644
index 0000000..39f8192
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/SaveSessionTest.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camilo Bernal <cabernal@redhat.com> - Initial Implementation.
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.perf.tests;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.internal.perf.PerfPlugin;
+import org.eclipse.linuxtools.internal.perf.StatData;
+import org.eclipse.linuxtools.internal.perf.ui.AbstractSaveDataHandler;
+import org.eclipse.linuxtools.internal.perf.ui.PerfSaveSessionHandler;
+import org.eclipse.linuxtools.internal.perf.ui.PerfSaveStatsHandler;
+
+import junit.framework.TestCase;
+
+public class SaveSessionTest extends TestCase {
+ private static final String WORKING_DIR = "resources/"; //$NON-NLS-1$
+ private static final String DATA_FILE_PATH = "/mock/data/path"; //$NON-NLS-1$
+ private static final String PERF_DATA_FILE_PATH = "resources/perf.data"; //$NON-NLS-1$
+ private static final String PERF_STATS_FILE_PATH = "stat_data"; //$NON-NLS-1$
+ private static final String DATA_FILE_NAME = "data"; //$NON-NLS-1$
+ private static final String DATA_FILE_EXT = "ext"; //$NON-NLS-1$
+ private ArrayList<File> testFiles = new ArrayList<File>();
+
+ @Override
+ protected void tearDown(){
+ for (File file : testFiles) {
+ file.delete();
+ }
+ }
+
+ public void testGenericHandler() {
+ GenericSaveDataHandler handler = new GenericSaveDataHandler();
+ assertTrue(handler.canSave(new File(DATA_FILE_PATH)));
+ assertEquals(WORKING_DIR, handler.getWorkingDir().toOSString());
+
+ IPath path = handler.getNewDataLocation(DATA_FILE_NAME, DATA_FILE_EXT);
+ assertEquals(WORKING_DIR + DATA_FILE_NAME + '.' + DATA_FILE_EXT, //$NON-NLS-1$
+ path.toOSString());
+
+ assertTrue(handler.isEnabled());
+ assertTrue(handler.isHandled());
+ }
+
+ public void testPerfSaveSessionHandler() {
+ PerfSaveSessionTestHandler handler = new PerfSaveSessionTestHandler();
+
+ PerfPlugin.getDefault().setPerfProfileData(null);
+ assertFalse(handler.verifyData());
+
+ PerfPlugin.getDefault().setPerfProfileData(
+ new Path(PERF_DATA_FILE_PATH));
+ assertTrue(handler.verifyData());
+
+ File data = handler.saveData(DATA_FILE_NAME);
+ assertNotNull(data);
+ testFiles.add(data);
+
+ }
+
+ // mock handlers
+
+ public void testPerfSaveStatsHandler() {
+ PerfSaveStatsTestHandler handler = new PerfSaveStatsTestHandler();
+
+ PerfPlugin.getDefault().setStatData(null);
+ assertFalse(handler.verifyData());
+
+ PerfPlugin.getDefault().setStatData(
+ new StatData("title", "prog", new String[] {}, 1) { //$NON-NLS-1$ //$NON-NLS-2$
+ @Override
+ public String getPerfData() {
+ return PERF_STATS_FILE_PATH;
+ }
+ });
+ assertTrue(handler.verifyData());
+
+ File stats = handler.saveData(DATA_FILE_NAME);
+ assertNotNull(stats);
+
+ testFiles.add(stats);
+ }
+
+ private class GenericSaveDataHandler extends AbstractSaveDataHandler {
+ @Override
+ public Object execute(ExecutionEvent event) {
+ return null;
+ }
+
+ @Override
+ public File saveData(String filename) {
+ return null;
+ }
+
+ @Override
+ public boolean verifyData() {
+ return true;
+ }
+
+ @Override
+ protected IPath getWorkingDir() {
+ return new Path(WORKING_DIR);
+ }
+ }
+
+ private class PerfSaveSessionTestHandler extends PerfSaveSessionHandler {
+ @Override
+ protected IPath getWorkingDir() {
+ return new Path(WORKING_DIR);
+ }
+ }
+
+ private class PerfSaveStatsTestHandler extends PerfSaveStatsHandler {
+ @Override
+ protected IPath getWorkingDir() {
+ return new Path(WORKING_DIR);
+ }
+ }
+
+}
diff --git a/perf/org.eclipse.linuxtools.perf/plugin.xml b/perf/org.eclipse.linuxtools.perf/plugin.xml
index 7dc8cd0..d362e67 100644
--- a/perf/org.eclipse.linuxtools.perf/plugin.xml
+++ b/perf/org.eclipse.linuxtools.perf/plugin.xml
@@ -174,6 +174,16 @@
style="push">
</command>
</menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="menu:org.eclipse.linuxtools.perf.ui.StatView">
+ <command
+ commandId="org.eclipse.linuxtools.perf.SaveStatData"
+ id="org.eclipse.linuxtools.perf.SaveStatData"
+ label="Save Statistics"
+ style="push">
+ </command>
+ </menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
@@ -182,5 +192,10 @@
id="org.eclipse.linuxtools.perf.SaveData"
name="Save Current Session">
</command>
+ <command
+ defaultHandler="org.eclipse.linuxtools.internal.perf.ui.PerfSaveStatsHandler"
+ id="org.eclipse.linuxtools.perf.SaveStatData"
+ name="Save Statistics">
+ </command>
</extension>
</plugin>
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/AbstractSaveDataHandler.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/AbstractSaveDataHandler.java
new file mode 100644
index 0000000..1526ea5
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/AbstractSaveDataHandler.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camilo Bernal <cabernal@redhat.com> - Initial Implementation.
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.perf.ui;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.text.MessageFormat;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.perf.PerfPlugin;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Class for handling general tasks handled by session saving commands:
+ * File name creation and validation, command enablement, data file verification.
+ */
+public abstract class AbstractSaveDataHandler implements IHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) {
+ InputDialog dialog = new InputDialog(Display.getCurrent()
+ .getActiveShell(), Messages.PerfSaveSession_title,
+ Messages.PerfSaveSession_msg, "", new IInputValidator() {
+
+ @Override
+ public String isValid(String newText) {
+ if ("".equals(newText)) {
+ return Messages.PerfSaveSession_invalid_filename_msg;
+ }
+ return null;
+ }
+ });
+
+ if (dialog.open() == Window.OK) {
+ saveData(dialog.getValue());
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ IPath curWorkingDirectory = getWorkingDir();
+ return curWorkingDirectory != null && !curWorkingDirectory.isEmpty()
+ && verifyData();
+ }
+
+ /**
+ * Get current working directory.
+ * @return current working directory.
+ */
+ protected IPath getWorkingDir() {
+ return PerfPlugin.getDefault().getWorkingDir();
+ }
+
+ /**
+ * New data location based on specified name, which the specified
+ * extension will be appended to.
+ *
+ * @param filename
+ * @param extension
+ * @return
+ */
+ public IPath getNewDataLocation(String filename, String extension) {
+ IPath newFilename = getWorkingDir().append(filename);
+ return newFilename.addFileExtension(extension);
+
+ }
+
+ /**
+ * Verify that we can save the specified file.
+ *
+ * @param file <code>File</code> to save
+ * @return true if we can go ahead and save the file, false otherwise
+ */
+ public boolean canSave(File file) {
+ if (file.exists()) {
+ String msg = MessageFormat.format(
+ Messages.PerfSaveSession_file_exists_msg,
+ new Object[] { file.getName() });
+ return MessageDialog.openQuestion(Display.getCurrent()
+ .getActiveShell(),
+ Messages.PerfSaveSession_file_exists_title, msg);
+ }
+ return true;
+ }
+
+ /**
+ * Open error dialog informing user of saving failure.
+ * @param filename
+ */
+ public void openErroDialog(String title, String pattern, String arg) {
+ String errorMsg = MessageFormat.format(pattern, new Object[] { arg });
+ MessageDialog.openError(Display.getCurrent().getActiveShell(), title,
+ errorMsg);
+ }
+
+ /**
+ * Close specified resource
+ *
+ * @param resrc resource to close
+ * @param resrcName resource name
+ */
+ public void closeResource(Closeable resrc, String resrcName) {
+ if (resrc != null) {
+ try {
+ resrc.close();
+ } catch (IOException e) {
+ openErroDialog(Messages.PerfResourceLeak_title,
+ Messages.PerfResourceLeak_msg, resrcName);
+ }
+ }
+ }
+
+ /**
+ * Save data to file with specified name and return handle
+ *
+ * @param filename the file name
+ */
+ public abstract File saveData(String filename);
+
+ /**
+ * Verify data to save.
+ *
+ * @return true if data is valid
+ */
+ public abstract boolean verifyData();
+
+ @Override
+ public boolean isHandled() {
+ return isEnabled();
+ }
+
+ @Override
+ public void removeHandlerListener(IHandlerListener handlerListener) {
+ }
+
+ @Override
+ public void addHandlerListener(IHandlerListener handlerListener) {
+
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+}
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/Messages.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/Messages.java
index b2f2a9d..986caa3 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/Messages.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/Messages.java
@@ -18,8 +18,14 @@ public class Messages extends NLS {
public static String PerfSaveSession_msg;
public static String PerfSaveSession_invalid_filename_title;
public static String PerfSaveSession_invalid_filename_msg;
- public static String PerfSaveSession_no_data_found_title;
- public static String PerfSaveSession_no_data_found_msg;
+ public static String PerfSaveSession_file_exists_title;
+ public static String PerfSaveSession_file_exists_msg;
+ public static String PerfSaveStat_error_title;
+ public static String PerfSaveStat_error_msg;
+ public static String PerfSaveSession_failure_title;
+ public static String PerfSaveSession_failure_msg;
+ public static String PerfResourceLeak_title;
+ public static String PerfResourceLeak_msg;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfSaveSessionHandler.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfSaveSessionHandler.java
index 3b238bd..6b93f10 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfSaveSessionHandler.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfSaveSessionHandler.java
@@ -11,86 +11,82 @@
package org.eclipse.linuxtools.internal.perf.ui;
import java.io.File;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.window.Window;
import org.eclipse.linuxtools.internal.perf.PerfPlugin;
-import org.eclipse.swt.widgets.Display;
-public class PerfSaveSessionHandler implements IHandler {
+/**
+ * Handler for saving a perf profile session.
+ */
+public class PerfSaveSessionHandler extends AbstractSaveDataHandler {
+ private static String DATA_EXT = "data"; //$NON-NLS-1$
@Override
- public Object execute(ExecutionEvent event) {
- InputDialog dialog = new InputDialog(Display.getCurrent()
- .getActiveShell(), Messages.PerfSaveSession_title,
- Messages.PerfSaveSession_msg, "", new IInputValidator() {
-
- @Override
- public String isValid(String newText) {
- if ("".equals(newText)) {
- return Messages.PerfSaveSession_invalid_filename_msg;
- }
- return null;
- }
- });
-
- if (dialog.open() == Window.OK) {
- String fileName = dialog.getValue();
-
- // get paths
- IPath curWorkingDirectory = PerfPlugin.getDefault().getWorkingDir();
- IPath newDataLoc = curWorkingDirectory.append(fileName).addFileExtension("data"); //$NON-NLS-1$
- IPath defaultDataLoc = PerfPlugin.getDefault().getPerfProfileData();
+ public File saveData(String filename) {
+ // get paths
+ IPath newDataLoc = getNewDataLocation(filename, DATA_EXT);
+ IPath defaultDataLoc = PerfPlugin.getDefault().getPerfProfileData();
- // get files
- File newDataFile = newDataLoc.toFile();
- File defaultDataFile = defaultDataLoc.toFile();
+ // get files
+ File newDataFile = new File(newDataLoc.toOSString());
+ File defaultDataFile = defaultDataLoc.toFile();
- // rename default perf data file
- if (defaultDataFile.renameTo(newDataFile)) {
+ if (canSave(newDataFile)) {
+ // copy default data into new location
+ try {
+ newDataFile.createNewFile();
+ copyFile(defaultDataFile, newDataFile);
PerfPlugin.getDefault().setPerfProfileData(newDataLoc);
- PerfPlugin.getDefault().getProfileView().setContentDescription(newDataLoc.toOSString());
- } else{
- MessageDialog.openError(Display.getCurrent().getActiveShell(),
- Messages.PerfSaveSession_no_data_found_title,
- Messages.PerfSaveSession_no_data_found_msg);
+ PerfPlugin.getDefault().getProfileView()
+ .setContentDescription(newDataLoc.toOSString());
+
+ return newDataFile;
+ } catch (IOException e) {
+ openErroDialog(Messages.PerfSaveSession_failure_title,
+ Messages.PerfSaveSession_failure_msg,
+ newDataLoc.lastSegment());
}
}
-
return null;
- }
- @Override
- public boolean isEnabled() {
- IPath defaultDataLoc = PerfPlugin.getDefault().getPerfProfileData();
- IPath curWorkingDirectory = PerfPlugin.getDefault().getWorkingDir();
- if (defaultDataLoc == null || curWorkingDirectory == null
- || defaultDataLoc.isEmpty() || curWorkingDirectory.isEmpty()) {
- return false;
- }
- return true;
}
@Override
- public boolean isHandled() {
- return isEnabled();
+ public boolean verifyData() {
+ IPath defaultDataLoc = PerfPlugin.getDefault().getPerfProfileData();
+ return defaultDataLoc != null && !defaultDataLoc.isEmpty();
}
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- }
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
+ private void copyFile(File src, File dest) {
+ InputStream destInput = null;
+ OutputStream srcOutput = null;
+ try {
+ destInput = new FileInputStream(src);
+ srcOutput = new FileOutputStream(dest);
- }
+ byte[] buffer = new byte[1024];
- @Override
- public void dispose() {
+ int length;
+ while ((length = destInput.read(buffer)) != -1) {
+ srcOutput.write(buffer, 0, length);
+ }
+ } catch (FileNotFoundException e) {
+ openErroDialog(Messages.PerfSaveSession_failure_title,
+ Messages.PerfSaveSession_failure_msg,
+ dest.toString());
+ } catch (IOException e) {
+ openErroDialog(Messages.PerfSaveSession_failure_title,
+ Messages.PerfSaveSession_failure_msg,
+ dest.toString());
+ } finally {
+ closeResource(destInput, dest.getName());
+ closeResource(srcOutput, src.getName());
+ }
}
}
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfSaveStatsHandler.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfSaveStatsHandler.java
new file mode 100644
index 0000000..a38984b
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfSaveStatsHandler.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camilo Bernal <cabernal@redhat.com> - Initial Implementation.
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.perf.ui;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.linuxtools.internal.perf.PerfPlugin;
+import org.eclipse.linuxtools.internal.perf.StatData;
+
+/**
+ * Handler for saving a perf statistics session.
+ */
+public class PerfSaveStatsHandler extends AbstractSaveDataHandler {
+
+ private static String DATA_EXT = "stat"; //$NON-NLS-1$
+
+ @Override
+ public File saveData(String filename) {
+ IPath newDataLoc = getNewDataLocation(filename, DATA_EXT);
+ StatData statData = PerfPlugin.getDefault().getStatData();
+
+ File statsData = new File(newDataLoc.toOSString());
+
+ if (canSave(statsData)) {
+ BufferedWriter bw = null;
+ try {
+ statsData.createNewFile();
+ FileWriter fw = new FileWriter(statsData.getAbsoluteFile());
+ bw = new BufferedWriter(fw);
+ bw.write(statData.getPerfData());
+ return statsData;
+ } catch (IOException e) {
+ openErroDialog(Messages.PerfSaveStat_error_title,
+ Messages.PerfSaveStat_error_msg,
+ newDataLoc.lastSegment());
+ } finally {
+ closeResource(bw, statsData.getName());
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean verifyData() {
+ StatData statData = PerfPlugin.getDefault().getStatData();
+ return statData != null && statData.getPerfData() != null;
+ }
+
+}
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/messages.properties b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/messages.properties
index 8df3e05..5e18869 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/messages.properties
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/messages.properties
@@ -2,5 +2,11 @@ PerfSaveSession_title=Save Current Session
PerfSaveSession_msg=Enter the new name of the current session
PerfSaveSession_invalid_filename_title=Invalid file name
PerfSaveSession_invalid_filename_msg=Please provide a valid file name
-PerfSaveSession_no_data_found_title=No profile data found
-PerfSaveSession_no_data_found_msg=No profile data found for the current session
+PerfSaveSession_file_exists_title=File already exists
+PerfSaveSession_file_exists_msg=Do you wish to overwrite {0} ?
+PerfSaveSession_failure_title= Error Saving Session
+PerfSaveSession_failure_msg= Could not save profiling session to {0}
+PerfSaveStat_error_title=Error Saving Statistics
+PerfSaveStat_error_msg=Could not save statistics to {0}
+PerfResourceLeak_title=Resource Leak
+PerfResourceLeak_msg=Could not close {0} \ No newline at end of file