http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/TamayaUI.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/TamayaUI.java b/ui/src/main/java/org/apache/tamaya/ui/TamayaUI.java deleted file mode 100644 index f446d6f..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/TamayaUI.java +++ /dev/null @@ -1,77 +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.server.VaadinServlet; -import org.apache.catalina.Context; -import org.apache.catalina.Wrapper; -import org.apache.catalina.startup.Tomcat; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; - -import java.io.File; -import java.util.logging.Logger; - -/** - * Tamaya UI Main class. - */ -public class TamayaUI { - - private static final Logger LOG = Logger.getLogger(TamayaUI.class.getName()); - - /** - * Not an instantiable class. - */ - private TamayaUI(){} - - /** - * The main entry point, use configuration as follows: - * <pre> - * tamaya.server.contextPath: the context path, default=/tamaya - * tamaya.server.port: the port, default=8090 - * tamaya.server.productionMode: vadiin production mode setting, default=false. - * </pre> - * @param args the args - * @throws Exception if startup fails. - */ - public static void main(String[] args) throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - String contextPath = config.getOrDefault("tamaya.server.contextPath", "/tamaya"); - String appBase = "."; - Tomcat tomcat = new Tomcat(); - tomcat.setPort(Integer.valueOf(config.getOrDefault("tamaya.server.port", Integer.class, 8090) )); - - // Define a web application context. - Context context = tomcat.addWebapp(contextPath, new File( - appBase).getAbsolutePath()); - // Add Vadiin servlet - Wrapper wrapper = tomcat.addServlet(context, "vadiin-servlet", - VaadinServlet.class.getName()); - wrapper.addInitParameter("ui", - VadiinApp.class.getName()); - wrapper.addInitParameter("productionMode",config.getOrDefault("tamaya.server.productionMode", String.class, - "false")); - wrapper.addInitParameter("asyncSupported", "true"); - context.addServletMapping("/*", "vadiin-servlet"); - // bootstrap.addBundle(new AssetsBundle("/VAADIN", "/VAADIN", null, "vaadin")); - tomcat.start(); - tomcat.getServer().await(); - } - -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index ecf90ff..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/UIConstants.java +++ /dev/null @@ -1,36 +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.themes.ValoTheme; - -/** - * Helper for theme. Less typos in CSS style names and easier to find usages in project. - */ -public class UIConstants extends ValoTheme { - - public static final String MAIN_LAYOUT = "main-layout"; - public static final String NAVBAR = "navbar"; - public static final String SELECTED = "selected"; - public static final String LOGIN_BOX = "login-box"; - - - public static final String BUTTON_LOGOUT = "logout"; - public static final String BUTTON_SETTINGS = BUTTON_TINY; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index ae5b34a..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/User.java +++ /dev/null @@ -1,154 +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 java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -/** - * A simple User object. - */ -public class User { - /** The user ID. */ - private final String userID; - /** The full name. */ - private String fulLName; - /** The credentials. */ - private String credentials; - /** The user's roles. */ - private Set<String> roles = new HashSet<>(); - /** The user's last login date. */ - private Date loginDate = new Date(); - /** The user's last logout date. */ - private Date logoutDate = new Date(); - - /** - * Constructor. - * @param uid the user ID, not null. - * @param fullName the full name. - * @param credentials the credentials. - * @param roles its roles. - */ - public User(String uid, String fullName, String credentials, String... roles){ - this.userID = Objects.requireNonNull(uid); - this.fulLName = fullName!=null?fullName:userID; - if(fullName==null){ - this.fulLName = userID; - } - this.roles.addAll(Arrays.asList(roles)); - this.credentials = credentials; - } - - /** - * èPerforms a login, checking the credentials. - * @param credentials the credentials. - * @return true, if the user could be logged in. - */ - public boolean login(String credentials){ - if(this.credentials!=null){ - this.loginDate = new Date(); - return this.credentials.equals(credentials); - } - return credentials==null || credentials.isEmpty(); - } - - /** - * Checks if the user is currently logged in. - * @return true, if the user is currently logged in. - */ - public boolean isLoggedin(){ - long now = System.currentTimeMillis(); - if(this.logoutDate!=null && this.logoutDate.getTime() < now){ - return false; - } - return this.loginDate!=null && this.loginDate.getTime() < now; - } - - /** - * Logs the user out. - */ - public void logout(){ - this.logoutDate = new Date(); - } - - /** - * Get the user ID. - * @return the user ID, never null. - */ - public String getUserID() { - return userID; - } - - /** - * Get the full name. - * @return the full name, never null. - */ - public String getFullName() { - return fulLName; - } - - /** - * Checks if the user has the given role. - * @param role the role to be checked, not null. - * @return true, if the user has the required role. - */ - public boolean hasRole(String role){ - return this.roles.contains(role); - } - - /** - * Get the user's roles. - * @return the roles, never null. - */ - public Set<String> getRoles(){ - return Collections.unmodifiableSet(roles); - } - - /** - * Get the last login timestamp. - * @return the last login date, or null. - */ - public Date getLoginDate(){ - return loginDate; - } - - /** - * Get the last login timestamp. - * @return the last login date, or null. - */ - public Date getLogoutDate(){ - return logoutDate; - } - - @Override - public String toString() { - return "User{" + - "fulLName='" + fulLName + '\'' + - ", userID='" + userID + '\'' + - ", roles=" + roles + - ", loginDate=" + loginDate + - ", logoutDate=" + logoutDate + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/VadiinApp.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/VadiinApp.java b/ui/src/main/java/org/apache/tamaya/ui/VadiinApp.java deleted file mode 100644 index 9e2510d..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/VadiinApp.java +++ /dev/null @@ -1,97 +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.google.common.eventbus.Subscribe; -import com.vaadin.annotations.Theme; -import com.vaadin.annotations.Title; -import com.vaadin.server.Page; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinSession; -import com.vaadin.ui.Panel; -import com.vaadin.ui.UI; -import org.apache.tamaya.ui.event.LogoutEvent; -import org.apache.tamaya.ui.event.NavigationEvent; -import org.apache.tamaya.ui.views.login.LoginEvent; -import org.apache.tamaya.ui.views.login.LoginView; - -/** - * This UI is the application entry point. A UI may either represent a browser window - * (or tab) or some part of a html page where a Vaadin application is embedded. - * <p> - * The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be - * overridden to add component to the user interface and initialize non-component functionality. - */ -@Theme("valo") -@Title("Tamaya") -public class VadiinApp extends UI { - - public VadiinApp(){ - super(new Panel()); - super.setPollInterval(2000); - } - - @Override - protected void init(VaadinRequest vaadinRequest) { - setupEventBus(); - if (CurrentUser.isLoggedIn()) { - setContent(new ApplicationLayout(this)); - } else { - setContent(new LoginView()); - } - } - - @Subscribe - public void userLoggedIn( - LoginEvent event) { - CurrentUser.set(event.getUser()); - setContent(new ApplicationLayout(this)); - } - - @Subscribe - public void navigateTo(NavigationEvent evt) { - if(getNavigator()==null){ - return; - } - if(evt.getViewName().isEmpty()){ - getNavigator().navigateTo("/home"); - - }else { - getNavigator().navigateTo(evt.getViewName()); - } - } - - public static VadiinApp getCurrent() { - return (VadiinApp) UI.getCurrent(); - } - - @Subscribe - public void logout(LogoutEvent logoutEvent) { - // Don't invalidate the underlying HTTP session if you are using it for something else - VaadinSession.getCurrent().getSession().invalidate(); - VaadinSession.getCurrent().close(); - Page.getCurrent().reload(); - - } - - private void setupEventBus() { - org.apache.tamaya.ui.event.EventBus.register(this); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/ViewProvider.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/ViewProvider.java b/ui/src/main/java/org/apache/tamaya/ui/ViewProvider.java deleted file mode 100644 index 578689f..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/ViewProvider.java +++ /dev/null @@ -1,73 +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.navigator.View; - -/** - * Interface to register Tamaya UI parts. For priorization also use the @Priority annotations. - */ -public interface ViewProvider { - - /** - * View lifecycle options that determine when a view is created and how long an instance is used. - */ - enum ViewLifecycle { - /** Creates a new view instance whenever the view is showed. */ - CREATE, - /** Loads the view on first access. */ - LAZY, - /** Eagerly preloads the view. */ - EAGER - } - - /** - * Get the view lifecycle model. - * @return the lifecycle model, not null. - */ - ViewLifecycle getLifecycle(); - - /** - * Get the view's name, used for resolving the view display name. - * @return the view's name. - */ - String getName(); - - /** - * Get the url pattern where this view should be accessible. - * @return the url pattern, not null. - */ - String getUrlPattern(); - - /** - * Get the name to be displayed for this view. This value will also be used to lookup a name from the {@code /ui/lang/tamaya} - * bundle. If not found the value returned will be used for display. - * - * @return the name to be displayed, or its resource bundle key, not null. - */ - String getDisplayName(); - - /** - * Method that is called to create a new view instance. - * @see #getLifecycle() - * @param params any parameters that may be needed to create the view. - * @return a new view instance, not null. - */ - View createView(Object... params); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index 2d1547f..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/components/LazyProvider.java +++ /dev/null @@ -1,81 +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.components; - -import com.vaadin.navigator.View; -import org.apache.tamaya.spi.ServiceContextManager; -import org.apache.tamaya.ui.ViewProvider; -import org.apache.tamaya.ui.services.MessageProvider; - -import java.util.Objects; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Lazily initializes a view when it's first accessed, then always returns the - * same instance on subsequent calls. - */ -public class LazyProvider implements ViewProvider { - private static final Logger LOG = Logger.getLogger( - LazyProvider.class.getName()); - private Class<? extends View> viewClass; - private View view; - private String urlPattern; - private String name; - - public LazyProvider(String name, String urlPattern, Class<? extends View> viewClass) { - this.viewClass = Objects.requireNonNull(viewClass); - this.urlPattern = Objects.requireNonNull(urlPattern); - this.name = Objects.requireNonNull(name); - } - - @Override - public String getUrlPattern() { - return urlPattern; - } - - - @Override - public ViewLifecycle getLifecycle() { - return ViewLifecycle.LAZY; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getDisplayName() { - return ServiceContextManager.getServiceContext().getService(MessageProvider.class) - .getMessage(name); - } - - @Override - public View createView(Object... params) { - if(view==null){ - try { - view = viewClass.newInstance(); - } catch (Exception e) { - LOG.log(Level.SEVERE, "Failed to create view: "+urlPattern, e); - } - } - return view; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index 83a0105..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/components/PageTitleUpdater.java +++ /dev/null @@ -1,47 +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.components; - -import com.vaadin.navigator.View; -import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.server.Page; -import org.apache.tamaya.spi.ServiceContextManager; -import org.apache.tamaya.ui.services.MessageProvider; - -/** - * Listener that updates the page title when a new view is shown. - */ -public class PageTitleUpdater implements ViewChangeListener { - - @Override - public boolean beforeViewChange(ViewChangeEvent event) { - return true; - } - - @Override - public void afterViewChange(ViewChangeEvent event) { - View view = event.getNewView(); - String displayName = ServiceContextManager.getServiceContext().getService(MessageProvider.class) - .getMessage("view."+view.getClass().getSimpleName()+".name"); - if (displayName != null) { - Page.getCurrent().setTitle(displayName); - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index 94fc980..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/components/VerticalSpacedLayout.java +++ /dev/null @@ -1,32 +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.components; - -import com.vaadin.ui.VerticalLayout; - -/** - * Vertical layout with spacing and margin on by default - */ -public class VerticalSpacedLayout extends VerticalLayout { - - public VerticalSpacedLayout() { - setMargin(true); - setSpacing(true); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index ffa9ba4..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/event/EventBus.java +++ /dev/null @@ -1,52 +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.event; - - -import com.google.common.eventbus.SubscriberExceptionContext; -import com.google.common.eventbus.SubscriberExceptionHandler; - -/** - * Convenience class for accessing the _UI Scoped_ EventBus. If you are using something like the CDI event - * bus, you don't need a class like this. - */ -public final class EventBus { - - private static final com.google.common.eventbus.EventBus EVENT_BUS = - new com.google.common.eventbus.EventBus(new SubscriberExceptionHandler(){ - @Override - public void handleException(Throwable throwable, SubscriberExceptionContext subscriberExceptionContext) { - throwable.printStackTrace(); - } - }); - - private EventBus(){} - - public static void register(final Object listener) { - EVENT_BUS.register(listener); - } - - public static void unregister(final Object listener) { - EVENT_BUS.unregister(listener); - } - - public static void post(final Object event) { - EVENT_BUS.post(event); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index 680acc3..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/event/LogoutEvent.java +++ /dev/null @@ -1,48 +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.event; - -import org.apache.tamaya.ui.User; - -import java.util.Objects; - -/** - * Event sent when the user has been logged out. - */ -public class LogoutEvent { - - /** The user logged out. */ - private User user; - - /** - * Creates a new event. - * @param user the user logged out, not null. - */ - public LogoutEvent(User user) { - this.user = Objects.requireNonNull(user); - } - - /** - * Get the user logged out. - * @return the user logged out, not null. - */ - public User getUser(){ - return user; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index bb863be..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/event/NavigationEvent.java +++ /dev/null @@ -1,53 +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.event; - - -import java.util.Objects; - -/** - * Event sent when the user wants to navigate. - */ -public class NavigationEvent { - /** The target view. */ - private String viewName; - - /** - * Constructor. - * @param viewName the target view, not null. - */ - public NavigationEvent(String viewName) { - this.viewName = Objects.requireNonNull(viewName); - } - - /** - * Access the target view name. - * @return the target view name, never null. - */ - public String getViewName() { - return viewName; - } - - @Override - public String toString() { - return "NavigationEvent{" + - "viewName='" + viewName + '\'' + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/internal/ConfigurationBasedMessageProvider.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/internal/ConfigurationBasedMessageProvider.java b/ui/src/main/java/org/apache/tamaya/ui/internal/ConfigurationBasedMessageProvider.java deleted file mode 100644 index e242418..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/internal/ConfigurationBasedMessageProvider.java +++ /dev/null @@ -1,176 +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.internal; - -import org.apache.tamaya.ConfigurationProvider; -import org.apache.tamaya.spi.ConfigurationContextBuilder; -import org.apache.tamaya.spisupport.DefaultConfiguration; -import org.apache.tamaya.ui.services.MessageProvider; - -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Component resolving messages for being shown in the UI, based on the ResourceBundle mechanisms. - * The baseName used can optionally be configured by setting {@code tamaya.ui.baseName} either as system property, - * environment property or Tamaya configuration. Be aware that the JDK resource bundle mechanism only reads - * the first property file on the classpath (or a corresponding class file implementing ResourceBundle). - */ -public final class ConfigurationBasedMessageProvider implements MessageProvider{ - - /** - * The property name for configuring the resource bundle's base name either as - * system property, environment property or configuration entry. - */ - private static final String TAMAYA_UI_BASE_NAME = "tamaya.ui.baseName"; - - private final String baseName = evaluateBaseName(); - - private Map<String, Map<String,String>> propertiesCache = new ConcurrentHashMap<>(); - - - /** - * Private singleton constructor. - */ - public ConfigurationBasedMessageProvider(){ - - } - - /** - * Get a message using the defaul locale. - * @param key the message key, not null. - * @return the resolved message, or the bundle ID, never null. - */ - public String getMessage(String key){ - return getMessage(key, Locale.getDefault()); - } - - /** - * Get a message. - * @param key the message key, not null. - * @param locale the target locale, or null, for the default locale. - * @return the resolved message, or the key, never null. - */ - public String getMessage(String key, Locale locale){ - List<String> bundleIds = evaluateBundleIds(locale); - for(String bundleID:bundleIds){ - Map<String,String> entries = this.propertiesCache.get(bundleID); - if(entries==null){ - entries = loadEntries(bundleID); - } - String value = entries.get(key); - if(value!=null){ - return value; - } - } - return key; - } - - private Map<String, String> loadEntries(String bundleID) { - ConfigurationContextBuilder ctxBuilder = ConfigurationProvider.getConfigurationContextBuilder(); - for(String format:new String[]{"xml", "properties"}) { - try { - Enumeration<URL> urls = getClass().getClassLoader().getResources(bundleID+"."+format); - while(urls.hasMoreElements()){ - URL url = urls.nextElement(); - ctxBuilder.addPropertySources(new URLPropertySource(url)); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - Map<String, String> entries = new DefaultConfiguration(ctxBuilder.build()).getProperties(); - this.propertiesCache.put(bundleID, entries); - return entries; - } - - private List<String> evaluateBundleIds(Locale locale) { - List<String> bundleIds = new ArrayList<>(); - String country = locale.getCountry(); - if(country==null){ - country=""; - } - String lang = locale.getLanguage(); - if(lang==null){ - lang=""; - } - String variant = locale.getVariant(); - if(variant==null){ - variant=""; - } - String key = baseName + "_"+country+"_"+lang+"_"+variant; - key = reduceKey(key); - if(!bundleIds.contains(key)){ - bundleIds.add(key); - } - key = baseName + "_"+country+"_"+lang; - key = reduceKey(key); - if(!bundleIds.contains(key)){ - bundleIds.add(key); - } - key = baseName + "_"+country; - key = reduceKey(key); - if(!bundleIds.contains(key)){ - bundleIds.add(key); - } - key = baseName; - if(!bundleIds.contains(key)){ - bundleIds.add(key); - } - return bundleIds; - } - - /** - * Remove all doubled '_' hereby normalizing the bundle key. - * @param key the key, not null. - * @return the normaliuzed key, not null. - */ - private String reduceKey(String key) { - String reduced = key.replace("___","_").replace("__","_"); - if(reduced.endsWith("_")){ - reduced = reduced.substring(0,reduced.length()-1); - } - return reduced; - } - - /** - * Evaluates the base name to be used for creating the resource bundle used. - * @return base name - */ - private String evaluateBaseName() { - String baseName = System.getProperty(TAMAYA_UI_BASE_NAME); - if(baseName==null || baseName.isEmpty()){ - baseName = System.getenv("tamaya.ui.baseName"); - } - if(baseName==null || baseName.isEmpty()){ - baseName = ConfigurationProvider.getConfiguration().get("tamaya.ui.baseName"); - } - if(baseName==null || baseName.isEmpty()){ - baseName = "ui/lang/tamaya"; - } - return baseName.replace('.', '/'); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/internal/ConfiguredMessageProvider.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/internal/ConfiguredMessageProvider.java b/ui/src/main/java/org/apache/tamaya/ui/internal/ConfiguredMessageProvider.java deleted file mode 100644 index 00c0ec7..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/internal/ConfiguredMessageProvider.java +++ /dev/null @@ -1,61 +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.internal; -// -//import org.apache.tamaya.ui.services.MessageProvider; -// -//import java.util.Locale; -//import java.util.ResourceBundle; -// -///** -// * Component resolving messages for being shown in the UI, based on the ResourceBundle mechanisms. -// */ -//public class ConfiguredMessageProvider implements MessageProvider{ -// -// /** -// * Private singleton constructor. -// */ -// public ConfiguredMessageProvider(){} -// -// /** -// * Get a message using the defaul locale. -// * @param bundleID the message bundle key, not null. -// * @return the resolved message, or the bundle ID, never null. -// */ -// public String getMessage(String bundleID){ -// return getMessage(bundleID, Locale.getDefault()); -// } -// -// /** -// * Get a message. -// * @param bundleID the message bundle key, not null. -// * @param locale the target locale, or null, for the default locale. -// * @return the resolved message, or the bundle ID, never null. -// */ -// public String getMessage(String bundleID, Locale locale){ -// try{ -// ResourceBundle bundle = ResourceBundle.getBundle("ui/ui.lang/tamaya", locale); -// return bundle.getString(bundleID); -// } -// catch(Exception e){ -// return bundleID; -// } -// } -// -//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/internal/ConfiguredUserService.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/internal/ConfiguredUserService.java b/ui/src/main/java/org/apache/tamaya/ui/internal/ConfiguredUserService.java deleted file mode 100644 index 14af644..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/internal/ConfiguredUserService.java +++ /dev/null @@ -1,76 +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.internal; - -import org.apache.tamaya.ConfigurationProvider; -import org.apache.tamaya.functions.ConfigurationFunctions; -import org.apache.tamaya.ui.User; -import org.apache.tamaya.ui.services.UserService; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * User service reading users and credentials from the configuration. Users are configured as follows (e.g. using - * properties format): - * <pre> - * tamaya.users.admin.pwd=admin - * tamaya.users.admin.fullName=Administrator - * tamaya.users.admin.roles=admin - * tamaya.users.john.pwd=meymey - * tamaya.users.john.fullName=John Doe - * tamaya.users.john.roles=admin,user - * </pre> - */ -public class ConfiguredUserService implements UserService{ - - private Map<String, User> users = new ConcurrentHashMap<>(); - - /** - * Constructor reading the configuration and initializing the users table. - */ - public ConfiguredUserService(){ - // read from config - Map<String,String> config = ConfigurationProvider.getConfiguration().with( - ConfigurationFunctions.section("tamaya.users.", true)).getProperties(); - for(Map.Entry<String,String> en:config.entrySet()){ - if(en.getKey().endsWith(".pwd")){ - String uid = en.getKey().substring(0,en.getKey().length()-4); - String pwd = en.getValue(); - String fullName = config.get(uid+".fullName"); - String roles = config.get(uid+".roles"); - if(roles==null){ - roles=""; - } - users.put(uid.toLowerCase(), new User(uid, fullName, pwd, roles.split(","))); - } - } - - } - - @Override - public User login(String userId, String credentials) { - User user = this.users.get(userId.toLowerCase()); - if(user!=null && user.login(credentials)){ - return user; - } - return null; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/internal/ResourceBundleMessageProvider.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/internal/ResourceBundleMessageProvider.java b/ui/src/main/java/org/apache/tamaya/ui/internal/ResourceBundleMessageProvider.java deleted file mode 100644 index 193144e..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/internal/ResourceBundleMessageProvider.java +++ /dev/null @@ -1,91 +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.internal; -// -//import org.apache.tamaya.ConfigurationProvider; -//import org.apache.tamaya.ui.services.MessageProvider; -// -//import java.util.Locale; -//import java.util.ResourceBundle; -// -///** -// * Component resolving messages for being shown in the UI, based on the ResourceBundle mechanisms. -// * The baseName used can optionally be configured by setting {@code tamaya.ui.baseName} either as system property, -// * environment property or Tamaya configuration. Be aware that the JDK resource bundle mechanism only reads -// * the first property file on the classpath (or a corresponding class file implementing ResourceBundle). -// */ -//public class ResourceBundleMessageProvider implements MessageProvider{ -// -// private static final String BASENAME = evaluateBaseName(); -// -// /** -// * The property name for configuring the resource bundle's base name either as -// * system property, environment property or configuration entry. -// */ -// private static final String TAMAYA_UI_BASE_NAME = "tamaya.ui.baseName"; -// -// /** -// * Evaluates the base name to be used for creating the resource bundle used. -// * @return -// */ -// private static String evaluateBaseName() { -// String baseName = System.getProperty(TAMAYA_UI_BASE_NAME); -// if(baseName==null || baseName.isEmpty()){ -// baseName = System.getenv("tamaya.ui.baseName"); -// } -// if(baseName==null || baseName.isEmpty()){ -// baseName = ConfigurationProvider.getConfiguration().get("tamaya.ui.baseName"); -// } -// if(baseName==null || baseName.isEmpty()){ -// baseName = "ui/ui.lang/tamaya"; -// } -// return baseName; -// } -// -// /** -// * Private singleton constructor. -// */ -// public ResourceBundleMessageProvider(){} -// -// /** -// * Get a message using the defaul locale. -// * @param bundleID the message bundle key, not null. -// * @return the resolved message, or the bundle ID, never null. -// */ -// public String getMessage(String bundleID){ -// return getMessage(bundleID, Locale.getDefault()); -// } -// -// /** -// * Get a message. -// * @param bundleID the message bundle key, not null. -// * @param locale the target locale, or null, for the default locale. -// * @return the resolved message, or the bundle ID, never null. -// */ -// public String getMessage(String bundleID, Locale locale){ -// try{ -// ResourceBundle bundle = ResourceBundle.getBundle(BASENAME, locale); -// return bundle.getString(bundleID); -// } -// catch(Exception e){ -// return bundleID; -// } -// } -// -//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/internal/URLPropertySource.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/internal/URLPropertySource.java b/ui/src/main/java/org/apache/tamaya/ui/internal/URLPropertySource.java deleted file mode 100644 index 83b4af4..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/internal/URLPropertySource.java +++ /dev/null @@ -1,78 +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.internal; - -import org.apache.tamaya.spisupport.BasePropertySource; -import org.apache.tamaya.spisupport.MapPropertySource; - -import java.io.InputStream; -import java.net.URL; -import java.util.Collections; -import java.util.Map; -import java.util.Objects; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Simple property source, used for internationalization. - */ -final class URLPropertySource extends BasePropertySource{ - - private static final Logger LOG = Logger.getLogger(URLPropertySource.class.getName()); - private URL url; - private Map<String, String> properties; - - public URLPropertySource(URL url){ - this.url = Objects.requireNonNull(url); - load(); - } - - /** - * Loads/reloads the properties from the URL. If loading of the properties failed the previus state is preserved, - * unless there is no such state. In this case an empty map is assigned. - */ - public void load(){ - try(InputStream is = url.openStream()) { - Properties props = new Properties(); - if (url.getFile().endsWith(".xml")) { - props.loadFromXML(is); - } else { - props.load(is); - } - properties = Collections.unmodifiableMap(MapPropertySource.getMap(props)); - } - catch(Exception e){ - LOG.log(Level.WARNING, "Failed to read config from "+url,e); - if(properties==null) { - properties = Collections.emptyMap(); - } - } - } - - @Override - public String getName() { - return url.toString(); - } - - @Override - public Map<String, String> getProperties() { - return properties; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/services/MessageProvider.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/services/MessageProvider.java b/ui/src/main/java/org/apache/tamaya/ui/services/MessageProvider.java deleted file mode 100644 index a15ae46..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/services/MessageProvider.java +++ /dev/null @@ -1,43 +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.services; - -import java.util.Locale; - -/** - * Component resolving messages for being shown in the UI. - */ -public interface MessageProvider { - - /** - * Get a message using the default locale. - * @param key the message key, not null. - * @return the resolved message, or the key, never null. - */ - String getMessage(String key); - - /** - * Get a message. - * @param key the message key, not null. - * @param locale the target locale, or null, for the default locale. - * @return the resolved message, or the key, never null. - */ - String getMessage(String key, Locale locale); - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/services/UserService.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/services/UserService.java b/ui/src/main/java/org/apache/tamaya/ui/services/UserService.java deleted file mode 100644 index 71a8a43..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/services/UserService.java +++ /dev/null @@ -1,30 +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.services; - -import org.apache.tamaya.ui.User; - -/** - * Created by atsticks on 29.03.16. - */ -public interface UserService { - - User login(String userId, String credentials); - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index fb0d41b..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/views/ConfigView.java +++ /dev/null @@ -1,229 +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.views; - -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.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.TextArea; -import com.vaadin.ui.TextField; -import com.vaadin.ui.Tree; -import com.vaadin.ui.VerticalLayout; -import org.apache.tamaya.ConfigurationProvider; -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.Locale; -import java.util.Map; -import java.util.TreeMap; - -/** - * View for evaluating the current convifugration tree. - */ -@Priority(10) -public class ConfigView extends VerticalSpacedLayout implements View { - - /** - * Provider to register this view. - */ - @Priority(10) - public static final class Provider implements ViewProvider{ - - @Override - public ViewLifecycle getLifecycle() { - return ViewLifecycle.CREATE; - } - - @Override - public String getName() { - return "view.config.name"; - } - - @Override - public String getUrlPattern() { - return "/config"; - } - - @Override - public String getDisplayName() { - return ServiceContextManager.getServiceContext().getService(MessageProvider.class) - .getMessage("view.config.name"); - } - - @Override - public View createView(Object... params){ - return new ConfigView(); - } - } - - private TextField keyFilter = new TextField("Key filter"); - private TextField valueFilter = new TextField("Value filter"); - private CheckBox showMetaEntries = new CheckBox("Show Metadata", false); - private Tree tree = new Tree("Current Configuration"); - - public ConfigView() { - Label caption = new Label("Raw Configuration"); - Label description = new Label( - "This view shows the overall <b>raw</b> configuration tree. Dependening on your access rights you" + - "may see partial or masked data. Similarly configuration can be <i>read-only</i> or <i>mutable</i>.", - ContentMode.HTML); - - TabSheet tabPane = new TabSheet(); - VerticalLayout configLayout = new VerticalLayout(); - - HorizontalLayout filters = new HorizontalLayout(); - - Button filterButton = new Button("Filter", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - fillTree(); - } - }); - filters.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT); - filters.addComponents(keyFilter, valueFilter, filterButton, showMetaEntries); - filters.setSpacing(true); - - fillTree(); - configLayout.addComponents(filters, tree); - tabPane.addTab(configLayout, "Configuration"); - TextArea envProps = new TextArea(); - StringBuilder b = new StringBuilder(); - envProps.setHeight("100%"); - envProps.setWidth("100%"); - envProps.setSizeFull(); - envProps.setRows(System.getenv().size()); - for(Map.Entry<String,String> en:new TreeMap<>(System.getenv()).entrySet()){ - b.append(en.getKey()).append("=").append(en.getValue()).append('\n'); - } - envProps.setValue(b.toString()); - envProps.setReadOnly(true); - tabPane.addTab(envProps, "Environment Properties"); - TextArea sysProps = new TextArea(); - sysProps.setSizeFull(); - sysProps.setRows(System.getProperties().size()); - b.setLength(0); - for(Map.Entry<Object,Object> en:new TreeMap<>(System.getProperties()).entrySet()){ - b.append(en.getKey()).append("=").append(en.getValue()).append('\n'); - } - sysProps.setValue(b.toString()); - sysProps.setReadOnly(true); - tabPane.addTab(sysProps, "System Properties"); - TextArea runtimeProps = new TextArea(); - runtimeProps.setRows(5); - b.setLength(0); - b.append("Available Processors : ").append(Runtime.getRuntime().availableProcessors()).append('\n'); - b.append("Free Memory : ").append(Runtime.getRuntime().freeMemory()).append('\n'); - b.append("Max Memory : ").append(Runtime.getRuntime().maxMemory()).append('\n'); - b.append("Total Memory : ").append(Runtime.getRuntime().totalMemory()).append('\n'); - b.append("Default Locale : ").append(Locale.getDefault()).append('\n'); - runtimeProps.setValue(b.toString()); - runtimeProps.setReadOnly(true); - tabPane.addTab(runtimeProps, "Runtime Properties"); - runtimeProps.setSizeFull(); - addComponents(caption, description, tabPane); - caption.addStyleName(UIConstants.LABEL_HUGE); - description.addStyleName(UIConstants.LABEL_LARGE); - showMetaEntries.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(Property.ValueChangeEvent valueChangeEvent) { - fillTree(); - } - }); - } - - private void fillTree() { - String keyFilterExp = this.keyFilter.getValue(); - if(keyFilterExp.isEmpty()){ - keyFilterExp = null; - } - String valueFilterExp = this.valueFilter.getValue(); - if(valueFilterExp.isEmpty()){ - valueFilterExp = null; - } - tree.removeAllItems(); - boolean showMetadata = showMetaEntries.getValue(); - for(Map.Entry<String,String> entry: ConfigurationProvider.getConfiguration().getProperties().entrySet()){ - String key = entry.getKey(); - if(keyFilterExp!=null && !key.matches(keyFilterExp)){ - continue; - } - if(valueFilterExp!=null && !entry.getValue().matches(valueFilterExp)){ - continue; - } - if(!showMetadata && entry.getKey().startsWith("_")){ - continue; - } - tree.addItem(key); - tree.setItemCaption(key, getCaption(key, entry.getValue())); - tree.setChildrenAllowed(key, false); - String parent = null; - int start = 0; - int index = key.indexOf('.', start); - while(index>0){ - String subItem = key.substring(0,index); - String caption = key.substring(start, index); - tree.addItem(subItem); - tree.setItemCaption(subItem, caption); - if(parent!=null){ - tree.setParent(subItem, parent); - } - parent = subItem; - start = index+1; - index = key.indexOf('.', start); - } - String lastItem = key.substring(start); - if(!lastItem.equals(key)){ - if(parent!=null){ - tree.setParent(key, parent); - }else{ - // should not happen - } - }else{ // singl root entry - if(parent!=null) { - tree.setParent(key, parent); - } - } - } - } - - 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-extensions/blob/5e94349a/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 deleted file mode 100644 index eef0db8..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/views/ErrorView.java +++ /dev/null @@ -1,43 +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.views; - -import com.vaadin.navigator.View; -import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Label; -import com.vaadin.ui.VerticalLayout; -import org.apache.tamaya.ui.UIConstants; - -/** - * View used for shoiwing unexpected errors. - */ -public class ErrorView extends VerticalLayout implements View { - - @Override - public void enter(ViewChangeListener.ViewChangeEvent event) { - setSizeFull(); - setMargin(true); - Label label = new Label("Could not find a view with that name. You are most likely doing it wrong."); - label.addStyleName(UIConstants.LABEL_FAILURE); - - addComponent(label); - setComponentAlignment(label, Alignment.MIDDLE_CENTER); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index 9d371d0..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/views/HomeView.java +++ /dev/null @@ -1,94 +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.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.ViewProvider; -import org.apache.tamaya.ui.components.VerticalSpacedLayout; -import org.apache.tamaya.ui.services.MessageProvider; - -import javax.annotation.Priority; - -/** - * Home view containing a title and a description, used as default entry point of the UI after login. - */ -public class HomeView extends VerticalSpacedLayout implements View { - - /** - * Provider to bew registered providing this view to the UI module. - */ - @Priority(0) - public static final class Provider implements ViewProvider{ - - @Override - public ViewLifecycle getLifecycle() { - return ViewLifecycle.LAZY; - } - - @Override - public String getName() { - return "view.home.name"; - } - - @Override - public String getUrlPattern() { - return "/home"; - } - - @Override - public String getDisplayName() { - return ServiceContextManager.getServiceContext().getService(MessageProvider.class) - .getMessage(getName()); - } - - @Override - public View createView(Object... params) { - return new HomeView(); - } - - } - - /** - * Constructor. - */ - public HomeView() { - Label caption = new Label("Welcome, " + CurrentUser.get().getUserID()); - Label description = new Label( - "<b>Apache Tamaya</b> is an API and extendable framework for accessing and managing configuration.<br/> \n" + - "Please check the project's home page <a href='http://tamaya.incubator.apache.org'>http://tamaya.incubator.apache.org</a>.", - ContentMode.HTML); - - addComponents(caption, description); - - caption.addStyleName(UIConstants.LABEL_HUGE); - description.addStyleName(UIConstants.LABEL_LARGE); - - } - - @Override - public void enter(ViewChangeListener.ViewChangeEvent event) { - // nothing to do - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/views/SystemView.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/views/SystemView.java b/ui/src/main/java/org/apache/tamaya/ui/views/SystemView.java deleted file mode 100644 index ea3421c..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/views/SystemView.java +++ /dev/null @@ -1,117 +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.views; - -import com.vaadin.navigator.View; -import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.ui.Label; -import com.vaadin.ui.Tree; -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; - -/** - * View showing the current loaded system components. - */ -@Priority(10000) -public class SystemView extends VerticalSpacedLayout implements View { - - - /** - * Provider to register this view. - */ - @Priority(20) - public static final class Provider implements ViewProvider{ - - @Override - public ViewLifecycle getLifecycle() { - return ViewLifecycle.CREATE; - } - - @Override - public String getName() { - return "view.system.name"; - } - - @Override - public String getUrlPattern() { - return "/system"; - } - - @Override - public String getDisplayName() { - return ServiceContextManager.getServiceContext().getService(MessageProvider.class) - .getMessage("view.system.name"); - } - - @Override - public View createView(Object... params){ - return new SystemView(); - } - } - - - private Tree configTree = new Tree(ServiceContextManager.getServiceContext().getService(MessageProvider.class) - .getMessage("default.label.system")); - - - public SystemView() { - Label caption = new Label("Tamaya Runtime"); - Label description = new Label( - "This view shows the system components currently active. This information may be useful when checking if an" + - "configuration extension is loaded and for inspection of the configuration and property sources" + - "invovlved.", - ContentMode.HTML); - - fillComponentTree(); - - addComponents(caption, description, configTree); - - caption.addStyleName(UIConstants.LABEL_HUGE); - description.addStyleName(UIConstants.LABEL_LARGE); - - } - - private void fillComponentTree() { - configTree.removeAllItems(); - for(SystemInfoProvider infoProvider:ServiceContextManager.getServiceContext() - .getServices(SystemInfoProvider.class)){ - infoProvider.provideSystemInfo(configTree); - } - } - - 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-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/views/TamayaGeneralSystemInfoProvider.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/views/TamayaGeneralSystemInfoProvider.java b/ui/src/main/java/org/apache/tamaya/ui/views/TamayaGeneralSystemInfoProvider.java deleted file mode 100644 index fd37136..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/views/TamayaGeneralSystemInfoProvider.java +++ /dev/null @@ -1,56 +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.views; - -import com.vaadin.ui.Tree; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.apache.tamaya.spi.PropertyValueCombinationPolicy; - -import javax.annotation.Priority; - -/** - * Created by atsticks on 29.06.16. - */ -@Priority(0) -public class TamayaGeneralSystemInfoProvider implements SystemInfoProvider{ - @Override - public void provideSystemInfo(Tree tree) { - Configuration config = ConfigurationProvider.getConfiguration(); - String currentParent = "General"; - tree.addItem(currentParent); - tree.addItem("Configuration.class"); - tree.setItemCaption("Configuration.class", "Configuration class = " + config.getClass().getName()); - tree.setParent("Configuration.class", currentParent); - tree.setChildrenAllowed("Configuration.class", false); - - tree.addItem("ConfigurationContext.class"); - tree.setItemCaption("ConfigurationContext.class", "ConfigurationContext class = " + - config.getContext().getClass().getName()); - tree.setParent("ConfigurationContext.class", currentParent); - tree.setChildrenAllowed("ConfigurationContext.class", false); - - tree.addItem("PropertyValueCombinationPolicy.class"); - tree.setItemCaption("PropertyValueCombinationPolicy.class", - PropertyValueCombinationPolicy.class.getSimpleName() + " class = " + - config.getContext().getPropertyValueCombinationPolicy().getClass().getName()); - tree.setParent("PropertyValueCombinationPolicy.class", currentParent); - tree.setChildrenAllowed("PropertyValueCombinationPolicy.class", false); - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/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 deleted file mode 100644 index 73cf018..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginBox.java +++ /dev/null @@ -1,112 +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.views.login; - -import com.vaadin.event.ShortcutAction; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Component; -import com.vaadin.ui.FormLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Notification; -import com.vaadin.ui.PasswordField; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import org.apache.tamaya.spi.ServiceContextManager; -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.MessageProvider; -import org.apache.tamaya.ui.services.UserService; - -/** - * Login dialog centerd on the screen. - */ -public class LoginBox extends VerticalLayout { - - private TextField username; - private PasswordField password; - - public LoginBox() { - setWidth("400px"); - addStyleName(UIConstants.LOGIN_BOX); - setSpacing(true); - setMargin(true); - - addCaption(); - addForm(); - addButtons(); - } - - private void addCaption() { - Label caption = new Label("Login to system"); - addComponent(caption); - - caption.addStyleName(UIConstants.LABEL_H1); - } - - private void addForm() { - FormLayout loginForm = new FormLayout(); - 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); - for(Component component:loginForm){ - component.setWidth("100%"); - } - username.focus(); - } - - private void addButtons() { - HorizontalLayout buttonsLayout = new HorizontalLayout(); - Button forgotButton = new Button("Forgot", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - Notification.show("Sorry, this feature is not yet implemented.", Notification.Type.TRAY_NOTIFICATION); - } - }); - Button loginButton = new Button("Login", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - login(); - } - }); - buttonsLayout.addComponents(forgotButton, loginButton); - addComponent(buttonsLayout); - buttonsLayout.setSpacing(true); - forgotButton.addStyleName(UIConstants.BUTTON_LINK); - loginButton.addStyleName(UIConstants.BUTTON_PRIMARY); - loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); - setComponentAlignment(buttonsLayout, Alignment.BOTTOM_RIGHT); - } - - private void login() { - User user = ServiceContextManager.getServiceContext().getService(UserService.class) - .login(username.getValue(), password.getValue()); - if(user!=null){ - EventBus.post(new LoginEvent(user)); - }else{ - Notification.show("Login failed.", "Sorry the system could not log you in.", Notification.Type.WARNING_MESSAGE); - username.focus(); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginEvent.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginEvent.java b/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginEvent.java deleted file mode 100644 index 004c545..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginEvent.java +++ /dev/null @@ -1,55 +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.views.login; - -import org.apache.tamaya.ui.User; - -import java.util.Objects; - -/** - * Event sent when a user has been authenticated. - */ -public class LoginEvent { - /** The user, not null. */ - private User user; - - /** - * Creates a new event. - * @param user the user logged in, not null. - */ - public LoginEvent(User user) { - this.user = Objects.requireNonNull(user); - } - - /** - * Get the user logged in. - * @return the user logged in, never null. - */ - public User getUser() { - return user; - } - - @Override - public String toString() { - return "LoginEvent{" + - "user=" + user + - '}'; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginView.java ---------------------------------------------------------------------- diff --git a/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginView.java b/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginView.java deleted file mode 100644 index 15730d3..0000000 --- a/ui/src/main/java/org/apache/tamaya/ui/views/login/LoginView.java +++ /dev/null @@ -1,37 +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.views.login; - -import com.vaadin.ui.Alignment; -import com.vaadin.ui.VerticalLayout; - -/** - * View used for login the users. - */ -public class LoginView extends VerticalLayout { - - /** - * Creates a new view. - */ - public LoginView() { - setSizeFull(); - setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); - addComponent(new LoginBox()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/resources/META-INF/javaconfiguration.properties ---------------------------------------------------------------------- diff --git a/ui/src/main/resources/META-INF/javaconfiguration.properties b/ui/src/main/resources/META-INF/javaconfiguration.properties deleted file mode 100644 index 98d7155..0000000 --- a/ui/src/main/resources/META-INF/javaconfiguration.properties +++ /dev/null @@ -1,21 +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 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. -# -tamaya.users.admin.pwd=admin -tamaya.users.admin.fullName=Administrator -tamaya.users.admin.roles=admin \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5e94349a/ui/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider ---------------------------------------------------------------------- diff --git a/ui/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider b/ui/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider deleted file mode 100644 index 5650c5f..0000000 --- a/ui/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider +++ /dev/null @@ -1,21 +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 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.ui.views.HomeView$Provider -org.apache.tamaya.ui.views.ConfigView$Provider -org.apache.tamaya.ui.views.SystemView$Provider \ No newline at end of file