tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject [23/50] [abbrv] incubator-tamaya-extensions git commit: ixed table rendering and setting of polling interval.
Date Sun, 23 Oct 2016 20:36:35 GMT
ixed table rendering and setting of polling interval.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/6ca5def8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/6ca5def8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/6ca5def8

Branch: refs/heads/old_master
Commit: 6ca5def80fe586081bf9297dfbeb8b68fa27f710
Parents: 032322b
Author: anatole <anatole@apache.org>
Authored: Sun Apr 17 23:55:50 2016 +0200
Committer: Oliver B. Fischer <plexus@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200

----------------------------------------------------------------------
 .../tamaya/events/ConfigEventManager.java       |  4 +-
 .../internal/DefaultConfigChangeObserver.java   |  9 ++--
 .../org/apache/tamaya/events/ui/EventView.java  | 53 ++++++++++++++++----
 3 files changed, 49 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6ca5def8/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
index 9989fbb..f6bd3da 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
@@ -168,7 +168,7 @@ public final class ConfigEventManager {
      *
      * @return the check period in ms.
      */
-    public long getChangeMonitoringPeriod(){
+    public static long getChangeMonitoringPeriod(){
         return SPI.getChangeMonitoringPeriod();
     }
 
@@ -179,7 +179,7 @@ public final class ConfigEventManager {
      * @see #enableChangeMonitoring(boolean)
      * @see #isChangeMonitoring()
      */
-    public void setChangeMonitoringPeriod(long millis){
+    public static void setChangeMonitoringPeriod(long millis){
         SPI.setChangeMonitoringPeriod(millis);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6ca5def8/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
index 5cd3f6c..f4457b2 100644
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
+++ b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
@@ -36,7 +36,7 @@ public class DefaultConfigChangeObserver {
 
     private static final Logger LOG = Logger.getLogger(DefaultConfigChangeObserver.class.getName());
 
-    private final Timer timer = new Timer("DefaultConfigChangeObserver", true);
+    private Timer timer = new Timer("DefaultConfigChangeObserver", true);
 
     private long checkPeriod = 2000L;
 
@@ -52,9 +52,9 @@ public class DefaultConfigChangeObserver {
         timer.scheduleAtFixedRate(new TimerTask() {
             @Override
             public void run() {
-                if(running) {
-                    checkConfigurationUpdate();
-                }
+            if(running) {
+                checkConfigurationUpdate();
+            }
             }
         }, START_DELAY, checkPeriod);
     }
@@ -98,6 +98,7 @@ public class DefaultConfigChangeObserver {
         LOG.finest("Resetting check period to " + checkPeriod + " ms, reregistering timer.");
         this.checkPeriod = checkPeriod;
         timer.cancel();
+        timer = new Timer("DefaultConfigChangeObserver", true);
         timer.scheduleAtFixedRate(new TimerTask() {
             @Override
             public void run() {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6ca5def8/src/main/java/org/apache/tamaya/events/ui/EventView.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ui/EventView.java b/src/main/java/org/apache/tamaya/events/ui/EventView.java
index a69b04c..56e4b35 100644
--- a/src/main/java/org/apache/tamaya/events/ui/EventView.java
+++ b/src/main/java/org/apache/tamaya/events/ui/EventView.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.events.ui;
 
+import com.vaadin.data.Item;
 import com.vaadin.data.Property;
 import com.vaadin.navigator.View;
 import com.vaadin.navigator.ViewChangeListener;
@@ -33,6 +34,7 @@ import org.apache.tamaya.ui.components.VerticalSpacedLayout;
 import org.apache.tamaya.ui.services.MessageProvider;
 
 import javax.annotation.Priority;
+import java.util.Date;
 
 
 public class EventView extends VerticalSpacedLayout implements View {
@@ -65,6 +67,8 @@ public class EventView extends VerticalSpacedLayout implements View {
             .getService(MessageProvider.class).getMessage("view.events.button.enableMonitoring"));
     private Button clearViewButton = new Button(ServiceContextManager.getServiceContext()
             .getService(MessageProvider.class).getMessage("view.events.button.clearView"));
+    private TextField pollingInterval = new TextField(ServiceContextManager.getServiceContext()
+            .getService(MessageProvider.class).getMessage("view.events.field.pollingInterval"));
     private Table eventsTable = new Table(ServiceContextManager.getServiceContext()
             .getService(MessageProvider.class).getMessage("view.events.table.name"));
 
@@ -86,35 +90,62 @@ public class EventView extends VerticalSpacedLayout implements View {
             @Override
             public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                 ConfigEventManager.enableChangeMonitoring(changeMonitorEnabled.getValue());
+                if(changeMonitorEnabled.getValue()) {
+                    Notification.show("Event Monitoring (Polling) active.");
+                }else{
+                    Notification.show("Event Monitoring (Polling) inactive.");
+                }
             }
         });
         clearViewButton.addClickListener(new Button.ClickListener() {
             @Override
             public void buttonClick(Button.ClickEvent clickEvent) {
                 eventsTable.removeAllItems();
+                Notification.show("Events cleared.");
             }
         });
 
-        changeMonitorEnabled.setData(ConfigEventManager.isChangeMonitoring());
-        eventsTable.addContainerProperty("Timestamp", Long.class, null);
-        eventsTable.addContainerProperty("Type", Class.class, null);
-        eventsTable.addContainerProperty("Payload", String.class, null);
-        eventsTable.addContainerProperty("Version",  String.class, null);
+        HorizontalLayout eventSettings = new HorizontalLayout();
+        eventSettings.addComponents(changeMonitorEnabled, new Label(" Polling Interval"),
pollingInterval, clearViewButton);
+        changeMonitorEnabled.setValue(ConfigEventManager.isChangeMonitoring());
+        pollingInterval.setValue(String.valueOf(ConfigEventManager.getChangeMonitoringPeriod()));
+        pollingInterval.setRequired(true);
+        pollingInterval.addValueChangeListener(new Property.ValueChangeListener() {
+            @Override
+            public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
+                try{
+                    long millis = Long.parseLong((String)valueChangeEvent.getProperty().getValue());
+                    ConfigEventManager.setChangeMonitoringPeriod(millis);
+                    Notification.show("Updated Event Monitoring Poll Interval to " + millis
+ " milliseconds.");
+                }catch(Exception e){
+                    Notification.show("Cannot update Event Monitoring Poll Interval to "
+                            + valueChangeEvent.getProperty().getValue(), Notification.Type.ERROR_MESSAGE);
+                }
+            }
+        });
+        eventsTable.addContainerProperty("Timestamp", Date.class, null);
+        eventsTable.addContainerProperty("Type", String.class, "?");
+        eventsTable.addContainerProperty("Payload", String.class, "<empty>");
+        eventsTable.addContainerProperty("Version",  String.class, "?");
         eventsTable.setPageLength(20);
         eventsTable.setWidth("100%");
         eventsTable.setResponsive(true);
 
-        HorizontalLayout hl = new HorizontalLayout();
-        hl.addComponents(changeMonitorEnabled, clearViewButton);
+
         caption.addStyleName(UIConstants.LABEL_HUGE);
         description.addStyleName(UIConstants.LABEL_LARGE);
-        addComponents(caption, description, hl, eventsTable);
+        addComponents(caption, description, eventSettings, eventsTable);
     }
 
     private void addEvent(ConfigEvent<?> evt){
-        eventsTable.addItem(new Object[]{evt.getTimestamp(), evt.getResourceType().getSimpleName(),
-                String.valueOf(evt.getResource()),evt.getVersion()});
-        this.markAsDirty();
+        Object newItemId = eventsTable.addItem();
+        Item row = eventsTable.getItem(newItemId);
+        row.getItemProperty("Timestamp").setValue(new Date(evt.getTimestamp()));
+        row.getItemProperty("Type").setValue(evt.getResourceType().getSimpleName());
+        String value = String.valueOf(evt.getResource());
+        String valueShort = value.length()<150?value:value.substring(0,147)+"...";
+        row.getItemProperty("Payload").setValue(valueShort);
+        row.getItemProperty("Version").setValue(evt.getVersion());
     }
 
 


Mime
View raw message