Author: lgiessmann Date: Mon Sep 12 06:17:58 2011 New Revision: 875
Log: gdl-frontend: Widgets: changed the behavior of the commit callback
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/GdlDeleteButton.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ICommitCallback.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java
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 Mon Sep 12 05:59:41 2011 (r874) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCommitButton.java Mon Sep 12 06:17:58 2011 (r875) @@ -7,9 +7,6 @@ import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; import us.isidor.gdl.anaToMia.Widgets.environment.ICommitCallback; import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; -import us.isidor.gdl.anaToMia.Widgets.view.GdlAssociationView; -import us.isidor.gdl.anaToMia.Widgets.view.GdlTopicView; - import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; @@ -31,17 +28,6 @@ } - public void resetCarriers(){ - GdlVisibleObject parent = this.getGdlParent(); - - while(parent != null){ - if(parent instanceof GdlTopicView)((GdlTopicView)parent).resetRepresentedTopic(); - if(parent instanceof GdlAssociationView)((GdlAssociationView)parent).resetRepresentedAssociations(); - parent = parent.getGdlParent(); - } - } - - protected class CommitButtonClickHandler implements ClickHandler { public CommitButtonClickHandler() { } @@ -51,7 +37,7 @@ try{ ICommitCallback callback = GdlCommitButton.this.getRoot().getCommitCallback(); - callback.commitTmConstruct(GdlCommitButton.this.getGdlParent().getContent(null, true), GdlCommitButton.this, GdlCommitButton.this.getRoot().getTmEngine()); + callback.commitTmConstruct(GdlCommitButton.this.getGdlParent().getContent(null, true), GdlCommitButton.this.getId(), GdlCommitButton.this.getRoot().getTmEngine()); }catch(Exception e){ e.printStackTrace(); Window.alert("caught: " + e.getMessage());
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 Mon Sep 12 05:59:41 2011 (r874) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlDeleteButton.java Mon Sep 12 06:17:58 2011 (r875) @@ -10,8 +10,6 @@ import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; import us.isidor.gdl.anaToMia.Widgets.environment.IDeleteCallback; import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; -import us.isidor.gdl.anaToMia.Widgets.view.GdlAssociationView; -import us.isidor.gdl.anaToMia.Widgets.view.GdlTopicView;
public class GdlDeleteButton extends GdlActionButton { // TODO: implement @@ -28,17 +26,6 @@ } - public void resetCarriers(){ - GdlVisibleObject parent = this.getGdlParent(); - - while(parent != null){ - if(parent instanceof GdlTopicView)((GdlTopicView)parent).resetRepresentedTopic(); - if(parent instanceof GdlAssociationView)((GdlAssociationView)parent).resetRepresentedAssociations(); - parent = parent.getGdlParent(); - } - } - - protected class DeleteButtonClickHandler implements ClickHandler { private GdlDeleteButton owner = null;
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ICommitCallback.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ICommitCallback.java Mon Sep 12 05:59:41 2011 (r874) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ICommitCallback.java Mon Sep 12 06:17:58 2011 (r875) @@ -5,9 +5,9 @@ import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; -import us.isidor.gdl.anaToMia.Widgets.button.GdlCommitButton; +
public interface ICommitCallback { - public void commitTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, GdlCommitButton sender, TmEngine tmEngine); + public void commitTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, String buttonId, TmEngine tmEngine); }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java Mon Sep 12 05:59:41 2011 (r874) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java Mon Sep 12 06:17:58 2011 (r875) @@ -3,7 +3,6 @@ import java.util.ArrayList; import us.isidor.gdl.anaToMia.Widgets.base.PSIs; import us.isidor.gdl.anaToMia.Widgets.base.TmHelper; -import us.isidor.gdl.anaToMia.Widgets.button.GdlCommitButton; import us.isidor.gdl.anaToMia.Widgets.environment.Pair; import com.google.gwt.core.client.JsArray; import com.google.gwt.http.client.Request; @@ -38,13 +37,12 @@ @Override - public void commitTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, GdlCommitButton sender, TmEngine tmEngine) { + public void commitTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, String buttonId, TmEngine tmEngine) { try{ - String buttonId = sender == null ? null : sender.getId(); if("hash_object_commit_button_id".equals(buttonId)){ this.commitCreatedHashObject(constructs, tmEngine, "edited_hash_object_commit_button_id".equals(buttonId)); } else if("environment_commit_button_id".equals(buttonId)){ - this.commitCreatedEnvironment(constructs, sender, tmEngine); + this.commitCreatedEnvironment(constructs, tmEngine); } }catch(Exception e){ Window.alert("failed to commit the Topic Maps data, because: " + e.getMessage()); @@ -52,7 +50,7 @@ } - private void commitCreatedEnvironment(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, GdlCommitButton sender, TmEngine tmEngine) throws ExporterException { + private void commitCreatedEnvironment(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine) throws ExporterException { final String carrierPsi = PSIs.GDL.gdl + "environment_default_creator_topic_view_id"; ArrayList<Topic> topics = new ArrayList<Topic>(); ArrayList<TopicMap> topicMaps = new ArrayList<TopicMap>(); @@ -73,11 +71,16 @@ } else if(topics.size() != 0){ tm = topics.get(0).getTopicMap(); - top = topics.get(0); + top = topics.get(0); carrierLocator = tm.createLocator(carrierPsi); } if(top != null){ + // remove old psis + JsArray<Locator> psis = top.getSubjectIdentifiers(); + for(int i = 0; i != psis.length(); ++i)top.removeSubjectIdentifier(psis.get(i)); + + // set the new vaid psi Name envName = top.getNames().get(0); Locator psi = tm.createLocator("http://textgrid.org/serviceregistry/environment/" + envName.getValue()); top.removeSubjectIdentifier(carrierLocator); @@ -96,7 +99,7 @@ try{ // a check for an existing environment topic is not necessary, // since it would be exactly the same topic. - builder.sendRequest(jtm, new EnvironmentCommitRequest(jtm, sender)); + builder.sendRequest(jtm, new EnvironmentCommitRequest(jtm)); }catch(RequestException e){ Window.alert("could not commit the topic: " + jtm + ", because(" + e.getClass() + "): " + e.getMessage()); } @@ -177,16 +180,14 @@ private class EnvironmentCommitRequest implements RequestCallback { private String objectToBeSend = null; - private GdlCommitButton sender = null; @SuppressWarnings("unused") private EnvironmentCommitRequest(){} - public EnvironmentCommitRequest(String objectToBeCommitted, GdlCommitButton sender){ + public EnvironmentCommitRequest(String objectToBeCommitted){ this.objectToBeSend = objectToBeCommitted; - this.sender = sender; } @@ -194,7 +195,6 @@ public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { Window.alert("commit operation of the object " + this.objectToBeSend + " succeeded"); - this.sender.resetCarriers(); // TODO: reset the web page } else { Window.alert("commit operation of the object " + this.objectToBeSend + " failed: " + response.getStatusCode() + "(" + response.getStatusText() + ")\n" + response.getText());
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Mon Sep 12 05:59:41 2011 (r874) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Mon Sep 12 06:17:58 2011 (r875) @@ -47,17 +47,6 @@ super(tmRepresentative, receivedData, gdlParent); } - - public void resetRepresentedAssociations(){ - for (Widget ctrl : this.subElements) { - if(ctrl instanceof ButtonableObject){ - if(((ButtonableObject)ctrl).getMainObject() instanceof AssociationItem){ - ((AssociationItem)((ButtonableObject)ctrl).getMainObject()).resetRepresentedAssociation(); - } - } - } - } - // content orientation has no effect on a view, so here must the original method // defined in GdlVisibleObject implemented @Override @@ -264,14 +253,6 @@ } - // can be called to set the represented topic to null, e.g. - // if a created association was submitted and a new association is created, - // so the old carrier is reset as well - public void resetRepresentedAssociation(){ - this.representedAssociation = null; - } - - @SuppressWarnings("unused") private AssociationItem(){ super();
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java Mon Sep 12 05:59:41 2011 (r874) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java Mon Sep 12 06:17:58 2011 (r875) @@ -224,12 +224,4 @@ return (Topic)this.receivedData; } } - - - // can be called to set the represented topic to null, e.g. - // if a created topic was submitted and a new topic is created, - // so the old carrier is reset as well - public void resetRepresentedTopic(){ - this.representedTopic = null; - } }