You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2016/04/19 13:54:47 UTC

[14/15] incubator-tamaya git commit: TAMAYA-150 Added UI module and related functionality.

TAMAYA-150 Added UI module and related functionality.


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

Branch: refs/heads/master
Commit: d9e6e55c79212f34915049006436a6f81a0e2828
Parents: 1a11d15
Author: anatole <an...@apache.org>
Authored: Tue Apr 19 13:52:19 2016 +0200
Committer: anatole <an...@apache.org>
Committed: Tue Apr 19 13:53:44 2016 +0200

----------------------------------------------------------------------
 .../org/apache/tamaya/events/ui/EventView.java  |  15 ++-
 .../events/delta/ConfigurationChangeTest.java   |   8 +-
 modules/mutable-config/pom.xml                  |  15 ++-
 .../mutableconfig/ui/ConfigUpdaterView.java     | 107 +++++++++++++++++++
 .../services/org.apache.tamaya.ui.ViewProvider  |  19 ++++
 5 files changed, 153 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9e6e55c/modules/events/src/main/java/org/apache/tamaya/events/ui/EventView.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ui/EventView.java b/modules/events/src/main/java/org/apache/tamaya/events/ui/EventView.java
index 56e4b35..bee6e7b 100644
--- a/modules/events/src/main/java/org/apache/tamaya/events/ui/EventView.java
+++ b/modules/events/src/main/java/org/apache/tamaya/events/ui/EventView.java
@@ -23,7 +23,13 @@ import com.vaadin.data.Property;
 import com.vaadin.navigator.View;
 import com.vaadin.navigator.ViewChangeListener;
 import com.vaadin.shared.ui.label.ContentMode;
-import com.vaadin.ui.*;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
 import org.apache.tamaya.events.ConfigEvent;
 import org.apache.tamaya.events.ConfigEventListener;
 import org.apache.tamaya.events.ConfigEventManager;
@@ -36,9 +42,14 @@ import org.apache.tamaya.ui.services.MessageProvider;
 import javax.annotation.Priority;
 import java.util.Date;
 
-
+/**
+ * Tamaya View for observing the current event stream.
+ */
 public class EventView extends VerticalSpacedLayout implements View {
 
+    /**
+     * Provider used to register the view.
+     */
     @Priority(20)
     public static final class Provider implements ViewProvider{
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9e6e55c/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java b/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
index 95269e2..b20ebef 100644
--- a/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
+++ b/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
@@ -45,9 +45,15 @@ public class ConfigurationChangeTest {
         Configuration config = ConfigurationProvider.getConfiguration();
         ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
         assertNotNull(change);
-        assertTrue(change.isEmpty());
+        assertTrue(change.getUpdatedSize()==0);
+        assertTrue(change.getAddedSize()==0);
+        assertTrue(change.getRemovedSize()==0);
+        assertTrue(change.getChanges().size()==0);
         for (Map.Entry<String, String> en : config.getProperties().entrySet()) {
             if (!"[meta]frozenAt".equals(en.getKey())) {
+                if(en.getKey().contains("random.new")){ // dynamic generated value!
+                    continue;
+                }
                 assertEquals("Error for " + en.getKey(), en.getValue(), change.getResource().get(en.getKey()));
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9e6e55c/modules/mutable-config/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mutable-config/pom.xml b/modules/mutable-config/pom.xml
index 0ddd7bf..cf06546 100644
--- a/modules/mutable-config/pom.xml
+++ b/modules/mutable-config/pom.xml
@@ -41,24 +41,23 @@ under the License.
             <groupId>org.apache.tamaya</groupId>
             <artifactId>tamaya-api</artifactId>
             <version>${project.version}</version>
-            <scope>provided</scope>
-            <optional>true</optional>
         </dependency>
         <dependency>
             <groupId>org.apache.tamaya.ext</groupId>
             <artifactId>tamaya-spisupport</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <!--<dependency>-->
-        <!--<groupId>org.apache.tamaya.ext</groupId>-->
-        <!--<artifactId>tamaya-events</artifactId>-->
-        <!--<version>${project.version}</version>-->
-        <!--</dependency>-->
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-ui</artifactId>
+            <version>${project.version}</version>
+            <optional>true</optional>
+        </dependency>
         <dependency>
             <groupId>org.apache.tamaya</groupId>
             <artifactId>tamaya-core</artifactId>
             <version>${project.version}</version>
-            <scope>test</scope>
+            <scope>runtime</scope>
         </dependency>
 
         <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9e6e55c/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ui/ConfigUpdaterView.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ui/ConfigUpdaterView.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ui/ConfigUpdaterView.java
new file mode 100644
index 0000000..7a4956c
--- /dev/null
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ui/ConfigUpdaterView.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig.ui;
+
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener;
+import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import org.apache.tamaya.mutableconfig.MutableConfigurationProvider;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.ui.UIConstants;
+import org.apache.tamaya.ui.ViewProvider;
+import org.apache.tamaya.ui.components.VerticalSpacedLayout;
+import org.apache.tamaya.ui.services.MessageProvider;
+
+import javax.annotation.Priority;
+import java.util.Arrays;
+
+/**
+ * Tamaya UI view to change configuration.
+ */
+public class ConfigUpdaterView extends VerticalSpacedLayout implements View {
+
+    /**
+     * Provider to register the view.
+     */
+    @Priority(20)
+    public static final class Provider implements ViewProvider{
+
+        @Override
+        public ViewLifecycle getLifecycle() {
+            return ViewLifecycle.LAZY;
+        }
+
+        @Override
+        public String getUrlPattern() {
+            return "/edit";
+        }
+
+        @Override
+        public String getDisplayName() {
+            return "view.update.name";
+        }
+
+        @Override
+        public View createView(){
+            return new ConfigUpdaterView();
+        }
+    }
+
+    private ComboBox changePropagationPolicy = new ComboBox("view.update.select.propagationPolicy",
+            Arrays.asList(new String[]{"ALL", "MOST_SIGNIFICANT_ONLY", "SELECTIVE", "NONE"}));
+
+    private TextField changePropagationPolicyOther = new TextField("view.update.text.propagationPolicyOther",
+            MutableConfigurationProvider.getApplyAllChangePolicy().getClass().getName());
+
+    private TextArea generalInfo = new TextArea(ServiceContextManager.getServiceContext()
+            .getService(MessageProvider.class).getMessage("view.update.textArea.general"));
+
+
+
+    public ConfigUpdaterView() {
+        Label caption = new Label(ServiceContextManager.getServiceContext()
+                .getService(MessageProvider.class).getMessage("view.update.name"));
+        Label description = new Label(ServiceContextManager.getServiceContext()
+                .getService(MessageProvider.class).getMessage("view.update.description"),
+                ContentMode.HTML);
+
+        caption.addStyleName(UIConstants.LABEL_HUGE);
+        description.addStyleName(UIConstants.LABEL_LARGE);
+        addComponents(caption, description,changePropagationPolicy,changePropagationPolicyOther,generalInfo);
+    }
+
+
+    private String getCaption(String key, String value) {
+        int index = key.lastIndexOf('.');
+        if(index<0){
+            return key + " = " + value;
+        }else{
+            return key.substring(index+1) + " = " + value;
+        }
+    }
+
+    @Override
+    public void enter(ViewChangeListener.ViewChangeEvent event) {
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9e6e55c/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider b/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
new file mode 100644
index 0000000..d2ac687
--- /dev/null
+++ b/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy current the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.mutableconfig.ui.ConfigUpdaterView$Provider
\ No newline at end of file