| 1 | package de.uka.ipd.sdq.sensorframework.visualisation.dialogs; |
| 2 | |
| 3 | import org.eclipse.swt.widgets.DirectoryDialog; |
| 4 | import org.eclipse.swt.widgets.Shell; |
| 5 | import org.eclipse.ui.PlatformUI; |
| 6 | |
| 7 | /** |
| 8 | * This class demonstrates the DirectoryDialog class. |
| 9 | * |
| 10 | * @author David Scherr |
| 11 | */ |
| 12 | public class CSVDirectoryDialog { |
| 13 | private String pathDir; |
| 14 | private boolean isCanceled = false; |
| 15 | |
| 16 | /** |
| 17 | * Runs the application. |
| 18 | * |
| 19 | * @param pathDir The full path of the directory. |
| 20 | */ |
| 21 | public CSVDirectoryDialog(String pathDir) { |
| 22 | |
| 23 | Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); |
| 24 | shell.setText("CSV Directory"); |
| 25 | |
| 26 | this.pathDir = pathDir; |
| 27 | DirectoryDialog dialog = new DirectoryDialog(shell); |
| 28 | dialog.setFilterPath(pathDir); |
| 29 | dialog.setText("Directory of Experiment Run"); |
| 30 | dialog.setMessage("Select a directory"); |
| 31 | |
| 32 | this.pathDir = dialog.open(); |
| 33 | |
| 34 | if (this.pathDir == null) { |
| 35 | this.pathDir = ""; |
| 36 | isCanceled = true; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @return The full path of the directory. |
| 42 | */ |
| 43 | public String getPathDir() { |
| 44 | return pathDir; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @return {@link CSVSettingsDialog#isSettingsDialogCanceled()} |
| 49 | */ |
| 50 | public boolean isCanceled() { |
| 51 | return isCanceled; |
| 52 | } |
| 53 | } |