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 4cf767cc5656558754b9618e69157bb64d7537bb..552ff11436657342bd0d65f04104400f9090a7e2 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 @@ -42,11 +42,9 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.Br import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.GlobalSearchLocatorResolver; import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.HomeLocatorResolver; import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.MaterialLocatorResolver; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.OpenViewAction; import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.PermlinkLocatorResolver; import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.ProjectLocatorResolver; import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.SearchLocatorResolver; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.ViewLocator; import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.ViewLocatorResolverRegistry; import ch.systemsx.cisd.openbis.generic.client.web.client.application.plugin.DefaultClientPluginFactoryProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.application.plugin.IClientPluginFactoryProvider; @@ -180,7 +178,6 @@ public class Client implements EntryPoint, ValueChangeHandler<String> viewContext = createViewContext(openUrlController); initializeControllers(openUrlController); } - final ViewLocator locator = createViewLocator(History.getToken()); History.addValueChangeHandler(this); // both modes final IClientServiceAsync service = getServiceForRetrievingApplicationInfo(viewContext); @@ -194,18 +191,20 @@ public class Client implements EntryPoint, ValueChangeHandler<String> @Override public final void process(final ApplicationInfo info) { - setViewMode(info); - viewContext.getModel().setApplicationInfo(info); + ViewMode viewMode = findViewMode(info); + ClientStaticState.setViewMode(viewMode); + GenericViewModel model = viewContext.getModel(); + model.setApplicationInfo(info); + model.setViewMode(viewMode); // the callback sets the SessionContext and redirects to the login page or the // initial page and may additionaly open an initial tab SessionContextCallback sessionContextCallback = new SessionContextCallback((CommonViewContext) viewContext, - new OpenViewAction(viewContext.getLocatorResolverRegistry(), - locator)); + UrlParamsHelper.createNavigateToCurrentUrlAction(viewContext)); service.tryToGetCurrentSessionContext(sessionContextCallback); } - private void setViewMode(ApplicationInfo info) + private ViewMode findViewMode(ApplicationInfo info) { // if view mode is specified in the URL it should override the default one final ViewMode userViewModeOrNull = tryGetUrlViewMode(); @@ -213,8 +212,7 @@ public class Client implements EntryPoint, ValueChangeHandler<String> userViewModeOrNull != null ? userViewModeOrNull : info .getWebClientConfiguration().getDefaultViewMode(); viewContext.log("viewMode = " + viewMode); - final boolean simpleMode = viewMode == ViewMode.SIMPLE; - ClientStaticState.setSimpleMode(simpleMode); + return viewMode; } private ViewMode tryGetUrlViewMode() @@ -235,11 +233,6 @@ public class Client implements EntryPoint, ValueChangeHandler<String> }); } - public static ViewLocator createViewLocator(String historyToken) - { - return new ViewLocator(historyToken); - } - protected IClientServiceAsync getServiceForRetrievingApplicationInfo( IViewContext<ICommonClientServiceAsync> context) { @@ -379,10 +372,7 @@ public class Client implements EntryPoint, ValueChangeHandler<String> public void onValueChange(ValueChangeEvent<String> event) { - ViewLocatorResolverRegistry resolver = viewContext.getLocatorResolverRegistry(); - ViewLocator viewLocator = createViewLocator(History.getToken()); - OpenViewAction openViewAction = new OpenViewAction(resolver, viewLocator); - openViewAction.execute(); + UrlParamsHelper.createNavigateToCurrentUrlAction(viewContext).execute(); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/CommonViewContext.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/CommonViewContext.java index 01cf89436052e487267ecb7275e50a3cb856fb7c..fccaa4455332f4f220c78f83e9e5b9b2a6c066fe 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/CommonViewContext.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/CommonViewContext.java @@ -28,6 +28,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDele import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.log.IProfilingTable; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.log.ProfilingTable; +import ch.systemsx.cisd.openbis.generic.shared.basic.ViewMode; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.WebClientConfiguration; @@ -46,7 +47,7 @@ public final class CommonViewContext implements IViewContext<ICommonClientServic */ public final static class ClientStaticState { - private static boolean simpleViewMode; + private static ViewMode viewMode; private static String pageTitleSuffix; @@ -61,12 +62,12 @@ public final class CommonViewContext implements IViewContext<ICommonClientServic @Deprecated public static boolean isSimpleMode() { - return simpleViewMode; + return viewMode != ViewMode.NORMAL; } - public static void setSimpleMode(boolean simpleMode) + public static void setViewMode(ViewMode viewModeParam) { - simpleViewMode = simpleMode; + viewMode = viewModeParam; } public static String getPageTitleSuffix() @@ -134,7 +135,7 @@ public final class CommonViewContext implements IViewContext<ICommonClientServic { return AbstractPluginViewContext.getPropertyOrNull(this, key); } - + public final GenericViewModel getModel() { return viewModel; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewModel.java index 863fc6ed04a838d608cd377d31d2fc17a01484af..78b2c11134baa6aa020b4c086ec6acd488de2f22 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewModel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewModel.java @@ -18,11 +18,12 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; +import ch.systemsx.cisd.openbis.generic.shared.basic.ViewMode; /** * The view model. * - * @author Franz-Josef Elmer + * @author Franz-Josef Elmer */ public class GenericViewModel { @@ -30,6 +31,8 @@ public class GenericViewModel private SessionContext sessionContext; + private ViewMode viewMode; + public final ApplicationInfo getApplicationInfo() { return applicationInfo; @@ -50,4 +53,13 @@ public class GenericViewModel this.sessionContext = sessionContext; } + public ViewMode getViewMode() + { + return viewMode; + } + + public void setViewMode(ViewMode viewMode) + { + this.viewMode = viewMode; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelper.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelper.java index 05691e74716e4dbf3970ba76987def42cb078ca4..353aef46a70789b9fb5d6515a0c052dd5b36da38 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelper.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelper.java @@ -16,6 +16,11 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application; +import com.google.gwt.user.client.History; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.OpenViewAction; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.ViewLocator; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.ViewLocatorResolverRegistry; import ch.systemsx.cisd.openbis.generic.shared.basic.URLMethodWithParameters; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; @@ -34,14 +39,22 @@ public final class UrlParamsHelper URLMethodWithParameters methodWithParameters = new URLMethodWithParameters(GenericConstants.TEMPLATE_SERVLET_NAME); methodWithParameters.addParameter(GenericConstants.ENTITY_KIND_KEY_PARAMETER, kind.name()); - methodWithParameters.addParameter(GenericConstants.ENTITY_TYPE_KEY_PARAMETER, type - .getCode()); + methodWithParameters.addParameter(GenericConstants.ENTITY_TYPE_KEY_PARAMETER, + type.getCode()); methodWithParameters.addParameter(GenericConstants.AUTO_GENERATE, withCodes); methodWithParameters.addParameter(GenericConstants.WITH_EXPERIMENTS, withExperiments); - methodWithParameters.addParameter(GenericConstants.BATCH_OPERATION_KIND, operationKind - .name()); + methodWithParameters.addParameter(GenericConstants.BATCH_OPERATION_KIND, + operationKind.name()); methodWithParameters.addParameter("timestamp", Long.toString(System.currentTimeMillis())); return methodWithParameters.toString(); } + /** Creates an action which opens a page pointed by the current URL. */ + public static OpenViewAction createNavigateToCurrentUrlAction(IViewContext<?> viewContext) + { + ViewLocatorResolverRegistry resolver = viewContext.getLocatorResolverRegistry(); + ViewLocator viewLocator = new ViewLocator(History.getToken()); + OpenViewAction openViewAction = new OpenViewAction(resolver, viewLocator); + return openViewAction; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/AppView.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/AppView.java index c5616d5a550392f2e984f6feeacb10a72fb7547a..efd59d415f53c7a5f3439b15f80e9e4dca3bfbd6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/AppView.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/AppView.java @@ -32,6 +32,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewConte import ch.systemsx.cisd.openbis.generic.client.web.client.application.menu.TopMenu; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.Footer; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.SimpleModeHeader; +import ch.systemsx.cisd.openbis.generic.shared.basic.ViewMode; /** * Main application view. @@ -46,8 +47,6 @@ final class AppView extends View private IMainPanel mainPanel; - private LayoutContainer north; - private ComponentProvider componentProvider; AppView(final Controller controller, final CommonViewContext viewContext) @@ -79,15 +78,31 @@ final class AppView extends View private final void createNorth() { - if (viewContext.isSimpleMode()) + LayoutContainer north; + ViewMode viewMode = getViewMode(); + if (viewMode == ViewMode.SIMPLE) { north = new SimpleModeHeader(viewContext, componentProvider); - } else + } else if (viewMode == ViewMode.NORMAL) { north = new TopMenu(viewContext, componentProvider); + } else if (viewMode == ViewMode.SIMPLE_EMBEDDED) + { + north = null; + } else + { + throw new IllegalStateException("Unknown view mode " + viewMode); + } + if (north != null) + { + final BorderLayoutData data = new BorderLayoutData(LayoutRegion.NORTH, 30); + viewport.add(north, data); } - final BorderLayoutData data = new BorderLayoutData(LayoutRegion.NORTH, 30); - viewport.add(north, data); + } + + private ViewMode getViewMode() + { + return viewContext.getModel().getViewMode(); } private final void createCenter() @@ -100,9 +115,12 @@ final class AppView extends View private final void createSouth() { - final Footer footer = new Footer(viewContext); - final BorderLayoutData data = new BorderLayoutData(LayoutRegion.SOUTH, 20); - viewport.add(footer, data); + if (getViewMode() != ViewMode.SIMPLE_EMBEDDED) + { + final Footer footer = new Footer(viewContext); + final BorderLayoutData data = new BorderLayoutData(LayoutRegion.SOUTH, 20); + viewport.add(footer, data); + } } // @@ -124,7 +142,7 @@ final class AppView extends View } else if (event.getType() == AppEvents.NAVI_EVENT) { activate(getData(event)); - } + } } private static IMainPanel createMainPanel(IViewContext<ICommonClientServiceAsync> viewContext) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/MainPagePanel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/MainPagePanel.java index 7c0afa8bbc0094ef57aedd3da82164ec2e29772f..dd50c7b9548661d6698d76ad9fe8b14a5341fd15 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/MainPagePanel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/MainPagePanel.java @@ -24,6 +24,7 @@ import com.google.gwt.user.client.ui.Widget; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericConstants; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.UrlParamsHelper; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils; /** @@ -47,7 +48,10 @@ public class MainPagePanel extends ContentPanel implements IMainPanel setBodyBorder(false); setBorders(false); setHeaderVisible(false); - add(createWelcomePanel()); + if (UrlParamsHelper.createNavigateToCurrentUrlAction(viewContext).isEmpty()) + { + add(createWelcomePanel()); + } } private final Component createWelcomePanel() diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/OpenViewAction.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/OpenViewAction.java index dfbe529fa0fdf3c357bb58bd151a08fea4b57453..7cd2629760d5e1849f540c5d59c86f13b81358d6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/OpenViewAction.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/OpenViewAction.java @@ -38,6 +38,12 @@ public class OpenViewAction implements IDelegatedAction this.viewLocator = viewLocator; } + /** @return true if executing this action would not result in opening any view */ + public boolean isEmpty() + { + return registry.canResolve(viewLocator) == false; + } + public void execute() { openView(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/ViewLocatorResolverRegistry.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/ViewLocatorResolverRegistry.java index 6a8d0401f472c48498ad9d862e8fb47823eb465a..496ed85fdf3af734e2e4f87b979a9bd505f507f8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/ViewLocatorResolverRegistry.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/ViewLocatorResolverRegistry.java @@ -60,4 +60,20 @@ public class ViewLocatorResolverRegistry } } + /** + * @return true if the locator can be resolved by one of the handlers. + * @exception UserFailureException Might be thrown by the handler. + */ + public boolean canResolve(ViewLocator locator) throws UserFailureException + { + for (IViewLocatorResolver handler : handlers) + { + if (handler.canHandleLocator(locator)) + { + return true; + } + } + return false; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/ViewMode.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/ViewMode.java index 2c5456aecee91f34431dc5a703431c1a60ed2675..0ac26951d04bb7b0a4a1eb9ef8560d9a2d83a47b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/ViewMode.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/ViewMode.java @@ -23,5 +23,12 @@ import com.google.gwt.user.client.rpc.IsSerializable; */ public enum ViewMode implements IsSerializable { - SIMPLE, NORMAL; + SIMPLE, + /** + * Embedded mode is a simple view mode which has less widgets (e.g. top toolbar and footer are + * invisible) to allow embedding the application on other web sites. + */ + SIMPLE_EMBEDDED, + + NORMAL; } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/OpenViewCommand.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/OpenViewCommand.java index 851c55577e76873cf25a5b4e4dd9b534fc341d04..a7f107ecd659de137499b87dd296997e9a64351b 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/OpenViewCommand.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/OpenViewCommand.java @@ -35,7 +35,7 @@ public class OpenViewCommand extends AbstractDefaultTestCommand { super(); this.client = client; - this.locator = Client.createViewLocator(urlParams); + this.locator = new ViewLocator(urlParams); } public void execute()