diff --git a/AlgebraicDataflowArchitectureModel/src/simulator/interfaces/html/HtmlPresenter.java b/AlgebraicDataflowArchitectureModel/src/simulator/interfaces/html/HtmlPresenter.java index b6fa822..796a0e7 100644 --- a/AlgebraicDataflowArchitectureModel/src/simulator/interfaces/html/HtmlPresenter.java +++ b/AlgebraicDataflowArchitectureModel/src/simulator/interfaces/html/HtmlPresenter.java @@ -26,6 +26,7 @@ protected DataTransferChannel setVisibleChannel; protected DataTransferChannel mouseEventChannel; protected DataTransferChannel textEventChannel; + protected Map> channelAndResourcesForReceiving = new HashMap<>();// ??? protected Map elements; @@ -34,18 +35,16 @@ this.simulator = simulator; screenUpdateChannel = (DataTransferChannel) simulator.getModel().getChannel(screenUpdateChannelName); setVisibleChannel = (DataTransferChannel) simulator.getModel().getChannel(setVisibleChannelName); - mouseEventChannel = (DataTransferChannel) simulator.getModel().getChannel(mouseEventChannelName); - textEventChannel = (DataTransferChannel) simulator.getModel().getChannel(textEventChannelName); + mouseEventChannel = (DataTransferChannel) simulator.getModel().getInputChannel(mouseEventChannelName); + textEventChannel = (DataTransferChannel) simulator.getModel().getInputChannel(textEventChannelName); simulator.addNativeReceiver(this, screenUpdateChannel); + + elements = new HashMap<>(); } @Override public void onReceiveFromModel(Event event) { - //websocketでjavascriptにinsertAdjacentHTMLを実行するように指示するのが簡単そう - //どうやってwebsocketを送るようにサーバーに指示するかが微妙 - //websocketのインスタンスをもらってきて送るみたいな? - //Javaでhtmlのエレメントをどう扱うかも考える必要がありそう - //エレメントを表すクラスが必要? + //画面遷移するときに呼ばれそう Expression message = event.getMessage(); @@ -63,8 +62,10 @@ JsonTerm screenContent = (JsonTerm) message; //受け取ったmessageをjsonとして扱う Resource screenResource = simulator.getCurState().getResource(event.getInputResource().getResourceIdentifier()); //出力チャンネルに接続されたresourceを取得? - Expression widgets = screenContent.get("\"widgets\""); //json化したmessageから"widgets"を取得 - Resource widgetsResource = screenResource.getChildrenMap().get("\"widgets\"");//??? + Expression widgets = screenContent.get("widgets"); //json化したmessageから"widgets"を取得 + Resource widgetsResource = screenResource.getChildrenMap().get("widgets");//??? + + elements.clear(); if(widgets instanceof MapTerm) { for(String key : ((MapTerm) widgets).keySet()) { // keyはなに? どうやって決められる? @@ -73,11 +74,11 @@ JsonTerm widget = (JsonTerm) value; //jsonとして扱えるように Resource widgetResouce = widgetsResource.getChildrenMap().get(key); //??? Expression type = widget.get("\"type\""); //widgetのtypeを取得 - if(type.toString().equals("button")) { + if(type.toString().equals("\"button\"")) { //こんな感じになりそう Expression text = widget.get("\"text\""); - HtmlElement button = new HtmlElement(type.toString(), key, text.toString()); + HtmlElement button = new HtmlElement(type.toString(), key, text.toString().replace("\"", "")); elements.put(key, button); //ボタンが押された時の処理 @@ -97,7 +98,7 @@ } else if(type.toString().equals("label")) { Expression text = widget.get("\"text\""); - HtmlElement elem = new HtmlElement(type.toString(), key, text.toString()); + HtmlElement elem = new HtmlElement(type.toString(), key, text.toString().replace("\"", "")); elements.put(key, elem); } else if(type.toString().equals("inputText")) {