Skip to content

Commit

Permalink
add mediocre back button
Browse files Browse the repository at this point in the history
  • Loading branch information
marcdichmann committed Sep 5, 2018
1 parent 1a39c7b commit 0744a99
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.Enumeration;
import java.util.Collections;

import javax.portlet.PortletSession;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;

import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.theme.ThemeDisplay;
Expand All @@ -41,6 +45,7 @@
import com.vaadin.server.FontAwesome;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinServletRequest;
import com.vaadin.server.WrappedPortletSession;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Alignment;
Expand All @@ -53,7 +58,10 @@
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Notification;
import com.vaadin.ui.themes.ValoTheme;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;

import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project;
import life.qbic.projectbrowser.controllers.*;
Expand Down Expand Up @@ -321,7 +329,7 @@ public GridLayout buildMainLayout(DataHandler datahandler, VaadinRequest request
w.setSizeFull();
}

mainLayout = new GridLayout(4, 3);
mainLayout = new GridLayout(5, 3);
mainLayout.setResponsive(true);
mainLayout.setWidth(100, Unit.PERCENTAGE);

Expand Down Expand Up @@ -390,22 +398,72 @@ public void buttonClick(ClickEvent event) {
//EINGEFÜGT VON MARC


Button infoButton = new Button("URL");
Button backButton = new Button("Back");
backButton.setStyleName(ValoTheme.BUTTON_LARGE);
backButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

backButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {

String url = UI.getCurrent().getPage().getLocation().toString();
String[] urlSplitted = url.split("!");
if(urlSplitted.length > 1) {
String level = url.split("!")[1].split("/")[0];
// LOG.info(url);
// LOG.info(level);
// LOG.info(url.split("!")[1]);
// LOG.info(url.split("!")[1].split("/")[0]);

String[] urlSplits = url.split("/");
String lastSplit = urlSplits[urlSplits.length - 1];

String last = url.substring(url.lastIndexOf("/") + 1);

if (level.equals("experiment")) {

LOG.info("experiment if");
LOG.info(last + ": " + lastSplit);

navigator.navigateTo(ProjectView.navigateToLabel);
} else if (level.equals("project")) {
LOG.info("project if");
LOG.info(last + ": " + lastSplit);

navigator.navigateTo("");
} else {
LOG.info("not experiment or project");
}
}
else {
Notification.show("You are in the home screen\n" + url);
}

}
});


mainLayout.addComponent(backButton, 3, 0);


Button infoButton = new Button("Info");
infoButton.setStyleName(ValoTheme.BUTTON_LARGE);
infoButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

infoButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
// VaadinRequest vaadinRequest = VaadinService.getCurrentRequest();
// HttpServletRequest httpServletRequest = ((VaadinServletRequest)vaadinRequest).getHttpServletRequest();
// String requestUrl = httpServletRequest.getRequestURL().toString();
// LOG.info(requestUrl);
LOG.info("URL Button");
}
});
String url = UI.getCurrent().getPage().getLocation().toString();
LOG.info(url);
Enumeration attributes = getPortletSession().getAttributeNames();
LOG.info("Session Attributes");
for (String s : Collections.list(attributes))
LOG.info(s);
}
});


mainLayout.addComponent(infoButton, 4, 0);
// if()
// Button header2 = new Button(String.format("Current Project"))

Expand All @@ -416,8 +474,7 @@ public void buttonClick(ClickEvent event) {
mainLayout.addComponent(header, 1, 0);

mainLayout.addComponent(searchBarView, 2, 0);
// einfügt von marc
mainLayout.addComponent(infoButton, 3, 0);


/*
* VerticalLayout versionLayout = new VerticalLayout(); versionLayout.setWidth(100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public void itemClick(ItemClickEvent event) {
if (visualize) {
// LOG.debug("Is resource null?: " + String.valueOf(res == null));
BrowserFrame frame = new BrowserFrame(datasetFileName, res);

subContent.addComponent(frame);


Expand Down

0 comments on commit 0744a99

Please sign in to comment.