Commit a0115b33 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke

Added a UI configurable monitoring

parent eb576806
......@@ -30,6 +30,7 @@ import kieker.diagnosis.service.export.ExportService;
import kieker.diagnosis.ui.about.AboutDialogView;
import kieker.diagnosis.ui.main.properties.LastImportPathProperty;
import kieker.diagnosis.ui.methods.MethodsView;
import kieker.diagnosis.ui.monitoring.MonitoringDialogView;
import kieker.diagnosis.ui.progress.ProgressDialog;
import kieker.diagnosis.ui.settings.SettingsDialogView;
import kieker.diagnosis.ui.traces.TracesView;
......@@ -43,6 +44,9 @@ public class MainController extends ControllerBase<MainViewModel> {
@Inject
AboutDialogView ivAboutDialogView;
@Inject
MonitoringDialogView ivMonitoringDialogView;
/**
* This action is performed, when the user wants to import a monitoring log.
*/
......@@ -204,4 +208,8 @@ public class MainController extends ControllerBase<MainViewModel> {
}
}
public void performMonitoring( ) {
ivMonitoringDialogView.open( getViewModel( ).getWindow( ) );
}
}
......@@ -53,6 +53,14 @@ public class MainView extends ViewBase<MainController> {
menu.getItems( ).add( separatorMenuItem );
}
{
final MenuItem menuItem = new MenuItem( );
menuItem.setText( getLocalizedString( "monitoring" ) );
menuItem.setOnAction( e -> getController( ).performMonitoring( ) );
menu.getItems( ).add( menuItem );
}
{
final MenuItem menuItem = new MenuItem( );
menuItem.setText( getLocalizedString( "settings" ) );
......
package kieker.diagnosis.ui.monitoring;
import com.google.inject.Singleton;
import kieker.diagnosis.architecture.monitoring.MonitoringConfiguration;
import kieker.diagnosis.architecture.monitoring.Status;
import kieker.diagnosis.architecture.service.monitoring.MonitoringService;
import kieker.diagnosis.architecture.ui.ControllerBase;
@Singleton
public class MonitoringDialogController extends ControllerBase<MonitoringDialogViewModel> {
public void performRefresh( ) {
// Get the current configuration and status...
final MonitoringService monitoringService = getService( MonitoringService.class );
final MonitoringConfiguration configuration = monitoringService.getCurrentConfiguration( );
final Status status = monitoringService.getCurrentStatus( );
// ...and display them.
getViewModel( ).updatePresentationConfiguration( configuration );
getViewModel( ).updatePresentationStatus( status );
}
/**
* This action is performed, when the user wants to save and close the dialog.
*
* @return
*/
public void performSaveAndClose( ) {
// Get the configuration...
final MonitoringConfiguration configuration = getViewModel( ).savePresentationConfiguration( );
// ...and apply it
final MonitoringService monitoringService = getService( MonitoringService.class );
monitoringService.configureMonitoring( configuration );
getViewModel( ).close( );
}
public void performClose( ) {
getViewModel( ).close( );
}
}
\ No newline at end of file
package kieker.diagnosis.ui.monitoring;
import java.io.InputStream;
import com.google.inject.Singleton;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ComboBoxBase;
import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;
import kieker.diagnosis.architecture.monitoring.Timer;
import kieker.diagnosis.architecture.monitoring.Writer;
import kieker.diagnosis.architecture.ui.EnumStringConverter;
import kieker.diagnosis.architecture.ui.ViewBase;
@Singleton
public class MonitoringDialogView extends ViewBase<MonitoringDialogController> {
private Label ivStatus;
private CheckBox ivActive;
private TextField ivOutputDirectory;
private ComboBox<Timer> ivTimer;
private ComboBox<Writer> ivWriter;
private TextField ivMaxEntriesPerFile;
private TextField ivQueueSize;
private TextField ivBuffer;
public MonitoringDialogView( ) {
setSpacing( 10 );
{
final GridPane gridPane = new GridPane( );
VBox.setMargin( gridPane, new Insets( 10, 10, 0, 10 ) );
gridPane.setVgap( 5 );
gridPane.setHgap( 5 );
int rowIndex = 0;
{
final Label label = new Label( );
label.setText( getLocalizedString( "status" ) );
GridPane.setRowIndex( label, rowIndex );
GridPane.setColumnIndex( label, 1 );
gridPane.getChildren( ).add( label );
}
{
ivStatus = new Label( );
ivStatus.setMaxWidth( Double.POSITIVE_INFINITY );
ivStatus.getStyleClass( ).add( "status" );
GridPane.setRowIndex( ivStatus, rowIndex++ );
GridPane.setColumnIndex( ivStatus, 2 );
GridPane.setHgrow( ivStatus, Priority.ALWAYS );
gridPane.getChildren( ).add( ivStatus );
}
{
final Label label = new Label( );
label.setText( getLocalizedString( "active" ) );
GridPane.setRowIndex( label, rowIndex );
GridPane.setColumnIndex( label, 1 );
gridPane.getChildren( ).add( label );
}
{
ivActive = new CheckBox( );
ivActive.setMaxWidth( Double.POSITIVE_INFINITY );
GridPane.setRowIndex( ivActive, rowIndex++ );
GridPane.setColumnIndex( ivActive, 2 );
gridPane.getChildren( ).add( ivActive );
}
{
final Label label = new Label( );
label.setText( getLocalizedString( "outputDirectory" ) );
GridPane.setRowIndex( label, rowIndex );
GridPane.setColumnIndex( label, 1 );
gridPane.getChildren( ).add( label );
}
{
ivOutputDirectory = new TextField( );
ivOutputDirectory.setMaxWidth( Double.POSITIVE_INFINITY );
GridPane.setRowIndex( ivOutputDirectory, rowIndex++ );
GridPane.setColumnIndex( ivOutputDirectory, 2 );
gridPane.getChildren( ).add( ivOutputDirectory );
}
{
final Label label = new Label( );
label.setText( getLocalizedString( "timer" ) );
GridPane.setRowIndex( label, rowIndex );
GridPane.setColumnIndex( label, 1 );
gridPane.getChildren( ).add( label );
}
{
ivTimer = new ComboBox<>( );
ivTimer.setMaxWidth( Double.POSITIVE_INFINITY );
ivTimer.setConverter( new EnumStringConverter<>( Timer.class ) );
ivTimer.setItems( FXCollections.observableArrayList( Timer.values( ) ) );
GridPane.setRowIndex( ivTimer, rowIndex++ );
GridPane.setColumnIndex( ivTimer, 2 );
gridPane.getChildren( ).add( ivTimer );
}
{
final Label label = new Label( );
label.setText( getLocalizedString( "writer" ) );
GridPane.setRowIndex( label, rowIndex );
GridPane.setColumnIndex( label, 1 );
gridPane.getChildren( ).add( label );
}
{
ivWriter = new ComboBox<>( );
ivWriter.setMaxWidth( Double.POSITIVE_INFINITY );
ivWriter.setConverter( new EnumStringConverter<>( Writer.class ) );
ivWriter.setItems( FXCollections.observableArrayList( Writer.values( ) ) );
GridPane.setRowIndex( ivWriter, rowIndex++ );
GridPane.setColumnIndex( ivWriter, 2 );
gridPane.getChildren( ).add( ivWriter );
}
{
final Label label = new Label( );
label.setText( getLocalizedString( "maxEntriesPerFile" ) );
GridPane.setRowIndex( label, rowIndex );
GridPane.setColumnIndex( label, 1 );
gridPane.getChildren( ).add( label );
}
{
ivMaxEntriesPerFile = new TextField( );
ivMaxEntriesPerFile.setMaxWidth( Double.POSITIVE_INFINITY );
GridPane.setRowIndex( ivMaxEntriesPerFile, rowIndex++ );
GridPane.setColumnIndex( ivMaxEntriesPerFile, 2 );
gridPane.getChildren( ).add( ivMaxEntriesPerFile );
}
{
final Label label = new Label( );
label.setText( getLocalizedString( "queueSize" ) );
GridPane.setRowIndex( label, rowIndex );
GridPane.setColumnIndex( label, 1 );
gridPane.getChildren( ).add( label );
}
{
ivQueueSize = new TextField( );
ivQueueSize.setMaxWidth( Double.POSITIVE_INFINITY );
GridPane.setRowIndex( ivQueueSize, rowIndex++ );
GridPane.setColumnIndex( ivQueueSize, 2 );
gridPane.getChildren( ).add( ivQueueSize );
}
{
final Label label = new Label( );
label.setText( getLocalizedString( "buffer" ) );
GridPane.setRowIndex( label, rowIndex );
GridPane.setColumnIndex( label, 1 );
gridPane.getChildren( ).add( label );
}
{
ivBuffer = new TextField( );
ivBuffer.setMaxWidth( Double.POSITIVE_INFINITY );
GridPane.setRowIndex( ivBuffer, rowIndex++ );
GridPane.setColumnIndex( ivBuffer, 2 );
gridPane.getChildren( ).add( ivBuffer );
}
getChildren( ).add( gridPane );
}
{
final Separator separator = new Separator( );
getChildren( ).add( separator );
}
{
final ButtonBar buttonBar = new ButtonBar( );
VBox.setMargin( buttonBar, new Insets( 0, 10, 0, 0 ) );
{
final Button button = new Button( );
button.setText( getLocalizedString( "cancel" ) );
button.setCancelButton( true );
button.setOnAction( e -> getController( ).performClose( ) );
buttonBar.getButtons( ).add( button );
}
{
final Button button = new Button( );
button.setText( getLocalizedString( "ok" ) );
button.setDefaultButton( true );
button.setOnAction( e -> {
getController( ).performSaveAndClose( );
} );
buttonBar.getButtons( ).add( button );
}
getChildren( ).add( buttonBar );
}
}
@Override
public void setParameter( final Object aParameter ) {
}
public void open( final Window aParent ) {
// Create a scene if necessary
Scene scene = getScene( );
if ( scene == null ) {
scene = new Scene( this );
}
// Load the icon
final String iconPath = getLocalizedString( "icon" );
final InputStream iconStream = getClass( ).getClassLoader( ).getResourceAsStream( iconPath );
final Image icon = new Image( iconStream );
// Prepare and show the stage
final Stage stage = new Stage( );
stage.setResizable( false );
stage.initModality( Modality.WINDOW_MODAL );
stage.initStyle( StageStyle.DECORATED );
stage.initOwner( aParent );
stage.getIcons( ).add( icon );
stage.setTitle( getLocalizedString( "title" ) );
stage.setScene( scene );
getController( ).performRefresh( );
stage.showAndWait( );
}
Label getStatus( ) {
return ivStatus;
}
CheckBox getActive( ) {
return ivActive;
}
TextField getOutputDirectory( ) {
return ivOutputDirectory;
}
ComboBoxBase<Timer> getTimer( ) {
return ivTimer;
}
ComboBoxBase<Writer> getWriter( ) {
return ivWriter;
}
TextField getMaxEntriesPerFile( ) {
return ivMaxEntriesPerFile;
}
TextField getQueueSize( ) {
return ivQueueSize;
}
TextField getBuffer( ) {
return ivBuffer;
}
}
\ No newline at end of file
package kieker.diagnosis.ui.monitoring;
import com.google.inject.Singleton;
import kieker.diagnosis.architecture.monitoring.MonitoringConfiguration;
import kieker.diagnosis.architecture.monitoring.Status;
import kieker.diagnosis.architecture.ui.ViewModelBase;
@Singleton
public class MonitoringDialogViewModel extends ViewModelBase<MonitoringDialogView> {
public void updatePresentationStatus( final Status aStatus ) {
String status;
String style;
switch ( aStatus ) {
case RUNNING:
status = getLocalizedString( "monitoringRunning" );
style = "monitoringRunning";
break;
case TERMINATED:
status = getLocalizedString( "monitoringTerminated" );
style = "monitoringTerminated";
break;
case NO_MONITORING:
default:
status = getLocalizedString( "noMonitoringStarted" );
style = "noMonitoringStarted";
break;
}
getView( ).getStatus( ).setText( status );
getView( ).getStatus( ).getStyleClass( ).add( style );
}
public void updatePresentationConfiguration( final MonitoringConfiguration aConfiguration ) {
getView( ).getActive( ).setSelected( aConfiguration.isActive( ) );
getView( ).getOutputDirectory( ).setText( aConfiguration.getOutputDirectory( ) );
getView( ).getTimer( ).setValue( aConfiguration.getTimer( ) );
getView( ).getWriter( ).setValue( aConfiguration.getWriter( ) );
getView( ).getMaxEntriesPerFile( ).setText( Integer.toString( aConfiguration.getMaxEntriesPerFile( ) ) );
getView( ).getQueueSize( ).setText( Integer.toString( aConfiguration.getQueueSize( ) ) );
getView( ).getBuffer( ).setText( Integer.toString( aConfiguration.getBuffer( ) ) );
}
public MonitoringConfiguration savePresentationConfiguration( ) {
final MonitoringConfiguration configuration = new MonitoringConfiguration( );
configuration.setActive( getView( ).getActive( ).isSelected( ) );
configuration.setOutputDirectory( getView( ).getOutputDirectory( ).getText( ) );
configuration.setTimer( getView( ).getTimer( ).getValue( ) );
configuration.setWriter( getView( ).getWriter( ).getValue( ) );
configuration.setMaxEntriesPerFile( Integer.parseInt( getView( ).getMaxEntriesPerFile( ).getText( ) ) );
configuration.setQueueSize( Integer.parseInt( getView( ).getQueueSize( ).getText( ) ) );
configuration.setBuffer( Integer.parseInt( getView( ).getBuffer( ).getText( ) ) );
return configuration;
}
}
\ No newline at end of file
file=File
importLog=Import monitoring log
settings=Settings
monitoring=Monitoring settings
close=Close
help=Help
......
file=Datei
importLog=Monitoring Log Importieren
settings=Einstellungen
monitoring=Monitoring Einstellungen
close=Beenden
help=Hilfe
......
.status {
-fx-background-color: transparent;
-fx-background-insets: 0px;
}
.noMonitoringStarted {
-fx-text-background-color: orange;
}
.monitoringTerminated {
-fx-text-background-color: red;
}
.monitoringRunning {
-fx-text-background-color: green;
}
\ No newline at end of file
title=Monitoring Settings
icon=kieker-logo.png
cancel=Cancel
ok=Ok
status=Status:
active=Monitoring active:
outputDirectory=Output directory:
timer=Timer:
writer=Writer:
maxEntriesPerFile=Maximal entries per file:
queueSize=Queue Size:
buffer=Buffer Size:
\ No newline at end of file
noMonitoringStarted=No monitoring started
monitoringTerminated=Monitoring terminated
monitoringRunning=Monitoring running
\ No newline at end of file
noMonitoringStarted=Kein Monitoring gestartet
monitoringTerminated=Monitoring terminiert
monitoringRunning=Monitoring luft
\ No newline at end of file
title=Monitoring Einstellungen
cancel=Abbrechen
ok=Ok
status=Status:
active=Monitoring aktiv:
outputDirectory=Ausgabeverzeichnis:
timer=Timer:
writer=Writer:
maxEntriesPerFile=Maximale Eintrge pro Datei:
queueSize=Queuegre:
buffer=Buffergre:
\ No newline at end of file
package kieker.diagnosis.architecture.monitoring;
public final class MonitoringConfiguration {
private String ivOutputDirectory;
private boolean ivActive;
private Timer ivTimer;
private Writer ivWriter;
private int ivMaxEntriesPerFile;
private int ivQueueSize;
private int ivBuffer;
public String getOutputDirectory( ) {
return ivOutputDirectory;
}
public void setOutputDirectory( final String aOutputDirectory ) {
ivOutputDirectory = aOutputDirectory;
}
public boolean isActive( ) {
return ivActive;
}
public void setActive( final boolean aActive ) {
ivActive = aActive;
}
public Timer getTimer( ) {
return ivTimer;
}
public void setTimer( final Timer aTimer ) {
ivTimer = aTimer;
}
public Writer getWriter( ) {
return ivWriter;
}
public void setWriter( final Writer aWriter ) {
ivWriter = aWriter;
}
public int getMaxEntriesPerFile( ) {
return ivMaxEntriesPerFile;
}
public void setMaxEntriesPerFile( final int aMaxEntriesPerFile ) {
ivMaxEntriesPerFile = aMaxEntriesPerFile;
}
public int getQueueSize( ) {
return ivQueueSize;
}
public void setQueueSize( final int aQueueSize ) {
ivQueueSize = aQueueSize;
}
public int getBuffer( ) {
return ivBuffer;
}
public void setBuffer( final int aBuffer ) {
ivBuffer = aBuffer;
}
}
package kieker.diagnosis.architecture.monitoring;
import kieker.monitoring.core.controller.IMonitoringController;
public final class MonitoringControllerHolder {
private static volatile IMonitoringController cvMonitoringController;
private static volatile MonitoringConfiguration cvMonitoringConfiguration;
public static IMonitoringController getMonitoringController( ) {
return cvMonitoringController;
}
public static void setMonitoringController( final IMonitoringController aMonitoringController ) {
cvMonitoringController = aMonitoringController;
}
public static MonitoringConfiguration getCurrentConfiguration( ) {
return cvMonitoringConfiguration;
}
public static void setCurrentConfiguration( final MonitoringConfiguration aMonitoringConfiguration ) {
cvMonitoringConfiguration = aMonitoringConfiguration;
}
public static IMonitoringController clearMonitoringController( ) {
final IMonitoringController controller = cvMonitoringController;
cvMonitoringController = null;
return controller;
}
}