You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/09/06 17:18:35 UTC
[39/50] [abbrv] incubator-tamaya-sandbox git commit: Fixed UI module,
adding modularity. Added initial version for the vents module.
Fixed UI module, adding modularity. Added initial version for the vents module.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/043a2556
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/043a2556
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/043a2556
Branch: refs/heads/master
Commit: 043a2556dfab70ebd3f9a2a82fa19943d4347b33
Parents: ae0a9f1
Author: anatole <an...@apache.org>
Authored: Sat Apr 16 08:21:36 2016 +0200
Committer: anatole <an...@apache.org>
Committed: Tue Apr 19 13:53:43 2016 +0200
----------------------------------------------------------------------
ui/pom.xml | 5 ++
.../org/apache/tamaya/ui/ApplicationLayout.java | 44 ++++++++++-----
.../java/org/apache/tamaya/ui/CurrentUser.java | 18 ++++++
.../main/java/org/apache/tamaya/ui/Header.java | 44 ---------------
ui/src/main/java/org/apache/tamaya/ui/MyUI.java | 2 -
.../main/java/org/apache/tamaya/ui/NavBar.java | 28 +++++++++-
.../java/org/apache/tamaya/ui/UIConstants.java | 23 ++++++--
ui/src/main/java/org/apache/tamaya/ui/User.java | 25 ++++++++-
.../java/org/apache/tamaya/ui/ViewConfig.java | 20 -------
.../tamaya/ui/components/LazyProvider.java | 36 ++++++++++--
.../tamaya/ui/components/PageTitleUpdater.java | 33 +++++++++--
.../ui/components/VerticalSpacedLayout.java | 18 ++++++
.../org/apache/tamaya/ui/event/EventBus.java | 18 ++++++
.../org/apache/tamaya/ui/event/LogoutEvent.java | 18 ++++++
.../apache/tamaya/ui/event/NavigationEvent.java | 18 ++++++
.../apache/tamaya/ui/services/LoginService.java | 12 ----
.../apache/tamaya/ui/views/ComponentView.java | 58 ++++++++++++++++++--
.../org/apache/tamaya/ui/views/ConfigView.java | 57 +++++++++++++++++--
.../org/apache/tamaya/ui/views/ErrorView.java | 19 +++++++
.../org/apache/tamaya/ui/views/HomeView.java | 50 ++++++++++++++++-
.../apache/tamaya/ui/views/login/LoginBox.java | 14 +++--
ui/src/main/resources/config/application.yml | 19 +++++++
ui/src/test/resources/config/application.yml | 19 +++++++
23 files changed, 470 insertions(+), 128 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/pom.xml
----------------------------------------------------------------------
diff --git a/ui/pom.xml b/ui/pom.xml
index f11aa75..3441951 100644
--- a/ui/pom.xml
+++ b/ui/pom.xml
@@ -89,6 +89,11 @@ under the License.
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-spisupport</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!--<dependency>-->
<!--<groupId>javax.servlet</groupId>-->
<!--<artifactId>javax.servlet-api</artifactId>-->
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/ApplicationLayout.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/ApplicationLayout.java b/ui/src/main/java/org/apache/tamaya/ui/ApplicationLayout.java
index 7d57362..c3aeabb 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/ApplicationLayout.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/ApplicationLayout.java
@@ -1,15 +1,32 @@
+/*
+ * 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.ui;
import com.vaadin.navigator.Navigator;
-import com.vaadin.navigator.View;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Panel;
+import org.apache.tamaya.spi.ServiceContextManager;
import org.apache.tamaya.ui.components.LazyProvider;
import org.apache.tamaya.ui.components.PageTitleUpdater;
-import org.apache.tamaya.ui.views.ComponentView;
-import org.apache.tamaya.ui.views.ConfigView;
+import org.apache.tamaya.ui.internal.ResourceBundleMessageProvider;
import org.apache.tamaya.ui.views.ErrorView;
-import org.apache.tamaya.ui.views.HomeView;
+
public class ApplicationLayout extends HorizontalLayout {
@@ -50,32 +67,31 @@ public class ApplicationLayout extends HorizontalLayout {
}
private void registerViews() {
- addView(HomeView.class);
- addView(ConfigView.class);
- addView(ComponentView.class);
+ for(ViewProvider provider: ServiceContextManager.getServiceContext().getServices(ViewProvider.class)) {
+ addView(provider);
+ }
navigator.setErrorView(ErrorView.class);
}
/**
* Registers av given view to the navigator and adds it to the NavBar
*/
- private void addView(Class<? extends View> viewClass) {
- ViewConfig viewConfig = viewClass.getAnnotation(ViewConfig.class);
+ private void addView(ViewProvider provider) {
- switch (viewConfig.createMode()) {
+ switch (provider.getLifecycle()) {
case CREATE:
- navigator.addView(viewConfig.uri(), viewClass);
+ navigator.addView(provider.getUrlPattern(), provider.createView());
break;
case LAZY:
- navigator.addProvider(new LazyProvider(viewConfig.uri(), viewClass));
+ navigator.addProvider(new LazyProvider(provider.getUrlPattern(), provider));
break;
case EAGER:
try {
- navigator.addView(viewConfig.uri(), viewClass.newInstance());
+ navigator.addView(provider.getUrlPattern(), provider.createView());
} catch (Exception e) {
e.printStackTrace();
}
}
- navBar.addView(viewConfig.uri(), viewConfig.displayName());
+ navBar.addView(provider.getUrlPattern(), provider.getDisplayName());
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/CurrentUser.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/CurrentUser.java b/ui/src/main/java/org/apache/tamaya/ui/CurrentUser.java
index c894420..8c754e2 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/CurrentUser.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/CurrentUser.java
@@ -1,3 +1,21 @@
+/*
+ * 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.ui;
import com.vaadin.server.VaadinSession;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/Header.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/Header.java b/ui/src/main/java/org/apache/tamaya/ui/Header.java
deleted file mode 100644
index 3e92dac..0000000
--- a/ui/src/main/java/org/apache/tamaya/ui/Header.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.ui;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Link;
-import sun.awt.HorizBagLayout;
-
-import java.io.Serializable;
-
-/**
- * Created by atsticks on 29.03.16.
- */
-public class Header extends HorizontalLayout implements Serializable{
-
- private Label titleLabel = new Label("Apache Tamaya");
- private HorizontalLayout buttonBar = new HorizontalLayout();
- private Label iconLabel = new Label();
-
- public Header(){
- buttonBar.addComponents(new Button("About"), new Button("Konfiguration"), new Button("PluginManagement"));
- addComponents(titleLabel, buttonBar, iconLabel);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/MyUI.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/MyUI.java b/ui/src/main/java/org/apache/tamaya/ui/MyUI.java
index 845c400..0dce440 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/MyUI.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/MyUI.java
@@ -50,9 +50,7 @@ import org.apache.tamaya.ui.views.login.LoginView;
@Title("Tamaya")
public class MyUI extends UI {
- private Header header = new Header();
private Content content = new Content();
- private Navigator navigator;
@Override
protected void init(VaadinRequest vaadinRequest) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/NavBar.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/NavBar.java b/ui/src/main/java/org/apache/tamaya/ui/NavBar.java
index caed4cd..5b3537a 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/NavBar.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/NavBar.java
@@ -1,3 +1,21 @@
+/*
+ * 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.ui;
import com.vaadin.navigator.ViewChangeListener;
@@ -6,9 +24,12 @@ import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Label;
+import org.apache.tamaya.spi.ServiceContextManager;
import org.apache.tamaya.ui.event.EventBus;
import org.apache.tamaya.ui.event.LogoutEvent;
import org.apache.tamaya.ui.event.NavigationEvent;
+import org.apache.tamaya.ui.internal.ResourceBundleMessageProvider;
+import org.apache.tamaya.ui.services.MessageProvider;
import java.util.HashMap;
import java.util.Map;
@@ -21,8 +42,8 @@ public class NavBar extends CssLayout implements ViewChangeListener {
setHeight("100%");
addStyleName(UIConstants.MENU_ROOT);
addStyleName(UIConstants.NAVBAR);
-
- Label logo = new Label("<strong>Apache Tamaya</strong>", ContentMode.HTML);
+ MessageProvider messages = ServiceContextManager.getServiceContext().getService(MessageProvider.class);
+ Label logo = new Label("<strong>"+ messages.getMessage("project.name")+"</strong>", ContentMode.HTML);
logo.addStyleName(UIConstants.MENU_TITLE);
addComponent(logo);
@@ -30,7 +51,8 @@ public class NavBar extends CssLayout implements ViewChangeListener {
}
private void addLogoutButton() {
- Button logout = new Button("Log out", new Button.ClickListener() {
+ MessageProvider messages = ServiceContextManager.getServiceContext().getService(MessageProvider.class);
+ Button logout = new Button(messages.getMessage("default.label.logout"), new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent clickEvent) {
EventBus.post(new LogoutEvent());
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/UIConstants.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/UIConstants.java b/ui/src/main/java/org/apache/tamaya/ui/UIConstants.java
index 1631e0b..2f75b5c 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/UIConstants.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/UIConstants.java
@@ -1,3 +1,21 @@
+/*
+ * 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.ui;
import com.vaadin.ui.themes.ValoTheme;
@@ -14,9 +32,4 @@ public class UIConstants extends ValoTheme {
public static final String BUTTON_LOGOUT = "logout";
- public static final String ORDER_LAYOUT = "order-layout";
- public static final String ORDER_ID = "order-id";
- public static final String ORDER_TOTAL = "order-total";
-
- public static final String LAYOUT_VIEW = "layout-view";
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/User.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/User.java b/ui/src/main/java/org/apache/tamaya/ui/User.java
index bf01664..4cb6f5a 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/User.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/User.java
@@ -1,5 +1,27 @@
+/*
+ * 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.ui;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.ui.internal.ResourceBundleMessageProvider;
+import org.apache.tamaya.ui.services.MessageProvider;
+
import java.util.Date;
import java.util.Objects;
@@ -9,7 +31,8 @@ import java.util.Objects;
public class User {
private String userID = "-";
- private String fulLName = "<unknown>";
+ private String fulLName = ServiceContextManager.getServiceContext().getService(MessageProvider.class)
+ .getMessage("default.label.unknown");
private Date logInDate = new Date();
public User(String userID, String fullName){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/ViewConfig.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/ViewConfig.java b/ui/src/main/java/org/apache/tamaya/ui/ViewConfig.java
deleted file mode 100644
index 0ab0c66..0000000
--- a/ui/src/main/java/org/apache/tamaya/ui/ViewConfig.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.apache.tamaya.ui;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation for easily collecting View meta info.
- */
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ViewConfig {
-
- enum CreateMode {CREATE, LAZY, EAGER}
-
- String uri();
- String displayName();
- CreateMode createMode() default CreateMode.CREATE;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/components/LazyProvider.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/components/LazyProvider.java b/ui/src/main/java/org/apache/tamaya/ui/components/LazyProvider.java
index ca36a21..867b802 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/components/LazyProvider.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/components/LazyProvider.java
@@ -1,23 +1,49 @@
+/*
+ * 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.ui.components;
-import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.View;
+import org.apache.tamaya.ui.ViewProvider;
+
+import java.util.Objects;
/**
* Lazily initializes a view when it's first accessed, then always returns the
* same instance on subsequent calls.
*/
-public class LazyProvider extends Navigator.ClassBasedViewProvider {
+public class LazyProvider implements com.vaadin.navigator.ViewProvider {
+ private ViewProvider provider;
private View view;
- public LazyProvider(String viewName, Class<? extends View> viewClass) {
- super(viewName, viewClass);
+ public LazyProvider(String viewName, ViewProvider provider) {
+ this.provider = Objects.requireNonNull(provider);
+ }
+
+ @Override
+ public String getViewName(String s) {
+ return provider.getDisplayName();
}
@Override
public View getView(String viewName) {
if (view == null) {
- view = super.getView(viewName);
+ view = provider.createView();
}
return view;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/components/PageTitleUpdater.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/components/PageTitleUpdater.java b/ui/src/main/java/org/apache/tamaya/ui/components/PageTitleUpdater.java
index 37a6e8f..9f95ae7 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/components/PageTitleUpdater.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/components/PageTitleUpdater.java
@@ -1,11 +1,33 @@
+/*
+ * 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.ui.components;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.server.Page;
-import org.apache.tamaya.ui.ViewConfig;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.ui.internal.ResourceBundleMessageProvider;
+import org.apache.tamaya.ui.services.MessageProvider;
+
public class PageTitleUpdater implements ViewChangeListener {
+
@Override
public boolean beforeViewChange(ViewChangeEvent event) {
return true;
@@ -13,12 +35,11 @@ public class PageTitleUpdater implements ViewChangeListener {
@Override
public void afterViewChange(ViewChangeEvent event) {
-
View view = event.getNewView();
- ViewConfig viewConfig = view.getClass().getAnnotation(ViewConfig.class);
-
- if (viewConfig != null) {
- Page.getCurrent().setTitle(viewConfig.displayName());
+ String displayName = ServiceContextManager.getServiceContext().getService(MessageProvider.class)
+ .getMessage("view."+view.getClass().getSimpleName()+".name");
+ if (displayName != null) {
+ Page.getCurrent().setTitle(displayName);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/components/VerticalSpacedLayout.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/components/VerticalSpacedLayout.java b/ui/src/main/java/org/apache/tamaya/ui/components/VerticalSpacedLayout.java
index 52fe525..94fc980 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/components/VerticalSpacedLayout.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/components/VerticalSpacedLayout.java
@@ -1,3 +1,21 @@
+/*
+ * 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.ui.components;
import com.vaadin.ui.VerticalLayout;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/event/EventBus.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/event/EventBus.java b/ui/src/main/java/org/apache/tamaya/ui/event/EventBus.java
index d269dc3..ffa9ba4 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/event/EventBus.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/event/EventBus.java
@@ -1,3 +1,21 @@
+/*
+ * 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.ui.event;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/event/LogoutEvent.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/event/LogoutEvent.java b/ui/src/main/java/org/apache/tamaya/ui/event/LogoutEvent.java
index 3168a76..ec00a42 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/event/LogoutEvent.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/event/LogoutEvent.java
@@ -1,3 +1,21 @@
+/*
+ * 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.ui.event;
public class LogoutEvent {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/event/NavigationEvent.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/event/NavigationEvent.java b/ui/src/main/java/org/apache/tamaya/ui/event/NavigationEvent.java
index 0ec1ec5..9d3b744 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/event/NavigationEvent.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/event/NavigationEvent.java
@@ -1,3 +1,21 @@
+/*
+ * 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.ui.event;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/services/LoginService.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/services/LoginService.java b/ui/src/main/java/org/apache/tamaya/ui/services/LoginService.java
deleted file mode 100644
index ceb4cc0..0000000
--- a/ui/src/main/java/org/apache/tamaya/ui/services/LoginService.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.apache.tamaya.ui.services;
-
-import org.apache.tamaya.ui.User;
-
-/**
- * Created by atsticks on 29.03.16.
- */
-public interface LoginService {
-
- User login(String userId, String credentials);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/views/ComponentView.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/views/ComponentView.java b/ui/src/main/java/org/apache/tamaya/ui/views/ComponentView.java
index abfdb11..19211f1 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/views/ComponentView.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/views/ComponentView.java
@@ -1,26 +1,74 @@
+/*
+ * 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.ui.views;
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.Label;
+import com.vaadin.ui.Tree;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.*;
+import org.apache.tamaya.ui.internal.ResourceBundleMessageProvider;
import org.apache.tamaya.ui.UIConstants;
-import org.apache.tamaya.ui.ViewConfig;
+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.List;
import java.util.Map;
-import java.util.Properties;
-@ViewConfig(uri = "/components", displayName = "Components")
public class ComponentView extends VerticalSpacedLayout implements View {
- private Tree configTree = new Tree("Components");
+
+ @Priority(20)
+ public static final class Provider implements ViewProvider{
+
+ @Override
+ public ViewLifecycle getLifecycle() {
+ return ViewLifecycle.CREATE;
+ }
+
+ @Override
+ public String getUrlPattern() {
+ return "/components";
+ }
+
+ @Override
+ public String getDisplayName() {
+ return ServiceContextManager.getServiceContext().getService(MessageProvider.class)
+ .getMessage("view.components.name");
+ }
+
+ @Override
+ public View createView(){
+ return new ComponentView();
+ }
+ }
+
+
+ private Tree configTree = new Tree(ServiceContextManager.getServiceContext().getService(MessageProvider.class)
+ .getMessage("default.label.components"));
public ComponentView() {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/views/ConfigView.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/views/ConfigView.java b/ui/src/main/java/org/apache/tamaya/ui/views/ConfigView.java
index c3828f9..79e3389 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/views/ConfigView.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/views/ConfigView.java
@@ -1,21 +1,70 @@
+/*
+ * 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.ui.views;
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.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Tree;
import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.ui.CurrentUser;
+import org.apache.tamaya.spi.ServiceContextManager;
import org.apache.tamaya.ui.UIConstants;
-import org.apache.tamaya.ui.ViewConfig;
+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.Map;
-@ViewConfig(uri = "/config", displayName = "Configuration")
public class ConfigView extends VerticalSpacedLayout implements View {
+ @Priority(10)
+ public static final class Provider implements ViewProvider{
+
+ @Override
+ public ViewLifecycle getLifecycle() {
+ return ViewLifecycle.CREATE;
+ }
+
+ @Override
+ public String getUrlPattern() {
+ return "/config";
+ }
+
+ @Override
+ public String getDisplayName() {
+ return ServiceContextManager.getServiceContext().getService(MessageProvider.class)
+ .getMessage("view.config.name");
+ }
+
+ @Override
+ public View createView(){
+ return new ConfigView();
+ }
+ }
+
private TextField keyFilter = new TextField("Key filter");
private TextField valueFilter = new TextField("Value filter");
private Tree tree = new Tree("Current Configuration");
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/views/ErrorView.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/views/ErrorView.java b/ui/src/main/java/org/apache/tamaya/ui/views/ErrorView.java
index ba16bf2..ef3fa2e 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/views/ErrorView.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/views/ErrorView.java
@@ -1,3 +1,21 @@
+/*
+ * 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.ui.views;
import com.vaadin.navigator.View;
@@ -8,6 +26,7 @@ import com.vaadin.ui.VerticalLayout;
import org.apache.tamaya.ui.UIConstants;
public class ErrorView extends VerticalLayout implements View {
+
@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
setSizeFull();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/views/HomeView.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/views/HomeView.java b/ui/src/main/java/org/apache/tamaya/ui/views/HomeView.java
index c656389..78297d2 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/views/HomeView.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/views/HomeView.java
@@ -1,18 +1,64 @@
+/*
+ * 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.ui.views;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Label;
+import org.apache.tamaya.spi.ServiceContextManager;
import org.apache.tamaya.ui.CurrentUser;
import org.apache.tamaya.ui.UIConstants;
-import org.apache.tamaya.ui.ViewConfig;
+import org.apache.tamaya.ui.ViewProvider;
import org.apache.tamaya.ui.components.VerticalSpacedLayout;
+import org.apache.tamaya.ui.services.MessageProvider;
+
+import javax.annotation.Priority;
-@ViewConfig(uri = "", displayName = "Home")
public class HomeView extends VerticalSpacedLayout implements View {
+ @Priority(0)
+ public static final class Provider implements ViewProvider{
+
+ @Override
+ public ViewLifecycle getLifecycle() {
+ return ViewLifecycle.CREATE;
+ }
+
+ @Override
+ public String getUrlPattern() {
+ return "";
+ }
+
+ @Override
+ public String getDisplayName() {
+ return ServiceContextManager.getServiceContext().getService(MessageProvider.class)
+ .getMessage("view.home.name");
+ }
+
+ @Override
+ public View createView(){
+ return new HomeView();
+ }
+ }
+
public HomeView() {
Label caption = new Label("Welcome, " + CurrentUser.get().getUserID());
Label description = new Label(
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginBox.java
----------------------------------------------------------------------
diff --git a/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginBox.java b/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginBox.java
index 83d6b20..8bdcbee 100644
--- a/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginBox.java
+++ b/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginBox.java
@@ -2,15 +2,18 @@ package org.apache.tamaya.ui.views.login;
import com.vaadin.event.ShortcutAction;
import com.vaadin.ui.*;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.ui.internal.ResourceBundleMessageProvider;
import org.apache.tamaya.ui.UIConstants;
import org.apache.tamaya.ui.User;
import org.apache.tamaya.ui.event.EventBus;
-import org.apache.tamaya.ui.services.LoginService;
+import org.apache.tamaya.ui.services.MessageProvider;
+import org.apache.tamaya.ui.services.UserService;
public class LoginBox extends VerticalLayout {
- private LoginService loginService = new LoginService() {
+ private UserService userService = new UserService() {
@Override
public User login(String userId, String credentials) {
if("admin".equals(userId)){
@@ -42,8 +45,9 @@ public class LoginBox extends VerticalLayout {
private void addForm() {
FormLayout loginForm = new FormLayout();
- username = new TextField("Username");
- password = new PasswordField("Password");
+ MessageProvider mp = ServiceContextManager.getServiceContext().getService(MessageProvider.class);
+ username = new TextField(mp.getMessage("default.label.username"));
+ password = new PasswordField(mp.getMessage("default.label.password"));
loginForm.addComponents(username, password);
addComponent(loginForm);
loginForm.setSpacing(true);
@@ -77,7 +81,7 @@ public class LoginBox extends VerticalLayout {
}
private void login() {
- User user = loginService.login(username.getValue(), password.getValue());
+ User user = userService.login(username.getValue(), password.getValue());
if(user!=null){
EventBus.post(new LoginEvent(user));
}else{
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/main/resources/config/application.yml
----------------------------------------------------------------------
diff --git a/ui/src/main/resources/config/application.yml b/ui/src/main/resources/config/application.yml
index a0a6fad..a22ec36 100644
--- a/ui/src/main/resources/config/application.yml
+++ b/ui/src/main/resources/config/application.yml
@@ -1,3 +1,22 @@
+#
+# 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.
+#
+
server:
type: default
maxThreads: 1024
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/043a2556/ui/src/test/resources/config/application.yml
----------------------------------------------------------------------
diff --git a/ui/src/test/resources/config/application.yml b/ui/src/test/resources/config/application.yml
index 9ec8d5b..33c353c 100644
--- a/ui/src/test/resources/config/application.yml
+++ b/ui/src/test/resources/config/application.yml
@@ -1,3 +1,22 @@
+#
+# 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.
+#
+
server:
type: default
maxThreads: 1024