use of de.neemann.digital.gui.components.SingleValueDialog in project Digital by hneemann.
the class InputShape method applyStateMonitor.
@Override
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
this.ioState = ioState;
ioState.getOutput(0).addObserverToValue(guiObserver);
return new Interactor() {
@Override
public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, Sync modelSync) {
ObservableValue value = ioState.getOutput(0);
if (value.getBits() == 1) {
modelSync.access(() -> {
if (isHighZ) {
if (value.isHighZ())
value.setValue(0);
else if (value.getValue() == 0)
value.setValue(1);
else
value.setToHighZ();
} else
value.setValue(1 - value.getValue());
});
return true;
} else {
if (dialog == null || !dialog.isVisible()) {
Model model = ((In) element).getModel();
dialog = new SingleValueDialog(model.getWindowPosManager().getMainFrame(), pos, label, value, isHighZ, cc, model, modelSync);
dialog.setVisible(true);
} else
dialog.requestFocus();
return false;
}
}
};
}
Aggregations