lttng: fix empty string handling in dialogs (bug 415580)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / dialogs / EnableKernelEventComposite.java
index 812e5cfb45b1c2ff212022d37d56382ad5a0a4bb..3f7c1cb0a83e30fb1259b051811dbd390598ff5f 100644 (file)
@@ -269,7 +269,9 @@ public class EnableKernelEventComposite extends Composite implements IEnableKern
 
         if (fIsDynamicProbe) {
             String temp = fProbeEventNameText.getText();
-            if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+            if (temp.isEmpty() ||
+                fProbeText.getText().matches("\\s*") || //$NON-NLS-1$
+                (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
                 MessageDialog.openError(getShell(),
                         Messages.TraceControl_EnableEventsDialogTitle,
                         Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n");  //$NON-NLS-1$ //$NON-NLS-2$
@@ -277,11 +279,9 @@ public class EnableKernelEventComposite extends Composite implements IEnableKern
                 return false;
             }
 
-            if(!fProbeText.getText().matches("\\s*")) { //$NON-NLS-1$
-                fProbeEventName = temp;
-                // fProbeString will be validated by lttng-tools
-                fProbeString = fProbeText.getText();
-            }
+            fProbeEventName = temp;
+            // fProbeString will be validated by lttng-tools
+            fProbeString = fProbeText.getText();
         }
 
         // initialize function string
@@ -289,7 +289,9 @@ public class EnableKernelEventComposite extends Composite implements IEnableKern
         fFunctionString = null;
         if (fIsDynamicFunctionProbe) {
             String functionTemp = fFunctionEventNameText.getText();
-            if (!functionTemp.matches("^[\\s]{0,}$") && !functionTemp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+            if (functionTemp.isEmpty() ||
+                functionTemp.matches("\\s*") || //$NON-NLS-1$
+                (!functionTemp.matches("^[\\s]{0,}$") && !functionTemp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
                 MessageDialog.openError(getShell(),
                         Messages.TraceControl_EnableEventsDialogTitle,
                         Messages.TraceControl_InvalidProbeNameError + " (" + functionTemp + ") \n");  //$NON-NLS-1$ //$NON-NLS-2$
@@ -297,11 +299,9 @@ public class EnableKernelEventComposite extends Composite implements IEnableKern
                 return false;
             }
 
-            if(!fFunctionText.getText().matches("\\s*")) { //$NON-NLS-1$
-                fFunctionEventName = functionTemp;
-                // fFunctionString will be validated by lttng-tools
-                fFunctionString = fFunctionText.getText();
-            }
+            fFunctionEventName = functionTemp;
+            // fFunctionString will be validated by lttng-tools
+            fFunctionString = fFunctionText.getText();
         }
 
         return true;
This page took 0.024666 seconds and 5 git commands to generate.