Show WebUI2ServiceConnection.java syntax highlighted
package ucalgary.ebe.webui.client;
import java.util.Vector;
import ucalgary.ebe.webui.client.data.BacklogWeb;
import ucalgary.ebe.webui.client.data.IterationWeb;
import ucalgary.ebe.webui.client.data.ProjectWeb;
import ucalgary.ebe.webui.client.data.StoryCardWeb;
import ucalgary.ebe.webui.server.service.AgilePlannerWebUIService;
import ucalgary.ebe.webui.server.service.AgilePlannerWebUIServiceAsync;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.ListBox;
public class WebUI2ServiceConnection {
private static final String WSADDR = "apwebui";
private WebUIDataChangeListener listener;
private AgilePlannerWebUIServiceAsync aps;
private ServiceDefTarget endpoint;
private ProjectWeb rootproject;
public WebUI2ServiceConnection() {
aps = (AgilePlannerWebUIServiceAsync) GWT.create(AgilePlannerWebUIService.class);
endpoint = (ServiceDefTarget) aps;
String moduleRelativeURL = GWT.getModuleBaseURL() + WSADDR;
endpoint.setServiceEntryPoint(moduleRelativeURL);
}
/****************************************************************************************
* LOAD *
****************************************************************************************/
public void loadProject(String name) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
ProjectWeb prj = (ProjectWeb)result;
rootproject = prj;
listener.loadedProject(prj);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.loadProject(name, callback);
}
public void getProjectNames() {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.gotProjectNames((Vector)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.getProjectNames(callback);
}
/****************************************************************************************
* CREATE *
****************************************************************************************/
public void createBacklog() {
if(this.rootproject.getBacklog() == null) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.createdBacklog((BacklogWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.createBacklog(callback);
} else {
//TODO popup error dialog
}
}
public void createIteration(String name, String description, float availableEffort,
String startDate, String endDate) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
IterationWeb iteration = (IterationWeb)result;
rootproject.addIteration(iteration);
listener.createdIteration(iteration);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.createIteration(name, description, availableEffort, startDate,
endDate, callback);
}
public void createProject(String name) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.createdProject((ProjectWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.createProject(name, callback);
}
//PROCESS RETURNED OBJECT
public void createStoryCard(String name, String description, long parentid,
float bestCaseEstimate, float mostlikelyEstimate,
float worstCaseEstimate, float actualEffort, boolean completed) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.createdStoryCard((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.createStoryCard(name, description, parentid, bestCaseEstimate,
mostlikelyEstimate, worstCaseEstimate, actualEffort, completed,
callback);
}
/****************************************************************************************
* DELETE *
****************************************************************************************/
public void deleteBacklog(long id) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.deletedBacklog((BacklogWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.deleteBacklog(id, callback);
}
public void deleteIteration(long id) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.deletedIteration((IterationWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.deleteIteration(id, callback);
}
public void deleteProject(long id) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.deletedProject((ProjectWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.deleteProject(id, callback);
}
public void deleteStoryCard(long id) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.deletedStoryCard((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.deleteStoryCard(id, callback);
}
/****************************************************************************************
* UPDATE STORYCARD *
****************************************************************************************/
public void updateStoryCardActualEffort(long id, float actualEffort) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedStoryCardActualEffort((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateStoryCardActualEffort(id, actualEffort, callback);
}
public void updateStoryCardBestCaseEstimate(long id, float bestCaseEstimate) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedStoryCardBestCaseEstimate((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateStoryCardBestCaseEstimate(id, bestCaseEstimate, callback);
}
public void updateStoryCardComplete(long id, boolean completed) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedStoryCardComplete((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateStoryCardComplete(id, completed, callback);
}
public void updateStoryCardDescription(long id, String description) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedStoryCardDescription((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateStoryCardDescription(id, description, callback);
}
public void updateStoryCardMostLikelyEstimate(long id,
float mostlikelyEstimate) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedStoryCardMostLikelyEstimate((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateStoryCardMostLikelyEstimate(id, mostlikelyEstimate, callback);
}
public void updateStoryCardName(long id, String name) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedStoryCardName((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateStoryCardName(id, name, callback);
}
public void updateStoryCardInProgress(long id, boolean started) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedStoryCardInProgress((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateStoryCardInProgress(id, started, callback);
}
public void updateStoryCardWorstCaseEstimate(long id,
float worstCaseEstimate) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedStoryCardWorstCaseEstimate((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateStoryCardWorstCaseEstimate(id, worstCaseEstimate, callback);
}
/****************************************************************************************
* MOVE STORYCARD BETWEEN PARENTS *
****************************************************************************************/
public void moveStoryCardToNewParent(long id, long oldparentid,
long newparentid) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.movedStoryCardToNewParent((StoryCardWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.moveStoryCardToNewParent(id, oldparentid, newparentid, callback);
}
/****************************************************************************************
* UPDATE ITERATION *
****************************************************************************************/
public void updateIterationAvailableEffort(long id, float availableEffort) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedIterationAvailableEffort((IterationWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateIterationAvailableEffort(id, availableEffort, callback);
}
public void updateIterationComplete(long id, boolean completed) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedIterationComplete((IterationWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateIterationComplete(id, completed, callback);
}
public void updateIterationDescription(long id, String description) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedIterationDescription((IterationWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateIterationDescription(id, description, callback);
}
public void updateIterationEndDate(long id, String endDate) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedIterationEndDate((IterationWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateIterationEndDate(id, endDate, callback);
}
public void updateIterationName(long id, String name) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedIterationName((IterationWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateIterationName(id, name, callback);
}
/****************************************************************************************
* UPDATE PROJECT *
****************************************************************************************/
public void updateProjectName(long id, String name) {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
listener.updatedProjectName((ProjectWeb)result);
}
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
};
aps.updateProjectName(id, name, callback);
}
/****************************************************************************************
* WEBUI DATA CHANGE LISTENER *
****************************************************************************************/
public void addWebUIChangeListener(WebUIDataChangeListener listener) {
this.listener = listener;
}
public void removeWebUIDataChangeListener() {
this.listener = null;
}
/****************************************************************************************
* GETTERS & SETTERS *
****************************************************************************************/
public ProjectWeb getProject() {
return this.rootproject;
}
}
See more files for this project here