lttng: fix empty string handling in dialogs (bug 415580)
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Wed, 21 Aug 2013 14:02:54 +0000 (10:02 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Thu, 22 Aug 2013 11:49:43 +0000 (07:49 -0400)
Change-Id: I9839ec7d8238556809cad48a39e44d72736c4544
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/15713
Tested-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableChannelDialog.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableKernelEventComposite.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/GetEventInfoDialog.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/messages.properties

index 6dbf51ecd3fa57d4cca8aa1f0664b8d64ac0599c..9a927d0f063775c63fb9d483a54a4c294014e546 100644 (file)
@@ -506,46 +506,48 @@ public class EnableChannelDialog extends Dialog implements IEnableChannelDialog
     @Override
     protected void okPressed() {
         // Set channel information
-        fChannelInfo = new ChannelInfo(fChannelNameText.getText());
-        fChannelInfo.setSubBufferSize(fSubBufferSizeText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.parseLong(fSubBufferSizeText.getText()));
-        fChannelInfo.setNumberOfSubBuffers(fNumberOfSubBuffersText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.parseInt(fNumberOfSubBuffersText.getText()));
-        fChannelInfo.setSwitchTimer(fSwitchTimerText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.parseLong(fSwitchTimerText.getText()));
-        fChannelInfo.setReadTimer(fReadTimerText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.parseLong(fReadTimerText.getText()));
-        fChannelInfo.setOverwriteMode(fOverwriteModeButton.getSelection());
+        ChannelInfo channelInfo = new ChannelInfo(fChannelNameText.getText());
+        channelInfo.setSubBufferSize(fSubBufferSizeText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.parseLong(fSubBufferSizeText.getText()));
+        channelInfo.setNumberOfSubBuffers(fNumberOfSubBuffersText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.parseInt(fNumberOfSubBuffersText.getText()));
+        channelInfo.setSwitchTimer(fSwitchTimerText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.parseLong(fSwitchTimerText.getText()));
+        channelInfo.setReadTimer(fReadTimerText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.parseLong(fReadTimerText.getText()));
+        channelInfo.setOverwriteMode(fOverwriteModeButton.getSelection());
         if (fTargetNodeComponent.isTraceFileRotationSupported()) {
-            fChannelInfo.setMaxSizeTraceFiles(fMaxSizeTraceText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.parseInt(fMaxSizeTraceText.getText()));
-            fChannelInfo.setMaxNumberTraceFiles(fMaxNumberTraceText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.parseInt(fMaxNumberTraceText.getText()));
+            channelInfo.setMaxSizeTraceFiles(fMaxSizeTraceText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.parseInt(fMaxSizeTraceText.getText()));
+            channelInfo.setMaxNumberTraceFiles(fMaxNumberTraceText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.parseInt(fMaxNumberTraceText.getText()));
         }
         if (fTargetNodeComponent.isBufferTypeConfigSupported()) {
             if (fSharedBuffersButton.getSelection()) {
-                fChannelInfo.setBufferType(BufferType.BUFFER_SHARED);
+                channelInfo.setBufferType(BufferType.BUFFER_SHARED);
             } else if (fPIDBuffersButton.getSelection()) {
-                fChannelInfo.setBufferType(BufferType.BUFFER_PER_PID);
+                channelInfo.setBufferType(BufferType.BUFFER_PER_PID);
             } else if (fUIDBuffersButton.getSelection()) {
-                fChannelInfo.setBufferType(BufferType.BUFFER_PER_UID);
+                channelInfo.setBufferType(BufferType.BUFFER_PER_UID);
             } else {
-                fChannelInfo.setBufferType(BufferType.BUFFER_TYPE_UNKNOWN);
+                channelInfo.setBufferType(BufferType.BUFFER_TYPE_UNKNOWN);
             }
         }
 
         fIsKernel = fKernelButton.getSelection();
 
         // Check for invalid names
-        if (!fChannelInfo.getName().matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
+        if (!channelInfo.getName().matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
             MessageDialog.openError(getShell(),
                   Messages.TraceControl_EnableChannelDialogTitle,
-                  Messages.TraceControl_InvalidChannelNameError + " (" + fChannelInfo.getName() + ") \n");  //$NON-NLS-1$ //$NON-NLS-2$
+                  Messages.TraceControl_InvalidChannelNameError + " (" + channelInfo.getName() + ") \n");  //$NON-NLS-1$ //$NON-NLS-2$
             return;
         }
 
         // Check for duplicate names
-        if (fDomain != null && fDomain.containsChild(fChannelInfo.getName())) {
+        if (fDomain != null && fDomain.containsChild(channelInfo.getName())) {
             MessageDialog.openError(getShell(),
                     Messages.TraceControl_EnableChannelDialogTitle,
-                    Messages.TraceControl_ChannelAlreadyExistsError + " (" + fChannelInfo.getName() + ") \n");  //$NON-NLS-1$ //$NON-NLS-2$
+                    Messages.TraceControl_ChannelAlreadyExistsError + " (" + channelInfo.getName() + ") \n");  //$NON-NLS-1$ //$NON-NLS-2$
             return;
         }
 
+        fChannelInfo = channelInfo;
+
         // validation successful -> call super.okPressed()
         super.okPressed();
     }
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;
index 15f0eb93a44608f34e04dc64c8ceb3441f8ef341..3e7329aff02bb291c4093b17e716f410fe45589b 100644 (file)
@@ -282,7 +282,9 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
             }
 
             String temp = fLogLevelEventNameText.getText();
-            if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+            if (temp.isEmpty() ||
+                temp.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_InvalidLogLevelEventNameError + " (" + temp + ") \n");  //$NON-NLS-1$ //$NON-NLS-2$
@@ -290,9 +292,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
                 return false;
             }
 
-            if(!temp.matches("\\s*")) { //$NON-NLS-1$
-                fLogLevelEventName = temp;
-            }
+            fLogLevelEventName = temp;
 
             TraceLogLevel[] levels = TraceLogLevel.values();
             int id = fLogLevelCombo.getSelectionIndex();
@@ -311,7 +311,9 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
         fWildcard = null;
         if (fIsWildcard) {
             String tempWildcard = fWildcardText.getText();
-            if (!tempWildcard.matches("^[\\s]{0,}$") && !tempWildcard.matches("^[a-zA-Z0-9\\-\\_\\*]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+            if (tempWildcard.isEmpty() ||
+                tempWildcard.matches("\\s*") || //$NON-NLS-1$
+                (!tempWildcard.matches("^[\\s]{0,}$") && !tempWildcard.matches("^[a-zA-Z0-9\\-\\_\\*]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
                 MessageDialog.openError(getShell(),
                         Messages.TraceControl_EnableEventsDialogTitle,
                         Messages.TraceControl_InvalidWildcardError + " (" + tempWildcard + ") \n");  //$NON-NLS-1$ //$NON-NLS-2$
@@ -319,9 +321,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
                 return false;
             }
 
-            if(!tempWildcard.matches("\\s*")) { //$NON-NLS-1$
-                fWildcard = tempWildcard;
-            }
+            fWildcard = tempWildcard;
         }
 
         // initialize filter with null
@@ -329,7 +329,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
         if (fProviderGroup.isEventFilteringSupported()) {
             String tempFilter = fFilterText.getText();
 
-            if(!tempFilter.matches("\\s*")) { //$NON-NLS-1$
+            if(!tempFilter.isEmpty() && !tempFilter.matches("\\s*")) { //$NON-NLS-1$
                 fFilterExpression = tempFilter;
             }
         }
index 28ebd7fb4ca70cb00dc9f543a936ddf0009fc999..15fcadc9d9ad5b9a5993d707e1e82b3351d0678d 100644 (file)
@@ -271,7 +271,7 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
         if (fSessions[0].isEventFilteringSupported() && !fIsKernel) {
             String tempFilter = fFilterText.getText();
 
-            if(!tempFilter.matches("\\s*")) { //$NON-NLS-1$
+            if(!tempFilter.isEmpty() && !tempFilter.matches("\\s*")) { //$NON-NLS-1$
                 fFilterExpression = tempFilter;
             }
         }
index 4d2dcad4ef327291e47e3b589356b2efc1e96279..89de0b4eed06ee0599b6a24547b92df54feb533d 100644 (file)
@@ -177,9 +177,9 @@ TraceControl_EnableEventsLoglevelEventNameTooltip=Event name for enabling log le
 TraceControl_EnableEventsFilterGroupName=Filter Expression
 TraceControl_EnableEventsFilterTooltip=Filter expression on event field.
 
-TraceControl_InvalidProbeNameError=The probe name is invalid 
-TraceControl_InvalidWildcardError=The wild card name is invalid
-TraceControl_InvalidLogLevelEventNameError=The event name for log level is invalid
+TraceControl_InvalidProbeNameError=The probe name is invalid or empty 
+TraceControl_InvalidWildcardError=The wild card name is invalid or empty
+TraceControl_InvalidLogLevelEventNameError=The event name for log level is invalid or empty
 TraceControl_InvalidLogLevel=No log level selected
 
 TraceControl_AddContextDialogTitle=Add Contexts
This page took 0.035483 seconds and 5 git commands to generate.