diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/OpenBIS.gwt.xml b/openbis/source/java/ch/systemsx/cisd/openbis/OpenBIS.gwt.xml index e8a7ae29ed8166a59fcbea7a56ef5ffa6cf31f13..ac5e68cd99c0882a456e25e094cac73670fad52b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/OpenBIS.gwt.xml +++ b/openbis/source/java/ch/systemsx/cisd/openbis/OpenBIS.gwt.xml @@ -3,7 +3,6 @@ // Inherit the core Web Toolkit stuff. --> <inherits name='com.google.gwt.user.User'/> - <inherits name="com.google.gwt.user.theme.chrome.Chrome"/> <inherits name="com.google.gwt.i18n.I18N" /> <!-- diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java index bb9b3c21149cd80d1c19cadb38c8b41c60e4ded9..443894824b05b31f6c44b81dc92d4600aaede96d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java @@ -37,4 +37,9 @@ public interface IGenericClientService extends RemoteService * Tries to return the current session context. If failed <code>null</code> is returned. */ public SessionContext tryToGetCurrentSessionContext(); + + /** + * Tries to login with specified user ID and password. If failed <code>null</code> is returned. + */ + public SessionContext tryToLogin(String userID, String password); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java index d0e460f26373b8f9e8fd5c4086fb399587a5b917..710474a2570709202754881901c3c90e93f68055 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java @@ -33,4 +33,7 @@ public interface IGenericClientServiceAsync /** @see IGenericClientService#tryToGetCurrentSessionContext() */ public void tryToGetCurrentSessionContext(AsyncCallback<SessionContext> callback); + + /** @see IGenericClientService#tryToLogin(String, String) */ + public void tryToLogin(String userID, String password, AsyncCallback<SessionContext> callback); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AbstractAsyncCallback.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AbstractAsyncCallback.java index e7f96df42cdc6169c09d7de1e7fda81a3ca9f6b8..4f2d096559a4eb70175c60fe3f35fd95af2b0ab8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AbstractAsyncCallback.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AbstractAsyncCallback.java @@ -16,8 +16,13 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application; -import com.extjs.gxt.ui.client.widget.Info; +import com.extjs.gxt.ui.client.widget.MessageBox; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.rpc.InvocationException; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.InvalidSessionException; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.StringUtils; + /** @@ -39,7 +44,33 @@ public abstract class AbstractAsyncCallback<T> implements AsyncCallback<T> public void onFailure(Throwable caught) { - Info.display("Error", caught.toString()); + final String msg; + if (caught instanceof InvocationException) + { + if (StringUtils.isBlank(caught.getMessage())) + { + msg = viewContext.getMessage("exception_invocationMessage"); + } else + { + msg = caught.getMessage(); + } + } else + { + final String message = caught.getMessage(); + if (StringUtils.isBlank(message)) + { + msg = viewContext.getMessage("exception_withoutMessage", caught.getClass().getName()); + } else + { + msg = message; + } + } + IPageController pageController = viewContext.getPageController(); + MessageBox.alert("Error", msg, null); + if (caught instanceof InvalidSessionException) + { + pageController.reload(); + } } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java index 0021d2b9c6e4b5ae457a0edafb032f48277f04bd..cf599e7fa774a13a44e4a45d75b5463d423c102f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java @@ -25,9 +25,11 @@ import com.extjs.gxt.ui.client.widget.HorizontalPanel; import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.extjs.gxt.ui.client.widget.Text; import com.extjs.gxt.ui.client.widget.VerticalPanel; +import com.extjs.gxt.ui.client.widget.Viewport; import com.extjs.gxt.ui.client.widget.layout.BorderLayout; import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; import com.extjs.gxt.ui.client.widget.layout.CenterLayout; +import com.extjs.gxt.ui.client.widget.layout.FitLayout; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.ServiceDefTarget; @@ -92,7 +94,14 @@ public class Client implements EntryPoint endpoint.setServiceEntryPoint(GenericConstants.SERVER_NAME); IGenericImageBundle imageBundle = GWT.<IGenericImageBundle> create(IGenericImageBundle.class); IMessageProvider messageProvider = new DictonaryBasedMessageProvider("generic"); - return new GenericViewContext(service, messageProvider, imageBundle); + IPageController pageController = new IPageController() + { + public void reload() + { + onModuleLoad(); + } + }; + return new GenericViewContext(service, messageProvider, imageBundle, pageController); } private LayoutContainer createLoginPage() @@ -124,15 +133,18 @@ public class Client implements EntryPoint { LayoutContainer container = new LayoutContainer(); container.setLayout(new BorderLayout()); + container.add(widget, new BorderLayoutData(LayoutRegion.CENTER)); - LayoutContainer footerPanel = new LayoutContainer(); - footerPanel.setStyleName("footer"); + String version = viewContext.getModel().getApplicationInfo().getVersion(); Text footerText = new Text(viewContext.getMessage("footer", version)); footerText.setStyleName("footer-text"); - footerPanel.add(footerText); - container.add(footerPanel, new BorderLayoutData(LayoutRegion.SOUTH)); - return container; + container.add(footerText, new BorderLayoutData(LayoutRegion.SOUTH)); + + Viewport viewport = new Viewport(); + viewport.setLayout(new FitLayout()); + viewport.add(container); + return viewport; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewContext.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewContext.java index 2cd08c5dbc7258ad6433c996e5adf3d8b5bca24a..64673794933119a9b57d2d3130adda4461d2ef44 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewContext.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewContext.java @@ -30,13 +30,15 @@ public class GenericViewContext implements IMessageProvider private final IMessageProvider messageProvider; private final IGenericImageBundle imageBundle; private final GenericViewModel viewModel; + private final IPageController pageController; GenericViewContext(IGenericClientServiceAsync service, IMessageProvider messageProvider, - IGenericImageBundle imageBundle) + IGenericImageBundle imageBundle, IPageController pageController) { this.service = service; this.messageProvider = messageProvider; this.imageBundle = imageBundle; + this.pageController = pageController; viewModel = new GenericViewModel(); } @@ -59,5 +61,10 @@ public class GenericViewContext implements IMessageProvider { return imageBundle; } + + public final IPageController getPageController() + { + return pageController; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/IPageController.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/IPageController.java new file mode 100644 index 0000000000000000000000000000000000000000..5edde319272510b2128235dc4d9e842f935e4f03 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/IPageController.java @@ -0,0 +1,27 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.client.application; + +/** + * + * + * @author Franz-Josef Elmer + */ +public interface IPageController +{ + public void reload(); +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/LoginWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/LoginWidget.java index 8a085aa40b9ca9f026ea81ff5e903f15826f0007..63dc0368aa6b3fb6eb5e1368bb23a88e4b4d030c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/LoginWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/LoginWidget.java @@ -18,14 +18,15 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; import com.extjs.gxt.ui.client.event.ComponentEvent; import com.extjs.gxt.ui.client.event.SelectionListener; -import com.extjs.gxt.ui.client.widget.Info; import com.extjs.gxt.ui.client.widget.Text; import com.extjs.gxt.ui.client.widget.VerticalPanel; import com.extjs.gxt.ui.client.widget.button.Button; import com.extjs.gxt.ui.client.widget.form.FormPanel; import com.extjs.gxt.ui.client.widget.form.TextField; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; /** * @@ -37,7 +38,7 @@ public class LoginWidget extends VerticalPanel private final TextField<String> userField; private final TextField<String> passwordField; - public LoginWidget(GenericViewContext viewContext) + public LoginWidget(final GenericViewContext viewContext) { add(new Text(viewContext.getMessage("login_invitation"))); @@ -61,18 +62,28 @@ public class LoginWidget extends VerticalPanel Button button = new Button(viewContext.getMessage("login_buttonLabel")); button.addSelectionListener(new SelectionListener<ComponentEvent>() { - @Override public void componentSelected(ComponentEvent ce) { - - Info.display("Login", "user: .{0}. password: .{1}.", userField.getValue(), passwordField.getValue()); + login(viewContext); } - }); formPanel.addButton(button); add(formPanel); } + private void login(final GenericViewContext viewContext) + { + viewContext.getService().tryToLogin(userField.getValue(), passwordField.getValue(), + new AbstractAsyncCallback<SessionContext>(viewContext) + { + public void onSuccess(SessionContext sessionContext) + { + viewContext.getPageController().reload(); + } + }); + + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/InvalidSessionException.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/InvalidSessionException.java new file mode 100644 index 0000000000000000000000000000000000000000..9dd1343a6e13259e41f37491f587a8c430e43a80 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/InvalidSessionException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.client.application.util; + +/** + * This <code>UserFailureException</code> extension signals that a <code>Session</code> has + * expired. + * + * @author Christian Ribeaud + */ +public final class InvalidSessionException extends UserFailureException +{ + private static final long serialVersionUID = 1L; + + // An non-empty constructor is mandatory in GWT for serializable objects + public InvalidSessionException() + { + } + + public InvalidSessionException(final String message) + { + super(message); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/StringUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/StringUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..b7018123ea7423fd3e08db3406e122876e2104d8 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/StringUtils.java @@ -0,0 +1,39 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.client.application.util; + +/** + * Some utilities around <code>String</code>. + * + * @author Christian Ribeaud + */ +public final class StringUtils +{ + private StringUtils() + { + // Can not be instantiated + } + + /** + * Whether given <var>value</var> is blank or not. + */ + public final static boolean isBlank(final String value) + { + return value == null || value.trim().length() == 0; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/UserFailureException.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/UserFailureException.java new file mode 100644 index 0000000000000000000000000000000000000000..74b290afd538237dc59dc736e437f4f71a885841 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/UserFailureException.java @@ -0,0 +1,41 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.client.application.util; + +import com.google.gwt.user.client.rpc.IsSerializable; + +/** + * The <code>UserFailureException</code> is the super class of all exceptions that have their + * cause in an inappropriate usage of the system. This implies that the user himself (without help + * of an administrator) can fix the problem. + * + * @author Christian Ribeaud + */ +public class UserFailureException extends RuntimeException implements IsSerializable +{ + private static final long serialVersionUID = 1L; + + // An non-empty constructor is mandatory in GWT for serializable objects + public UserFailureException() + { + } + + public UserFailureException(final String message) + { + super(message); + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/public/generic-dictionary.js b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/public/generic-dictionary.js index 8431a66f8e44ac8ac2c4652c5da0b067812e8f89..fad11412b8d21b4d1ae514336eab2b30fc5d0761 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/public/generic-dictionary.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/public/generic-dictionary.js @@ -1,9 +1,23 @@ // Generic dictionary var generic = { welcome: "Welcome to " + common["applicationName"], + footer: "openBIS (Version {0})", + + // + // LoginWidget + // + login_invitation: "Please login to start your session:", login_userLabel: "User", login_passwordLabel: "Password", login_buttonLabel: "login", - footer: "openBIS (Version {0})" + + // + // AbstractAsyncCallback + // + exception_invocationMessage: "Failed to contact service.", + exception_withoutMessage: "Unknown failure has occurred (ask administrator):<br>{0}", + + + lastline: "" // we need a line without a comma }; \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java index 7f6f8f2c8062daff4b8d53cc10e309b1e81ea626..59f4530d253d00659815a7d824d8d03843c93c80 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java @@ -45,4 +45,10 @@ public class GenericClientService implements IGenericClientService return null; } + public SessionContext tryToLogin(String userID, String password) + { + // TODO Auto-generated method stub + return null; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java index 70379a3886f95a4dacbddd5773237fdf56493d44..2d2cf6df20b837f900f5b8f101b2853bc90cc519 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java @@ -104,4 +104,9 @@ public class GenericClientServiceServlet extends GWTSpringController implements return service.tryToGetCurrentSessionContext(); } + public SessionContext tryToLogin(String userID, String password) + { + return service.tryToLogin(userID, password); + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/css/openbis.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/css/openbis.css index ca3eaf5f51598dc7c49f7e7de6ab4154d76dd10d..51ab3583794d2c48e2cdc560f511a9c692aee09a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/css/openbis.css +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/css/openbis.css @@ -27,6 +27,6 @@ body,div,td { width: 100%; text-align: center; font-size: 80%; - color: grey; + color: gray; }