ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1539718 - in /ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin: VaadinClient.java VaadinServlet.java component/ArtifactsPanel.java component/BaseObjectPanel.java
Date Thu, 07 Nov 2013 17:10:32 GMT
Author: jawi
Date: Thu Nov  7 17:10:31 2013
New Revision: 1539718

URL: http://svn.apache.org/r1539718
Log:
ACE-291 - scrolling the artifacts table doesn't work well:

- reduced the number of times each table was (re)populated in the UI
  to the bare minimum. This was done several times without a real need;
- added two additional configuration settings 'artifacts.cache.rate' &
  'artifacts.page.length' that allows you to tweak how aggressively
  Vaadin caches the artifacts column. Settings the page length to around
  500 already seems to reduce the number of times the server is needed 
  while scrolling.


Modified:
    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/VaadinServlet.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java

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=1539718&r1=1539717&r2=1539718&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
Thu Nov  7 17:10:31 2013
@@ -178,10 +178,13 @@ public class VaadinClient extends com.va
 
     private final URL m_repository;
     private final boolean m_useAuth;
-
     private final String m_userName;
     private final AssociationHelper m_associations = new AssociationHelper();
     private final AtomicBoolean m_dependenciesResolved = new AtomicBoolean(false);
+    // for the artifacts list...
+    private final int m_cacheRate;
+    private final int m_pageLength;
+
     private ProgressIndicator m_progress;
 
     private DependencyManager m_manager;
@@ -206,7 +209,7 @@ public class VaadinClient extends com.va
      * @param userName
      *            the hardcoded username to use when authentication is disabled.
      */
-    public VaadinClient(DependencyManager manager, URL aceHost, URL obrUrl, String repositoryXML,
boolean useAuth, String userName, String password) {
+    public VaadinClient(DependencyManager manager, URL aceHost, URL obrUrl, String repositoryXML,
boolean useAuth, String userName, String password, int cacheRate, int pageLength) {
         m_manager = manager;
         try {
             m_repository = new URL(aceHost, endpoint);
@@ -218,6 +221,8 @@ public class VaadinClient extends com.va
         m_repositoryXML = repositoryXML;
         m_useAuth = useAuth;
         m_userName = userName;
+        m_cacheRate = cacheRate;
+        m_pageLength = pageLength;
 
         if (!m_useAuth && (m_userName == null || "".equals(m_userName.trim()))) {
             throw new IllegalArgumentException("Need a valid user name when no authentication
is used!");
@@ -644,7 +649,7 @@ public class VaadinClient extends com.va
     }
 
     private ArtifactsPanel createArtifactsPanel() {
-        return new ArtifactsPanel(m_associations, this) {
+        return new ArtifactsPanel(m_associations, this, m_cacheRate, m_pageLength) {
             @Override
             protected EditWindow createEditor(final NamedObject object, final List<UIExtensionFactory>
extensions) {
                 return new EditWindow("Edit Artifact", object, extensions) {

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java?rev=1539718&r1=1539717&r2=1539718&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
Thu Nov  7 17:10:31 2013
@@ -55,6 +55,8 @@ public class VaadinServlet extends Abstr
     private static final String KEY_OBR_XML = "obr.xml";
     /** The timeout (in seconds) of a session. */
     private static final String KEY_SESSION_TIMEOUT = "session.timeout";
+    private static final String KEY_CACHE_RATE = "artifacts.cache.rate";
+    private static final String KEY_PAGE_LENGTH = "artifacts.page.length";
 
     private static final boolean DEFAULT_USE_AUTHENTICATION = false;
     private static final String DEFAULT_USER_NAME = "";
@@ -64,6 +66,8 @@ public class VaadinServlet extends Abstr
     private static final String DEFAULT_OBR_XML = "repository.xml";
     private static final String DEFAULT_SERVLET_ENDPOINT = "/ace";
     private static final int DEFAULT_SESSION_TIMEOUT = 300; // in seconds.
+    private static final int DEFAULT_CACHE_RATE = 2;
+    private static final int DEFAULT_PAGE_LENGTH = 100;
 
     static {
         try {
@@ -84,6 +88,8 @@ public class VaadinServlet extends Abstr
     private volatile String m_repositoryXML;
     private volatile String m_servletEndpoint;
     private volatile int m_sessionTimeout;
+    private volatile int m_cacheRate;
+    private volatile int m_pageLength;
 
     /**
      * Creates a new {@link VaadinServlet} instance.
@@ -97,6 +103,8 @@ public class VaadinServlet extends Abstr
         m_repositoryXML = DEFAULT_OBR_XML;
         m_servletEndpoint = DEFAULT_SERVLET_ENDPOINT;
         m_sessionTimeout = DEFAULT_SESSION_TIMEOUT;
+        m_cacheRate = DEFAULT_CACHE_RATE;
+        m_pageLength = DEFAULT_PAGE_LENGTH;
     }
 
     @Override
@@ -109,6 +117,8 @@ public class VaadinServlet extends Abstr
         String repositoryXML = DEFAULT_OBR_XML;
         String servletEndpoint = DEFAULT_SERVLET_ENDPOINT;
         int sessionTimeout = DEFAULT_SESSION_TIMEOUT;
+        int cacheRate = DEFAULT_CACHE_RATE;
+        int pageLength = DEFAULT_PAGE_LENGTH;
 
         if (dictionary != null) {
             useAuth = getBoolean(dictionary, KEY_USE_AUTHENTICATION);
@@ -119,6 +129,16 @@ public class VaadinServlet extends Abstr
             repositoryXML = getOptionalString(dictionary, KEY_OBR_XML);
             servletEndpoint = getOptionalString(dictionary, KEY_SERVLET_ENDPOINT);
             sessionTimeout = getInteger(dictionary, KEY_SESSION_TIMEOUT);
+            
+            Integer value = getOptionalInteger(dictionary, KEY_CACHE_RATE);
+            if (value != null) {
+                cacheRate = value.intValue(); 
+            }
+
+            value = getOptionalInteger(dictionary, KEY_PAGE_LENGTH);
+            if (value != null) {
+                pageLength = value.intValue(); 
+            }
         }
 
         if ("".equals(repositoryXML)) {
@@ -137,6 +157,8 @@ public class VaadinServlet extends Abstr
         m_repositoryXML = repositoryXML;
         m_servletEndpoint = servletEndpoint;
         m_sessionTimeout = sessionTimeout;
+        m_cacheRate = cacheRate;
+        m_pageLength = pageLength;
     }
 
     @Override
@@ -153,7 +175,7 @@ public class VaadinServlet extends Abstr
 
     @Override
     protected Application getNewApplication(HttpServletRequest request) throws ServletException
{
-        return new VaadinClient(m_manager, m_aceHost, m_obrUrl, m_repositoryXML, m_useAuth,
m_userName, m_password);
+        return new VaadinClient(m_manager, m_aceHost, m_obrUrl, m_repositoryXML, m_useAuth,
m_userName, m_password, m_cacheRate, m_pageLength);
     }
 
     @Override
@@ -186,10 +208,25 @@ public class VaadinServlet extends Abstr
     }
 
     private int getInteger(Dictionary dictionary, String key) throws ConfigurationException
{
-        Object value = dictionary.get(key);
-        if (value == null || !(value instanceof String)) {
+        Integer value = getOptionalInteger(dictionary, key);
+        if (value == null) {
             throw new ConfigurationException(key, "Missing property");
         }
+        return value.intValue();
+    }
+
+    private Integer getOptionalInteger(Dictionary dictionary, String key) throws ConfigurationException
{
+        Object value = dictionary.get(key);
+        if (value == null) {
+            return null;
+        }
+        if (!(value instanceof Integer) && !(value instanceof String)) {
+            throw new ConfigurationException(key, "Invalid value!");
+        }
+        if (value instanceof Integer) {
+            return (Integer) value;
+        }
+
         try {
             String valueStr = ((String) value).trim();
             return Integer.parseInt(valueStr);

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java?rev=1539718&r1=1539717&r2=1539718&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
Thu Nov  7 17:10:31 2013
@@ -37,6 +37,9 @@ import com.vaadin.data.Item;
  * Provides an object panel for displaying artifacts.
  */
 public abstract class ArtifactsPanel extends BaseObjectPanel<ArtifactObject, ArtifactRepository,
RepositoryObject, FeatureObject> {
+    private final int m_cacheRate;
+    private final int m_pageLength;
+
     /**
      * Creates a new {@link ArtifactsPanel} instance.
      * 
@@ -45,14 +48,29 @@ public abstract class ArtifactsPanel ext
      * @param associationMgr
      *            the helper for creating/removing associations.
      */
-    public ArtifactsPanel(AssociationHelper associations, AssociationManager associationMgr)
{
+    public ArtifactsPanel(AssociationHelper associations, AssociationManager associationMgr,
int cacheRate, int pageLength) {
         super(associations, associationMgr, "Artifact", UIExtensionFactory.EXTENSION_POINT_VALUE_ARTIFACT,
true, ArtifactObject.class);
+
+        m_cacheRate = cacheRate;
+        m_pageLength = pageLength;
+
+        setCacheRate(m_cacheRate);
+        setPageLength(m_pageLength);
+    }
+
+    @Override
+    public void populate() {
+        super.populate();
+        // For some reason, we need to explicitly set these two properties as Vaadin seems
to loose their values
+        // somewhere...
+        setCacheRate(m_cacheRate);
+        setPageLength(m_pageLength);
     }
 
     @Override
     protected void defineTableColumns() {
         super.defineTableColumns();
-        
+
         setColumnCollapsed(OBJECT_DESCRIPTION, true);
     }
 

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java?rev=1539718&r1=1539717&r2=1539718&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
Thu Nov  7 17:10:31 2013
@@ -292,6 +292,7 @@ abstract class BaseObjectPanel<REPO_OBJ 
         m_entityType = entityType;
 
         setSizeFull();
+        setAnimationsEnabled(false);
         setCellStyleGenerator(this);
         setSelectable(true);
         setMultiSelect(true);
@@ -304,6 +305,9 @@ abstract class BaseObjectPanel<REPO_OBJ 
         setItemIconPropertyId(ICON);
         setHierarchyColumn(ICON);
 
+        setSortAscending(true);
+        setSortContainerPropertyId(OBJECT_NAME);
+
         if (hasEdit) {
             addListener(new ItemClickListener() {
                 public void itemClick(ItemClickEvent event) {
@@ -337,7 +341,6 @@ abstract class BaseObjectPanel<REPO_OBJ 
         synchronized (m_extensionFactories) {
             m_extensionFactories.add(new UIExtensionFactoryHolder(ref, factory));
         }
-        populate();
     }
 
     @Override
@@ -401,7 +404,7 @@ abstract class BaseObjectPanel<REPO_OBJ 
             if (isSupportedEntity(entity)) {
                 handleEvent(topic, entity, event);
             }
-            else if (RepositoryAdmin.TOPIC_REFRESH.equals(topic) || RepositoryAdmin.TOPIC_LOGIN.equals(topic))
{
+            else if (RepositoryAdmin.TOPIC_LOGIN.equals(topic)) {
                 populate();
             }
         }
@@ -425,13 +428,15 @@ abstract class BaseObjectPanel<REPO_OBJ 
     }
 
     /**
-     * Called to populate this table.
+     * Removes all current items and (re)populates this table.
      */
     public void populate() {
         removeAllItems();
         for (REPO_OBJ object : getAllRepositoryObjects()) {
             add(object);
         }
+        // Ensure the table is properly sorted...
+        sort();
     }
 
     /**
@@ -446,7 +451,6 @@ abstract class BaseObjectPanel<REPO_OBJ 
         synchronized (m_extensionFactories) {
             m_extensionFactories.remove(new UIExtensionFactoryHolder(ref, factory));
         }
-        populate();
     }
 
     /**
@@ -721,6 +725,15 @@ abstract class BaseObjectPanel<REPO_OBJ 
     }
 
     /**
+     * Returns all repository objects.
+     * 
+     * @return an {@link Iterable} with all repository objects, never <code>null</code>.
+     */
+    protected final Iterable<REPO_OBJ> getAllRepositoryObjects() {
+        return getRepository().get();
+    }
+
+    /**
      * Returns a user-friendly name for a given repository object.
      * 
      * @param object
@@ -979,15 +992,6 @@ abstract class BaseObjectPanel<REPO_OBJ 
     }
 
     /**
-     * Returns all repository objects.
-     * 
-     * @return an {@link Iterable} with all repository objects, never <code>null</code>.
-     */
-    private Iterable<REPO_OBJ> getAllRepositoryObjects() {
-        return getRepository().get();
-    }
-
-    /**
      * @return a list of current extension factories, properly ordered, never <code>null</code>.
      */
     private List<UIExtensionFactory> getExtensionFactories() {



Mime
View raw message