GUIWires now have names
[Mograsim.git] / net.mograsim.logic.model / src / net / mograsim / logic / model / model / ViewModelModifiable.java
1 package net.mograsim.logic.model.model;
2
3 import java.util.Set;
4
5 import net.mograsim.logic.model.model.components.GUIComponent;
6 import net.mograsim.logic.model.model.wires.GUIWire;
7
8 public class ViewModelModifiable extends ViewModel
9 {
10         public String getDefaultComponentName(GUIComponent component)
11         {
12                 Set<String> componentNames = getComponentsByName().keySet();
13                 String nameBase = component.getClass().getSimpleName() + '#';
14                 for (int i = 0;; i++)
15                 {
16                         String nameCandidate = nameBase + i;
17                         if (!componentNames.contains(nameCandidate))
18                                 return nameCandidate;
19                 }
20         }
21
22         public String getDefaultWireName()
23         {
24                 Set<String> wireNames = getWiresByName().keySet();
25                 for (int i = 0;; i++)
26                 {
27                         String nameCandidate = "unnamedWire#" + i;
28                         if (!wireNames.contains(nameCandidate))
29                                 return nameCandidate;
30                 }
31         }
32
33         @Override
34         public void componentCreated(GUIComponent component)
35         {
36                 super.componentCreated(component);
37         }
38
39         @Override
40         public void componentDestroyed(GUIComponent component)
41         {
42                 super.componentDestroyed(component);
43         }
44
45         @Override
46         public void wireCreated(GUIWire wire)
47         {
48                 super.wireCreated(wire);
49         }
50
51         @Override
52         public void wireDestroyed(GUIWire wire)
53         {
54                 super.wireDestroyed(wire);
55         }
56 }