Author: lgiessmann Date: Thu Sep 15 04:50:43 2011 New Revision: 908
Log: gdl-frontend: Widgets: implemented a click handler that creates a GdlPanel when clicking on the "create new" button
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/IsidorusConstants.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 04:26:17 2011 (r907) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/HashObjectUi.java Thu Sep 15 04:50:43 2011 (r908) @@ -1,6 +1,8 @@ package us.isidor.gdl.anaToMia.Widgets.isidorus;
+import java.util.ArrayList; + import us.isidor.gdl.anaToMia.TmEngine.jtmsBasedEngine.JtmsTmEngine; import us.isidor.gdl.anaToMia.Widgets.base.GdlPanel; import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; @@ -42,8 +44,10 @@ @Override public void onModuleLoad() { try{ + GdlPanel.addClickHandler("hash_object_reset_button_id", new ResetClickHandler()); this.psiContainer = new PsiContainer(new PsiClickHandler()); - }catch(ExecutionException e){ + this.createNewButton.addClickHandler(new CreateNewClickHandler()); + }catch(Exception e){ Window.alert("could not create web page, becuase: (" + e.getClass() + ") " + e.getMessage()); this.resetPage(); } @@ -75,6 +79,28 @@ } + private class CreateNewClickHandler implements ClickHandler { + @Override + public void onClick(ClickEvent event) { + try{ + if(HashObjectUi.this.gdlPanel != null) HashObjectUi.this.gdlPanel.removeFromParent(); + ArrayList<Pair<String, TopicIdentifierTypes>> topicsToCreate = new ArrayList<Pair<String, TopicIdentifierTypes>>(); + topicsToCreate.add(new Pair<String, TopicIdentifierTypes>(IsidorusConstants.HASH_OBJECT_PSI, TopicIdentifierTypes.SubjectIdentifier)); + HashObjectUi.this.gdlPanel = new GdlPanel(null, topicsToCreate, 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 PsiClickHandler implements ClickHandler { @Override @@ -83,7 +109,6 @@ 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); @@ -102,7 +127,6 @@ } - private class ResetClickHandler implements ClickHandler { @Override public void onClick(ClickEvent event) { @@ -114,7 +138,6 @@ } - private class PsiRequest implements RequestCallback { public PsiRequest(){}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/IsidorusConstants.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/IsidorusConstants.java Thu Sep 15 04:26:17 2011 (r907) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/IsidorusConstants.java Thu Sep 15 04:50:43 2011 (r908) @@ -9,6 +9,8 @@ public class IsidorusConstants { public final static String XSD_STRING = "http://www.w3.org/2001/XMLSchema#string"; public final static String TOPIC_MAP_IDENTIFIER = "http://textgrid.org/serviceregistry/gdl-frontend/gdl-tm"; + public final static String HASH_OBJECT_PSI = "http://textgrid.org/serviceregistry/model/types/Hash-Object"; + public final static String ENVIRONMENT_PSI = "http://textgrid.org/serviceregistry/model/types/Environment"; public final static String DELETE_REQUEST_URL = Window.Location.getProtocol() + "//" + Window.Location.getHost() + "/gdl/delete"; public final static String COMMIT_REQUEST_URL = Window.Location.getProtocol() + "//" + Window.Location.getHost() + "/gdl/commit"; public final static String GET_FRAGMENT_REQUEST_URL = Window.Location.getProtocol() + "//" + Window.Location.getHost() + "/gdl/fragment/";