1 package net.mograsim.logic.model.model;
5 import net.mograsim.logic.model.model.components.GUIComponent;
6 import net.mograsim.logic.model.model.wires.GUIWire;
8 //TODO a ViewModel is modifiable without casting to ViewModelModifiable via GUIWire::destroy and GUIComponent::destroy
9 public class ViewModelModifiable extends ViewModel
11 public String getDefaultComponentName(GUIComponent component)
13 Set<String> componentNames = getComponentsByName().keySet();
14 // TODO get the ID of component
15 // The following does not work because this method is called in the constructor of DeserializedSubmodelComponent at a time where
16 // idForSerializingOverride is not yet set
17 // String componentID = null;
18 // if (component instanceof DeserializedSubmodelComponent)
19 // componentID = ((DeserializedSubmodelComponent) component).idForSerializingOverride;
20 // if (componentID == null)
21 // componentID = component.getClass().getSimpleName();
22 String componentID = component.getClass().getSimpleName();
23 String nameBase = componentID + '#';
26 String nameCandidate = nameBase + i;
27 if (!componentNames.contains(nameCandidate))
32 public String getDefaultWireName()
34 Set<String> wireNames = getWiresByName().keySet();
37 String nameCandidate = "unnamedWire#" + i;
38 if (!wireNames.contains(nameCandidate))
44 public void componentCreated(GUIComponent component)
46 super.componentCreated(component);
50 public void componentDestroyed(GUIComponent component)
52 super.componentDestroyed(component);
56 public void wireCreated(GUIWire wire)
58 super.wireCreated(wire);
62 public void wireDestroyed(GUIWire wire)
64 super.wireDestroyed(wire);