diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/DeleteAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/DeleteAction.java index 4470a7f..1ac8a47 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/DeleteAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/DeleteAction.java @@ -17,7 +17,7 @@ @Override public void actionPerformed(ActionEvent e) { - + editor.delete(); } } diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/JavaPrototypeGenerateAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/JavaPrototypeGenerateAction.java index 78a39ac..53939bd 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/JavaPrototypeGenerateAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/JavaPrototypeGenerateAction.java @@ -39,6 +39,7 @@ ModelExtension.extendModel(model); TypeInference.infer(graph, model); String fileName = editor.getCurFileName(); + if (fileName == null) fileName = "Main"; String mainTypeName = fileName.split("\\.")[0]; boolean exist = false; for (IdentifierTemplate id: model.getIdentifierTemplates()) { diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/JerseyPrototypeGenerateAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/JerseyPrototypeGenerateAction.java index 0236d5d..dfa7a57 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/JerseyPrototypeGenerateAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/JerseyPrototypeGenerateAction.java @@ -40,6 +40,7 @@ ModelExtension.extendModel(model); TypeInference.infer(graph, model); String fileName = editor.getCurFileName(); + if (fileName == null) fileName = "Main"; String mainTypeName = fileName.split("\\.")[0]; boolean exist = false; for (IdentifierTemplate id: model.getIdentifierTemplates()) { diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewChannelAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewChannelAction.java index 153ebdf..9d8f747 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewChannelAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewChannelAction.java @@ -4,13 +4,8 @@ import javax.swing.JOptionPane; -import algorithms.NecessityOfStoringResourceStates; -import algorithms.SelectableDataTransfers; import graphicalrefactor.editor.Editor; -import models.dataConstraintModel.ChannelGenerator; -import models.dataFlowModel.DataFlowModel; import models.dataFlowModel.DataflowChannelGenerator; -import models.dataFlowModel.ResourceDependencyGraph; public class NewChannelAction extends AbstractEditorAction { @@ -20,7 +15,7 @@ private static final long serialVersionUID = 5979007029473101802L; public NewChannelAction(Editor editor) { - super("New Channel...", editor); + super("Channel...", editor); } @Override diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewIOChannelAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewIOChannelAction.java index 06f828d..7e2c884 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewIOChannelAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewIOChannelAction.java @@ -4,12 +4,9 @@ import javax.swing.JOptionPane; -import algorithms.NecessityOfStoringResourceStates; -import algorithms.SelectableDataTransfers; + import graphicalrefactor.editor.Editor; -import models.dataFlowModel.DataFlowModel; import models.dataFlowModel.DataflowChannelGenerator; -import models.dataFlowModel.ResourceDependencyGraph; public class NewIOChannelAction extends AbstractEditorAction { @@ -19,7 +16,7 @@ private static final long serialVersionUID = -1657072017390171313L; public NewIOChannelAction(Editor editor) { - super("New I/O Channel", editor); + super("I/O Channel", editor); } @Override diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewResourceAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewResourceAction.java index cb24554..600daf7 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewResourceAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewResourceAction.java @@ -4,12 +4,8 @@ import javax.swing.JOptionPane; -import algorithms.NecessityOfStoringResourceStates; -import algorithms.SelectableDataTransfers; import graphicalrefactor.editor.Editor; import models.dataConstraintModel.IdentifierTemplate; -import models.dataFlowModel.DataFlowModel; -import models.dataFlowModel.ResourceDependencyGraph; public class NewResourceAction extends AbstractEditorAction { @@ -19,7 +15,7 @@ private static final long serialVersionUID = -4439207504700741286L; public NewResourceAction(Editor editor) { - super("New Resource...", editor); + super("Resource...", editor); } @Override diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAction.java index 118f37a..0d503de 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAction.java @@ -2,22 +2,23 @@ import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; +import graphicalrefactor.editor.Editor; -public class SaveAction extends AbstractAction { +public class SaveAction extends AbstractEditorAction { /** * */ private static final long serialVersionUID = 5660460585305281982L; - public SaveAction() { - super("Save"); + public SaveAction(Editor editor) { + super("Save", editor); } @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - + if (editor != null && editor.getCurFileName() != null) { + editor.save(); + } } } diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/editor/Editor.java index 34d3d66..9683074 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/editor/Editor.java @@ -4,6 +4,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -24,6 +26,7 @@ import algorithms.UpdateConflictCheck; import code.ast.CompilationUnit; import models.Edge; +import models.EdgeAttribute; import models.Node; import models.dataConstraintModel.ChannelGenerator; import models.dataConstraintModel.ChannelMember; @@ -54,6 +57,7 @@ private mxGraph graph = null; private String curFileName = null; + private String curFilePath = null; private DataFlowModel model = null; private ResourceDependencyGraph resourceDependencyGraph = null; private ArrayList codes = null; @@ -87,6 +91,7 @@ public ResourceDependencyGraph updateResourceDependencyGraph(DataFlowModel model) { ResourceDependencyGraph resourceGraph = NecessityOfStoringResourceStates.doDecide(model); resourceDependencyGraph = SelectableDataTransfers.init(resourceGraph); + updateEdgeAttiributes(resourceDependencyGraph); return resourceDependencyGraph; } @@ -107,11 +112,26 @@ } public String getCurFileName() { - if (curFileName == null) { - curFileName = "notitle"; - } return curFileName; } + + public String getCurFilePath() { + return curFilePath; + } + + public void setCurFilePath(String curFilePath) { + this.curFilePath = curFilePath; + this.curFileName = new File(curFilePath).getName(); + } + + public void clear() { + model = null; + ((mxGraphModel) graph.getModel()).clear(); + resourceDependencyGraph = null; + curFilePath = null; + curFileName = null; + codes = null; + } /** * Open a given file, parse the file, construct a DataFlowModel and a mxGraph @@ -123,9 +143,11 @@ Parser parser = new Parser(new BufferedReader(new FileReader(file))); try { model = parser.doParse(); + curFilePath = file.getAbsolutePath(); curFileName = file.getName(); if (!UpdateConflictCheck.run(model)) return null; - graph = constructGraph(model, updateResourceDependencyGraph(model)); + graph = constructGraph(model); + updateResourceDependencyGraph(model); return model; } catch (ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression @@ -137,6 +159,19 @@ } return null; } + + public void save() { + if (curFilePath != null) { + try { + File file = new File(curFilePath); + FileWriter filewriter = new FileWriter(file); + filewriter.write(model.toString()); + filewriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } /** * Construct a mxGraph from DataFlowModel and DataFlowModel @@ -144,7 +179,7 @@ * @param resourceDependencyGraph * @return constructed mxGraph */ - public mxGraph constructGraph(DataFlowModel model, ResourceDependencyGraph resourceDependencyGraph) { + public mxGraph constructGraph(DataFlowModel model) { ((mxGraphModel) graph.getModel()).clear(); Object parent = graph.getDefaultParent(); graph.getModel().beginUpdate(); @@ -160,9 +195,6 @@ Map channelsIn = new HashMap<>(); Map channelsOut = new HashMap<>(); Map resources = new HashMap<>(); - Map> resourceToChannels = new HashMap<>(); - Map> channelToResources = new HashMap<>(); - Set refEdgeCreated = new HashSet<>(); // create channel vertices for (ChannelGenerator c: model.getChannelGenerators()) { @@ -189,42 +221,19 @@ } // add input, output and reference edges - for (Edge e : resourceDependencyGraph.getEdges()) { - if (e instanceof ResourceDependency) { - ResourceDependency dependency = (ResourceDependency) e; - DataflowChannelGenerator channelGen = dependency.getChannelGenerator(); - ResourceNode srcResource = (ResourceNode) dependency.getSource(); - ResourceNode dstResource = (ResourceNode) dependency.getDestination(); - // input edge - Map resToChannelEdges = resourceToChannels.get(srcResource); - if (resToChannelEdges == null) { - resToChannelEdges = new HashMap<>(); - resourceToChannels.put(srcResource, resToChannelEdges); - } - if (resToChannelEdges.get(channelGen) == null) { - mxCell edge = (mxCell) graph.insertEdge(parent, null, dependency.getAttribute(), resources.get(srcResource.getIdentifierTemplate()), channelsIn.get(channelGen), "movable=false"); - resToChannelEdges.put(channelGen, edge); - } else { - mxCell edge = resToChannelEdges.get(channelGen); - ((PushPullAttribute) edge.getValue()).intersectOptions(((PushPullAttribute) dependency.getAttribute()).getOptions()); - } - // output edge - Set resSet = channelToResources.get(channelGen); - if (resSet == null) { - resSet = new HashSet<>(); - channelToResources.put(channelGen, resSet); - } - if (!resSet.contains(dstResource)) { - graph.insertEdge(parent, null, null, channelsOut.get(channelGen), resources.get(dstResource.getIdentifierTemplate()), "movable=false"); - resSet.add(dstResource); - } - // reference edges - if (!refEdgeCreated.contains(channelGen)) { - refEdgeCreated.add(channelGen); - for (IdentifierTemplate refRes: channelGen.getReferenceIdentifierTemplates()) { - mxCell edge = (mxCell) graph.insertEdge(parent, null, null, resources.get(refRes), channelsIn.get(channelGen), "dashed=true;movable=false"); - } - } + for (ChannelGenerator ch: model.getChannelGenerators()) { + DataflowChannelGenerator channelGen = (DataflowChannelGenerator) ch; + // input edge + for (IdentifierTemplate srcRes: channelGen.getInputIdentifierTemplates()) { + graph.insertEdge(parent, null, new SrcDstAttribute(srcRes, channelGen), resources.get(srcRes), channelsIn.get(channelGen), "movable=false"); + } + // output edge + for (IdentifierTemplate dstRes: channelGen.getOutputIdentifierTemplates()) { + graph.insertEdge(parent, null, new SrcDstAttribute(channelGen, dstRes), channelsOut.get(channelGen), resources.get(dstRes), "movable=false"); + } + // reference edges + for (IdentifierTemplate refRes: channelGen.getReferenceIdentifierTemplates()) { + graph.insertEdge(parent, null, null, resources.get(refRes), channelsIn.get(channelGen), "dashed=true;movable=false"); } } @@ -247,6 +256,35 @@ return graph; } + + public void updateEdgeAttiributes(ResourceDependencyGraph resourceDependencyGraph) { + Object parent = graph.getDefaultParent(); + graph.getModel().beginUpdate(); + try { + // add input, output and reference edges + for (Edge e : resourceDependencyGraph.getEdges()) { + if (e instanceof ResourceDependency) { + ResourceDependency dependency = (ResourceDependency) e; + DataflowChannelGenerator channelGen = dependency.getChannelGenerator(); + ResourceNode srcRes = (ResourceNode) dependency.getSource(); + // input edge + for (Object edge: graph.getChildEdges(parent)) { + mxCell edgeCell = (mxCell) edge; + if (edgeCell.getValue() instanceof SrcDstAttribute) { + SrcDstAttribute edgeAttr = (SrcDstAttribute) edgeCell.getValue(); + if (edgeAttr.getSrouce() == srcRes.getIdentifierTemplate() && edgeAttr.getDestination() == channelGen) { + edgeCell.setValue(dependency.getAttribute()); + break; + } + } + } + } + } + } finally { + graph.getModel().endUpdate(); + } + graph.refresh(); + } public void setTreeLayout() { Object parent = graph.getDefaultParent(); @@ -331,7 +369,7 @@ } } - public boolean connectEdge(mxCell src, mxCell dst) { + public boolean connectEdge(mxCell edge, mxCell src, mxCell dst) { DataFlowModel model = getModel(); ChannelGenerator srcCh = model.getChannelGenerator((String) src.getValue()); if (srcCh == null) { @@ -340,19 +378,56 @@ IdentifierTemplate srcRes = model.getIdentifierTemplate((String) src.getValue()); ChannelGenerator dstCh = model.getChannelGenerator((String) dst.getValue()); if (srcRes == null || dstCh == null) return false; + // resource to channel edge ChannelMember srcCm = new ChannelMember(srcRes); ((DataflowChannelGenerator ) dstCh).addChannelMemberAsInput(srcCm); + edge.setValue(new SrcDstAttribute(srcRes, dstCh)); resetResourceDependencyGraph(); return true; } } IdentifierTemplate dstRes = model.getIdentifierTemplate((String) dst.getValue()); if (dstRes == null) return false; + // channel to resource edge ChannelMember dstCm = new ChannelMember(dstRes); ((DataflowChannelGenerator) srcCh).addChannelMemberAsOutput(dstCm); + edge.setValue(new SrcDstAttribute(srcCh, dstRes)); resetResourceDependencyGraph(); return true; } + + public void delete() { + for (Object obj: graph.getSelectionCells()) { + mxCell cell = (mxCell) obj; + if (cell.isEdge()) { + String srcName = (String) cell.getSource().getValue(); + String dstName = (String) cell.getTarget().getValue(); + if (model.getIdentifierTemplate(srcName) != null) { + // resource to channel edge + ChannelGenerator ch = model.getChannelGenerator(dstName); + ch.removeChannelMember(model.getIdentifierTemplate(srcName)); + } else if (model.getIdentifierTemplate(dstName) != null) { + // channel to resource edge + ChannelGenerator ch = model.getChannelGenerator(srcName); + if (ch == null) { + ch = model.getIOChannelGenerator(srcName); + } + ch.removeChannelMember(model.getIdentifierTemplate(dstName)); + } + } else if (cell.isVertex()) { + String name = (String) cell.getValue(); + if (model.getChannelGenerator(name) != null) { + model.removeChannelGenerator(name); + } else if (model.getIOChannelGenerator(name) != null) { + model.removeIOChannelGenerator(name); + } else if (model.getIdentifierTemplate(name) != null) { + model.removeIdentifierTemplate(name); + } + } + } + graph.removeCells(graph.getSelectionCells()); + resetResourceDependencyGraph(); + } public void setChannelCode(DataflowChannelGenerator ch, String code) { TokenStream stream = new TokenStream(); @@ -392,4 +467,26 @@ e.printStackTrace(); } } + + private class SrcDstAttribute extends EdgeAttribute { + private Object src; + private Object dst; + + public SrcDstAttribute(Object src, Object dst) { + this.src = src; + this.dst = dst; + } + + public Object getSrouce() { + return src; + } + + public Object getDestination() { + return dst; + } + + public String toString() { + return ""; + } + } } diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactor.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactor.java index aa6d385..c9d905d 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactor.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactor.java @@ -52,16 +52,19 @@ graph.getModel().addListener(mxEvent.CHANGE, new mxIEventListener() { public void invoke(Object sender, mxEventObject evt) { List terminals = new ArrayList<>(); + mxCell cell = null; for (Object change: ((List) evt.getProperties().get("changes"))) { if (change instanceof mxGraphModel.mxTerminalChange) { mxGraphModel.mxTerminalChange terminalChange = (mxGraphModel.mxTerminalChange) change; - mxCell cell = (mxCell) terminalChange.getCell(); + cell = (mxCell) terminalChange.getCell(); mxCell terminal = (mxCell) terminalChange.getTerminal(); terminals.add(terminal); } } if (terminals.size() == 2) { - editor.connectEdge(terminals.get(0), terminals.get(1)); + if (!editor.connectEdge(cell, terminals.get(0), terminals.get(1))) { + graph.removeCells(new mxCell[] {cell}); + } } } }); diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactorMenuBar.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactorMenuBar.java index a1b2436..23f06bf 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactorMenuBar.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactorMenuBar.java @@ -14,8 +14,10 @@ import graphicalrefactor.actions.JerseyPrototypeGenerateAction; import graphicalrefactor.actions.NewChannelAction; import graphicalrefactor.actions.NewIOChannelAction; +import graphicalrefactor.actions.NewModelAction; import graphicalrefactor.actions.NewResourceAction; import graphicalrefactor.actions.SaveAction; +import graphicalrefactor.actions.SaveAsAction; import graphicalrefactor.actions.TreeLayoutAction; import graphicalrefactor.actions.ZoomInAction; import graphicalrefactor.actions.ZoomOutAction; @@ -25,6 +27,7 @@ private static final long serialVersionUID = 4811536194182272888L; private GraphicalRefactor graphicalModelRefactor = null; + private NewModelAction newModelAction = null; private NewResourceAction newResourceAction = null; private NewChannelAction newChannelAction = null; private NewIOChannelAction newIOChannelAction = null; @@ -37,14 +40,18 @@ public GraphicalRefactorMenuBar(GraphicalRefactor graphicalModelRefactor) { this.graphicalModelRefactor = graphicalModelRefactor; + JMenu newMenu = new JMenu("New"); + newMenu.add(newModelAction = new NewModelAction(graphicalModelRefactor.getEditor())); + newMenu.add(newResourceAction = new NewResourceAction(graphicalModelRefactor.getEditor())); + newMenu.add(newChannelAction = new NewChannelAction(graphicalModelRefactor.getEditor())); + newMenu.add(newIOChannelAction = new NewIOChannelAction(graphicalModelRefactor.getEditor())); JMenu menu = null; menu = add(new JMenu("File")); - menu.add(newResourceAction = new NewResourceAction(graphicalModelRefactor.getEditor())); - menu.add(newChannelAction = new NewChannelAction(graphicalModelRefactor.getEditor())); - menu.add(newIOChannelAction = new NewIOChannelAction(graphicalModelRefactor.getEditor())); + menu.add(newMenu); menu.add(openAction = new OpenAction(graphicalModelRefactor.getEditor())); menu.addSeparator(); - menu.add(new SaveAction()); + menu.add(new SaveAction(graphicalModelRefactor.getEditor())); + menu.add(new SaveAsAction(graphicalModelRefactor.getEditor())); menu.addSeparator(); menu.add(new ExitAction()); diff --git a/AlgebraicDataflowArchitectureModel/src/models/algebra/Variable.java b/AlgebraicDataflowArchitectureModel/src/models/algebra/Variable.java index 99ae839..fa0095b 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/algebra/Variable.java +++ b/AlgebraicDataflowArchitectureModel/src/models/algebra/Variable.java @@ -77,6 +77,11 @@ } public String toString() { + if (type == null) return name; + return name + ":" + type.getTypeName(); + } + + public String toImplementation(String[] sideEffects) { return name; } } diff --git a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/ChannelGenerator.java b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/ChannelGenerator.java index 1f1e01d..ac571de 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/ChannelGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/ChannelGenerator.java @@ -71,6 +71,15 @@ addSelector(selector); } } + + public void removeChannelMember(IdentifierTemplate id) { + for (ChannelMember cm: channelMembers) { + if (cm.getIdentifierTemplate() == id) { + channelMembers.remove(cm); + break; + } + } + } public Set getIdentifierTemplates() { Set identifierTemplates = new HashSet<>(); diff --git a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java index 0e400ef..1679f1a 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java +++ b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java @@ -245,6 +245,17 @@ this.identifierTemplates = identifierTemplates; } + public void removeIdentifierTemplate(String resourceName) { + IdentifierTemplate id = identifierTemplates.get(resourceName); + identifierTemplates.remove(resourceName); + for (ChannelGenerator ch: channelGenerators.values()) { + ch.removeChannelMember(id); + } + for (ChannelGenerator ch: ioChannelGenerators.values()) { + ch.removeChannelMember(id); + } + } + public Collection getChannelGenerators() { return channelGenerators.values(); } @@ -269,6 +280,10 @@ } } + public void removeChannelGenerator(String channelName) { + channelGenerators.remove(channelName); + } + public Collection getIOChannelGenerators() { return ioChannelGenerators.values(); } @@ -293,6 +308,10 @@ } } + public void removeIOChannelGenerator(String ioChannelName) { + ioChannelGenerators.remove(ioChannelName); + } + public void addType(Type type) { types.put(type.getTypeName(), type); } diff --git a/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/DataflowChannelGenerator.java b/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/DataflowChannelGenerator.java index b4bdb35..62870b3 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/DataflowChannelGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/DataflowChannelGenerator.java @@ -78,6 +78,30 @@ addReferenceChannelMember(groupDependentResource); } + public void removeChannelMember(IdentifierTemplate id) { + for (ChannelMember cm: inputChannelMembers) { + if (cm.getIdentifierTemplate() == id) { + inputChannelMembers.remove(cm); + super.removeChannelMember(id); + return; + } + } + for (ChannelMember cm: outputChannelMembers) { + if (cm.getIdentifierTemplate() == id) { + outputChannelMembers.remove(cm); + super.removeChannelMember(id); + return; + } + } + for (ChannelMember cm: referenceChannelMembers) { + if (cm.getIdentifierTemplate() == id) { + referenceChannelMembers.remove(cm); + super.removeChannelMember(id); + return; + } + } + } + public Set getInputIdentifierTemplates() { Set inputIdentifierTemplates = new HashSet<>(); for (ChannelMember member: inputChannelMembers) {