[jbpm-commits] JBoss JBPM SVN: r4581 - in projects/gwt-console/branches/hbraun: plugin-api/src/main/java/org/jboss/bpm/console/client/v2 and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Apr 20 08:49:13 EDT 2009


Author: heiko.braun at jboss.com
Date: 2009-04-20 08:49:13 -0400 (Mon, 20 Apr 2009)
New Revision: 4581

Added:
   projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/v2/
   projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/v2/LazyPanel.java
Modified:
   projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/ApplicationContext.java
   projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Editor.java
   projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Workspace.java
   projects/gwt-console/branches/hbraun/plugin-example/src/main/java/org/jboss/bpm/console/client/mapsplugin/MapsEditor.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/MainView.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/LoginView.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/MainLayout.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java
Log:
Added LazyPanel. Fix ProcessEditor rendering bug

Modified: projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/ApplicationContext.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/ApplicationContext.java	2009-04-19 18:34:59 UTC (rev 4580)
+++ projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/ApplicationContext.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -22,6 +22,7 @@
 package org.jboss.bpm.console.client;
 
 import com.mvc4g.client.Controller;
+import org.gwt.mosaic.ui.client.Viewport;
 
 /**
  * Provides context information to console components and plugins.
@@ -42,4 +43,6 @@
 
   Controller getController();
 
+  Viewport getViewport();
+
 }

Modified: projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Editor.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Editor.java	2009-04-19 18:34:59 UTC (rev 4580)
+++ projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Editor.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -22,8 +22,10 @@
 package org.jboss.bpm.console.client;
 
 import com.mvc4g.client.Controller;
+import com.google.gwt.user.client.Window;
 import org.gwt.mosaic.ui.client.layout.LayoutPanel;
 import org.gwt.mosaic.ui.client.layout.BorderLayout;
+import org.jboss.bpm.console.client.v2.LazyPanel;
 
 
 /**
@@ -37,15 +39,17 @@
  * 
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
-public abstract class Editor extends LayoutPanel
+public abstract class Editor extends LayoutPanel implements LazyPanel
 {
   protected ApplicationContext appContext;
 
   protected Controller controller;
 
+  protected boolean isInitialized;
+
   public Editor(ApplicationContext appContext)
   {
-    super( new BorderLayout() );
+    super(new BorderLayout());
     this.appContext = appContext;
 
     // hmvc controller chain.
@@ -53,6 +57,13 @@
     this.controller.setParent(appContext.getController());        
   }
 
+  public boolean isInitialized()
+  {
+    return this.isInitialized;
+  }
+
+  public abstract void initialize();
+    
   public abstract String getEditorId();
 
   public abstract String getTitle();
@@ -70,7 +81,7 @@
   @Deprecated
   public void showView(String viewId)
   {
-    appContext.getWorkpace().showEditor(viewId);
+    throw new RuntimeException("Not implemented");
   }
 
   @Deprecated
@@ -89,4 +100,15 @@
     System.out.println("*** addView should be re-implemented ***");
     
   }
+
+  /**
+   * hack in order to correctly display widgets that have
+   * been rendered hidden
+   */
+  protected void refreshView()
+  {
+    final int width = Window.getClientWidth();
+    final int height = Window.getClientHeight();
+    appContext.getViewport().onWindowResized(width, height);    
+  }
 }

Modified: projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Workspace.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Workspace.java	2009-04-19 18:34:59 UTC (rev 4580)
+++ projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Workspace.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -23,8 +23,6 @@
 
 import org.gwt.mosaic.ui.client.DeckLayoutPanel;
 import org.gwt.mosaic.ui.client.layout.LayoutPanel;
-import com.mvc4g.client.ActionInterface;
-import com.mvc4g.client.Controller;
 
 /**
  * Maintains {@link Editor}'s
@@ -66,6 +64,8 @@
     if(null==deck)
       throw new IllegalArgumentException("No such editor: " +id);
     this.showWidget(deck.index);
+    
+    deck.editor.initialize();    
   }
 
   private EditorDeck createDeck(Editor editor)

Added: projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/v2/LazyPanel.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/v2/LazyPanel.java	                        (rev 0)
+++ projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/v2/LazyPanel.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.v2;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface LazyPanel
+{
+  boolean isInitialized();
+
+  void initialize();
+}

Modified: projects/gwt-console/branches/hbraun/plugin-example/src/main/java/org/jboss/bpm/console/client/mapsplugin/MapsEditor.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-example/src/main/java/org/jboss/bpm/console/client/mapsplugin/MapsEditor.java	2009-04-19 18:34:59 UTC (rev 4580)
+++ projects/gwt-console/branches/hbraun/plugin-example/src/main/java/org/jboss/bpm/console/client/mapsplugin/MapsEditor.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -68,6 +68,12 @@
     addView(defaultView, false);
   }
 
+
+  public void initialize()
+  {
+    isInitialized = true;
+  }
+
   public String getEditorId()
   {
     return ID;

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/MainView.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/MainView.java	2009-04-19 18:34:59 UTC (rev 4580)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/MainView.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -67,6 +67,11 @@
   }
 
 
+  public Viewport getViewport()
+  {
+    return null;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
   public Controller getController()
   {
     throw new RuntimeException("NYI");

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/LoginView.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/LoginView.java	2009-04-19 18:34:59 UTC (rev 4580)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/LoginView.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -90,6 +90,11 @@
   public void display()
   {
     createLayoutWindowPanel();
+
+    // remove later on
+    usernameInput.setText("alex");
+    passwordInput.setText("password");
+
     window.center();
   }
 

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/MainLayout.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/MainLayout.java	2009-04-19 18:34:59 UTC (rev 4580)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/MainLayout.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -23,18 +23,16 @@
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.RootPanel;
 import com.mvc4g.client.Controller;
+import org.gwt.mosaic.ui.client.InfoPanel;
 import org.gwt.mosaic.ui.client.MessageBox;
 import org.gwt.mosaic.ui.client.Viewport;
-import org.gwt.mosaic.ui.client.InfoPanel;
 import org.gwt.mosaic.ui.client.layout.BorderLayout;
 import static org.gwt.mosaic.ui.client.layout.BorderLayout.Region;
 import org.gwt.mosaic.ui.client.layout.BorderLayoutData;
 import org.gwt.mosaic.ui.client.layout.LayoutPanel;
 import org.jboss.bpm.console.client.*;
-import org.jboss.bpm.console.client.v2.process.ProcessEditor;
 
 /**
  * The main composite that assembles the gwt console application.
@@ -45,19 +43,18 @@
 {
   
   public final static String NAME = "mainLayout";
-
-  private HTML status = new HTML();
+  
   private Header header;
   private Menu menu;
+  
   private Workspace workspace;
-
   private URLBuilder urlBuilder;
   private Authentication auth;
-
   private ConsoleConfig config;
 
   private Controller controller;
-  
+  private Viewport viewport;
+
   public MainLayout(Controller controller, Authentication auth, URLBuilder urlBuilder, ConsoleConfig config)
   {
     this.controller = controller;   
@@ -70,7 +67,7 @@
 
   public void display()
   {    
-    Viewport viewport = new Viewport();
+    viewport = new Viewport();
 
     LayoutPanel layout = createLayout();
     viewport.add(layout);
@@ -108,6 +105,11 @@
   // ---- ApplicationContext interface ----
 
 
+  public Viewport getViewport()
+  {
+    return viewport;
+  }
+
   public Controller getController()
   {
     return this.controller;
@@ -120,8 +122,6 @@
 
   public void displayMessage(final String message, final boolean isError)
   {
-    status.setText(message);
-
     if(isError)
       MessageBox.error("Error", message);
     else

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java	2009-04-19 18:34:59 UTC (rev 4580)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -35,13 +35,15 @@
 import org.gwt.mosaic.ui.client.layout.LayoutPanel;
 import org.gwt.mosaic.ui.client.list.DefaultListModel;
 import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.v2.LazyPanel;
 
 import java.util.List;
 
 /**
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
-public class DefinitionListView extends LayoutPanel implements ViewInterface
+public class DefinitionListView extends LayoutPanel
+    implements ViewInterface, LazyPanel
 {
   public final static String ID = DefinitionListView.class.getName();
 
@@ -51,95 +53,115 @@
 
   private ListBox<ProcessDefinitionRef> listBox;
 
+  private boolean isInitialized;
+
   public DefinitionListView()
   {
     super();
     setTitle("Process Definitions");
+  }
 
-    definitionList = new LayoutPanel( new BoxLayout(BoxLayout.Orientation.VERTICAL));
-    definitionList.setPadding(0);
-    definitionList.setWidgetSpacing(0);
+  public boolean isInitialized()
+  {
+    return isInitialized;
+  }
 
-    listBox =
-        new ListBox<ProcessDefinitionRef>(
-            new String[] {
-                "Process ID", "Name", "Key", "Version"}
-        );
+  public void initialize()
+  {
+    if(!isInitialized)
+    {
 
+      System.out.println("init DefinitionListView");
+      
+      definitionList = new LayoutPanel( new BoxLayout(BoxLayout.Orientation.VERTICAL));
+      definitionList.setPadding(0);
+      definitionList.setWidgetSpacing(0);
 
-    listBox.setCellRenderer(new ListBox.CellRenderer<ProcessDefinitionRef>() {
-      public void renderCell(ListBox<ProcessDefinitionRef> listBox, int row, int column,
-                             ProcessDefinitionRef item) {
-        switch (column) {
-          case 0:
-            listBox.setText(row, column, item.getId());
-            break;
-          case 1:
-            listBox.setText(row, column, item.getName());
-            break;
-          case 2:
-            listBox.setText(row, column, item.getKey());
-            break;
-          case 3:
-            listBox.setText(row, column, String.valueOf(item.getVersion()));
-            break;
-          default:
-            throw new RuntimeException("Unexpected column size");
-        }
-      }
-    });
+      listBox =
+          new ListBox<ProcessDefinitionRef>(
+              new String[] {
+                  "Process ID", "Name", "Key", "Version"}
+          );
 
-    final DefaultListModel<ProcessDefinitionRef> model =
-        (DefaultListModel<ProcessDefinitionRef>) listBox.getModel();
 
-    // toolbar
-
-    final LayoutPanel toolBox = new LayoutPanel();
-    toolBox.setPadding(0);
-    toolBox.setWidgetSpacing(5);
-    //toolBox.setLayout(new BoxLayout(BoxLayout.Orientation.VERTICAL));
-
-    final ToolBar toolBar = new ToolBar();
-    toolBar.add(
-        new ToolButton("Refresh", new ClickListener() {
-          public void onClick(Widget sender) {
-            // force loading
-            controller.handleEvent(
-                new Event(LoadDefinitionsAction.ID, null)
-            );
+      listBox.setCellRenderer(new ListBox.CellRenderer<ProcessDefinitionRef>() {
+        public void renderCell(ListBox<ProcessDefinitionRef> listBox, int row, int column,
+                               ProcessDefinitionRef item) {
+          switch (column) {
+            case 0:
+              listBox.setText(row, column, item.getId());
+              break;
+            case 1:
+              listBox.setText(row, column, item.getName());
+              break;
+            case 2:
+              listBox.setText(row, column, item.getKey());
+              break;
+            case 3:
+              listBox.setText(row, column, String.valueOf(item.getVersion()));
+              break;
+            default:
+              throw new RuntimeException("Unexpected column size");
           }
         }
-        )
-    );
+      });
 
-    toolBar.addSeparator();
+      final DefaultListModel<ProcessDefinitionRef> model =
+          (DefaultListModel<ProcessDefinitionRef>) listBox.getModel();
 
-    toolBar.add(
-        new ToolButton("View Instances", new ClickListener() {
-          public void onClick(Widget sender) {
-            int index = listBox.getSelectedIndex();
-            if(index==-1)
-              MessageBox.alert("Missing selection", "Please select a process");
-            else
+      // toolbar
+
+      final LayoutPanel toolBox = new LayoutPanel();
+      toolBox.setPadding(0);
+      toolBox.setWidgetSpacing(5);
+      //toolBox.setLayout(new BoxLayout(BoxLayout.Orientation.VERTICAL));
+
+      final ToolBar toolBar = new ToolBar();
+      toolBar.add(
+          new ToolButton("Refresh", new ClickListener() {
+            public void onClick(Widget sender) {
+              // force loading
               controller.handleEvent(
-                  new Event(
-                      LoadInstancesAction.ID,
-                      listBox.getItem( listBox.getSelectedIndex())
-                  )
+                  new Event(LoadDefinitionsAction.ID, null)
               );
+            }
           }
-        }
-        )
-    );
+          )
+      );
 
-    toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+      toolBar.addSeparator();
 
-    this.definitionList.add(toolBox, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
-    this.definitionList.add(listBox, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
+      toolBar.add(
+          new ToolButton("View Instances", new ClickListener() {
+            public void onClick(Widget sender) {
+              int index = listBox.getSelectedIndex();
+              if(index==-1)
+                MessageBox.alert("Missing selection", "Please select a process");
+              else
+                controller.handleEvent(
+                    new Event(
+                        LoadInstancesAction.ID,
+                        listBox.getItem( listBox.getSelectedIndex())
+                    )
+                );
+            }
+          }
+          )
+      );
 
-    this.add(definitionList);
+
+      toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+
+      this.definitionList.add(toolBox, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+      this.definitionList.add(listBox, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
+
+      this.add(definitionList);
+
+      isInitialized = true;
+    }
   }
 
+
   public void setController(Controller controller)
   {
     this.controller = controller;
@@ -147,17 +169,17 @@
 
   public void update(List<ProcessDefinitionRef> definitions)
   {
+    // lazy init
+    initialize();
+    
     final DefaultListModel<ProcessDefinitionRef> model =
         (DefaultListModel<ProcessDefinitionRef>) listBox.getModel();
 
     model.clear();
-    
+
     for(ProcessDefinitionRef def : definitions)
     {
       model.add(def);
     }
-
-    // layout again
-    this.invalidate();
   }
 }

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java	2009-04-19 18:34:59 UTC (rev 4580)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java	2009-04-20 12:49:13 UTC (rev 4581)
@@ -22,6 +22,9 @@
 package org.jboss.bpm.console.client.v2.process;
 
 import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.TabListener;
+import com.google.gwt.user.client.ui.SourcesTabEvents;
+import com.google.gwt.user.client.Window;
 import com.mvc4g.client.ActionInterface;
 import com.mvc4g.client.Event;
 import com.mvc4g.client.ViewInterface;
@@ -29,6 +32,7 @@
 import org.gwt.mosaic.ui.client.TabLayoutPanel;
 import static org.gwt.mosaic.ui.client.layout.BorderLayout.Region;
 import org.gwt.mosaic.ui.client.layout.BorderLayoutData;
+import org.gwt.mosaic.ui.client.layout.LayoutPanel;
 import org.jboss.bpm.console.client.ApplicationContext;
 import org.jboss.bpm.console.client.Editor;
 import org.jboss.bpm.console.client.MenuSection;
@@ -44,28 +48,38 @@
 
   public ProcessEditor(ApplicationContext appContext)
   {
-    super(appContext);
+    super(appContext);    
+  }
 
-    // create inner tab layout
-    this.tabPanel = new DecoratedTabLayoutPanel();
-    tabPanel.setPadding(5);
-    this.add(tabPanel, new BorderLayoutData(Region.CENTER, false));
+  public void initialize()
+  {
+    if(!isInitialized)
+    {
+      // create inner tab layout
+      tabPanel = new DecoratedTabLayoutPanel();
+      tabPanel.setPadding(5);     
+      this.add(tabPanel, new BorderLayoutData(Region.CENTER));
 
-    // create and register views
-    addView(DefinitionListView.ID, new DefinitionListView());
-    addView(InstanceListView.ID, new InstanceListView());
-    
-    // create and register actions
-    addAction(LoadDefinitionsAction.ID, new LoadDefinitionsAction(appContext));
-    addAction(LoadInstancesAction.ID, new LoadInstancesAction(appContext));
+      // create and register views
+      addView(DefinitionListView.ID, new DefinitionListView());
+      addView(InstanceListView.ID, new InstanceListView());
 
-    // force loading
-    super.controller.handleEvent(
-        new Event(LoadDefinitionsAction.ID, null)
-    );
+      // create and register actions
+      addAction(LoadDefinitionsAction.ID, new LoadDefinitionsAction(appContext));
+      addAction(LoadInstancesAction.ID, new LoadInstancesAction(appContext));
 
-    tabPanel.selectTab(0);
-            
+      // display tab, needs to visible for correct rendering
+      tabPanel.selectTab(0);
+
+      // force loading
+      super.controller.handleEvent(
+          new Event(LoadDefinitionsAction.ID, null)
+      );
+
+      refreshView();
+
+      isInitialized = true;
+    }
   }
 
   private void addView(String id, Widget view)
@@ -79,7 +93,7 @@
 
   private void addAction(String name, ActionInterface action)
   {
-    super.controller.addAction(name, action);  
+    super.controller.addAction(name, action);
   }
 
   public String getEditorId()




More information about the jbpm-commits mailing list