projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
GUIComponents now have names
[Mograsim.git]
/
net.mograsim.logic.ui
/
src
/
net
/
mograsim
/
logic
/
ui
/
serializing
/
IndirectGUIComponentCreator.java
diff --git
a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/serializing/IndirectGUIComponentCreator.java
b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/serializing/IndirectGUIComponentCreator.java
index
456d19c
..
365fe9a
100644
(file)
--- a/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/serializing/IndirectGUIComponentCreator.java
+++ b/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/serializing/IndirectGUIComponentCreator.java
@@
-16,7
+16,7
@@
public class IndirectGUIComponentCreator
{
private static final Map<String, String> standardComponentIDs = new HashMap<>();
{
private static final Map<String, String> standardComponentIDs = new HashMap<>();
- private static final Map<String, Component
Provider> componentProvid
ers = new HashMap<>();
+ private static final Map<String, Component
Supplier> componentSuppli
ers = new HashMap<>();
static
{
static
{
@@
-51,17
+51,27
@@
public class IndirectGUIComponentCreator
standardComponentIDs.put(standardComponentID, associatedComponentID);
}
standardComponentIDs.put(standardComponentID, associatedComponentID);
}
- public static void setComponent
Provider(String className, ComponentProvider componentProvid
er)
+ public static void setComponent
Supplier(String className, ComponentSupplier componentSuppli
er)
{
{
- component
Providers.put(className, componentProvid
er);
+ component
Suppliers.put(className, componentSuppli
er);
}
public static GUIComponent createComponent(ViewModelModifiable model, String id)
{
}
public static GUIComponent createComponent(ViewModelModifiable model, String id)
{
- return createComponent(model, id, JsonNull.INSTANCE);
+ return createComponent(model, id, (String) null);
+ }
+
+ public static GUIComponent createComponent(ViewModelModifiable model, String id, String name)
+ {
+ return createComponent(model, id, JsonNull.INSTANCE, name);
}
public static GUIComponent createComponent(ViewModelModifiable model, String id, JsonElement params)
}
public static GUIComponent createComponent(ViewModelModifiable model, String id, JsonElement params)
+ {
+ return createComponent(model, id, params, null);
+ }
+
+ public static GUIComponent createComponent(ViewModelModifiable model, String id, JsonElement params, String name)
{
if (id != null)
{
{
if (id != null)
{
@@
-74,15
+84,15
@@
public class IndirectGUIComponentCreator
{
String className = resolvedID.substring(6);
tryLoadComponentClass(className);
{
String className = resolvedID.substring(6);
tryLoadComponentClass(className);
- Component
Provider componentProvider = componentProvid
ers.get(className);
- if (component
Provid
er != null)
- return component
Provider.create(model, params
);
+ Component
Supplier componentSupplier = componentSuppli
ers.get(className);
+ if (component
Suppli
er != null)
+ return component
Supplier.create(model, params, name
);
} else
// we know id has to start with "file:" here
// because standardComponentIDs only contains strings starting with "class:" or "file:"
} else
// we know id has to start with "file:" here
// because standardComponentIDs only contains strings starting with "class:" or "file:"
- return SubmodelComponentDeserializer.create(model, resolvedID.substring(5));
+ return SubmodelComponentDeserializer.create(model, resolvedID.substring(5)
, name
);
}
}
- throw new RuntimeException("Could not get component
provid
er for ID " + id);
+ throw new RuntimeException("Could not get component
suppli
er for ID " + id);
}
private static void tryLoadComponentClass(String componentClassName)
}
private static void tryLoadComponentClass(String componentClassName)
@@
-90,8
+100,8
@@
public class IndirectGUIComponentCreator
CodeSnippetSupplier.tryInvokeStaticInitializer(componentClassName, "Error loading component class %s: %s\n");
}
CodeSnippetSupplier.tryInvokeStaticInitializer(componentClassName, "Error loading component class %s: %s\n");
}
- public static interface Component
Provid
er
+ public static interface Component
Suppli
er
{
{
- public GUIComponent create(ViewModelModifiable model, JsonElement params);
+ public GUIComponent create(ViewModelModifiable model, JsonElement params
, String name
);
}
}
\ No newline at end of file
}
}
\ No newline at end of file