org.epics.gpclient.javafx.tools.EventLogViewer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gpclient-javafx Show documentation
Show all versions of gpclient-javafx Show documentation
Java FX support for the EPICS Generic Purpose Client.
The newest version!
/**
* Copyright information and license terms for this software can be
* found in the file LICENSE.TXT included with the distribution.
*/
package org.epics.gpclient.javafx.tools;
import java.io.IOException;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.ListView;
import javafx.scene.layout.HBox;
public final class EventLogViewer extends HBox {
@FXML
private ListView eventList;
@FXML
private ValueViewer valueViewer;
@FXML
private EventViewer eventViewer;
private Log eventLog = new Log(new Runnable() {
@Override
public void run() {
onNewEvent();
}
});
public EventLogViewer() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("EventLogViewer.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
eventList.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue extends Event> observable, Event oldValue, Event newValue) {
eventViewer.setEvent(newValue);
valueViewer.setValue(newValue.getValue(), newValue.isConnected());
}
});
}
public Log eventLog() {
return eventLog;
}
private void onNewEvent() {
eventList.getItems().add(0, eventLog.getEvents().get(eventLog.getEvents().size() - 1));
}
}