Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2013-11-17 18:25:26 -0500
committerMarc-Andre Laperle2013-11-20 17:30:01 -0500
commit25e044e1ff112997944f04bdedbd69af9d80c385 (patch)
tree18e5142678205bbad85c5d19da5d05f279de9b35
parenta949439c632ffa75b80ecabe05c7e012774bc2ee (diff)
downloadorg.eclipse.linuxtools-25e044e1ff112997944f04bdedbd69af9d80c385.tar.gz
org.eclipse.linuxtools-25e044e1ff112997944f04bdedbd69af9d80c385.tar.xz
org.eclipse.linuxtools-25e044e1ff112997944f04bdedbd69af9d80c385.zip
tmf: Remember last selected directory in Batch Import wizard
Change-Id: I2a166af74ef8720ec672b56980493967bf7eb874 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/18480 Tested-by: Hudson CI IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardSelectDirectoriesPage.java41
1 files changed, 39 insertions, 2 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardSelectDirectoriesPage.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardSelectDirectoriesPage.java
index d59e3cc114..98cd73d259 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardSelectDirectoriesPage.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardSelectDirectoriesPage.java
@@ -8,12 +8,14 @@
*
* Contributors:
* Matthew Khouzam - Initial API and implementation
+ * Marc-Andre Laperle - Remember last selected directory
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace;
import java.io.File;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -43,6 +45,8 @@ public class ImportTraceWizardSelectDirectoriesPage extends AbstractImportTraceW
*/
public static String ID = "org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace.ImportTraceWizardPagePopulate"; //$NON-NLS-1$
+ private static final String STORE_DIRECTORY_ID = ID + ".STORE_DIRECTORY_ID"; //$NON-NLS-1$
+
/**
* Constructor. Creates the trace wizard page.
*
@@ -144,12 +148,18 @@ public class ImportTraceWizardSelectDirectoriesPage extends AbstractImportTraceW
FileDialog dialog = new
FileDialog(Display.getCurrent().getActiveShell(), SWT.NONE);
+
+ String lastDirectory = getLastSelectedDirectory();
+ if (lastDirectory != null) {
+ dialog.setFilterPath(lastDirectory);
+ }
+
String fn = dialog.open();
if (null != fn) {
File f = new File(fn);
if (f.exists()) {
getBatchWizard().addFileToScan(fn);
-
+ saveSelectedDirectory(f.getParentFile());
}
}
updateButtons();
@@ -184,12 +194,17 @@ public class ImportTraceWizardSelectDirectoriesPage extends AbstractImportTraceW
DirectoryDialog dialog = new
DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.NONE);
+ String lastDirectory = getLastSelectedDirectory();
+ if (lastDirectory != null) {
+ dialog.setFilterPath(lastDirectory);
+ }
+
String fn = dialog.open();
if (null != fn) {
File f = new File(fn);
if (f.exists()) {
getBatchWizard().addFileToScan(fn);
-
+ saveSelectedDirectory(f);
}
}
updateButtons();
@@ -200,6 +215,28 @@ public class ImportTraceWizardSelectDirectoriesPage extends AbstractImportTraceW
}
}
+ private String getLastSelectedDirectory() {
+ final IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ final String directory = settings.get(STORE_DIRECTORY_ID);
+ if (directory != null && !directory.isEmpty()) {
+ final File file = new File(directory);
+ if (file.exists()) {
+ return directory.toString();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private void saveSelectedDirectory(File directory) {
+ final IDialogSettings settings = getDialogSettings();
+ if (settings != null && directory != null && directory.exists()) {
+ settings.put(STORE_DIRECTORY_ID, directory.toString());
+ }
+ }
+
private final class RemoveFileHandler implements SelectionListener {
private final Table selectedFiles;

Back to the top