diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AbstractViewer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AbstractViewer.java index 24e0ffa7c837b80291c10ea2104462cc101511df..82f2850c9c103454e8e05cf82d9c0222e096de7d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AbstractViewer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AbstractViewer.java @@ -31,7 +31,6 @@ import com.extjs.gxt.ui.client.widget.ContentPanel; import com.extjs.gxt.ui.client.widget.Html; import com.extjs.gxt.ui.client.widget.Layout; import com.extjs.gxt.ui.client.widget.LayoutContainer; -import com.extjs.gxt.ui.client.widget.Text; import com.extjs.gxt.ui.client.widget.button.Button; import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; import com.extjs.gxt.ui.client.widget.layout.TableRowLayout; @@ -39,6 +38,7 @@ import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem; import com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem; import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Widget; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; @@ -57,6 +57,9 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.ID import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.listener.OpenEntityDetailsTabClickListener; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.listener.OpenEntityEditorTabClickListener; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.listener.OpenExperimentBrowserTabClickListener; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.webapp.WebAppComponent; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.webapp.WebAppSortingAndCodeComparator; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.webapp.WebAppUrl; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.SectionsPanel; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; @@ -68,7 +71,6 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.IEntityInformationHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.IEntityInformationHolderWithIdentifier; import ch.systemsx.cisd.openbis.generic.shared.basic.IEntityInformationHolderWithPermId; import ch.systemsx.cisd.openbis.generic.shared.basic.IEntityInformationHolderWithProperties; -import ch.systemsx.cisd.openbis.generic.shared.basic.WebAppSortingAndCodeComparator; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityVisit; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; @@ -465,7 +467,14 @@ public abstract class AbstractViewer<D extends IEntityInformationHolder> extends @Override public Component getComponent() { - return new Text(webApp.getCode()); + WebAppUrl url = + new WebAppUrl(Window.Location.getProtocol(), + Window.Location.getHost(), + webApp.getCode(), getSessionId()); + url.setEntityKind(entity.getEntityKind()); + url.setEntityType(entity.getEntityType()); + url.setEntityPermId(entity.getPermId()); + return new WebAppComponent(url); } @Override @@ -607,4 +616,9 @@ public abstract class AbstractViewer<D extends IEntityInformationHolder> extends return getViewContext().getModel().getApplicationInfo(); } + protected String getSessionId() + { + return getViewContext().getModel().getSessionContext().getSessionID(); + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppComponent.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppComponent.java new file mode 100644 index 0000000000000000000000000000000000000000..fb9c0b93f3c9d39192224fe315ba58b08ffd73f1 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppComponent.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012 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.ui.webapp; + +import com.extjs.gxt.ui.client.widget.WidgetComponent; +import com.google.gwt.user.client.ui.Frame; + +/** + * Component that displays a web application in an IFRAME. + * + * @author pkupczyk + */ +public class WebAppComponent extends WidgetComponent +{ + + public WebAppComponent(WebAppUrl url) + { + super(new Frame(url.toString())); + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/WebAppSortingAndCodeComparator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppSortingAndCodeComparator.java similarity index 95% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/WebAppSortingAndCodeComparator.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppSortingAndCodeComparator.java index f789eb89e4198589cb5a17c3b69568184e665191..a5fa7bc8ac3c87e7f4a3e1f1eaab2bd64bac6984 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/WebAppSortingAndCodeComparator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppSortingAndCodeComparator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.shared.basic; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.webapp; import java.util.Comparator; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrl.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrl.java new file mode 100644 index 0000000000000000000000000000000000000000..6fa4b40dba43ee9aecfd0e169d7948ad36f47c8c --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrl.java @@ -0,0 +1,89 @@ +/* + * Copyright 2012 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.ui.webapp; + +import com.google.gwt.http.client.UrlBuilder; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BasicEntityType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; + +/** + * A web application URL that will be used for displaying the web application in an IFRAME. + * + * @author pkupczyk + */ +public class WebAppUrl +{ + + private UrlBuilder builder = new UrlBuilder(); + + public WebAppUrl(String openbisProtocol, String openbisHost, String webAppCode, String sessionId) + { + if (openbisProtocol == null) + { + throw new IllegalArgumentException("OpenBIS protocol cannot be null"); + } + if (openbisHost == null) + { + throw new IllegalArgumentException("OpenBIS host cannot be null"); + } + if (webAppCode == null) + { + throw new IllegalArgumentException("Web application code cannot be null"); + } + if (sessionId == null) + { + throw new IllegalArgumentException("Session id cannot be null"); + } + + builder.setProtocol(openbisProtocol); + builder.setHost(openbisHost); + builder.setPath(webAppCode); + builder.setParameter(WebAppUrlParameter.SESSION_ID.getName(), sessionId); + } + + public void setEntityKind(EntityKind entityKind) + { + if (entityKind != null) + { + builder.setParameter(WebAppUrlParameter.ENTITY_KIND.getName(), entityKind.name()); + } + } + + public void setEntityType(BasicEntityType entityType) + { + if (entityType != null) + { + builder.setParameter(WebAppUrlParameter.ENTITY_TYPE.getName(), entityType.getCode()); + } + } + + public void setEntityPermId(String entityPermId) + { + if (entityPermId != null) + { + builder.setParameter(WebAppUrlParameter.ENTITY_PERM_ID.getName(), entityPermId); + } + } + + @Override + public String toString() + { + return builder.buildString(); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrlParameter.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrlParameter.java new file mode 100644 index 0000000000000000000000000000000000000000..551fd183d7e20121c35fed00032a681c3e9b1a05 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrlParameter.java @@ -0,0 +1,42 @@ +/* + * Copyright 2012 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.ui.webapp; + +/** + * Parameters that are passed to a web application in an URL query string. + * + * @author pkupczyk + */ +public enum WebAppUrlParameter +{ + + SESSION_ID("session-id"), ENTITY_KIND("entity-kind"), ENTITY_TYPE("entity-type"), + ENTITY_PERM_ID("entity-perm-id"); + + private final String name; + + private WebAppUrlParameter(String name) + { + this.name = name; + } + + public String getName() + { + return this.name; + } + +} diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/WebAppSortingAndCodeComparatorTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppSortingAndCodeComparatorTest.java similarity index 97% rename from openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/WebAppSortingAndCodeComparatorTest.java rename to openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppSortingAndCodeComparatorTest.java index 24d2f811702325cb6faae25623001958e4896756..ccd3ffb4f34c14b068b16abf06a10ce95d991e5b 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/WebAppSortingAndCodeComparatorTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppSortingAndCodeComparatorTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.shared.basic; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.webapp; import java.util.ArrayList; import java.util.Collections;