[isidorus-cvs] r907 - branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Thu Sep 15 11:26:18 UTC 2011


Author: lgiessmann
Date: Thu Sep 15 04:26:17 2011
New Revision: 907

Log:
gdl-frontend: Widgets: implemented a click handler that creates a GdlPanel when clicking on a psi

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/HashObjectUi.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/PsiContainer.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/HashObjectUi.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/HashObjectUi.java	Thu Sep 15 01:58:58 2011	(r906)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/HashObjectUi.java	Thu Sep 15 04:26:17 2011	(r907)
@@ -1,7 +1,17 @@
 package us.isidor.gdl.anaToMia.Widgets.isidorus;
 
 
+import us.isidor.gdl.anaToMia.TmEngine.jtmsBasedEngine.JtmsTmEngine;
+import us.isidor.gdl.anaToMia.Widgets.base.GdlPanel;
+import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
+import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
+import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes;
+
 import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.TextAreaElement;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.http.client.Request;
 import com.google.gwt.http.client.RequestBuilder;
 import com.google.gwt.http.client.RequestCallback;
@@ -12,9 +22,11 @@
 import com.google.gwt.json.client.JSONParser;
 import com.google.gwt.json.client.JSONString;
 import com.google.gwt.json.client.JSONValue;
+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.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.VerticalPanel;
 
@@ -23,12 +35,19 @@
 	private HorizontalPanel mainPanel = new HorizontalPanel();
 	private VerticalPanel navigationPanel = new VerticalPanel();
 	private Button createNewButton = new Button("create new");
-	private PsiContainer psiContainer = new PsiContainer();
-	//private Image textGridLogo = new Image(IsidorusConstants.TEXTGRID_LOGO_URL);
+	private PsiContainer psiContainer = null;
+	private GdlPanel gdlPanel = null;
 	
 	
 	@Override
 	public void onModuleLoad() {
+		try{
+			this.psiContainer = new PsiContainer(new PsiClickHandler());
+		}catch(ExecutionException e){
+			Window.alert("could not create web page, becuase: (" + e.getClass() + ") " + e.getMessage());
+			this.resetPage();
+		}
+		
 		RootPanel.get("GWT_Content").add(this.mainPanel);
 		mainPanel.add(this.navigationPanel);
 		mainPanel.setBorderWidth(1);
@@ -46,6 +65,7 @@
 		}catch(RequestException e){
 			e.printStackTrace();
 			Window.alert("could not request existing instances of http://textgrid.org/serviceregistry/model/types/Hash-Object, because(" + e.getClass() + "): " + e.getMessage());
+			HashObjectUi.this.resetPage();
 		}
 	}
 	
@@ -56,6 +76,42 @@
 	
 	
 	
+	private class PsiClickHandler implements ClickHandler {
+		@Override
+		public void onClick(ClickEvent event) {
+			Object obj = event.getSource();
+			if(obj instanceof Label){
+				Label source = (Label)obj;				
+				try{
+					GdlPanel.addClickHandler("hash_object_reset_button_id", new ResetClickHandler());
+					if(HashObjectUi.this.gdlPanel != null) HashObjectUi.this.gdlPanel.removeFromParent();
+					HashObjectUi.this.gdlPanel = new GdlPanel(new Pair<String, TopicIdentifierTypes>(source.getText(), TopicIdentifierTypes.SubjectIdentifier), null, 400, 400);
+					HashObjectUi.this.mainPanel.add(gdlPanel);
+					gdlPanel.setTmEngine(new JtmsTmEngine());
+					gdlPanel.setLoadSchemaCallback(new LoadSchemaCallback());
+					gdlPanel.setCommitCallback(new CommitCallback());
+					gdlPanel.setDeleteCallback(new DeleteCallback());
+					gdlPanel.loadSchema();
+				}catch(Exception e){
+					e.printStackTrace();
+					Window.alert("could not instantiate the GdlPanel, because(" + e.getClass() + "): " + e.getMessage());
+					HashObjectUi.this.resetPage();	
+				}
+			}
+		}
+	}
+	
+	
+	
+	private class ResetClickHandler implements ClickHandler {
+		@Override
+		public void onClick(ClickEvent event) {
+			Element elem = DOM.getElementById("hash_object_text_key_id__GDL_0");
+			((TextAreaElement)elem).setValue("");
+			elem = DOM.getElementById("hash_object_text_value_id__GDL_0");
+			((TextAreaElement)elem).setValue("");
+		}
+	}
 	
 	
 	

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/PsiContainer.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/PsiContainer.java	Thu Sep 15 01:58:58 2011	(r906)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/PsiContainer.java	Thu Sep 15 04:26:17 2011	(r907)
@@ -1,6 +1,10 @@
 package us.isidor.gdl.anaToMia.Widgets.isidorus;
 
 import java.util.ArrayList;
+
+import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
+
+import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.json.client.JSONString;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.Panel;
@@ -11,9 +15,13 @@
 public class PsiContainer {
 	private ArrayList<Label> psiLabels = new ArrayList<Label>();
 	private VerticalPanel containerPanel = new VerticalPanel();
+	private ClickHandler lblClickHandler = null;
 	
 	
-	public PsiContainer(){}
+	public PsiContainer(ClickHandler labelClikcHandler) throws ExecutionException{
+		if(labelClikcHandler == null) throw new ExecutionException("labelClickHandler must not be null");
+		this.lblClickHandler = labelClikcHandler;
+	}
 	
 	
 	public void addPsi(String psi){
@@ -31,6 +39,7 @@
 			}
 		}
 		if(widgetIdx == this.containerPanel.getWidgetCount()) this.containerPanel.add(lbl);
+		if(this.lblClickHandler != null)lbl.addClickHandler(this.lblClickHandler);
 	}
 	
 	




More information about the Isidorus-cvs mailing list