[isidorus-cvs] r677 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets: src/us/isidor/gdl/anaToMia/Widgets src/us/isidor/gdl/anaToMia/Widgets/base src/us/isidor/gdl/anaToMia/Widgets/button war/gdl_widgets
lgiessmann at common-lisp.net
lgiessmann at common-lisp.net
Wed Jul 27 12:56:41 UTC 2011
Author: lgiessmann
Date: Wed Jul 27 05:56:40 2011
New Revision: 677
Log:
gdl-frontend: Widgets: implemented the registration of ClickHandlers for buttons
Modified:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt
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/base/TmHelper.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCommitButton.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCreateButton.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlDeleteButton.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlValidateButton.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Wed Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Wed Jul 27 05:56:40 2011 (r677)
@@ -1,7 +1,4 @@
-* Fix GdlActionButton => Text-Attributes
* Implement GdlInfo
-* Implement GdlButton(s)
* Implement TopicMaps data consumption
* Implement TopicMaps data generation
-* ImplementGdlVisibleObject => (de)registerButtonCallback
-* Fix css-pseudo-class-handlers
\ No newline at end of file
+* Fix css-pseudo-class-handlers (=> Buttons)
\ No newline at end of file
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 Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Wed Jul 27 05:56:40 2011 (r677)
@@ -15,7 +15,6 @@
import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes;
import us.isidor.gdl.anaToMia.Widgets.view.GdlDefaultTopicView;
-
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.AbsolutePanel;
@@ -55,7 +54,7 @@
// contains all callbacks that are used as click handlers and the corresponding
// html element id of the button element
- private ArrayList<Pair<String, ClickHandler>> buttonCallbacks = new ArrayList<Pair<String, ClickHandler>>();
+ private static ArrayList<Pair<String, ArrayList<ClickHandler>>> buttonCallbacks = new ArrayList<Pair<String,ArrayList<ClickHandler>>>();
// some constructors
@@ -64,39 +63,48 @@
}
- protected GdlPanel(Pair<String, TopicIdentifierTypes> topicToEdit, ArrayList<Pair<String, TopicIdentifierTypes>> topicToCreate, ArrayList<Pair<String, ClickHandler>> buttonCallbacks) throws ExecutionException{
+ protected GdlPanel(Pair<String, TopicIdentifierTypes> topicToEdit, ArrayList<Pair<String, TopicIdentifierTypes>> topicToCreate) throws ExecutionException{
this();
if(topicToEdit != null)this.requestedTopicToEdit = topicToEdit;
if(topicToCreate != null && topicToCreate.size() != 0)this.requestedTopicsToCreate = topicToCreate;
if(this.requestedTopicsToCreate.size() != 0 && this.requestedTopicToEdit != null)
throw new ExecutionException("only one container can be set, i.e. either topics to create or a topic to edit");
-
- if(buttonCallbacks != null){
- this.buttonCallbacks = buttonCallbacks;
- }
}
- public GdlPanel(Pair<String, TopicIdentifierTypes> topicToEdit, ArrayList<Pair<String, TopicIdentifierTypes>> topicToCreate, ArrayList<Pair<String, ClickHandler>> buttonCallbacks, int width, int height) throws ExecutionException{
- this(topicToEdit, topicToCreate, buttonCallbacks);
+ public GdlPanel(Pair<String, TopicIdentifierTypes> topicToEdit, ArrayList<Pair<String, TopicIdentifierTypes>> topicToCreate, int width, int height) throws ExecutionException{
+ this(topicToEdit, topicToCreate);
this.setPixelSize(width, height);
}
- public GdlPanel(Pair<String, TopicIdentifierTypes> topicToEdit, ArrayList<Pair<String, TopicIdentifierTypes>> topicToCreate, ArrayList<Pair<String, ClickHandler>> buttonCallbacks, String width, String height) throws ExecutionException{
- this(topicToEdit, topicToCreate, buttonCallbacks);
+ public GdlPanel(Pair<String, TopicIdentifierTypes> topicToEdit, ArrayList<Pair<String, TopicIdentifierTypes>> topicToCreate, String width, String height) throws ExecutionException{
+ this(topicToEdit, topicToCreate);
this.setSize(width, height);
}
- public ClickHandler getclickHandler(String id){
- if(id == null) return null;
-
- for (Pair<String, ClickHandler> pair : this.buttonCallbacks)
- if(pair.getFirst().equals(id)) return pair.getSecond();
+ public static ArrayList<ClickHandler> getClickHandlers(String id){
+ for (Pair<String, ArrayList<ClickHandler>> item : GdlPanel.buttonCallbacks)
+ if(item.getFirst().equals(id)) return item.getSecond();
+
+ return new ArrayList<ClickHandler>();
+ }
+
+
+ public static void addClickHandler(String id, ClickHandler handler) throws ExecutionException {
+ if(id == null && handler == null) return;
+ if(id == null || handler == null) throw new ExecutionException("id and handler must be set, but are: " + id + ", " + handler);
- return null;
+ ArrayList<ClickHandler> item = GdlPanel.getClickHandlers(id);
+ if(item.size() == 0){
+ ArrayList<ClickHandler> handlers = new ArrayList<ClickHandler>();
+ handlers.add(handler);
+ GdlPanel.buttonCallbacks.add(new Pair<String, ArrayList<ClickHandler>>(id, handlers));
+ } else{
+ item.add(handler);
+ }
}
@@ -292,6 +300,5 @@
// remove all content from the main panel
public void clear(){
this.mainPanel.clear();
- this.buttonCallbacks = new ArrayList<Pair<String,ClickHandler>>();
}
}
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 Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Wed Jul 27 05:56:40 2011 (r677)
@@ -30,7 +30,13 @@
ArrayList<Pair<String, TopicIdentifierTypes>> requestedTopicsToCreate = new ArrayList<Pair<String,TopicIdentifierTypes>>();
requestedTopicsToCreate.add(new Pair<String, TopicIdentifierTypes>("http://psi.test.org/gdl-test/Poet", TopicIdentifierTypes.SubjectIdentifier));
requestedTopicsToCreate.add(new Pair<String, TopicIdentifierTypes>("http://psi.test.org/gdl-test/Musician", TopicIdentifierTypes.SubjectIdentifier));
- gdlPanel = new GdlPanel(null, requestedTopicsToCreate, null);
+ GdlPanel.addClickHandler("unit_1_text_create_button_id", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ Window.alert("you clicked " + ((Button)event.getSource()).getText());
+ }
+ });
+ gdlPanel = new GdlPanel(null, requestedTopicsToCreate);
mainPanel.add(gdlPanel);
gdlPanel.setTmEngine(new JtmsTmEngine());
gdlPanel.setLoadSchemaCallback(new LoadSchemaCallback());
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Wed Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Wed Jul 27 05:56:40 2011 (r677)
@@ -18,7 +18,6 @@
import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes;
import com.google.gwt.core.client.JsArray;
-import com.google.gwt.user.client.Window;
public class TmHelper {
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java Wed Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java Wed Jul 27 05:56:40 2011 (r677)
@@ -1,9 +1,12 @@
package us.isidor.gdl.anaToMia.Widgets.button;
+import java.util.ArrayList;
+import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Button;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
+import us.isidor.gdl.anaToMia.Widgets.base.GdlPanel;
import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
@@ -24,8 +27,10 @@
public GdlActionButton(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
super(tmRepresentative);
+
// TODO: set all tm values
this.createButton().setText("Action-Button"); // TODO: remove set text
+ this.setClickHandlers();
}
@@ -41,12 +46,19 @@
}
+ protected void setClickHandlers() throws InvalidGdlSchemaException{
+ ArrayList<ClickHandler> handlers = GdlPanel.getClickHandlers(this.getId());
+ if(handlers == null || this.subElements.size() == 0) return;
+
+ for (ClickHandler handler : handlers)
+ ((Button)this.subElements.get(0)).addClickHandler(handler);
+ }
+
// sets the id property of this element by using the GWT DOM class
@Override
public void setId(String id){
- if(id != null && this.subElements.size() != 0){
+ if(id != null && this.subElements.size() != 0)
DOM.setElementProperty(this.subElements.get(0).getElement(), "id", id);
- }
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCommitButton.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCommitButton.java Wed Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCommitButton.java Wed Jul 27 05:56:40 2011 (r677)
@@ -3,6 +3,7 @@
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+import com.google.gwt.user.client.ui.Button;
public class GdlCommitButton extends GdlActionButton {
// TODO: implement
@@ -14,7 +15,6 @@
public GdlCommitButton(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
super(tmRepresentative);
- // TODO: set all tm values
- this.createButton().setText("commit");
+ ((Button)this.subElements.get(0)).setText("commit");
}
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCreateButton.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCreateButton.java Wed Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCreateButton.java Wed Jul 27 05:56:40 2011 (r677)
@@ -3,6 +3,7 @@
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+import com.google.gwt.user.client.ui.Button;
public class GdlCreateButton extends GdlActionButton {
// TODO: implement
@@ -14,7 +15,6 @@
public GdlCreateButton(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
super(tmRepresentative);
- // TODO: set all tm values
- this.createButton().setText("create");
+ ((Button)this.subElements.get(0)).setText("create");
}
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlDeleteButton.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlDeleteButton.java Wed Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlDeleteButton.java Wed Jul 27 05:56:40 2011 (r677)
@@ -1,6 +1,8 @@
package us.isidor.gdl.anaToMia.Widgets.button;
+import com.google.gwt.user.client.ui.Button;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
@@ -15,7 +17,6 @@
public GdlDeleteButton(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
super(tmRepresentative);
- // TODO: set all tm values
- this.createButton().setText("delete");
+ ((Button)this.subElements.get(0)).setText("delete");
}
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlValidateButton.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlValidateButton.java Wed Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlValidateButton.java Wed Jul 27 05:56:40 2011 (r677)
@@ -1,5 +1,7 @@
package us.isidor.gdl.anaToMia.Widgets.button;
+import com.google.gwt.user.client.ui.Button;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
@@ -14,7 +16,6 @@
public GdlValidateButton(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
super(tmRepresentative);
- // TODO: set all tm values
- this.createButton().setText("validate");
+ ((Button)this.subElements.get(0)).setText("validate");
}
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm Wed Jul 27 04:07:48 2011 (r676)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm Wed Jul 27 05:56:40 2011 (r677)
@@ -75,8 +75,8 @@
{"subject_identifiers":["[doc:title-1]"], "instance_of":["si:[gdl:Title]"], "occurrences":[{"type":"si:[gdl:id]", "value":"title_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:text-decoration]", "value":"underline"}, {"type":"si:[gdl:background-color]", "value":"#ccc"}, {"type":"si:[gdl:font-weight]", "value":"bold"}]},
{"subject_identifiers":["[doc:unit-1-reference]"], "instance_of":["si:[gdl:Reference]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_reference_id"},{"type":"si:[gdl:float]", "value":"left"}]},
{"subject_identifiers":["[doc:unit-1-text]"], "instance_of":["si:[gdl:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_text_id"}, {"type":"si:[gdl:clear]","value":"right"}]},
- {"subject_identifiers":["[doc:unit-1-text-delete-button]"], "instance_of":["si:[gdl:Delete-Button]"], "occurrences":[{"type":"si:[gdl:id]","value":"unit_1_text_delete_button"}, {"type":"si:[gdl:font-size]", "value":"8px"}]},
- {"subject_identifiers":["[doc:unit-1-text-create-button]"], "instance_of":["si:[gdl:Create-Button]"], "occurrences":[{"type":"si:[gdl:id]","value":"unit_1_text_create_button"}, {"type":"si:[gdl:font-size]", "value":"8px"}]},
+ {"subject_identifiers":["[doc:unit-1-text-delete-button]"], "instance_of":["si:[gdl:Delete-Button]"], "occurrences":[{"type":"si:[gdl:id]","value":"unit_1_text_delete_button_id"}, {"type":"si:[gdl:font-size]", "value":"8px"}]},
+ {"subject_identifiers":["[doc:unit-1-text-create-button]"], "instance_of":["si:[gdl:Create-Button]"], "occurrences":[{"type":"si:[gdl:id]","value":"unit_1_text_create_button_id"}, {"type":"si:[gdl:font-size]", "value":"8px"}]},
{"subject_identifiers":["[doc:pos-of-unit-1-reference]"], "instance_of":["si:[gdl:Position]"]},
{"subject_identifiers":["[doc:pos-of-unit-1-radio-button]"], "instance_of":["si:[gdl:Position]"]},
{"subject_identifiers":["[doc:pos-of-unit-1-check-box]"], "instance_of":["si:[gdl:Position]"]},
More information about the Isidorus-cvs
mailing list