Add button to clear filter issue #1254
authoreriks <eriks@netxms.org>
Tue, 16 Aug 2016 10:06:20 +0000 (13:06 +0300)
committereriks <eriks@netxms.org>
Tue, 16 Aug 2016 10:08:17 +0000 (13:08 +0300)
ChangeLog
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/widgets/FilterText.java
webui/webapp/Core/src/org/netxms/ui/eclipse/widgets/FilterText.java

index ebdb1f0..e401191 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,7 +16,7 @@
 - Management console
        - New editors for Agent Config Policy and Log Parser Policy. 
        - DCI summary tables with empty menu path not shown in object context menu
-- Fixed issues: #92, #906, #1096, #1187, #1191, #1230, #1237, #1263
+- Fixed issues: #92, #906, #1096, #1187, #1191, #1230, #1237, #1254, #1263
 
 
 *
index 90f9e87..b1c5a41 100644 (file)
@@ -51,6 +51,7 @@ public class FilterText extends Composite
        private Composite buttonArea;
        private List<Button> attrButtons = new ArrayList<Button>(4);
        private Label closeButton;
+       private Label clearButton;
        private Action closeAction = null;
        private int delay = 300;
        private Set<ModifyListener> modifyListeners = new HashSet<ModifyListener>();
@@ -64,7 +65,7 @@ public class FilterText extends Composite
        {
                super(parent, style);
                GridLayout layout = new GridLayout();
-               layout.numColumns = 4;
+               layout.numColumns = 5;
                setLayout(layout);
                
                final Label label = new Label(this, SWT.NONE);
@@ -119,6 +120,39 @@ public class FilterText extends Composite
                gd.verticalAlignment = SWT.CENTER;
                buttonArea.setLayoutData(gd);
                
+               clearButton = new Label(this, SWT.NONE);
+               clearButton.setBackground(getBackground());
+               clearButton.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND));
+               clearButton.setImage(SharedIcons.IMG_CLEAR);
+               clearButton.setToolTipText("Clear");
+               gd = new GridData();
+               gd.verticalAlignment = SWT.CENTER;
+               clearButton.setLayoutData(gd);
+               clearButton.addMouseListener(new MouseListener() {
+                  private boolean doAction = false;
+                  
+                  @Override
+                  public void mouseDoubleClick(MouseEvent e)
+                  {
+                     if (e.button ==1)
+                        doAction = false;
+                  }
+                  
+                  @Override
+                  public void mouseDown(MouseEvent e)
+                  {
+                     if (e.button == 1)
+                        doAction = true;
+                  }
+                  
+                  @Override
+                  public void mouseUp(MouseEvent e)
+                  {
+                     if ((e.button == 1) && doAction)
+                        clearFilter();
+                  }
+               });             
+               
                closeButton = new Label(this, SWT.NONE);
                closeButton.setBackground(getBackground());
                closeButton.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND));
@@ -153,6 +187,12 @@ public class FilterText extends Composite
                });
        }
        
+       private void clearFilter()
+   {
+          if (text.getText().equals("") != true)
+             text.setText("");
+   }
+       
        /**
         * Close filter widget
         */
index 4f5aa63..500d2ce 100644 (file)
@@ -51,6 +51,7 @@ public class FilterText extends Composite
        private Composite buttonArea;
        private List<Button> attrButtons = new ArrayList<Button>(4);
        private Label closeButton;
+       private Label clearButton;
        private Action closeAction = null;
        private int delay = 300;
        private Set<ModifyListener> modifyListeners = new HashSet<ModifyListener>();
@@ -64,7 +65,7 @@ public class FilterText extends Composite
        {
                super(parent, style);
                GridLayout layout = new GridLayout();
-               layout.numColumns = 4;
+               layout.numColumns = 5;
                setLayout(layout);
                
                final Label label = new Label(this, SWT.NONE);
@@ -121,6 +122,39 @@ public class FilterText extends Composite
                gd.heightHint = 1;
                buttonArea.setLayoutData(gd);
                
+               clearButton = new Label(this, SWT.NONE);
+               clearButton.setBackground(getBackground());
+               clearButton.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND));
+               clearButton.setImage(SharedIcons.IMG_CLEAR);
+               clearButton.setToolTipText("Clear");
+               gd = new GridData();
+               gd.verticalAlignment = SWT.CENTER;
+               clearButton.setLayoutData(gd);
+               clearButton.addMouseListener(new MouseListener() {
+                  private boolean doAction = false;
+                  
+                  @Override
+                  public void mouseDoubleClick(MouseEvent e)
+                  {
+                     if (e.button ==1)
+                        doAction = false;
+                  }
+                  
+                  @Override
+                  public void mouseDown(MouseEvent e)
+                  {
+                     if (e.button == 1)
+                        doAction = true;
+                  }
+                  
+                  @Override
+                  public void mouseUp(MouseEvent e)
+                  {
+                     if ((e.button == 1) && doAction)
+                        clearFilter();
+                  }
+               });             
+               
                closeButton = new Label(this, SWT.NONE);
                closeButton.setBackground(getBackground());
                closeButton.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND));
@@ -156,6 +190,12 @@ public class FilterText extends Composite
                });
        }
        
+       private void clearFilter()
+   {
+          if (text.getText().equals("") != true)
+             text.setText("");
+   }
+       
        /**
         * Close filter widget
         */