Author: lgiessmann Date: Wed Jun 29 14:37:50 2011 New Revision: 532
Log: gdl-frontend: Widgets: added the class Pair<T, U>; added a dialogbox example; started to implement a LoadSchemaCallback class for isidorus
Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/LoadSchemaCallback.java Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/GDL_Widgets.gwt.xml branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ILoadSchemaCallback.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/Pair.java
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/GDL_Widgets.gwt.xml ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/GDL_Widgets.gwt.xml Wed Jun 29 13:00:44 2011 (r531) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/GDL_Widgets.gwt.xml Wed Jun 29 14:37:50 2011 (r532) @@ -2,6 +2,7 @@ <module rename-to='gdl_widgets'> <!-- Inherit the core Web Toolkit stuff. --> <inherits name='com.google.gwt.user.User'/> + <inherits name="com.google.gwt.http.HTTP" />
<!-- Inherit the default GWT style sheet. You can change --> <!-- the theme of your GWT application by uncommenting -->
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Wed Jun 29 13:00:44 2011 (r531) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Wed Jun 29 14:37:50 2011 (r532) @@ -99,14 +99,14 @@ }
- public void addOnErrorHandler(String descriptorId, IGdlErrorHandler handler){ + public void registerOnErrorHandler(String descriptorId, IGdlErrorHandler handler){ if(!localOnErrorContainer.contains(handler)){ localOnErrorContainer.add(handler); } } - public void removeOnErrorHandler(String descriptorId, IGdlErrorHandler handler){ + public void deregisterOnErrorHandler(String descriptorId, IGdlErrorHandler handler){ localOnErrorContainer.remove(handler); } @@ -165,6 +165,11 @@ return this.deleteCallback; } + // a getter for the internal topic map + public TopicMap getTm(){ + return this.tm; + } + // this method is responsible for loading the Topic Map by using the // loadCallback. After a successfully load operation the @@ -177,7 +182,7 @@ if(this.loadSchemaCallback == null){ throw new ExecutionException("No LoadCallback was set yet"); } - this.loadSchemaCallback.loadSchema(tm, this.requestedInstance, this.requestedTypes); + this.loadSchemaCallback.loadSchema(this, this.requestedInstance, this.requestedTypes); }catch(Exception e){ for (IGdlErrorHandler handler : localOnErrorContainer) { @@ -269,7 +274,7 @@ public void createView(){ try{ // TODO: Implement - // TODO: register the handlers to the elements with the corresponding id + // TODO: register callbacks to the elements with the corresponding id }catch(Exception e){ for (IGdlErrorHandler handler : localOnErrorContainer) { handler.onError(GdlErrorTypes.ViewCreationError, e); @@ -282,4 +287,9 @@ public void clear(){ this.mainPanel.clear(); } + + + // TODO: implement registration/deregistration for event handlers/callbacks for a specific element + // specified by its element id + // TODO: implement a registration for Action-Buttons specified by the element's id }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Wed Jun 29 13:00:44 2011 (r531) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Wed Jun 29 14:37:50 2011 (r532) @@ -1,10 +1,17 @@ package us.isidor.gdl.anaToMia.Widgets.base;
import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.SimplePanel; +import com.google.gwt.user.client.ui.VerticalPanel;
public class TestClass implements EntryPoint{ @@ -22,6 +29,42 @@ gdlPanel.setPixelSize(100, 100); DOM.setStyleAttribute(gdlPanel.getElement(), "backgroundColor", "yellow"); mainPanel.add(gdlPanel); + + testDialogBox(); + } + + + public void testDialogBox(){ + final DialogBox dialogbox = new DialogBox(); + VerticalPanel dialogBoxContents = new VerticalPanel(); + dialogbox.setText("DialogBox"); + HTML message = new HTML("Click 'Close' to close"); + message.setStyleName("demo-DialogBox-message"); + ClickHandler listener = new ClickHandler() + { + @Override + public void onClick(ClickEvent event) { + dialogbox.hide(); + } + }; + Button button = new Button("Close", listener); + SimplePanel holder = new SimplePanel(); + holder.add(button); + dialogBoxContents.add(message); + dialogBoxContents.add(holder); + dialogbox.setWidget(dialogBoxContents); + + // + // Add a button to the demo to show the above DialogBox + listener = new ClickHandler() + { + @Override + public void onClick(ClickEvent event) { + dialogbox.center(); + } + }; + button = new Button("Show DialogBox", listener); + mainPanel.add(button); }
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ILoadSchemaCallback.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ILoadSchemaCallback.java Wed Jun 29 13:00:44 2011 (r531) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ILoadSchemaCallback.java Wed Jun 29 14:37:50 2011 (r532) @@ -1,8 +1,11 @@ package us.isidor.gdl.anaToMia.Widgets.environment;
+import com.google.gwt.http.client.RequestException; + import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; +import us.isidor.gdl.anaToMia.Widgets.base.GdlPanel;
public interface ILoadSchemaCallback { - public Construct loadSchema(TopicMap tm, String instanceIdentifier, String[] typeIdentifiers); + public void loadSchema(GdlPanel panel, String instanceIdentifier, String[] typeIdentifiers)throws RequestException; }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/Pair.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/Pair.java Wed Jun 29 13:00:44 2011 (r531) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/Pair.java Wed Jun 29 14:37:50 2011 (r532) @@ -1,5 +1,26 @@ package us.isidor.gdl.anaToMia.Widgets.environment;
-public class Pair { - +public class Pair<T, U> { + private T first = null; + private U second = null; + + + @SuppressWarnings("unused") + private Pair(){} + + + public Pair(T first, U second){ + this.first = first; + this.second = second; + } + + + public T getFirst(){ + return this.first; + } + + + public U getSecond(){ + return this.second; + } }
Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/LoadSchemaCallback.java ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/LoadSchemaCallback.java Wed Jun 29 14:37:50 2011 (r532) @@ -0,0 +1,57 @@ +package us.isidor.gdl.anaToMia.Widgets.isidorus; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.http.client.Request; +import com.google.gwt.http.client.RequestBuilder; +import com.google.gwt.http.client.RequestCallback; +import com.google.gwt.http.client.RequestException; +import com.google.gwt.http.client.Response; +import com.google.gwt.http.client.URL; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; +import us.isidor.gdl.anaToMia.Widgets.base.GdlPanel; +import us.isidor.gdl.anaToMia.Widgets.environment.ILoadSchemaCallback; + + +public class LoadSchemaCallback implements ILoadSchemaCallback{ + private final String isidorusUrl = URL.encode(GWT.getModuleBaseURL() + "testJson.txt"); // TODO: replace with the correct URL + private RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, isidorusUrl); + + public LoadSchemaCallback(){} + + + @Override + public void loadSchema(GdlPanel panel, String instanceIdentifier, String[] typeIdentifiers) throws RequestException { + Request request = requestBuilder.sendRequest(null, new RequestCallbackImpl(panel)); + } + + + private class RequestCallbackImpl implements RequestCallback{ + private GdlPanel panel = null; + + + @SuppressWarnings("unused") + private RequestCallbackImpl() {} + + + public RequestCallbackImpl(GdlPanel panel){ + this.panel = panel; + } + + + @Override + public void onResponseReceived(Request request, Response response) { + if(Response.SC_OK == response.getStatusCode()){ + panel.createView(); + } else { + // TODO: implement error handling => http://examples.roughian.com/index.htm#Widgets~DialogBox + } + } + + + @Override + public void onError(Request request, Throwable exception) { + // TODO: implement error handling => http://examples.roughian.com/index.htm#Widgets~DialogBox + } + } +}