diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CockpitBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CockpitBean.java index 29ad9012d8b88f56c46a78eafd73bb826d0176e8..7c4d79641b89cb09f573332e5d54f97087795b93 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CockpitBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CockpitBean.java @@ -18,20 +18,22 @@ package kieker.webgui.web.beans.view; import java.io.IOException; import java.util.Arrays; -import java.util.Collections; +import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; +import javax.el.ValueExpression; import javax.faces.application.Application; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.component.UISelectItem; import javax.faces.component.html.HtmlForm; import javax.faces.component.html.HtmlOutputText; -import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.component.html.HtmlPanelGroup; import javax.faces.context.FacesContext; import javax.faces.event.AbortProcessingException; import javax.faces.event.ActionEvent; @@ -62,7 +64,8 @@ import org.primefaces.component.chart.pie.PieChart; import org.primefaces.component.commandbutton.CommandButton; import org.primefaces.component.dashboard.Dashboard; import org.primefaces.component.panel.Panel; -import org.primefaces.component.selectmanycheckbox.SelectManyCheckbox; +import org.primefaces.component.selectcheckboxmenu.SelectCheckboxMenu; +import org.primefaces.component.separator.Separator; import org.primefaces.component.tagcloud.TagCloud; import org.primefaces.model.DashboardColumn; import org.primefaces.model.DashboardModel; @@ -111,6 +114,9 @@ public final class CockpitBean { private MIProject project; private MIView activeView; + private final Map<String, List<String>> xyplotSelections = new HashMap<String, List<String>>(); + private String selectedDisplayConnector; + @Autowired private GlobalPropertiesBean globalPropertiesBean; @Autowired @@ -592,8 +598,20 @@ public final class CockpitBean { meterGaugeChartModel = new MeterGaugeChartModel(); meterGaugeChart.setValue(meterGaugeChartModel); + // Create the Primefaces Commandbutton component + final CommandButton button = (CommandButton) application.createComponent(facesContext, "org.primefaces.component.CommandButton", + "org.primefaces.component.CommandButtonRenderer"); + button.setValue("Settings"); + button.setAjax(true); + button.setUpdate(":displaySettingsDialogForm"); + + final Separator separator = (Separator) application.createComponent(facesContext, + "org.primefaces.component.Separator", "org.primefaces.component.SeparatorRenderer"); + component.getChildren().clear(); component.getChildren().add(meterGaugeChart); + component.getChildren().add(separator); + component.getChildren().add(button); } try { @@ -664,8 +682,20 @@ public final class CockpitBean { pieChartModel = new PieChartModel(); pieChart.setValue(pieChartModel); + // Create the Primefaces Commandbutton component + final CommandButton button = (CommandButton) application.createComponent(facesContext, "org.primefaces.component.CommandButton", + "org.primefaces.component.CommandButtonRenderer"); + button.setValue("Settings"); + button.setAjax(true); + button.setUpdate(":displaySettingsDialogForm"); + + final Separator separator = (Separator) application.createComponent(facesContext, + "org.primefaces.component.Separator", "org.primefaces.component.SeparatorRenderer"); + component.getChildren().clear(); component.getChildren().add(pieChart); + component.getChildren().add(separator); + component.getChildren().add(button); } try { @@ -740,8 +770,12 @@ public final class CockpitBean { }); button.setUpdate(":displaySettingsDialogForm"); + final Separator separator = (Separator) application.createComponent(facesContext, + "org.primefaces.component.Separator", "org.primefaces.component.SeparatorRenderer"); + component.getChildren().clear(); component.getChildren().add(lineChart); + component.getChildren().add(separator); component.getChildren().add(button); } @@ -749,6 +783,12 @@ public final class CockpitBean { final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnectorName); final Set<String> keys = (Set<String>) new Mirror().on(displayObj).invoke().method("getKeys").withoutArgs(); + if (!this.xyplotSelections.containsKey(displayConnectorName)) { + final List<String> selection = new LinkedList<String>(); + selection.addAll(keys); + this.xyplotSelections.put(displayConnectorName, selection); + } + lineChart.setLegendCols((int) (Math.ceil(keys.size() / 10.0))); linearModel.clear(); @@ -758,6 +798,9 @@ public final class CockpitBean { linearModel.addSeries(series); } else { for (final String key : keys) { + if (!this.xyplotSelections.get(displayConnectorName).contains(key)) { + continue; + } final Map<Object, Number> entries = (Map<Object, Number>) new Mirror().on(displayObj).invoke().method("getEntries").withArgs(key); final LineChartSeries lineChartSeries = new LineChartSeries(); lineChartSeries.setLabel(key); @@ -789,43 +832,65 @@ public final class CockpitBean { @SuppressWarnings("unchecked") private void updateXYPlotDisplaySettings(final String displayConnectorName) { try { + this.selectedDisplayConnector = displayConnectorName; final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnectorName); final Set<String> keys = (Set<String>) new Mirror().on(displayObj).invoke().method("getKeys").withoutArgs(); final FacesContext facesContext = FacesContext.getCurrentInstance(); final Application application = facesContext.getApplication(); - final int numberColumns = (int) (Math.ceil(keys.size() / 10.0)); - - final HtmlPanelGrid grid = new HtmlPanelGrid(); - grid.setColumns(numberColumns); - - grid.setColumnClasses(Collections.nCopies(numberColumns, "settings-dialog-column").toString().replace("[", "").replace("]", "")); + final SelectCheckboxMenu selectManyCheckbox = (SelectCheckboxMenu) application.createComponent(facesContext, + "org.primefaces.component.SelectCheckboxMenu", "org.primefaces.component.SelectCheckboxMenuRenderer"); + selectManyCheckbox.setLabel("Visible Plots"); + selectManyCheckbox.setFilter(true); + selectManyCheckbox.setValueExpression("value", CockpitBean.createValueExpression("#{cockpitBean.xyplotSelection}", List.class)); final Iterator<String> keyIter = keys.iterator(); - for (int i = 0; i < numberColumns; i++) { - final SelectManyCheckbox selectManyCheckbox = (SelectManyCheckbox) application.createComponent(facesContext, - "org.primefaces.component.SelectManyCheckbox", - "org.primefaces.component.SelectManyCheckboxRenderer"); - selectManyCheckbox.setLayout("pageDirection"); - for (int j = 0; j < 10; j++) { - if (keyIter.hasNext()) { - final UISelectItem item = new UISelectItem(); - item.setValue(new SelectItem(keyIter.next())); - selectManyCheckbox.getChildren().add(item); - } - } - grid.getChildren().add(selectManyCheckbox); + while (keyIter.hasNext()) { + final UISelectItem item = new UISelectItem(); + item.setValue(new SelectItem(keyIter.next())); + selectManyCheckbox.getChildren().add(item); } this.displaySettingsDialog.getChildren().clear(); - this.displaySettingsDialog.getChildren().add(grid); + this.displaySettingsDialog.getChildren().add(selectManyCheckbox); + + final HtmlPanelGroup div = new HtmlPanelGroup(); + div.setLayout("block"); + div.setStyle("align: right"); + + final Separator separator = (Separator) application.createComponent(facesContext, + "org.primefaces.component.Separator", "org.primefaces.component.SeparatorRenderer"); + final CommandButton button = (CommandButton) application.createComponent(facesContext, + "org.primefaces.component.CommandButton", + "org.primefaces.component.CommandButtonRenderer"); + + button.setValue("Ok"); + button.setOnclick("displaySettingsDlg.hide()"); + + div.getChildren().add(separator); + div.getChildren().add(button); + this.displaySettingsDialog.getChildren().add(div); } catch (final Exception ex) { // NOCS NOPMD (Temporary catch) ex.printStackTrace(); } } + public List<String> getXyplotSelection() { + return this.xyplotSelections.get(this.selectedDisplayConnector); + } + + public void setXyplotSelection(final List<String> xyplotSelection) { + this.xyplotSelections.put(this.selectedDisplayConnector, xyplotSelection); + } + + private static ValueExpression createValueExpression(final String valueExpression, final Class<?> valueType) { + final FacesContext context = FacesContext.getCurrentInstance(); + return context.getApplication().getExpressionFactory() + .createValueExpression(context.getELContext(), valueExpression, valueType); + } + public HtmlForm getDisplaySettingsDialog() { return this.displaySettingsDialog; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/ControllerBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/ControllerBean.java index fe8c0279eba3d70edd00e20136e92b2335da7998..1b1df342a5b44f86ee40ea2cc97e034514f4ee45 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/ControllerBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/ControllerBean.java @@ -115,7 +115,7 @@ public final class ControllerBean { this.addLogEntry("The project does not exist."); } catch (final LockProjectException ex) { ControllerBean.LOG.info("An error occured during the operation.", ex); - this.addLogEntry("An error occured during the operation."); + this.addLogEntry(this.globalPropertiesBean.getLogMsgErrorOccured()); } } @@ -134,13 +134,13 @@ public final class ControllerBean { this.addLogEntry("The project does not exist."); } catch (final IOException ex) { ControllerBean.LOG.info("An error occured during the initialization.", ex); - this.addLogEntry("An error occured during the initialization.", ex); + this.addLogEntry(this.globalPropertiesBean.getLogMsgErrorDuringInitialization(), ex); } catch (final AnalysisInitializationException ex) { ControllerBean.LOG.info("An error occured during the initialization.", ex); - this.addLogEntry("An error occured during the initialization.", ex); + this.addLogEntry(this.globalPropertiesBean.getLogMsgErrorDuringInitialization(), ex); } catch (final LockProjectException ex) { ControllerBean.LOG.info("An error occured during the initialization.", ex); - this.addLogEntry("An error occured during the initialization."); + this.addLogEntry(this.globalPropertiesBean.getLogMsgErrorDuringInitialization()); } } @@ -159,7 +159,7 @@ public final class ControllerBean { this.addLogEntry("The analysis has not been instantiated yet."); } catch (final LockProjectException ex) { ControllerBean.LOG.info("An error occured during the operation.", ex); - this.addLogEntry("An error occured during the operation."); + this.addLogEntry(this.globalPropertiesBean.getLogMsgErrorOccured()); } } diff --git a/Kieker.WebGUI/src/main/resources/lang/ControllerPage_en.properties b/Kieker.WebGUI/src/main/resources/lang/ControllerPage_en.properties index ebf148ad48d0f7940cf1a8813da56e6c78dfb634..5f1bb094d1f6c995b9b8f3b49bc43a8fb5658298 100644 --- a/Kieker.WebGUI/src/main/resources/lang/ControllerPage_en.properties +++ b/Kieker.WebGUI/src/main/resources/lang/ControllerPage_en.properties @@ -20,10 +20,10 @@ lblNoLogEntries = No log entries available. #-------------------------------------------------------------------------------------------------------------------------------------------------------------------- logMsgAnalysisAlreadyStarted = The analysis has already been started. -logMsgErrorOccured = An error occured during the operation. +logMsgErrorOccured = An error occurred during the operation. logMsgAnalysisNotStarted = The analysis has not been started yet. logMsgAnalysisAlreadyInstantiated = The analysis has already been instantiated. -logMsgErrorDuringInitialization = An error occured during the initialization. +logMsgErrorDuringInitialization = An error occurred during the initialization. logMsgNotInstantiated = The analysis has not been instantiated yet. logMsgStartingAnalysis = Starting Analysis... diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/ControllerPageDialogs.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/ControllerPageDialogs.xhtml index 273851f14c1617c691e50d3afc4ce8efdcf370ef..79c42b1016669da8f3aa1fdd496b84369662b552 100644 --- a/Kieker.WebGUI/src/main/webapp/dialogs/ControllerPageDialogs.xhtml +++ b/Kieker.WebGUI/src/main/webapp/dialogs/ControllerPageDialogs.xhtml @@ -6,7 +6,6 @@ xmlns:f="http://java.sun.com/jsf/core"> <p:dialog header="#{localizedMessages.lblDetails}" resizable="false" closable="false" modal="true" width="800" widgetVar="detailsDialog"> - <!-- Make sure that closing the dialog updates the input fields and the messages. --> <p:ajax event="close" update="detailsDialogForm" /> <h:form id="detailsDialogForm">