Commit 26a19621 authored by Andrey Filippov's avatar Andrey Filippov

MCP initial files

parent 9c971dfc
package com.elphel.imagej.mcp;
public class McpDialogField {
public enum Type {
MESSAGE,
BOOLEAN,
NUMBER,
STRING,
CHOICE
}
public final Type type;
public final String label;
public final String tooltip;
public final String tab;
public final String units;
public final String[] choices;
public final String defaultValue;
public McpDialogField(Type type,
String label,
String tooltip,
String tab,
String units,
String[] choices,
String defaultValue) {
this.type = type;
this.label = label;
this.tooltip = tooltip;
this.tab = tab;
this.units = units;
this.choices = choices;
this.defaultValue = defaultValue;
}
}
package com.elphel.imagej.mcp;
import java.util.concurrent.atomic.AtomicReference;
public class McpDialogRegistry {
private static final AtomicReference<McpDialogSession> CURRENT = new AtomicReference<McpDialogSession>(null);
private McpDialogRegistry() {
}
public static void setCurrent(McpDialogSession session) {
CURRENT.set(session);
}
public static McpDialogSession getCurrent() {
return CURRENT.get();
}
public static void setValue(String label, String value) {
McpDialogSession session = CURRENT.get();
if (session == null) {
return;
}
session.setValue(label, value);
}
}
package com.elphel.imagej.mcp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class McpDialogSession {
private final String id;
private final String title;
private final List<McpDialogField> fields;
private final Map<String, String> valuesByLabel;
public McpDialogSession(String title, List<McpDialogField> fields) {
this.id = UUID.randomUUID().toString();
this.title = title;
this.fields = new ArrayList<McpDialogField>(fields);
this.valuesByLabel = new HashMap<String, String>();
}
public String getId() {
return id;
}
public String getTitle() {
return title;
}
public List<McpDialogField> getFields() {
return Collections.unmodifiableList(fields);
}
public void setValue(String label, String value) {
if (label == null) {
return;
}
valuesByLabel.put(label, value);
}
public String getValue(String label) {
if (label == null) {
return null;
}
return valuesByLabel.get(label);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment