[jbpm-commits] JBoss JBPM SVN: r5120 - in projects/gwt-console/trunk/gui/war/src/main: java/org/jboss/bpm/console/client/process and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jun 25 08:55:05 EDT 2009


Author: heiko.braun at jboss.com
Date: 2009-06-25 08:55:05 -0400 (Thu, 25 Jun 2009)
New Revision: 5120

Modified:
   projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/deployment/DeploymentListView.java
   projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java
   projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/console.css
Log:
Add filter to deployment and process list views

Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/deployment/DeploymentListView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/deployment/DeploymentListView.java	2009-06-25 11:45:04 UTC (rev 5119)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/deployment/DeploymentListView.java	2009-06-25 12:55:05 UTC (rev 5120)
@@ -61,6 +61,13 @@
 
   private SimpleDateFormat dateFormat = new SimpleDateFormat();
 
+  private int FILTER_NONE       = 10;
+  private int FILTER_ACTIVE     = 20;
+  private int FILTER_SUSPENDED  = 30;
+  private int currentFilter = FILTER_NONE;
+
+  private List<DeploymentRef> deployments = null;
+
   public DeploymentListView()
   {
     super();
@@ -69,6 +76,7 @@
     setIcon(icons.deploymentIcon());
 
     listBox = createListBox();
+
   }
 
   private ListBox createListBox()
@@ -143,8 +151,8 @@
 
       final LayoutPanel toolBox = new LayoutPanel();
       toolBox.setPadding(0);
-      toolBox.setWidgetSpacing(5);
-      //toolBox.setLayout(new BoxLayout(BoxLayout.Orientation.VERTICAL));
+      toolBox.setWidgetSpacing(0);
+      toolBox.setLayout(new BoxLayout(BoxLayout.Orientation.HORIZONTAL));
 
       final ToolBar toolBar = new ToolBar();
       toolBar.add(
@@ -164,26 +172,26 @@
       toolBar.add(
           new ToolButton("Delete", new ClickListener() {
             public void onClick(Widget sender) {
-              
+
               DeploymentRef deploymentRef = getSelection();
               if(deploymentRef!=null)
               {
                 MessageBox.confirm("Delete deployment",
-                  "Do you want to delete this deployment? Any related data will be removed.",
-                  new MessageBox.ConfirmationCallback() {
-                    public void onResult(boolean doIt)
-                    {
-                      if(doIt)
+                    "Do you want to delete this deployment? Any related data will be removed.",
+                    new MessageBox.ConfirmationCallback() {
+                      public void onResult(boolean doIt)
                       {
-                        controller.handleEvent(
-                            new Event(
-                                DeleteDeploymentAction.ID,
-                                getSelection().getId()
-                            )
-                        );
+                        if(doIt)
+                        {
+                          controller.handleEvent(
+                              new Event(
+                                  DeleteDeploymentAction.ID,
+                                  getSelection().getId()
+                              )
+                          );
+                        }
                       }
-                    }
-                  });
+                    });
               }
               else
               {
@@ -196,6 +204,39 @@
 
       toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
 
+      // filter
+      LayoutPanel filterPanel = new LayoutPanel();
+      filterPanel.setStyleName("bpm-filter-panel");
+      final com.google.gwt.user.client.ui.ListBox dropBox = new com.google.gwt.user.client.ui.ListBox(false);
+      dropBox.setStyleName("bpm-operation-ui");
+      dropBox.addItem("All");
+      dropBox.addItem("Active");
+      dropBox.addItem("Suspended");
+
+      dropBox.addChangeListener(new ChangeListener() {
+        public void onChange(Widget sender) {
+          switch (dropBox.getSelectedIndex())
+          {
+            case 0:
+              currentFilter = FILTER_NONE;
+              break;
+            case 1:
+              currentFilter = FILTER_ACTIVE;
+              break;
+            case 2:
+              currentFilter = FILTER_SUSPENDED;
+              break;
+            default:
+              throw new IllegalArgumentException("No such index");
+          }
+
+          renderFiltered();
+        }
+      });
+      filterPanel.add(dropBox);
+
+      toolBox.add(filterPanel, new BoxLayoutData(BoxLayoutData.FillStyle.VERTICAL));
+
       this.deploymentList.add(toolBox, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
       this.deploymentList.add(listBox, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
 
@@ -226,20 +267,42 @@
 
   public void update(List<DeploymentRef> deployments)
   {
-    final DefaultListModel<DeploymentRef> model =
-        (DefaultListModel<DeploymentRef>) listBox.getModel();
+    this.deployments = deployments;
 
-    model.clear();
+    renderFiltered();
+  }
 
-    for(DeploymentRef dpl : deployments)
+  private void renderFiltered()
+  {
+    if(this.deployments!=null)
     {
-      model.add(dpl);
+      final DefaultListModel<DeploymentRef> model =
+          (DefaultListModel<DeploymentRef>) listBox.getModel();
+
+      model.clear();
+
+      for(DeploymentRef dpl : deployments)
+      {
+        if(FILTER_NONE==currentFilter)
+        {
+          model.add(dpl);
+        }
+        else
+        {
+          boolean showSuspended = (FILTER_SUSPENDED==currentFilter);
+          if(dpl.isSuspended()==showSuspended)
+            model.add(dpl);
+        }
+      }
+
+      if(listBox.getSelectedIndex()!=-1)
+        listBox.setItemSelected(listBox.getSelectedIndex(), false);
+
+      // clear details
+      controller.handleEvent(
+          new Event(UpdateDeploymentDetailAction.ID, null)
+      );
     }
-
-    // clear details
-    controller.handleEvent(
-        new Event(UpdateDeploymentDetailAction.ID, null)
-    );
   }
 
   public void select(String deploymentId)

Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java	2009-06-25 11:45:04 UTC (rev 5119)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java	2009-06-25 12:55:05 UTC (rev 5120)
@@ -28,7 +28,6 @@
 import com.mvc4g.client.Controller;
 import com.mvc4g.client.Event;
 import org.gwt.mosaic.ui.client.ListBox;
-import org.gwt.mosaic.ui.client.MessageBox;
 import org.gwt.mosaic.ui.client.ToolBar;
 import org.gwt.mosaic.ui.client.ToolButton;
 import org.gwt.mosaic.ui.client.layout.*;
@@ -37,6 +36,7 @@
 import org.jboss.bpm.console.client.common.AbstractView;
 import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
 import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.ServerPlugins;
 
 import java.util.List;
 
@@ -55,6 +55,13 @@
 
   private boolean isInitialized;
 
+  private int FILTER_NONE       = 10;
+  private int FILTER_ACTIVE     = 20;
+  private int FILTER_SUSPENDED  = 30;
+  private int currentFilter = FILTER_NONE;
+
+  private List<ProcessDefinitionRef> definitions = null;
+
   public DefinitionListView()
   {
     super();
@@ -63,7 +70,7 @@
     setIcon(icons.processIcon());
 
     listBox = createListBox();
-    
+
   }
 
   public boolean isInitialized()
@@ -83,9 +90,10 @@
 
       final LayoutPanel toolBox = new LayoutPanel();
       toolBox.setPadding(0);
-      toolBox.setWidgetSpacing(5);
-      //toolBox.setLayout(new BoxLayout(BoxLayout.Orientation.VERTICAL));
+      toolBox.setWidgetSpacing(0);
+      toolBox.setLayout(new BoxLayout(BoxLayout.Orientation.HORIZONTAL));
 
+      // toolbar
       final ToolBar toolBar = new ToolBar();
       toolBar.add(
           new ToolButton("Refresh", new ClickListener() {
@@ -98,9 +106,41 @@
           }
           )
       );
-
       toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
 
+      // filter
+      LayoutPanel filterPanel = new LayoutPanel();
+      filterPanel.setStyleName("bpm-filter-panel");
+      final com.google.gwt.user.client.ui.ListBox dropBox = new com.google.gwt.user.client.ui.ListBox(false);
+      dropBox.setStyleName("bpm-operation-ui");
+      dropBox.addItem("All");
+      dropBox.addItem("Active");
+      dropBox.addItem("Suspended");
+
+      dropBox.addChangeListener(new ChangeListener() {
+        public void onChange(Widget sender) {
+          switch (dropBox.getSelectedIndex())
+          {
+            case 0:
+              currentFilter = FILTER_NONE;
+              break;
+            case 1:
+              currentFilter = FILTER_ACTIVE;
+              break;
+            case 2:
+              currentFilter = FILTER_SUSPENDED;
+              break;
+            default:
+              throw new IllegalArgumentException("No such index");
+          }
+
+          renderFiltered();
+        }
+      });
+      filterPanel.add(dropBox);
+
+      toolBox.add(filterPanel, new BoxLayoutData(BoxLayoutData.FillStyle.VERTICAL));
+
       this.definitionList.add(toolBox, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
       this.definitionList.add(listBox, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
 
@@ -142,7 +182,7 @@
           case 2:
             listBox.setText(row, column, item.getName());
             break;
-           case 3:
+          case 3:
             listBox.setText(row, column, String.valueOf(item.isSuspended()));
             break;
           default:
@@ -176,6 +216,8 @@
       }
     });
 
+    ListModel<ProcessDefinitionRef> origModel = listBox.getModel();
+
     return listBox;
   }
 
@@ -186,21 +228,43 @@
   }
 
   public void update(List<ProcessDefinitionRef> definitions)
-  {   
-    final DefaultListModel<ProcessDefinitionRef> model =
-        (DefaultListModel<ProcessDefinitionRef>) listBox.getModel();
+  {
+    this.definitions = definitions;
 
-    model.clear();
+    renderFiltered();
+  }
 
-    for(ProcessDefinitionRef def : definitions)
+  private void renderFiltered()
+  {
+    if(this.definitions!=null)
     {
-      model.add(def);
+      final DefaultListModel<ProcessDefinitionRef> model =
+          (DefaultListModel<ProcessDefinitionRef>) listBox.getModel();
+
+      model.clear();
+
+      for(ProcessDefinitionRef def : definitions)
+      {
+        if(FILTER_NONE==currentFilter)
+        {
+          model.add(def);
+        }
+        else
+        {
+          boolean showSuspended = (FILTER_SUSPENDED==currentFilter);
+          if(def.isSuspended()==showSuspended)
+            model.add(def);
+        }
+      }
+
+      if(listBox.getSelectedIndex()!=-1)
+        listBox.setItemSelected(listBox.getSelectedIndex(), false);
+
+      // clear details
+      controller.handleEvent(
+          new Event(UpdateProcessDetailAction.ID, null)
+      );
     }
-
-    // clear details
-    controller.handleEvent(
-        new Event(UpdateProcessDetailAction.ID, null)
-    );
   }
 
   public ProcessDefinitionRef getSelection()
@@ -210,5 +274,5 @@
       selection = listBox.getItem( listBox.getSelectedIndex());
     return selection;
   }
-  
+
 }

Modified: projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/console.css
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/console.css	2009-06-25 11:45:04 UTC (rev 5119)
+++ projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/console.css	2009-06-25 12:55:05 UTC (rev 5120)
@@ -41,6 +41,13 @@
   padding-top:10px;  
 }
 
+.bpm-filter-panel {
+  padding-top:5px;
+  padding-right:2px;
+  background-color:#dfe8f6;
+  border-bottom: 1px solid #bbbbbb;
+}
+
 .bpm-editor-info {
   font-family: sans-serif;
   font-size:18px;  




More information about the jbpm-commits mailing list