projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated to new SWTHelper version
[Mograsim.git]
/
net.mograsim.logic.ui
/
src
/
net
/
mograsim
/
logic
/
ui
/
model
/
ViewModel.java
diff --git
a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/ViewModel.java
b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/ViewModel.java
index
1f69acf
..
4d1f21b
100644
(file)
--- a/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/ViewModel.java
+++ b/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/ViewModel.java
@@
-2,7
+2,9
@@
package net.mograsim.logic.ui.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.List;
+import java.util.Map;
import java.util.function.Consumer;
import net.mograsim.logic.ui.model.components.GUIComponent;
import java.util.function.Consumer;
import net.mograsim.logic.ui.model.components.GUIComponent;
@@
-10,8
+12,8
@@
import net.mograsim.logic.ui.model.wires.GUIWire;
public class ViewModel
{
public class ViewModel
{
- private final
List<
GUIComponent> components;
- private final
List<
GUIComponent> componentsUnmodifiable;
+ private final
Map<String,
GUIComponent> components;
+ private final
Map<String,
GUIComponent> componentsUnmodifiable;
private final List<GUIWire> wires;
private final List<GUIWire> wiresUnmodifiable;
private final List<GUIWire> wires;
private final List<GUIWire> wiresUnmodifiable;
@@
-25,8
+27,8
@@
public class ViewModel
protected ViewModel()
{
protected ViewModel()
{
- components = new
ArrayList
<>();
- componentsUnmodifiable = Collections.unmodifiable
List
(components);
+ components = new
HashMap
<>();
+ componentsUnmodifiable = Collections.unmodifiable
Map
(components);
wires = new ArrayList<>();
wiresUnmodifiable = Collections.unmodifiableList(wires);
wires = new ArrayList<>();
wiresUnmodifiable = Collections.unmodifiableList(wires);
@@
-41,13
+43,13
@@
public class ViewModel
/**
* Adds the given component to the list of components and calls all componentAddedListeners. Don't call this method from application
/**
* Adds the given component to the list of components and calls all componentAddedListeners. Don't call this method from application
- * code as it is automatically called in
GUIComponent::new
.
+ * code as it is automatically called in
{@link GUIComponent}'s constructor
.
*/
protected void componentCreated(GUIComponent component)
{
*/
protected void componentCreated(GUIComponent component)
{
- if (components.contains
(component
))
+ if (components.contains
Key(component.name
))
throw new IllegalStateException("Don't add the same component twice!");
throw new IllegalStateException("Don't add the same component twice!");
- components.
add(
component);
+ components.
put(component.name,
component);
callComponentAddedListeners(component);
component.addRedrawListener(redrawListenerForSubcomponents);
callRedrawListeners();
callComponentAddedListeners(component);
component.addRedrawListener(redrawListenerForSubcomponents);
callRedrawListeners();
@@
-55,13
+57,13
@@
public class ViewModel
/**
* Removes the given component from the list of components and calls all componentRemovedListeners. Don't call this method from
/**
* Removes the given component from the list of components and calls all componentRemovedListeners. Don't call this method from
- * application code as it is automatically called in
GUIComponent::destroy
.
+ * application code as it is automatically called in
{@link GUIComponent#destroy()}
.
*/
protected void componentDestroyed(GUIComponent component)
{
*/
protected void componentDestroyed(GUIComponent component)
{
- if (!components.contains
(component
))
+ if (!components.contains
Key(component.name
))
throw new IllegalStateException("Don't remove the same component twice!");
throw new IllegalStateException("Don't remove the same component twice!");
- components.remove(component);
+ components.remove(component
.name
);
callComponentRemovedListeners(component);
component.removeRedrawListener(redrawListenerForSubcomponents);
callRedrawListeners();
callComponentRemovedListeners(component);
component.removeRedrawListener(redrawListenerForSubcomponents);
callRedrawListeners();
@@
-69,7
+71,7
@@
public class ViewModel
/**
* Adds the given wire to the list of wires and calls all wireAddedListeners. Don't call this method from application code as it is
/**
* Adds the given wire to the list of wires and calls all wireAddedListeners. Don't call this method from application code as it is
- * automatically called in
GUIWire::new
.
+ * automatically called in
{@link GUIWire}'s constructor(s)
.
*/
protected void wireCreated(GUIWire wire)
{
*/
protected void wireCreated(GUIWire wire)
{
@@
-83,7
+85,7
@@
public class ViewModel
/**
* Removes the given wire from the list of wires and calls all wireRemovedListeners. Don't call this method from application code as it
/**
* Removes the given wire from the list of wires and calls all wireRemovedListeners. Don't call this method from application code as it
- * is automatically called in
GUIWire::destroy
.
+ * is automatically called in
{@link GUIWire#destroy()}
.
*/
protected void wireDestroyed(GUIWire wire)
{
*/
protected void wireDestroyed(GUIWire wire)
{
@@
-95,7
+97,7
@@
public class ViewModel
callRedrawListeners();
}
callRedrawListeners();
}
- public
List<GUIComponent> getComponents
()
+ public
Map<String, GUIComponent> getComponentsByName
()
{
return componentsUnmodifiable;
}
{
return componentsUnmodifiable;
}