Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 57:246af33f621c
Adjusted the look of the 'next' button in the parameter panel.
flys-client/trunk@1516 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 Mar 2011 11:32:05 +0000 |
parents | 44c63e7fd0d0 |
children | a26489e55730 |
line wrap: on
line source
package de.intevation.flys.client.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.xml.client.XMLParser; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.DefaultCollection; import de.intevation.flys.client.shared.model.River; import de.intevation.flys.client.shared.model.User; import de.intevation.flys.client.client.services.ArtifactService; import de.intevation.flys.client.client.services.ArtifactServiceAsync; import de.intevation.flys.client.client.services.RiverService; import de.intevation.flys.client.client.services.RiverServiceAsync; import de.intevation.flys.client.client.services.UserService; import de.intevation.flys.client.client.services.UserServiceAsync; import de.intevation.flys.client.client.ui.CollectionView; import de.intevation.flys.client.client.ui.FLYSHeader; import de.intevation.flys.client.client.ui.FLYSView; import de.intevation.flys.client.client.ui.FLYSWorkspace; import de.intevation.flys.client.client.ui.MainMenu; import de.intevation.flys.client.client.ui.ProjectList; /** * Entry point classes define <code>onModuleLoad()</code>. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class FLYS implements EntryPoint { /** The UserService used to retrieve information about the current user. */ protected UserServiceAsync userService = GWT.create(UserService.class); /** The RiverService used to retrieve the supported rivers of the server.*/ protected RiverServiceAsync riverService = GWT.create(RiverService.class); /** The ArtifactService used to communicate with the Artifact server. */ protected ArtifactServiceAsync artifactService = GWT.create(ArtifactService.class); /** The menu bar at the top of the application.*/ protected MainMenu menu; /** The content window. It takes the whole space beneath the menu bar.*/ protected FLYSView view; /** The project list that displays the projects of the user.*/ protected ProjectList projectList; /** The FLYSWorkspace.*/ protected FLYSWorkspace workspace; /** The user who is currently logged in.*/ protected User currentUser; /** The list of rivers supported by the server.*/ protected River[] rivers; /** * This is the entry point method. */ public void onModuleLoad() { VLayout vertical = new VLayout(); vertical.setMembersMargin(2); vertical.setLayoutMargin(1); vertical.setWidth100(); vertical.setHeight100(); menu = new MainMenu(this); view = new FLYSView(); vertical.addMember(new FLYSHeader()); vertical.addMember(menu); vertical.addMember(view); RootPanel.get("app").add(vertical); initConfiguration(); String serverUrl = Config.getInstance().getServerUrl(); getRivers(); userService.getCurrentUser(serverUrl, new AsyncCallback<User>() { public void onFailure(Throwable caught) { GWT.log("Could not find a logged in user."); // TODO do something } public void onSuccess(User user) { GWT.log("Found a user. Set '"+ user.getName() + "'"); setCurrentUser(user); menu.setCurrentUser(user); projectList = new ProjectList(user); workspace = new FLYSWorkspace(); view.setProjectList(projectList); view.setFLYSWorkspace(workspace); } }); } /** * This method should be called at system start. It initialzes the client * configuration. */ protected void initConfiguration() { String xml = FLYSResources.INSTANCE.initialConfiguration().getText(); Config.getInstance(XMLParser.parse(xml)); } /** * Returns the user that is currently logged in. * * @return the current user. */ public User getCurrentUser() { return currentUser; } /** * Sets the current user. */ public void setCurrentUser(User user) { currentUser = user; } /** * Returns the project list. */ public ProjectList getProjectList() { return projectList; } /** * Returns a list of rivers supported by the artifact server. * * @return a list of rivers supported by the artifact server. */ public River[] getRivers() { if (rivers == null) { String url = Config.getInstance().getServerUrl(); GWT.log("Fetch rivers from server '" + url + "'"); riverService.list(url, new AsyncCallback<River[]>() { public void onFailure(Throwable caught) { GWT.log("Could not recieve a list of rivers."); GWT.log(caught.getMessage()); } public void onSuccess(River[] newRivers) { GWT.log("Retrieved " + newRivers.length + " new rivers."); rivers = newRivers; } }); } return rivers; } /** * This method creates a new CollectionView and adds it to the workspace. */ public void newProject() { // TODO Call the REST service to create a new Collection // TODO Use the UUID of the Collection to add a new CollectionView! Collection c = new DefaultCollection(new java.util.Date().toString()); workspace.addView(c.identifier(), new CollectionView(this, c)); } /** * Create a new Artifact. */ public void newArtifact(String factory) { String url = Config.getInstance().getServerUrl(); artifactService.create(url, factory, new AsyncCallback<Artifact>() { public void onFailure(Throwable caught) { GWT.log("Could not create the new artifact."); GWT.log(caught.getMessage()); } public void onSuccess(Artifact artifact) { GWT.log("Successfully created a new artifact."); } }); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :