control: Improve check for empty strings
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Fri, 8 Jan 2016 15:48:35 +0000 (10:48 -0500)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Wed, 13 Jan 2016 12:19:14 +0000 (07:19 -0500)
Change-Id: I1d1c6d6e6bf33a3d2eb424683f702d170cde5746
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/63861
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/EnableKernelEventComposite.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/EnableUstEventsComposite.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/GetEventInfoDialog.java

index 4ae2cae64e6a99234fa4d1511d83e44ee0e0d0d9..d7f6db270c1bcf977346b518b2b6cf93459747b8 100644 (file)
@@ -293,8 +293,7 @@ public class EnableKernelEventComposite extends Composite implements IEnableKern
 
         if (fIsDynamicProbe) {
             String temp = fProbeEventNameText.getText();
-            if (temp.isEmpty() ||
-                fProbeText.getText().matches("\\s*") || //$NON-NLS-1$
+            if (temp.trim().isEmpty() ||
                 (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
                 MessageDialog.openError(getShell(),
                         Messages.TraceControl_EnableEventsDialogTitle,
@@ -313,8 +312,7 @@ public class EnableKernelEventComposite extends Composite implements IEnableKern
         fFunctionString = null;
         if (fIsDynamicFunctionProbe) {
             String functionTemp = fFunctionEventNameText.getText();
-            if (functionTemp.isEmpty() ||
-                functionTemp.matches("\\s*") || //$NON-NLS-1$
+            if (functionTemp.trim().isEmpty() ||
                 (!functionTemp.matches("^[\\s]{0,}$") && !functionTemp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
                 MessageDialog.openError(getShell(),
                         Messages.TraceControl_EnableEventsDialogTitle,
@@ -333,7 +331,7 @@ public class EnableKernelEventComposite extends Composite implements IEnableKern
         if (fProviderGroup.isEventFilteringSupported(true)) {
             String tempFilter = fFilterText.getText();
 
-            if(!tempFilter.isEmpty() && !tempFilter.matches("\\s*")) { //$NON-NLS-1$
+            if(!tempFilter.trim().isEmpty()) {
                 fFilterExpression = tempFilter;
             }
         }
index c585246223069c86870a5cd2e0a94feba9ec40b7..03e69c3c6a9b6259f99a878650331388b09267ad 100644 (file)
@@ -298,8 +298,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
             }
 
             String temp = fLogLevelEventNameText.getText();
-            if (temp.isEmpty() ||
-                temp.matches("\\s*") || //$NON-NLS-1$
+            if (temp.trim().isEmpty() ||
                 (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
                 MessageDialog.openError(getShell(),
                         Messages.TraceControl_EnableEventsDialogTitle,
@@ -327,8 +326,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
         fWildcard = null;
         if (fIsWildcard) {
             String tempWildcard = fWildcardText.getText();
-            if (tempWildcard.isEmpty() ||
-                tempWildcard.matches("\\s*") || //$NON-NLS-1$
+            if (tempWildcard.trim().isEmpty() ||
                 (!tempWildcard.matches("^[\\s]{0,}$") && !tempWildcard.matches("^[a-zA-Z0-9\\-\\_\\*\\\\\\']{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
                 MessageDialog.openError(getShell(),
                         Messages.TraceControl_EnableEventsDialogTitle,
@@ -345,7 +343,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
         if (fProviderGroup.isEventFilteringSupported(false)) {
             String tempFilter = fFilterText.getText();
 
-            if(!tempFilter.isEmpty() && !tempFilter.matches("\\s*")) { //$NON-NLS-1$
+            if(!tempFilter.trim().isEmpty()) {
                 fFilterExpression = tempFilter;
             }
         }
index 59f4046f77842f2ade42a762492fc837d214387d..c4334b5f2ef7015ff4acf44d12391b4d3a436df3 100644 (file)
@@ -271,7 +271,7 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
         if (fSessions[0].isEventFilteringSupported(fIsKernel)) {
             String tempFilter = fFilterText.getText();
 
-            if(!tempFilter.isEmpty() && !tempFilter.matches("\\s*")) { //$NON-NLS-1$
+            if(!tempFilter.trim().isEmpty()) {
                 fFilterExpression = tempFilter;
             }
         }
This page took 0.028579 seconds and 5 git commands to generate.