[isidorus-cvs] r538 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base environment views
lgiessmann at common-lisp.net
lgiessmann at common-lisp.net
Thu Jun 30 11:45:05 UTC 2011
Author: lgiessmann
Date: Thu Jun 30 04:45:04 2011
New Revision: 538
Log:
gdl-frontend: Widgets: added an interface for registering callbacks via a specified id attribute for buttons defined in GDL
Added:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IOnErrorCallback.java
- copied, changed from r532, branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IGdlErrorHandler.java
Deleted:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IGdlErrorHandler.java
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/views/GdlCreatorAssociationView.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlDefaultCreatorTopicView.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlDefaultEditorTopicView.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlEditorAssociationView.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlSpecialCreatorTopicView.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlSpecialEditorTopicView.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlView.java
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 Thu Jun 30 03:53:32 2011 (r537)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Thu Jun 30 04:45:04 2011 (r538)
@@ -8,10 +8,12 @@
import us.isidor.gdl.anaToMia.Widgets.environment.GdlErrorTypes;
import us.isidor.gdl.anaToMia.Widgets.environment.ICommitCallback;
import us.isidor.gdl.anaToMia.Widgets.environment.IDeleteCallback;
-import us.isidor.gdl.anaToMia.Widgets.environment.IGdlErrorHandler;
+import us.isidor.gdl.anaToMia.Widgets.environment.IOnErrorCallback;
import us.isidor.gdl.anaToMia.Widgets.environment.ILoadSchemaCallback;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidContentException;
+import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
import us.isidor.gdl.anaToMia.Widgets.views.GdlDefaultTopicView;
+import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
@@ -19,11 +21,15 @@
public class GdlPanel extends Composite{
// tmEngine is used as Topic Maps engine for this GdlPanel instance
private TmEngine tmEngine = null;
+
// onErrorContainer references handlers that are executed if an error occurred, i.e. if one of the processes
// GDL loading, GDL commit, GDL validate, GDL delete failed, but any other execution error also executes an
// error handler
- private ArrayList<IGdlErrorHandler> localOnErrorContainer = new ArrayList<IGdlErrorHandler>();
-
+ private ArrayList<IOnErrorCallback> localOnErrorContainer = new ArrayList<IOnErrorCallback>();
+ // buttonCallbacks contains pairs of ClickHandlers and Strings that acts as IDs.
+ // The ClickHandlers will be registered on the buttons with the corresponding id attribute.
+ private ArrayList<Pair<ClickHandler, String>> buttonCallbacks = new ArrayList<Pair<ClickHandler, String>>();
+
// If requestedTypes is not null or length != 0, the string values must be treated as topic
// identifiers of a topic type. The created GDL view must be a Default-Topic-Creator-View
private String[] requestedTypes = new String[]{};
@@ -99,14 +105,14 @@
}
- public void registerOnErrorHandler(String descriptorId, IGdlErrorHandler handler){
+ public void registerOnErrorHandler(String descriptorId, IOnErrorCallback handler){
if(!localOnErrorContainer.contains(handler)){
localOnErrorContainer.add(handler);
}
}
- public void deregisterOnErrorHandler(String descriptorId, IGdlErrorHandler handler){
+ public void deregisterOnErrorHandler(String descriptorId, IOnErrorCallback handler){
localOnErrorContainer.remove(handler);
}
@@ -185,7 +191,7 @@
this.loadSchemaCallback.loadSchema(this, this.requestedInstance, this.requestedTypes);
}catch(Exception e){
- for (IGdlErrorHandler handler : localOnErrorContainer) {
+ for (IOnErrorCallback handler : localOnErrorContainer) {
handler.onError(GdlErrorTypes.LoadError, e);
}
}
@@ -205,7 +211,7 @@
}
this.commitCallback.commitTmConstruct(requestedSchemaTm, TopicMapsTypes.TopicMap);
}catch(Exception e){
- for (IGdlErrorHandler handler : localOnErrorContainer) {
+ for (IOnErrorCallback handler : localOnErrorContainer) {
handler.onError(GdlErrorTypes.CommitError, e);
}
}
@@ -225,11 +231,11 @@
throw new InvalidContentException("The topic map content is not valid:\n" + tmEngine.exportTm(view.getContent()));
}
}catch(InvalidContentException e){
- for (IGdlErrorHandler handler : localOnErrorContainer) {
+ for (IOnErrorCallback handler : localOnErrorContainer) {
handler.onError(GdlErrorTypes.ValidateError, e);
}
} catch(Exception e){
- for (IGdlErrorHandler handler : localOnErrorContainer) {
+ for (IOnErrorCallback handler : localOnErrorContainer) {
handler.onError(GdlErrorTypes.ExecutionError, e);
}
}
@@ -249,7 +255,7 @@
}
this.deleteCallback.deleteTmConstruct(requestedSchemaTm, TopicMapsTypes.TopicMap);
}catch(Exception e){
- for (IGdlErrorHandler handler : localOnErrorContainer) {
+ for (IOnErrorCallback handler : localOnErrorContainer) {
handler.onError(GdlErrorTypes.DeleteError, e);
}
}
@@ -262,7 +268,7 @@
try{
return this.view.getContent();
}catch(Exception e){
- for (IGdlErrorHandler handler : localOnErrorContainer) {
+ for (IOnErrorCallback handler : localOnErrorContainer) {
handler.onError(GdlErrorTypes.TopicMapsGenerationError, e);
}
throw e;
@@ -274,22 +280,60 @@
public void createView(){
try{
// TODO: Implement
- // TODO: register callbacks to the elements with the corresponding id
+
+ for (Pair<ClickHandler, String> item : this.buttonCallbacks) {
+ view.registerButtonCallback(item.getFirst(), item.getSecond());
+ }
}catch(Exception e){
- for (IGdlErrorHandler handler : localOnErrorContainer) {
+ for (IOnErrorCallback handler : localOnErrorContainer) {
handler.onError(GdlErrorTypes.ViewCreationError, e);
}
}
}
+
+ // this method is responsible for registering ClickHandlers of buttons
+ // of the actual view element. If no view exist, the ClickHandlers and ids
+ // are stored until the creation of a view, finally they are registered on the
+ // created view
+ public void registerButtonCallback(ClickHandler handler, String id){
+ if(handler == null || id == null){
+ if(this.view == null){
+ this.buttonCallbacks.add(new Pair<ClickHandler, String>(handler, id));
+ } else {
+ this.view.registerButtonCallback(handler, id);
+ }
+ }
+ }
+
+
+ // this method is responsible for deregistering ClickHandlers of buttons
+ // of the actual view element. If no view exist, the ClickHandlers are removed
+ // from the private stored ClickHandler ArrayList and so they won't be
+ // added when a view is created
+ public void deregisterButtonCallback(ClickHandler handler, String id){
+ if(handler == null || id == null){
+ if(this.view == null){
+ ArrayList<Pair<ClickHandler, String>> toDelete = new ArrayList<Pair<ClickHandler,String>>();
+ for (Pair<ClickHandler, String> item : this.buttonCallbacks) {
+ if(item.getFirst().equals(handler) && item.getSecond().equals(id)){
+ toDelete.add(item);
+ }
+ }
+
+ for(Pair<ClickHandler, String> item : toDelete) {
+ this.buttonCallbacks.remove(item);
+ }
+ } else {
+ this.view.deregisterButtonCallback(handler, id);
+ }
+ }
+ }
+
// remove all content from the main panel
public void clear(){
this.mainPanel.clear();
+ this.buttonCallbacks = new ArrayList<Pair<ClickHandler,String>>();
}
-
-
- // 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
}
Copied and modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IOnErrorCallback.java (from r532, branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IGdlErrorHandler.java)
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IGdlErrorHandler.java Wed Jun 29 14:37:50 2011 (r532, copy source)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IOnErrorCallback.java Thu Jun 30 04:45:04 2011 (r538)
@@ -1,6 +1,6 @@
package us.isidor.gdl.anaToMia.Widgets.environment;
-public interface IGdlErrorHandler {
+public interface IOnErrorCallback {
public void onError(GdlErrorTypes errorType, Exception errorInformation);
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlCreatorAssociationView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlCreatorAssociationView.java Thu Jun 30 03:53:32 2011 (r537)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlCreatorAssociationView.java Thu Jun 30 04:45:04 2011 (r538)
@@ -1,5 +1,7 @@
package us.isidor.gdl.anaToMia.Widgets.views;
+import com.google.gwt.event.dom.client.ClickHandler;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
@@ -48,4 +50,16 @@
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public void registerButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deregisterButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlDefaultCreatorTopicView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlDefaultCreatorTopicView.java Thu Jun 30 03:53:32 2011 (r537)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlDefaultCreatorTopicView.java Thu Jun 30 04:45:04 2011 (r538)
@@ -1,5 +1,7 @@
package us.isidor.gdl.anaToMia.Widgets.views;
+import com.google.gwt.event.dom.client.ClickHandler;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
@@ -48,4 +50,16 @@
return null;
}
+ @Override
+ public void registerButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deregisterButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlDefaultEditorTopicView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlDefaultEditorTopicView.java Thu Jun 30 03:53:32 2011 (r537)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlDefaultEditorTopicView.java Thu Jun 30 04:45:04 2011 (r538)
@@ -1,5 +1,7 @@
package us.isidor.gdl.anaToMia.Widgets.views;
+import com.google.gwt.event.dom.client.ClickHandler;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
@@ -7,7 +9,7 @@
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
-public class GdlDefaultEditorTopicView extends GdlDefaultTopicView {
+public abstract class GdlDefaultEditorTopicView extends GdlDefaultTopicView {
@Override
public String getViewName() {
@@ -47,6 +49,12 @@
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public void registerButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlEditorAssociationView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlEditorAssociationView.java Thu Jun 30 03:53:32 2011 (r537)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlEditorAssociationView.java Thu Jun 30 04:45:04 2011 (r538)
@@ -1,5 +1,7 @@
package us.isidor.gdl.anaToMia.Widgets.views;
+import com.google.gwt.event.dom.client.ClickHandler;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
@@ -48,4 +50,16 @@
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public void registerButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deregisterButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlSpecialCreatorTopicView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlSpecialCreatorTopicView.java Thu Jun 30 03:53:32 2011 (r537)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlSpecialCreatorTopicView.java Thu Jun 30 04:45:04 2011 (r538)
@@ -1,5 +1,7 @@
package us.isidor.gdl.anaToMia.Widgets.views;
+import com.google.gwt.event.dom.client.ClickHandler;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
@@ -47,4 +49,16 @@
return null;
}
+ @Override
+ public void registerButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deregisterButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlSpecialEditorTopicView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlSpecialEditorTopicView.java Thu Jun 30 03:53:32 2011 (r537)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlSpecialEditorTopicView.java Thu Jun 30 04:45:04 2011 (r538)
@@ -1,5 +1,7 @@
package us.isidor.gdl.anaToMia.Widgets.views;
+import com.google.gwt.event.dom.client.ClickHandler;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
@@ -48,4 +50,16 @@
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public void registerButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deregisterButtonCallback(ClickHandler handler, String id) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlView.java Thu Jun 30 03:53:32 2011 (r537)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/views/GdlView.java Thu Jun 30 04:45:04 2011 (r538)
@@ -1,6 +1,7 @@
package us.isidor.gdl.anaToMia.Widgets.views;
import com.google.gwt.core.client.JsArray;
+import com.google.gwt.event.dom.client.ClickHandler;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Name;
@@ -42,6 +43,10 @@
public abstract TopicMap getContent();
+ public abstract void registerButtonCallback(ClickHandler handler, String id);
+
+
+ public abstract void deregisterButtonCallback(ClickHandler handler, String id);
// hierarchy
More information about the Isidorus-cvs
mailing list