teichmann@5861: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
teichmann@5861: * Software engineering by Intevation GmbH
teichmann@5861: *
teichmann@5993: * This file is Free Software under the GNU AGPL (>=v3)
teichmann@5861: * and comes with ABSOLUTELY NO WARRANTY! Check out the
teichmann@5993: * documentation coming with Dive4Elements River for details.
teichmann@5861: */
teichmann@5861:
teichmann@5835: package org.dive4elements.river.client.client;
ingo@0:
ingo@0: import com.google.gwt.core.client.EntryPoint;
ingo@2: import com.google.gwt.core.client.GWT;
ingo@605: import com.google.gwt.event.shared.UmbrellaException;
ingo@2: import com.google.gwt.user.client.rpc.AsyncCallback;
ingo@9: import com.google.gwt.xml.client.XMLParser;
ingo@217: import com.smartgwt.client.util.SC;
christian@3501: import com.smartgwt.client.widgets.HTMLPane;
ingo@605: import com.smartgwt.client.widgets.Window;
christian@3501: import com.smartgwt.client.widgets.events.CloseClickEvent;
ingo@557: import com.smartgwt.client.widgets.events.CloseClickHandler;
christian@3501: import com.smartgwt.client.widgets.layout.VLayout;
ingo@6:
christian@6475: import java.util.ArrayList;
christian@6475: import java.util.List;
christian@6475: import java.util.Map;
christian@6475: import java.util.MissingResourceException;
christian@6475: import java.util.Set;
christian@6475:
teichmann@5835: import org.dive4elements.river.client.client.event.CollectionChangeEvent;
teichmann@5835: import org.dive4elements.river.client.client.event.CollectionChangeHandler;
teichmann@5835: import org.dive4elements.river.client.client.services.ArtifactService;
teichmann@5835: import org.dive4elements.river.client.client.services.ArtifactServiceAsync;
teichmann@5835: import org.dive4elements.river.client.client.services.CreateCollectionService;
teichmann@5835: import org.dive4elements.river.client.client.services.CreateCollectionServiceAsync;
teichmann@5835: import org.dive4elements.river.client.client.services.DescribeCollectionService;
teichmann@5835: import org.dive4elements.river.client.client.services.DescribeCollectionServiceAsync;
teichmann@5835: import org.dive4elements.river.client.client.services.GetArtifactService;
teichmann@5835: import org.dive4elements.river.client.client.services.GetArtifactServiceAsync;
teichmann@5835: import org.dive4elements.river.client.client.services.RiverService;
teichmann@5835: import org.dive4elements.river.client.client.services.RiverServiceAsync;
christian@6475: import org.dive4elements.river.client.client.services.ServerInfoService;
christian@6475: import org.dive4elements.river.client.client.services.ServerInfoServiceAsync;
teichmann@5835: import org.dive4elements.river.client.client.services.UserService;
teichmann@5835: import org.dive4elements.river.client.client.services.UserServiceAsync;
teichmann@5835: import org.dive4elements.river.client.client.ui.CollectionView;
teichmann@5835: import org.dive4elements.river.client.client.ui.FLYSHeader;
teichmann@5835: import org.dive4elements.river.client.client.ui.FLYSView;
teichmann@5835: import org.dive4elements.river.client.client.ui.FLYSWorkspace;
teichmann@5835: import org.dive4elements.river.client.client.ui.ProjectList;
christian@6475: import org.dive4elements.river.client.client.ui.wq.WQAutoTabSet;
teichmann@5835: import org.dive4elements.river.client.shared.model.Artifact;
teichmann@5835: import org.dive4elements.river.client.shared.model.Collection;
teichmann@5835: import org.dive4elements.river.client.shared.model.CollectionItem;
teichmann@5835: import org.dive4elements.river.client.shared.model.GaugeInfo;
teichmann@5835: import org.dive4elements.river.client.shared.model.River;
teichmann@5835: import org.dive4elements.river.client.shared.model.User;
christian@3501:
ingo@0:
ingo@0: /**
ingo@0: * Entry point classes define onModuleLoad()
.
ingo@1: *
ingo@1: * @author Ingo Weinzierl
ingo@0: */
ingo@611: public class FLYS implements EntryPoint, CollectionChangeHandler {
ingo@0:
ingo@217: /** The message class that provides i18n strings.*/
ingo@217: protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
ingo@217:
ingo@2: /** The UserService used to retrieve information about the current user. */
ingo@2: protected UserServiceAsync userService = GWT.create(UserService.class);
ingo@2:
christian@6475: protected ServerInfoServiceAsync serverInfoService = GWT.create(ServerInfoService.class);
christian@6475:
ingo@29: /** The RiverService used to retrieve the supported rivers of the server.*/
ingo@29: protected RiverServiceAsync riverService = GWT.create(RiverService.class);
ingo@29:
ingo@9: /** The ArtifactService used to communicate with the Artifact server. */
ingo@9: protected ArtifactServiceAsync artifactService =
ingo@9: GWT.create(ArtifactService.class);
ingo@9:
ingo@225: /** The ArtifactService used to communicate with the Artifact server. */
ingo@225: protected DescribeCollectionServiceAsync describeCollectionService =
ingo@225: GWT.create(DescribeCollectionService.class);
ingo@225:
ingo@225: /** The GetArtifactService used to open an existing collection. */
ingo@225: protected GetArtifactServiceAsync getArtifactService =
ingo@225: GWT.create(GetArtifactService.class);
ingo@225:
bjoern@3865: /** The CreateCollectionServiceAsync used to create a new collection */
bjoern@3865: protected CreateCollectionServiceAsync collectionService =
bjoern@3865: GWT.create(CreateCollectionService.class);
ingo@225:
bjoern@4603: /** The content window. It takes the whole space beneath the header. */
ingo@2: protected FLYSView view;
ingo@2:
felix@864: /** The project list that displays the projects of the user. */
ingo@4: protected ProjectList projectList;
ingo@4:
felix@864: /** The FLYSWorkspace. */
ingo@6: protected FLYSWorkspace workspace;
ingo@6:
felix@864: /** The user who is currently logged in. */
ingo@25: protected User currentUser;
ingo@25:
felix@864: /** The list of rivers supported by the server. */
ingo@29: protected River[] rivers;
ingo@29:
felix@864: /** This list is used to track the opened projects. */
ingo@557: protected List openProjects;
ingo@557:
bjoern@4603: private FLYSHeader header;
bjoern@4603:
ingo@2:
christian@4062: public static String getExceptionString(FLYSConstants msg, Throwable caught) {
christian@3989: try {
christian@4062: return msg.getString(caught.getMessage());
christian@3989: }
christian@3989: catch(MissingResourceException ex) {
christian@3989: // There are some server error exceptions with
christian@3989: // varying text messages that cannot be localized
christian@3989: // easily. In this rare cases, use the plain
christian@3989: // exception message.
christian@3989: GWT.log("Missing resource for: " + caught.getMessage());
christian@3989: return caught.getLocalizedMessage();
christian@3989: }
christian@3989: }
christian@3989:
ingo@1: /**
ingo@1: * This is the entry point method.
ingo@1: */
christian@3501: @Override
ingo@1: public void onModuleLoad() {
ingo@557: openProjects = new ArrayList();
ingo@0:
ingo@787: //GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
ingo@787: // public void onUncaughtException(Throwable e) {
ingo@787: // showWarning(e);
ingo@787: // }
ingo@787: //});
ingo@605:
christian@6475: initConfiguration();
christian@6475:
ingo@1: VLayout vertical = new VLayout();
ingo@1: vertical.setLayoutMargin(1);
ingo@1: vertical.setWidth100();
ingo@1: vertical.setHeight100();
ingo@0:
ingo@2: view = new FLYSView();
bjoern@4603: header = new FLYSHeader(this);
ingo@1:
bjoern@4603: vertical.addMember(header);
ingo@1: vertical.addMember(view);
ingo@1:
ingo@797: vertical.draw();
ingo@2:
ingo@229: Config config = Config.getInstance();
christian@6479: final String locale = config.getLocale();
ingo@9:
christian@6475: serverInfoService.getConfig(locale, new AsyncCallback