Skip to content
Snippets Groups Projects
Commit 1dd481ef authored by tpylak's avatar tpylak
Browse files

LMS-2153 1. introduce "simple embedded view" to remove toolbar and footer 2....

LMS-2153 1. introduce "simple embedded view" to remove toolbar and footer 2. remove the blinking welcome page when a URL from SVM is accessed.

SVN: 20446
parent 58355f14
No related branches found
No related tags found
No related merge requests found
Showing
with 109 additions and 42 deletions
......@@ -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();
}
}
......@@ -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;
......
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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)
......
......@@ -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()
......
......@@ -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();
......
......@@ -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;
}
}
......@@ -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;
}
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment