Merge branch 'development' of https://gitlab.lrz.de/lrr-tum/students/eragp-misim...
authorFabian Stemmler <stemmler@in.tum.de>
Mon, 24 Jun 2019 14:25:25 +0000 (16:25 +0200)
committerFabian Stemmler <stemmler@in.tum.de>
Mon, 24 Jun 2019 14:25:25 +0000 (16:25 +0200)
1  2 
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/GUIComponent.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SimpleRectangularSubmodelComponent.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SubmodelComponent.java

@@@ -12,6 -12,7 +12,7 @@@ import java.util.function.Supplier
  import net.haspamelodica.swt.helper.gcs.GeneralGC;
  import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
  import net.mograsim.logic.ui.model.ViewModelModifiable;
+ import net.mograsim.logic.ui.model.Visitable;
  import net.mograsim.logic.ui.model.wires.Pin;
  
  /**
@@@ -20,7 -21,7 +21,7 @@@
   * 
   * @author Daniel Kirschten
   */
- public abstract class GUIComponent
+ public abstract class GUIComponent implements Visitable
  {
        /**
         * The model this component is a part of.
@@@ -43,7 -44,7 +44,7 @@@
  
        private final Runnable redrawListenerForSubcomponents;
        // Defines how the GUIComponent is referenced in SubmodelComponentParams
 -      protected Supplier<String> identifierDelegate = () -> "class:".concat(getClass().getCanonicalName());
 +      protected Supplier<String> identifierDelegate = () -> getClass().getSimpleName();
  
        // creation and destruction
  
@@@ -12,6 -12,7 +12,7 @@@ import net.haspamelodica.swt.helper.gcs
  import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
  import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
  import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
+ import net.mograsim.logic.ui.model.ModelVisitor;
  import net.mograsim.logic.ui.model.ViewModelModifiable;
  import net.mograsim.logic.ui.model.wires.MovablePin;
  import net.mograsim.logic.ui.model.wires.Pin;
@@@ -128,8 -129,8 +129,8 @@@ public class SimpleRectangularSubmodelC
                ret.type = SimpleRectangularSubmodelComponent.class.getSimpleName();
                Map<String, Object> m = new TreeMap<>();
                m.put(kLabel, label);
 -              m.put(kInCount, inputPinNames.size());
 -              m.put(kOutCount, outputPinNames.size());
 +              m.put(kInCount, inputPinNames.toArray());
 +              m.put(kOutCount, outputPinNames.toArray());
                m.put(kLogicWidth, logicWidth);
                ret.specialized = m;
                return ret;
                throw new UnsupportedOperationException(
                                "Can't set the size of a SimpleRectangularSubmodelComponent directly, call setInputPins / setOutputPins instead");
        }
+       @Override
+       public void accept(ModelVisitor mv)
+       {
+               mv.visit(this);
+       }
  }
@@@ -331,7 -331,6 +331,7 @@@ public abstract class SubmodelComponen
        public SubmodelComponentParams calculateParams()
        {
                SubmodelComponentParams params = new SubmodelComponentParams();
 +              params.name = getIdentifier();
                params.type = SubmodelComponent.class.getSimpleName();
                params.composition = calculateCompositionParams();
  
                        InnerComponentParams inner = new InnerComponentParams();
                        comps[i] = inner;
                        inner.params = component.getInstantiationParameters();
 -                      inner.pos = new Point(getPosX(), getPosY());
 -                      inner.type = component.getIdentifier();
 +                      inner.pos = new Point(component.getPosX(), component.getPosY());
 +                      inner.name = component.getIdentifier();
                        i++;
                }
                params.subComps = comps;
                return params;
        }
  
+       public List<GUIComponent> getComponents()
+       {
+               return submodel.getComponents();
+       }
+       public List<GUIWire> getWires()
+       {
+               return submodel.getWires();
+       }
        // operations no longer supported
  
        @Override