[jbpm-commits] JBoss JBPM SVN: r4592 - in projects/gwt-console/branches/hbraun: plugin-api/src/main/java/org/jboss/bpm/console/client/util and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Apr 21 10:08:04 EDT 2009
Author: heiko.braun at jboss.com
Date: 2009-04-21 10:08:03 -0400 (Tue, 21 Apr 2009)
New Revision: 4592
Added:
projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/AbstractDataRequestAction.java
projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/util/
projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/util/WindowUtil.java
projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/images/icons/error.png
Removed:
projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/util/JSONRequest.java
projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/util/JSONRequestHandler.java
projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java
projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/js/ext/
Modified:
projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/MainLayout.java
projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java
Log:
Drop JSON request handler. Improve error handling and verbosity upon HTTP requests
Modified: projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2009-04-21 11:54:32 UTC (rev 4591)
+++ projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2009-04-21 14:08:03 UTC (rev 4592)
@@ -21,7 +21,6 @@
*/
package org.jboss.bpm.console.client.model;
-import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.json.client.*;
import org.jboss.bpm.console.client.model.jbpm3.TokenReference;
import org.jboss.bpm.console.client.util.ConsoleLog;
@@ -38,11 +37,11 @@
*/
public class DTOParser
{
- public static List<ProcessDefinitionRef> parseProcessDefinitions(JavaScriptObject jso)
+ public static List<ProcessDefinitionRef> parseProcessDefinitions(JSONValue jso)
{
List<ProcessDefinitionRef> results = new ArrayList<ProcessDefinitionRef>();
- JSONArray arr = JSONWalk.on( new JSONObject(jso)).next("definitions").asArray();
+ JSONArray arr = JSONWalk.on(jso).next("definitions").asArray();
for(int i=0; i<arr.size(); i++)
{
results.add(parseProcessDefinition(arr.get(i)));
@@ -178,11 +177,11 @@
return p;
}
- public static List<ProcessInstanceRef> parseProcessInstances(JavaScriptObject jso)
+ public static List<ProcessInstanceRef> parseProcessInstances(JSONValue jso)
{
List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>();
- JSONArray arr = JSONWalk.on( new JSONObject(jso)).next("instances").asArray();
+ JSONArray arr = JSONWalk.on(jso).next("instances").asArray();
for(int i=0; i<arr.size(); i++)
{
results.add(parseProcessInstance(arr.get(i)));
Deleted: projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/util/JSONRequest.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/util/JSONRequest.java 2009-04-21 11:54:32 UTC (rev 4591)
+++ projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/util/JSONRequest.java 2009-04-21 14:08:03 UTC (rev 4592)
@@ -1,57 +0,0 @@
-/*
- * 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.util;
-
-/**
- * Request helper, to bypass SOP restrictions.<br>
- * Can only be used to retrieve Json data, wrapped in a script tag.
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class JSONRequest
-{
- public static void get(String url, JSONRequestHandler handler)
- {
- String callbackName = "JSONCallback" + handler.hashCode();
- get(url + "?callback=" + callbackName, callbackName, handler);
- }
-
- public static void get(String url, String callbackName, JSONRequestHandler handler)
- {
- createCallbackFunction(handler, callbackName);
- addScript(url);
- }
-
- public static native void addScript(String url) /*-{
- var scr = document.createElement("script");
- scr.setAttribute("language", "JavaScript");
- scr.setAttribute("src", url);
- document.getElementsByTagName("body")[0].appendChild(scr);
- }-*/;
-
- private native static void createCallbackFunction(JSONRequestHandler obj, String callbackName)/*-{
- tmpcallback = function(j) {
- obj. at org.jboss.bpm.console.client.util.JSONRequestHandler::onRequestComplete(Lcom/google/gwt/core/client/JavaScriptObject;)(j);
- };
- eval( "window." + callbackName + "=tmpcallback" );
- }-*/;
-}
Deleted: projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/util/JSONRequestHandler.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/util/JSONRequestHandler.java 2009-04-21 11:54:32 UTC (rev 4591)
+++ projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/util/JSONRequestHandler.java 2009-04-21 14:08:03 UTC (rev 4592)
@@ -1,32 +0,0 @@
-/*
- * 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.util;
-
-import com.google.gwt.core.client.JavaScriptObject;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public interface JSONRequestHandler
-{
- void onRequestComplete(JavaScriptObject json);
-}
Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/MainLayout.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/MainLayout.java 2009-04-21 11:54:32 UTC (rev 4591)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/MainLayout.java 2009-04-21 14:08:03 UTC (rev 4592)
@@ -24,14 +24,15 @@
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Image;
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.*;
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.util.WindowUtil;
/**
* The main composite that assembles the gwt console application.
@@ -128,7 +129,18 @@
public void displayMessage(final String message, final boolean isError)
{
if(isError)
- MessageBox.error("Error", message);
+ {
+ WindowPanel err = new WindowPanel("Error");
+ err.getHeader().add( new Image("images/icons/error.png") );
+ err.setAnimationEnabled(true);
+ err.setSize("320px", "240px");
+ err.setWidget( new HTML(message) );
+
+ WindowUtil.addMaximizeButton(err, Caption.CaptionRegion.RIGHT);
+ WindowUtil.addMinimizeButton(err, Caption.CaptionRegion.RIGHT);
+
+ err.center();
+ }
else
{
InfoPanel.show("", message, "");
Copied: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/AbstractDataRequestAction.java (from rev 4588, projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java)
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/AbstractDataRequestAction.java (rev 0)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/AbstractDataRequestAction.java 2009-04-21 14:08:03 UTC (rev 4592)
@@ -0,0 +1,132 @@
+/*
+ * 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.process;
+
+import com.google.gwt.http.client.*;
+import com.google.gwt.user.client.Timer;
+import com.mvc4g.client.ActionInterface;
+import com.mvc4g.client.Controller;
+import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.LoadingStatusAction;
+
+import java.io.IOException;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+abstract class AbstractDataRequestAction implements ActionInterface
+{
+ protected ApplicationContext appContext;
+
+ protected AbstractDataRequestAction(ApplicationContext appContetext)
+ {
+ this.appContext = appContetext;
+ }
+
+ abstract String getId();
+ abstract String getUrl(Object event);
+ abstract RequestBuilder.Method getRequestMethod();
+ abstract void handleSuccessfulResponse(final Controller controller, final Object event, Response response);
+
+ public void execute(final Controller controller, final Object object)
+ {
+ final String url = getUrl(object);
+ RequestBuilder builder = new RequestBuilder(getRequestMethod(), URL.encode(url));
+
+ try
+ {
+ controller.handleEvent( LoadingStatusAction.ON );
+
+ final Request request = builder.sendRequest(null,
+ new RequestCallback()
+ {
+ public void onError(Request request, Throwable exception) {
+ // Couldn't connect to server (could be timeout, SOP violation, etc.)
+ handleError(url, exception);
+ controller.handleEvent( LoadingStatusAction.OFF );
+ }
+
+ public void onResponseReceived(Request request, Response response) {
+ try
+ {
+ if (200 == response.getStatusCode())
+ {
+ handleSuccessfulResponse(controller, object, response);
+ }
+ else
+ {
+ final String msg = response.getText().equals("") ? "Unknown error" : response.getText();
+ handleError(
+ url,
+ new RequestException("HTTP "+ response.getStatusCode()+ ": " + msg)
+ );
+ }
+ }
+ finally
+ {
+ controller.handleEvent( LoadingStatusAction.OFF );
+ }
+ }
+ }
+ );
+
+ // Timer to handle pending request
+ Timer t = new Timer() {
+
+ public void run()
+ {
+ if(request.isPending())
+ {
+ request.cancel();
+ handleError(
+ url,
+ new IOException("Request timeout")
+ );
+ }
+
+ }
+ };
+ t.schedule(5000);
+
+ }
+ catch (RequestException e)
+ {
+ // Couldn't connect to server
+ handleError(url, e);
+ controller.handleEvent( LoadingStatusAction.OFF );
+ }
+ }
+
+ protected void handleError(String url, Throwable t)
+ {
+ final String out =
+ "<ul>"+
+ "<li>URL: '" + url + "'\n"+
+ "<li>Action: '" + getId() + "'\n" +
+ "<li>Exception: '" + t.getClass() +
+ "</ul>'\n\n"+
+ t.getMessage();
+
+ appContext.displayMessage(out, true);
+
+ }
+}
Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java 2009-04-21 11:54:32 UTC (rev 4591)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java 2009-04-21 14:08:03 UTC (rev 4592)
@@ -21,14 +21,14 @@
*/
package org.jboss.bpm.console.client.process;
-import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.json.client.JSONParser;
+import com.google.gwt.json.client.JSONValue;
import com.mvc4g.client.Controller;
import org.jboss.bpm.console.client.ApplicationContext;
-import org.jboss.bpm.console.client.LoadingStatusAction;
import org.jboss.bpm.console.client.model.DTOParser;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
-import org.jboss.bpm.console.client.util.JSONRequest;
-import org.jboss.bpm.console.client.util.JSONRequestHandler;
import java.util.List;
@@ -37,7 +37,7 @@
*
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-class LoadDefinitionsAction extends AbstractContextAwareAction
+class LoadDefinitionsAction extends AbstractDataRequestAction
{
public final static String ID = LoadDefinitionsAction.class.getName();
@@ -46,48 +46,41 @@
super(appContext);
}
- /**
- *
- * @param controller
- * @param object - ignored, can be null
- */
- public void execute(final Controller controller, Object object)
+
+ String getId()
{
- String url = appContext.getUrlBuilder().getProcessDefinitionsURL();
+ return ID;
+ }
- controller.handleEvent( LoadingStatusAction.ON );
+ String getUrl(Object event)
+ {
+ return appContext.getUrlBuilder().getProcessDefinitionsURL();
+ }
- JSONRequest.get(
- url, new JSONRequestHandler()
+ RequestBuilder.Method getRequestMethod()
+ {
+ return RequestBuilder.GET;
+ }
+
+ void handleSuccessfulResponse(final Controller controller, final Object event, Response response)
+ {
+ if (200 == response.getStatusCode())
{
- public void onRequestComplete(JavaScriptObject json)
- {
- try
- {
- if (json == null) {
- appContext.displayMessage("Couldn't retrieve process definition data", true);
- return;
- }
+ JSONValue json = JSONParser.parse(response.getText());
+ List<ProcessDefinitionRef> definitions = DTOParser.parseProcessDefinitions(json);
+ DefinitionListView view = (DefinitionListView) controller.getView(DefinitionListView.ID);
+ view.update(definitions);
- List<ProcessDefinitionRef> definitions = DTOParser.parseProcessDefinitions(json);
- DefinitionListView view = (DefinitionListView) controller.getView(DefinitionListView.ID);
- view.update(definitions);
-
- appContext.displayMessage("Loaded " + definitions.size() + " process definitions", false);
-
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- appContext.displayMessage(e.getMessage(), true);
- }
- finally
- {
- controller.handleEvent( LoadingStatusAction.OFF );
- }
- }
+ appContext.displayMessage("Loaded " + definitions.size() + " process definitions", false);
}
- );
-
+ else
+ {
+ // Handle the error. Can get the status text from response.getStatusText()
+ appContext.displayMessage("Failed to load instances. " +
+ "HTTP " + response.getStatusCode()+
+ ": " +response.getText(),
+ true
+ );
+ }
}
}
Deleted: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java 2009-04-21 11:54:32 UTC (rev 4591)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java 2009-04-21 14:08:03 UTC (rev 4592)
@@ -1,95 +0,0 @@
-/*
- * 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.process;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.mvc4g.client.Controller;
-import org.jboss.bpm.console.client.ApplicationContext;
-import org.jboss.bpm.console.client.LoadingStatusAction;
-import org.jboss.bpm.console.client.model.DTOParser;
-import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
-import org.jboss.bpm.console.client.model.ProcessInstanceRef;
-import org.jboss.bpm.console.client.util.JSONRequest;
-import org.jboss.bpm.console.client.util.JSONRequestHandler;
-
-import java.util.List;
-
-/**
- * Force loading of a process instance list.
- * Triggered through {@link org.jboss.bpm.console.client.model.ProcessDefinitionRef}.
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-class LoadInstancesAction extends AbstractContextAwareAction
-{
- public final static String ID = LoadInstancesAction.class.getName();
-
- public LoadInstancesAction(ApplicationContext appContext)
- {
- super(appContext);
- }
-
- /**
- *
- * @param controller
- * @param object - a {@link org.jboss.bpm.console.client.model.ProcessDefinitionRef}
- */
- public void execute(final Controller controller, Object object)
- {
- final ProcessDefinitionRef def = (ProcessDefinitionRef)object;
-
- String url = appContext.getUrlBuilder().getProcessInstancesURL(def.getId());
-
- controller.handleEvent( LoadingStatusAction.ON );
-
- JSONRequest.get(
- url, new JSONRequestHandler()
- {
- public void onRequestComplete(JavaScriptObject json)
- {
- try
- {
- if (json == null) {
- appContext.displayMessage("Couldn't retrieve process instance data", true);
- return;
- }
-
- List<ProcessInstanceRef> instances = DTOParser.parseProcessInstances(json);
- InstanceListView view = (InstanceListView) controller.getView(InstanceListView.ID);
- view.update(def, instances);
-
- appContext.displayMessage("Loaded " + instances.size() + " process instances", false);
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- appContext.displayMessage(e.getMessage(), true);
- }
- finally
- {
- controller.handleEvent( LoadingStatusAction.OFF );
- }
- }
- }
- );
- }
-}
Added: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/util/WindowUtil.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/util/WindowUtil.java (rev 0)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/util/WindowUtil.java 2009-04-21 14:08:03 UTC (rev 4592)
@@ -0,0 +1,82 @@
+/*
+ * 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.util;
+
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Widget;
+import org.gwt.mosaic.ui.client.Caption;
+import org.gwt.mosaic.ui.client.ImageButton;
+import org.gwt.mosaic.ui.client.WindowPanel;
+
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class WindowUtil
+{
+ /**
+ *
+ * @param windowPanel
+ */
+ public static void addMaximizeButton(final WindowPanel windowPanel,
+ Caption.CaptionRegion captionRegion) {
+ final ImageButton maximizeBtn = new ImageButton(
+ Caption.IMAGES.windowMaximize());
+ maximizeBtn.addClickListener(new ClickListener() {
+ public void onClick(Widget sender) {
+ if (windowPanel.getWindowState() == WindowPanel.WindowState.MAXIMIZED) {
+ windowPanel.setWindowState(WindowPanel.WindowState.NORMAL);
+ } else {
+ windowPanel.setWindowState(WindowPanel.WindowState.MAXIMIZED);
+ }
+ }
+ });
+ windowPanel.addWindowStateListener(new WindowPanel.WindowStateListener() {
+ public void onWindowStateChange(WindowPanel sender) {
+ if (sender.getWindowState() == WindowPanel.WindowState.MAXIMIZED) {
+ maximizeBtn.setImage(Caption.IMAGES.windowRestore().createImage());
+ } else {
+ maximizeBtn.setImage(Caption.IMAGES.windowMaximize().createImage());
+ }
+
+ }
+ });
+ windowPanel.getHeader().add(maximizeBtn, captionRegion);
+ }
+
+ /**
+ *
+ * @param windowPanel
+ */
+ public static void addMinimizeButton(final WindowPanel windowPanel,
+ Caption.CaptionRegion captionRegion) {
+ final ImageButton minimizeBtn = new ImageButton(
+ Caption.IMAGES.windowMinimize());
+ minimizeBtn.addClickListener(new ClickListener() {
+ public void onClick(Widget sender) {
+ windowPanel.setWindowState(WindowPanel.WindowState.NORMAL);
+ }
+ });
+ windowPanel.getHeader().add(minimizeBtn, captionRegion);
+ }
+
+}
Added: projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/images/icons/error.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/images/icons/error.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
More information about the jbpm-commits
mailing list