projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implemented GUIMerger + GUISplitter
[Mograsim.git]
/
net.mograsim.logic.model
/
src
/
net
/
mograsim
/
logic
/
model
/
modeladapter
/
ViewLogicModelAdapter.java
diff --git
a/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/ViewLogicModelAdapter.java
b/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/ViewLogicModelAdapter.java
index
16b52ee
..
17dc22f
100644
(file)
--- a/
net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/ViewLogicModelAdapter.java
+++ b/
net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/ViewLogicModelAdapter.java
@@
-1,9
+1,9
@@
package net.mograsim.logic.model.modeladapter;
package net.mograsim.logic.model.modeladapter;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@
-43,7
+43,8
@@
public class ViewLogicModelAdapter
private static void convert(ViewModel viewModel, LogicModelParameters params, Timeline timeline, Map<Pin, Wire> externalWires)
{
private static void convert(ViewModel viewModel, LogicModelParameters params, Timeline timeline, Map<Pin, Wire> externalWires)
{
- Map<Pin, Wire> logicWiresPerPin = convertWires(getAllPins(viewModel), viewModel.getWires(), externalWires, params, timeline);
+ Map<Pin, Wire> logicWiresPerPin = convertWires(getAllPins(viewModel), viewModel.getWiresByName().values(), externalWires, params,
+ timeline);
Map<Pin, Wire> logicWiresPerPinUnmodifiable = Collections.unmodifiableMap(logicWiresPerPin);
for (GUIComponent guiComp : viewModel.getComponentsByName().values())
Map<Pin, Wire> logicWiresPerPinUnmodifiable = Collections.unmodifiableMap(logicWiresPerPin);
for (GUIComponent guiComp : viewModel.getComponentsByName().values())
@@
-60,7
+61,7
@@
public class ViewLogicModelAdapter
WireCrossPoint guiCompCasted = (WireCrossPoint) guiComp;
guiCompCasted.setLogicModelBinding(logicWiresPerPin.get(guiCompCasted.getPin()).createReadOnlyEnd());
} else if (!(guiComp instanceof SubmodelInterface))// nothing to do for SubmodelInterfaces
WireCrossPoint guiCompCasted = (WireCrossPoint) guiComp;
guiCompCasted.setLogicModelBinding(logicWiresPerPin.get(guiCompCasted.getPin()).createReadOnlyEnd());
} else if (!(guiComp instanceof SubmodelInterface))// nothing to do for SubmodelInterfaces
- createAndLinkComponent(timeline, params, guiComp, logicWiresPerPinUnmodifiable
, componentAdapters.get(guiComp.getClass())
);
+ createAndLinkComponent(timeline, params, guiComp, logicWiresPerPinUnmodifiable);
}
}
}
}
@@
-70,7
+71,7
@@
public class ViewLogicModelAdapter
.collect(Collectors.toSet());
}
.collect(Collectors.toSet());
}
- private static Map<Pin, Wire> convertWires(Set<Pin> allPins,
List
<GUIWire> wires, Map<Pin, Wire> externalWires,
+ private static Map<Pin, Wire> convertWires(Set<Pin> allPins,
Collection
<GUIWire> wires, Map<Pin, Wire> externalWires,
LogicModelParameters params, Timeline timeline)
{
Map<Pin, Set<Pin>> connectedPinGroups = getConnectedPinGroups(allPins, wires);
LogicModelParameters params, Timeline timeline)
{
Map<Pin, Set<Pin>> connectedPinGroups = getConnectedPinGroups(allPins, wires);
@@
-105,7
+106,7
@@
public class ViewLogicModelAdapter
return logicWiresPerPin;
}
return logicWiresPerPin;
}
- private static void setGUIWiresLogicModelBinding(
List
<GUIWire> wires, Map<Pin, Wire> logicWiresPerPin)
+ private static void setGUIWiresLogicModelBinding(
Collection
<GUIWire> wires, Map<Pin, Wire> logicWiresPerPin)
{
Map<Wire, ReadEnd> guiWireSharedReadEnd = logicWiresPerPin.values().stream().distinct()
.collect(Collectors.toMap(Function.identity(), Wire::createReadOnlyEnd));
{
Map<Wire, ReadEnd> guiWireSharedReadEnd = logicWiresPerPin.values().stream().distinct()
.collect(Collectors.toMap(Function.identity(), Wire::createReadOnlyEnd));
@@
-113,7
+114,7
@@
public class ViewLogicModelAdapter
guiWire.setLogicModelBinding(guiWireSharedReadEnd.get(logicWiresPerPin.get(guiWire.getPin1())));
}
guiWire.setLogicModelBinding(guiWireSharedReadEnd.get(logicWiresPerPin.get(guiWire.getPin1())));
}
- private static Map<Pin, Set<Pin>> getConnectedPinGroups(Set<Pin> allPins,
List
<GUIWire> wires)
+ private static Map<Pin, Set<Pin>> getConnectedPinGroups(Set<Pin> allPins,
Collection
<GUIWire> wires)
{
Map<Pin, Set<Pin>> connectedPinsPerPin = new HashMap<>();
{
Map<Pin, Set<Pin>> connectedPinsPerPin = new HashMap<>();
@@
-143,8
+144,15
@@
public class ViewLogicModelAdapter
@SuppressWarnings("unchecked")
private static <G extends GUIComponent> void createAndLinkComponent(Timeline timeline, LogicModelParameters params,
@SuppressWarnings("unchecked")
private static <G extends GUIComponent> void createAndLinkComponent(Timeline timeline, LogicModelParameters params,
- GUIComponent guiComponent, Map<Pin, Wire> logicWiresPerPin
, ComponentAdapter<G> adapter
)
+ GUIComponent guiComponent, Map<Pin, Wire> logicWiresPerPin)
{
{
+ Class<?> cls = guiComponent.getClass();
+ ComponentAdapter<? super G> adapter = null;
+ while (cls != GUIComponent.class && adapter == null)
+ {
+ adapter = (ComponentAdapter<? super G>) componentAdapters.get(cls);
+ cls = cls.getSuperclass();
+ }
if (adapter == null)
throw new IllegalArgumentException("Unknown component class: " + guiComponent.getClass());
adapter.createAndLinkComponent(timeline, params, (G) guiComponent, logicWiresPerPin);
if (adapter == null)
throw new IllegalArgumentException("Unknown component class: " + guiComponent.getClass());
adapter.createAndLinkComponent(timeline, params, (G) guiComponent, logicWiresPerPin);