ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1801736 - in /ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin: LoginWindow.java VaadinClient.java component/MainActionToolbar.java component/StatusLine.java
Date Wed, 12 Jul 2017 13:53:04 GMT
Author: jawi
Date: Wed Jul 12 13:53:04 2017
New Revision: 1801736

URL: http://svn.apache.org/viewvc?rev=1801736&view=rev
Log:
Fixed some annoyances and abbeyances:

- log information to the log service in case a generic action like "store" or
  "revert" fails;
- in case a login fails due to problems with the backend, do not show the main
  grid (causing multiple grids to appear when trying to login again);
- show more information about the state changes of a target in the status line
  (instead of `Target foo null` message).


Modified:
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/StatusLine.java

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java?rev=1801736&r1=1801735&r2=1801736&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
Wed Jul 12 13:53:04 2017
@@ -18,6 +18,9 @@
  */
 package org.apache.ace.webui.vaadin;
 
+import static org.osgi.service.log.LogService.LOG_INFO;
+import static org.osgi.service.log.LogService.LOG_WARNING;
+
 import java.util.Map;
 
 import org.osgi.service.log.LogService;
@@ -40,7 +43,7 @@ import com.vaadin.ui.themes.Reindeer;
  */
 public class LoginWindow extends Window {
     /**
-     *  
+     *
      */
     public static interface LoginFunction {
         boolean login(String name, String password);
@@ -53,7 +56,7 @@ public class LoginWindow extends Window
 
     /**
      * Creates a new {@link LoginWindow} instance.
-     * 
+     *
      * @param log
      *            the log service to use;
      * @param loginFunction
@@ -109,12 +112,12 @@ public class LoginWindow extends Window
                     String password = (String) passwordField.getValue();
 
                     if (m_loginFunction.login(username, password)) {
-                        m_log.log(LogService.LOG_INFO, "Apache Ace WebUI succesfull login
by user: " + username);
+                        m_log.log(LOG_INFO, "Apache Ace WebUI succesfull login by user: "
+ username);
 
                         closeWindow();
                     }
                     else {
-                        m_log.log(LogService.LOG_WARNING, "Apache Ace WebUI invalid username
or password entered.");
+                        m_log.log(LOG_WARNING, "Apache Ace WebUI invalid username or password
entered.");
 
                         m_additionalInfo.setValue("Invalid username or password!");
 
@@ -145,7 +148,7 @@ public class LoginWindow extends Window
 
     /**
      * Shows this login window on screen.
-     * 
+     *
      * @param parent
      *            the parent window, cannot be <code>null</code>.
      */

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1801736&r1=1801735&r2=1801736&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
Wed Jul 12 13:53:04 2017
@@ -106,7 +106,6 @@ import com.vaadin.ui.Window.Notification
 /**
  * Main application entry point.
  */
-@SuppressWarnings("serial")
 public class VaadinClient extends com.vaadin.Application implements AssociationManager, LoginFunction
{
 
     // basic session ID generator
@@ -116,7 +115,7 @@ public class VaadinClient extends com.va
 
     /**
      * Remove the given directory and all it's files and subdirectories
-     * 
+     *
      * @param directory
      *            the name of the directory to remove
      */
@@ -202,9 +201,9 @@ public class VaadinClient extends com.va
 
     /**
      * Creates a new {@link VaadinClient} instance.
-     * 
+     *
      * @param m_manager2
-     * 
+     *
      * @param aceHost
      *            the hostname where the management service can be reached;
      * @param obrUrl
@@ -470,7 +469,7 @@ public class VaadinClient extends com.va
 
     /**
      * Create a new distribution in the distribution repository
-     * 
+     *
      * @param name
      *            the name of the new distribution;
      * @param description
@@ -486,7 +485,7 @@ public class VaadinClient extends com.va
 
     /**
      * Create a new feature in the feature repository.
-     * 
+     *
      * @param name
      *            the name of the new feature;
      * @param description
@@ -502,7 +501,7 @@ public class VaadinClient extends com.va
 
     /**
      * Create a new target in the stateful target repository.
-     * 
+     *
      * @param name
      *            the name of the new target;
      */
@@ -573,9 +572,9 @@ public class VaadinClient extends com.va
 
     /**
      * Create a button to show a pop window for adding new features.
-     * 
+     *
      * @param user
-     * 
+     *
      * @param main
      *            Main Window
      * @return Button
@@ -594,9 +593,9 @@ public class VaadinClient extends com.va
     /**
      * Create a button to show a popup window for adding a new distribution. On success this
calls the
      * createDistribution() method.
-     * 
+     *
      * @param user
-     * 
+     *
      * @return the add-distribution button instance.
      */
     private Button createAddDistributionButton() {
@@ -624,9 +623,9 @@ public class VaadinClient extends com.va
 
     /***
      * Create a button to show popup window for adding a new feature. On success this calls
the createFeature() method.
-     * 
+     *
      * @param user
-     * 
+     *
      * @return the add-feature button instance.
      */
     private Button createAddFeatureButton() {
@@ -653,9 +652,9 @@ public class VaadinClient extends com.va
 
     /**
      * Create a button to show a popup window for adding a new target. On success this calls
the createTarget() method
-     * 
+     *
      * @param user
-     * 
+     *
      * @return the add-target button instance.
      */
     private Button createAddTargetButton() {
@@ -977,6 +976,11 @@ public class VaadinClient extends com.va
                 return m_admin;
             }
 
+            @Override
+            protected void log(int level, String msg, Exception e, Object... args) {
+                m_log.log(level, String.format(msg, args), e);
+            }
+
             private void updateTableData() {
                 m_artifactsPanel.populate();
                 m_featuresPanel.populate();
@@ -990,7 +994,7 @@ public class VaadinClient extends com.va
 
     /**
      * Authenticates the given user by creating all dependent services.
-     * 
+     *
      * @param user
      * @throws IOException
      *             in case of I/O problems.
@@ -1010,9 +1014,10 @@ public class VaadinClient extends com.va
             // @formatter:on
 
             m_admin.login(context);
-            initGrid();
             m_admin.checkout();
 
+            initGrid();
+
             return true;
         }
         catch (Exception e) {

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java?rev=1801736&r1=1801735&r2=1801736&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
Wed Jul 12 13:53:04 2017
@@ -18,6 +18,9 @@
  */
 package org.apache.ace.webui.vaadin.component;
 
+import static org.osgi.service.log.LogService.LOG_ERROR;
+import static org.osgi.service.log.LogService.LOG_WARNING;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -87,7 +90,7 @@ public abstract class MainActionToolbar
 
         /**
          * Does the actual logout of the user.
-         * 
+         *
          * @throws IOException
          *             in case of I/O problems during the logout.
          */
@@ -140,7 +143,7 @@ public abstract class MainActionToolbar
 
         /**
          * Does the actual retrieval of the latest version.
-         * 
+         *
          * @throws IOException
          *             in case of I/O problems during the retrieve.
          */
@@ -193,7 +196,7 @@ public abstract class MainActionToolbar
 
         /**
          * Does the actual revert of changes.
-         * 
+         *
          * @throws IOException
          *             in case of problems during I/O exception.
          */
@@ -234,7 +237,7 @@ public abstract class MainActionToolbar
 
         /**
          * Does the actual commit of changes.
-         * 
+         *
          * @throws IOException
          *             in case of I/O problems during the commit.
          */
@@ -256,10 +259,10 @@ public abstract class MainActionToolbar
 
     /**
      * Creates a new {@link MainActionToolbar} instance.
-     * 
+     *
      * @param user
      * @param manager
-     * 
+     *
      * @param showLogoutButton
      *            <code>true</code> if a logout button should be shown, <code>false</code>
if it should not.
      */
@@ -317,28 +320,28 @@ public abstract class MainActionToolbar
 
     /**
      * Called after a commit/store has taken place, allows additional UI-updates to be performed.
-     * 
+     *
      * @throws IOException
      */
     protected abstract void doAfterCommit() throws IOException;
 
     /**
      * Called after a logout has taken place, allows additional UI-updates to be performed.
-     * 
+     *
      * @throws IOException
      */
     protected abstract void doAfterLogout() throws IOException;
 
     /**
      * Called after a retrieve has taken place, allows additional UI-updates to be performed.
-     * 
+     *
      * @throws IOException
      */
     protected abstract void doAfterRetrieve() throws IOException;
 
     /**
      * Called after a revert has taken place, allows additional UI-updates to be performed.
-     * 
+     *
      * @throws IOException
      */
     protected abstract void doAfterRevert() throws IOException;
@@ -375,8 +378,7 @@ public abstract class MainActionToolbar
         component.add(dm.createServiceDependency()
             .setService(UIExtensionFactory.class, "(" + UIExtensionFactory.EXTENSION_POINT_KEY
+ "=" + UIExtensionFactory.EXTENSION_POINT_VALUE_MENU + ")")
             .setCallbacks("add", "remove")
-            .setRequired(false)
-        );
+            .setRequired(false));
     }
 
     protected final void remove(ServiceReference<UIExtensionFactory> ref, UIExtensionFactory
factory) {
@@ -393,13 +395,21 @@ public abstract class MainActionToolbar
         else {
             sb.append("<br/>unknown error!");
         }
+        log(LOG_ERROR, message, e);
         getWindow().showNotification(title, sb.toString(), Notification.TYPE_ERROR_MESSAGE);
     }
 
     protected void showWarning(String title, String message) {
+        log(LOG_WARNING, message);
         getWindow().showNotification(title, String.format("<br/>%s", message), Notification.TYPE_WARNING_MESSAGE);
     }
 
+    protected final void log(int level, String msg, Object... args) {
+        log(level, msg, null, args);
+    }
+
+    protected abstract void log(int level, String msg, Exception e, Object... args);
+
     private void addCrossPlatformShortcut(Button button, int key, String description) {
         // ACE-427 - NPE when using getMainWindow() if no authentication is used...
         WebApplicationContext context = (WebApplicationContext) getApplication().getContext();

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/StatusLine.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/StatusLine.java?rev=1801736&r1=1801735&r2=1801736&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/StatusLine.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/StatusLine.java
Wed Jul 12 13:53:04 2017
@@ -36,7 +36,6 @@ import com.vaadin.ui.Label;
 /**
  * Denotes a status line in which a short summary of the latest actions in the UI are displayed.
  */
-@SuppressWarnings("unchecked")
 public class StatusLine extends Label implements EventHandler {
 
     /**
@@ -52,22 +51,25 @@ public class StatusLine extends Label im
         RepositoryObject entity = (RepositoryObject) event.getProperty(RepositoryObject.EVENT_ENTITY);
 
         String type = getType(topic);
+        if (type == null) {
+            // Nothing to do...
+            return;
+        }
+
         String action = getAction(topic);
         String name = getName(entity);
 
-        if (type != null) {
-            if (name != null) {
-                setStatus("%s '%s' %s...", type, name, action);
-            }
-            else if (action != null) {
-                setStatus("%s %s...", type, action);
-            }
+        if (name != null && action != null) {
+            setStatus("%s '%s' %s...", type, name, action);
+        }
+        else if (action != null) {
+            setStatus("%s %s...", type, action);
         }
     }
 
     /**
      * Sets the status to the given message.
-     * 
+     *
      * @param msg
      *            the message;
      * @param args
@@ -82,15 +84,23 @@ public class StatusLine extends Label im
      * @return
      */
     private String getAction(String topic) {
-        if (topic.endsWith("/" + RepositoryObject.TOPIC_REMOVED_SUFFIX)) {
+        if (topic.endsWith("/REMOVED")) {
             return "removed";
         }
-        else if (topic.endsWith("/" + RepositoryObject.TOPIC_ADDED_SUFFIX)) {
+        else if (topic.endsWith("/ADDED")) {
             return "added";
         }
-        else if (topic.endsWith("/" + RepositoryObject.TOPIC_CHANGED_SUFFIX)) {
+        else if (topic.endsWith("/CHANGED")) {
             return "changed";
         }
+        else if (topic.endsWith("/STATUS_CHANGED")) {
+            // for stateful target objects only...
+            return "status updated";
+        }
+        else if (topic.endsWith("/AUDITEVENTS_CHANGED")) {
+            // for stateful target objects only...
+            return "audit log updated";
+        }
         return null;
     }
 



Mime
View raw message