From aa9dffd527c962ff51830789348c08c9598c6f15 Mon Sep 17 00:00:00 2001 From: Dmytro Titov Date: Thu, 10 Oct 2019 14:50:21 +0200 Subject: [PATCH] Add "Clear all button" --- pom.xml | 2 +- .../no/uio/ifi/trackfind/frontend/TrackFindMainUI.java | 10 ++++++++-- .../frontend/listeners/MoveAttributeValueHandler.java | 2 +- .../trackfind/backend/services/SchemaServiceTest.java | 3 --- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 200015b8..58ec45c2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ no.uio.ifi trackfind - 2.8.5 + 2.8.6 jar trackfind diff --git a/src/main/java/no/uio/ifi/trackfind/frontend/TrackFindMainUI.java b/src/main/java/no/uio/ifi/trackfind/frontend/TrackFindMainUI.java index 22f50e98..5b19150b 100644 --- a/src/main/java/no/uio/ifi/trackfind/frontend/TrackFindMainUI.java +++ b/src/main/java/no/uio/ifi/trackfind/frontend/TrackFindMainUI.java @@ -200,6 +200,11 @@ public void handleAction(Object sender, Object target) { executeQuery(queryTextArea.getValue()); } }); + + Button clearAllButton = new Button("Clear all"); + clearAllButton.setSizeFull(); + clearAllButton.addClickListener((Button.ClickListener) event -> queryTextArea.clear()); + Button searchButton = new Button("Search ➚", (Button.ClickListener) clickEvent -> executeQuery(queryTextArea.getValue())); queryTextArea.addValueChangeListener((HasValue.ValueChangeListener) event -> searchButton.setEnabled(StringUtils.isNotEmpty(queryTextArea.getValue()))); queryTextArea.addStyleName("scrollable-text-area"); @@ -239,8 +244,9 @@ public void handleAction(Object sender, Object target) { Panel categoriesChecklistPanel = new Panel("Categories", new VerticalLayout(categoriesChecklist)); categoriesChecklistPanel.setSizeFull(); - VerticalLayout queryLayout = new VerticalLayout(queryPanel, categoriesChecklistPanel, searchLayout); - queryLayout.setExpandRatio(queryPanel, 0.5f); + VerticalLayout queryLayout = new VerticalLayout(queryPanel, clearAllButton, categoriesChecklistPanel, searchLayout); + queryLayout.setExpandRatio(queryPanel, 0.4f); + queryLayout.setExpandRatio(clearAllButton, 0.1f); queryLayout.setExpandRatio(categoriesChecklistPanel, 0.4f); queryLayout.setExpandRatio(searchLayout, 0.1f); queryLayout.setSizeFull(); diff --git a/src/main/java/no/uio/ifi/trackfind/frontend/listeners/MoveAttributeValueHandler.java b/src/main/java/no/uio/ifi/trackfind/frontend/listeners/MoveAttributeValueHandler.java index 0ab213e9..900d01c5 100644 --- a/src/main/java/no/uio/ifi/trackfind/frontend/listeners/MoveAttributeValueHandler.java +++ b/src/main/java/no/uio/ifi/trackfind/frontend/listeners/MoveAttributeValueHandler.java @@ -90,7 +90,7 @@ private void processDragAndDropMultiple(TextArea textArea, boolean logicalOperat private void processDragAndDropSingle(TextArea textArea, boolean logicalOperation, boolean inversion, TreeNode item) { String condition = CONDITIONS.get(logicalOperation); String query = textArea.getValue(); - if (StringUtils.isNoneEmpty(query)) { + if (StringUtils.isNoneEmpty(query.trim())) { query += condition; } if (inversion) { diff --git a/src/test/java/no/uio/ifi/trackfind/backend/services/SchemaServiceTest.java b/src/test/java/no/uio/ifi/trackfind/backend/services/SchemaServiceTest.java index 94701b7f..86354153 100644 --- a/src/test/java/no/uio/ifi/trackfind/backend/services/SchemaServiceTest.java +++ b/src/test/java/no/uio/ifi/trackfind/backend/services/SchemaServiceTest.java @@ -18,9 +18,6 @@ public class SchemaServiceTest { public static final String ATTRIBUTES = "{\n" + - " \"@schema\": [\n" + - " \"\"\n" + - " ],\n" + " \"experiments\": [\n" + " \"'@schema'\",\n" + " \"'aggregated_from'\",\n" +