tmf: Enable the finish button when default target project is selected
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / wizards / importtrace / ImportTraceWizardPageOptions.java
index 0ac5582bb5041f55647729c41a52dec156e555e4..f1b6c9848c851f1bb62dd2984482d176f1e9b852 100644 (file)
@@ -77,34 +77,36 @@ public class ImportTraceWizardPageOptions extends AbstractImportTraceWizardPage
         fProjects.getSelection();
         fProjects.addSelectionListener(new SelectionListener() {
 
-            private static final String TRACE = "Traces"; //$NON-NLS-1$
-
             @Override
             public void widgetSelected(SelectionEvent e) {
-                handleSelected();
+                updateWithSelection();
             }
 
             @Override
             public void widgetDefaultSelected(SelectionEvent e) {
-                handleSelected();
-            }
-
-            private void handleSelected() {
-                String[] selection = fProjects.getSelection();
-                if (selection.length > 0) {
-                    final String listItem = selection[0];
-                    IFolder folder = fProjectsMap.get(listItem).getFolder(TRACE);
-                    getBatchWizard().setTraceFolder(folder);
-                    ImportTraceWizardPageOptions.this.setErrorMessage(null);
-                }
+                updateWithSelection();
             }
         });
         if (proj != null) {
             fProjects.setSelection(fProjects.indexOf(proj.getName()));
-            this.setErrorMessage(null);
-        } else {
-            this.setErrorMessage(Messages.SharedSelectProject);
+        } else if (fProjects.getItemCount() > 0) {
+            fProjects.setSelection(0);
         }
+        updateWithSelection();
+        setMessage(Messages.SharedSelectProject);
         this.setTitle(Messages.ImportTraceWizardPageOptionsTitle);
     }
+
+    private void updateWithSelection() {
+        final String TRACE = "Traces"; //$NON-NLS-1$
+        String[] selection = fProjects.getSelection();
+        if (selection.length > 0) {
+            final String listItem = selection[0];
+            IFolder folder = fProjectsMap.get(listItem).getFolder(TRACE);
+            getBatchWizard().setTraceFolder(folder);
+            ImportTraceWizardPageOptions.this.setErrorMessage(null);
+        } else {
+            ImportTraceWizardPageOptions.this.setErrorMessage(Messages.SharedSelectProject);
+        }
+    }
 }
This page took 0.024586 seconds and 5 git commands to generate.