diff --git a/Kieker.WebGUI/bin/data/CPU-and-Memory-Example/CPU-and-Memory-Example.kax b/Kieker.WebGUI/bin/data/CPU-and-Memory-Example/CPU-and-Memory-Example.kax index 5b3c000ed01607f8543b439d27266f3063861689..d806a6449591b1bf9979dda98460aa03c941537d 100644 --- a/Kieker.WebGUI/bin/data/CPU-and-Memory-Example/CPU-and-Memory-Example.kax +++ b/Kieker.WebGUI/bin/data/CPU-and-Memory-Example/CPU-and-Memory-Example.kax @@ -33,15 +33,15 @@ <outputPorts name="eventsNotMatchingType" id="23" subscribers="10"/> <inputPorts name="events" id="24"/> </plugins> - <views name="CPU View" description="View on the CPU Utilization" id="14"> - <displayConnectors name="XYPlot CPU utilization Display" display="7" id="15"/> - <displayConnectors name="Meter Gauge CPU total utilization Display" display="8" id="16"/> - </views> <views name="Memory View" description="View on the MemSwap Utilization" id="17"> <displayConnectors name="XYPlot Memory utilization Display" display="11" id="18"/> <displayConnectors name="PieChart Memory Utilization Display" display="12" id="19"/> <displayConnectors name="PieChart Swap Utilization Display" display="13" id="20"/> </views> + <views name="CPU View" description="View on the CPU Utilization" id="14"> + <displayConnectors name="XYPlot CPU utilization Display" display="7" id="15"/> + <displayConnectors name="Meter Gauge CPU total utilization Display" display="8" id="16"/> + </views> <properties name="recordsTimeUnit" value="NANOSECONDS"/> <properties name="projectName" value="AnalysisProject"/> </Project> diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/DisplayType.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/DisplayType.java index 6c696b108ce9c1967e747c7a244677d69d3163db..d63f2db3f8ebef227085e4cd0a1eeb2e5a21c22b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/DisplayType.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/DisplayType.java @@ -36,5 +36,6 @@ public enum DisplayType { /** Represents the meter gauge display type. */ METER_GAUGE, /** Represents the tag cloud display type. */ - TAG_CLOUD + TAG_CLOUD, + UNKNOWN } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/AnalysisManagementService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/AnalysisManagementService.java index e8f5449b2ae5b931ef5153791ab1623cd381b5da..f7c409fb50fef1f7ef3cd5483783fa70aad0a1fb 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/AnalysisManagementService.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/AnalysisManagementService.java @@ -239,7 +239,7 @@ public final class AnalysisManagementService { if (this.analyses.containsKey(projectName)) { return this.analyses.get(projectName).getDisplayType(viewName, displayConnectorName); } else { - return null; + return DisplayType.UNKNOWN; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/Analysis.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/Analysis.java index 9aae5cef0d4df52d2054c738422ab1fdad0d2550..5ff619dc0f8d326528adc74bedcfe4340c2f3f85 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/Analysis.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/Analysis.java @@ -262,7 +262,7 @@ public final class Analysis { } else if (parameter == this.classContainer.getPieChartClass()) { return DisplayType.PIE_CHART; } else { - return null; + return DisplayType.UNKNOWN; } } 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 82b4fcf8bebb574cada307a61cf0a239fd7d0620..6bed650e1df55e0dbf3e2852ce42fea2627b595c 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,31 +18,19 @@ package kieker.webgui.web.beans.view; import java.io.IOException; import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; 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.HtmlPanelGroup; import javax.faces.context.FacesContext; -import javax.faces.event.AbortProcessingException; -import javax.faces.event.ActionEvent; -import javax.faces.event.ActionListener; -import javax.faces.model.SelectItem; + +import com.google.common.base.Functions; +import com.google.common.collect.Maps; import kieker.analysis.AnalysisController; -import kieker.analysis.AnalysisController.STATE; -import kieker.analysis.model.analysisMetaModel.MIDisplayConnector; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIView; import kieker.common.logging.Log; @@ -60,22 +48,11 @@ import kieker.webgui.domain.DisplayType; import kieker.webgui.service.IProjectService; import kieker.webgui.web.beans.application.GlobalPropertiesBean; import kieker.webgui.web.utility.CockpitLayout; +import kieker.webgui.web.utility.IDisplayConnectorSettings; +import kieker.webgui.web.utility.MeterGaugeDisplaySettings; +import kieker.webgui.web.utility.PieChartDisplaySettings; +import kieker.webgui.web.utility.XYPlotDisplaySettings; -import org.primefaces.component.chart.line.LineChart; -import org.primefaces.component.chart.metergauge.MeterGaugeChart; -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.selectbooleancheckbox.SelectBooleanCheckbox; -import org.primefaces.component.selectcheckboxmenu.SelectCheckboxMenu; -import org.primefaces.component.selectonelistbox.SelectOneListbox; -import org.primefaces.component.separator.Separator; -import org.primefaces.component.tagcloud.TagCloud; -import org.primefaces.model.DashboardColumn; -import org.primefaces.model.DashboardModel; -import org.primefaces.model.DefaultDashboardColumn; -import org.primefaces.model.DefaultDashboardModel; import org.primefaces.model.chart.CartesianChartModel; import org.primefaces.model.chart.LineChartSeries; import org.primefaces.model.chart.MeterGaugeChartModel; @@ -105,22 +82,15 @@ public final class CockpitBean { private static final Log LOG = LogFactory.getLog(CockpitBean.class); - private static final String DASHBOARD_ID = "dashboard"; - private static final String PANEL_ID_PREFIX = "panel_"; private static final int NUMBER_OF_COCKPIT_COLUMNS = 2; - private final Registry<MIDisplayConnector> displayConnectors = new Registry<MIDisplayConnector>(); + private final Map<MIView, Map<String, IDisplayConnectorSettings>> displaySettings = new ConcurrentHashMap<MIView, Map<String, IDisplayConnectorSettings>>(); - private HtmlForm displaySettingsDialog; private CockpitLayout cockpitLayout; - private DashboardModel dashboardModel; - private Dashboard dashboard; private String projectName; private MIProject project; private MIView activeView; - - private final Map<MIDisplayConnector, IDisplaySetting> displaySettings = new ConcurrentHashMap<MIDisplayConnector, IDisplaySetting>(); - private MIDisplayConnector selectedDisplayConnector; + private String selectedDisplay; @Autowired private GlobalPropertiesBean globalPropertiesBean; @@ -145,8 +115,8 @@ public final class CockpitBean { this.loadProject(); if (this.project != null) { - this.createDashboardComponent(); this.loadCockpitLayout(); + this.createSettingsMapsForViews(); } } } catch (final ProjectLoadException ex) { @@ -159,45 +129,24 @@ public final class CockpitBean { } } - /** - * Sets the active view to a new value and updates the dashboard. - * - * @param activeView - * The new active view. - */ - public void setActiveView(final MIView activeView) { - this.activeView = activeView; - - this.fillDashboardWithActiveView(); - } - - public void setSettingForDisplay(final MIDisplayConnector display, final IDisplaySetting setting) { - this.displaySettings.put(display, setting); + public String getSelectedDisplay() { + return this.selectedDisplay; } - public IDisplaySetting getSettingForDisplay(final MIDisplayConnector display) { - return this.displaySettings.get(display); + public void setSelectedDisplay(final String selectedDisplay) { + this.selectedDisplay = selectedDisplay; } - /** - * Sets the dashboard of this bean. - * - * @param dashboard - * The new dashboard. - */ - public void setDashboard(final Dashboard dashboard) { - this.dashboard = dashboard; - - // This step is necessary as we lose otherwise the dashboard model - this.dashboard.setModel(this.dashboardModel); + public void setActiveView(final MIView activeView) { + this.activeView = activeView; } public MIView getActiveView() { return this.activeView; } - public Dashboard getDashboard() { - return this.dashboard; + public CockpitLayout getCockpitLayout() { + return this.cockpitLayout; } public MIProject getProject() { @@ -213,678 +162,211 @@ public final class CockpitBean { } /** - * Checks whether the analysis is currently running. + * Delivers the current meter gauge settings container for the given connector name. If it does not exist, it will be created. * - * @return true if and only if the analysis is running. - */ - public boolean isAnalysisRunning() { - try { - return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.RUNNING; - } catch (final NullPointerException ex) { - // This exception can occur, when the projectsBean has not been initialized - LOG.warn("A null pointer exception occured.", ex); - } catch (final LockProjectException ex) { - LOG.warn("An error occured.", ex); - } - return false; - } - - /** - * Checks whether the analysis is currently in the ready state. + * @param displayConnectorName + * The name of the display connector. * - * @return true if and only if the analysis is ready to be started. + * @return The settings container for the given display connector. */ - public boolean isAnalysisReady() { - try { - return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.READY; - } catch (final NullPointerException ex) { - // This exception can occur, when the projectsBean has not been initialized - LOG.warn("A null pointer exception occured.", ex); - } catch (final LockProjectException ex) { - LOG.warn("An error occured.", ex); - } - return false; - } + public MeterGaugeDisplaySettings getMeterGaugeDisplaySettings(final String displayConnectorName) { + // Get the existing settings container + final IDisplayConnectorSettings existingSettingsContainer = this.displaySettings.get(this.activeView).get(displayConnectorName); - /** - * Checks whether the analysis is not available. - * - * @return true if and only if the analysis is <b>not</b> available. - */ - public boolean isAnalysisNotAvailable() { - try { - return this.projectService.getCurrentState(this.projectName) == null; - } catch (final NullPointerException ex) { - // This exception can occur, when the projectsBean has not been initialized - LOG.warn("A null pointer exception occured.", ex); - } catch (final LockProjectException ex) { - LOG.warn("An error occured.", ex); + // Check if we have to create a new settings container + if (existingSettingsContainer instanceof MeterGaugeDisplaySettings) { + return (MeterGaugeDisplaySettings) existingSettingsContainer; + } else { + final MeterGaugeDisplaySettings newSettingsContainer = new MeterGaugeDisplaySettings(); + this.displaySettings.get(this.activeView).put(displayConnectorName, newSettingsContainer); + return newSettingsContainer; } - return true; } /** - * Checks whether the analysis is currently terminated. + * Delivers the current xy plot settings container for the given connector name. If it does not exist, it will be created. * - * @return true if and only if the analysis has been terminated. - */ - public boolean isAnalysisTerminated() { - try { - return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.TERMINATED; - } catch (final NullPointerException ex) { - // This exception can occur, when the projectsBean has not been initialized - LOG.warn("A null pointer exception occured.", ex); - } catch (final LockProjectException ex) { - LOG.warn("An error occured.", ex); - } - return false; - } - - /** - * Checks whether the analysis is currently terminating. + * @param displayConnectorName + * The name of the display connector. * - * @return true if and only if the analysis is currently terminating. + * @return The settings container for the given display connector. */ - public boolean isAnalysisTerminating() { - try { - return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.TERMINATING; - } catch (final NullPointerException ex) { - // This exception can occur, when the projectsBean has not been initialized - LOG.warn("A null pointer exception occured.", ex); - } catch (final LockProjectException ex) { - LOG.warn("An error occured.", ex); - } - return false; - } + public XYPlotDisplaySettings getXYPlotDisplaySettings(final String displayConnectorName) { + // Get the existing settings container + final IDisplayConnectorSettings existingSettingsContainer = this.displaySettings.get(this.activeView).get(displayConnectorName); - /** - * Checks whether the analysis is currently in the failed state. - * - * @return true if and only if the analysis has failed. - */ - public boolean isAnalysisFailed() { - try { - return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.FAILED; - } catch (final NullPointerException ex) { - // This exception can occur, when the projectsBean has not been initialized - LOG.warn("A null pointer exception occured.", ex); - } catch (final LockProjectException ex) { - LOG.warn("An error occured.", ex); + // Check if we have to create a new settings container + if (existingSettingsContainer instanceof XYPlotDisplaySettings) { + return (XYPlotDisplaySettings) existingSettingsContainer; + } else { + final XYPlotDisplaySettings newSettingsContainer = new XYPlotDisplaySettings(); + this.displaySettings.get(this.activeView).put(displayConnectorName, newSettingsContainer); + return newSettingsContainer; } - return false; } /** - * Updates all displays of the currently active view. + * Delivers the current pie chart settings container for the given connector name. If it does not exist, it will be created. + * + * @param displayConnectorName + * The name of the display connector. + * + * @return The settings container for the given display connector. */ - public void updateDisplaysOfActiveView() { - if (this.projectName != null) { - for (final UIComponent component : this.dashboard.getChildren()) { - // Get the correct display type of the current component - final int componentID = Integer.valueOf(component.getId().replace(PANEL_ID_PREFIX, "")); - final MIDisplayConnector displayConnector = this.displayConnectors.get(componentID); - - STATE currentState; - try { - currentState = this.projectService.getCurrentState(this.projectName); - } catch (final LockProjectException ex) { - currentState = null; - } - if (currentState != null) { - DisplayType displayType; - try { - displayType = this.projectService.getDisplayType(this.projectName, this.activeView.getName(), displayConnector.getName()); - } catch (final LockProjectException ex) { - displayType = null; - } - - if (displayType != null) { - // Update the element depending on the display type - switch (displayType) { - case PLAIN_TEXT: - this.updatePlainTextDisplay(component, displayConnector); - break; - case HTML_TEXT: - this.updateHTMLTextDisplay(component, displayConnector); - break; - case IMAGE: - this.updateImageDisplay(component, displayConnector); - break; - case XY_PLOT: - this.updateXYPlotDisplay(component, displayConnector); - break; - case METER_GAUGE: - this.updateMeterGaugeDisplay(component, displayConnector); - break; - case TAG_CLOUD: - this.updateTagCloudDisplay(component, displayConnector); - break; - case PIE_CHART: - this.updatePieChartDisplay(component, displayConnector); - break; - default: - // Unknown type - this.updateDisplayWithDefaultContent(component, displayConnector); - break; - } - } else { - this.updateDisplayWithDefaultContent(component, displayConnector); - } - } else { - // If the analysis has not yet been initialized, we add a simple note to each of the panels - this.updateDisplayWithDefaultContent(component, displayConnector); - } - } - } - } - - private void loadCockpitLayout() { - try { - this.cockpitLayout = new CockpitLayout(this.project, this.projectService.getCockpitLayout(this.projectName), NUMBER_OF_COCKPIT_COLUMNS); - } catch (final LockProjectException ex) { - LOG.error("An error occured while loading the layout.", ex); - this.cockpitLayout = new CockpitLayout(this.project, null, NUMBER_OF_COCKPIT_COLUMNS); - } - } - - private void createDashboardComponent() { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final Application application = facesContext.getApplication(); - - // Create the Primefaces dashboard component - this.dashboard = (Dashboard) application.createComponent(facesContext, "org.primefaces.component.Dashboard", "org.primefaces.component.DashboardRenderer"); - this.dashboard.setId(DASHBOARD_ID); - - // Create the corresponding model with the correct number of columns - this.dashboard.setModel(new DefaultDashboardModel()); - - for (int i = 0; i < NUMBER_OF_COCKPIT_COLUMNS; i++) { - this.dashboard.getModel().addColumn(new DefaultDashboardColumn()); - } - - // Remember the dashboard model - this.dashboardModel = this.dashboard.getModel(); - } - - private void loadProject() throws ProjectLoadException { - try { - this.project = this.projectService.loadProject(this.projectName); - } catch (final IOException ex) { - LOG.error("An error occured while loading the project.", ex); - throw new ProjectLoadException("An error occured while loading the project.", ex); - } catch (final ProjectNotExistingException ex) { - LOG.info("A project with the given name does not exist.", ex); - throw new ProjectLoadException("A project with the given name does not exist.", ex); - } catch (final LockProjectException ex) { - LOG.error("An error occured while loading the project.", ex); - throw new ProjectLoadException("An error occured while loading the project.", ex); - } - } - - private void fillDashboardWithActiveView() { - // Dump the old entries - this.clearDashboard(); - - // Now add the entries from the active view - if (this.activeView != null) { - final List<List<MIDisplayConnector>> layout = this.cockpitLayout.getCurrentLayout(this.activeView); - - for (int columnIndex = 0; columnIndex < NUMBER_OF_COCKPIT_COLUMNS; columnIndex++) { - final DashboardColumn column = this.dashboard.getModel().getColumn(columnIndex); - - for (final MIDisplayConnector displayConnector : layout.get(columnIndex)) { - final Panel panel = this.createPanelFromDisplayConnector(displayConnector); - - // Add the panel to the dashboard and to its model - this.dashboard.getChildren().add(panel); - column.addWidget(panel.getId()); - } - } - } - } - - private void clearDashboard() { - // Run through all columns of the dashboard and remove the items - final List<DashboardColumn> columns = this.dashboard.getModel().getColumns(); - for (final DashboardColumn column : columns) { - column.getWidgets().clear(); - } - - // Now clear the dashboard itself - this.dashboard.getChildren().clear(); - } - - private Panel createPanelFromDisplayConnector(final MIDisplayConnector connector) { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final Application application = facesContext.getApplication(); - - // Create the Primefaces panel component - final Panel panel = (Panel) application.createComponent(facesContext, "org.primefaces.component.Panel", "org.primefaces.component.PanelRenderer"); - - // Set the usual properties of the panel - panel.setId(this.displayConnectorToID(connector)); - panel.setHeader(connector.getName()); - panel.setClosable(false); - panel.setToggleable(false); - - return panel; - } - - private String displayConnectorToID(final MIDisplayConnector displayConnector) { - return PANEL_ID_PREFIX + this.displayConnectors.get(displayConnector); - } - - private void updateDisplayWithDefaultContent(final UIComponent component, final MIDisplayConnector displayConnector) { - final boolean isAlreadyCorrectlyInitialized = (component.getChildCount() == 1) && (component.getChildren().get(0) instanceof HtmlOutputText); - final HtmlOutputText htmlOutputText; + public PieChartDisplaySettings getPieChartDisplaySettings(final String displayConnectorName) { + // Get the existing settings container + final IDisplayConnectorSettings existingSettingsContainer = this.displaySettings.get(this.activeView).get(displayConnectorName); - // Avoid unnecessary component creation. Use the existing components if they are already existing and from the correct type. - if (isAlreadyCorrectlyInitialized) { - htmlOutputText = (HtmlOutputText) component.getChildren().get(0); + // Check if we have to create a new settings container + if (existingSettingsContainer instanceof PieChartDisplaySettings) { + return (PieChartDisplaySettings) existingSettingsContainer; } else { - htmlOutputText = new HtmlOutputText(); - - component.getChildren().clear(); - component.getChildren().add(htmlOutputText); - - this.addButtonBoxToComponent(component, displayConnector, null); + final PieChartDisplaySettings newSettingsContainer = new PieChartDisplaySettings(); + this.displaySettings.get(this.activeView).put(displayConnectorName, newSettingsContainer); + return newSettingsContainer; } - - htmlOutputText.setValue("N/A"); - } - - private void updateHTMLTextDisplay(final UIComponent component, final MIDisplayConnector displayConnector) { // NOPMD (Not implemented yet) - // Not implemented yet - this.updateDisplayWithDefaultContent(component, displayConnector); } - private void updateImageDisplay(final UIComponent component, final MIDisplayConnector displayConnector) { // NOPMD (Not implemented yet) - // Not implemented yet - this.updateDisplayWithDefaultContent(component, displayConnector); - } - - private void updatePlainTextDisplay(final UIComponent component, final MIDisplayConnector displayConnector) { - final boolean isAlreadyCorrectlyInitialized = (component.getChildCount() == 1) && (component.getChildren().get(0) instanceof HtmlOutputText); - final HtmlOutputText htmlOutputText; - - // Avoid unnecessary component creation. Use the existing components if they are already existing and from the correct type. - if (isAlreadyCorrectlyInitialized) { - htmlOutputText = (HtmlOutputText) component.getChildren().get(0); - } else { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - facesContext.getApplication(); - - htmlOutputText = new HtmlOutputText(); - - component.getChildren().clear(); - component.getChildren().add(htmlOutputText); - this.addButtonBoxToComponent(component, displayConnector, DisplayType.PLAIN_TEXT); - } + /** + * Delivers a plain text update for the given display connector. + * + * @param displayConnectorName + * The name of the display connector. + * + * @return The current plain text visualization of the given display connector. + */ + public String getPlainTextUpdate(final String displayConnectorName) { + String result = "N/A"; try { - final Object displayObject = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnector.getName()); + final Object displayObject = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnectorName); final String text = (String) new Mirror().on(displayObject).invoke().method("getText").withoutArgs(); - htmlOutputText.setValue(text); - + result = text; } catch (final DisplayNotFoundException ex) { CockpitBean.LOG.warn("Display not found.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final MirrorException ex) { CockpitBean.LOG.warn("Reflection exception.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final InvalidAnalysisStateException ex) { CockpitBean.LOG.info("Project is in invalid state.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final LockProjectException ex) { CockpitBean.LOG.info("An error occured.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } - } - - @SuppressWarnings("unchecked") - private void updateTagCloudDisplay(final UIComponent component, final MIDisplayConnector displayConnector) { - final boolean isAlreadyCorrectlyInitialized = (component.getChildCount() == 1) && (component.getChildren().get(0) instanceof MeterGaugeChart); - - final TagCloudModel tagCloudModel; - - // Avoid unnecessary component creation. Use the existing components if they are already existing and from the correct type. - if (isAlreadyCorrectlyInitialized) { - final TagCloud tagCloud = (TagCloud) component.getChildren().get(0); - tagCloudModel = tagCloud.getModel(); - } else { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final Application application = facesContext.getApplication(); - - // Create the Primefaces chart component - final TagCloud tagCloud = (TagCloud) application.createComponent(facesContext, "org.primefaces.component.TagCloud", - "org.primefaces.component.TagCloudRenderer"); - // Add the corresponding model - tagCloudModel = new DefaultTagCloudModel(); - tagCloud.setModel(tagCloudModel); - tagCloud.setStyle("width: 100%; Height: 100%;"); - - component.getChildren().clear(); - component.getChildren().add(tagCloud); - this.addButtonBoxToComponent(component, displayConnector, DisplayType.TAG_CLOUD); - } - - try { - final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnector.getName()); - - final Map<String, AtomicLong> counters = (Map<String, AtomicLong>) new Mirror().on(displayObj).invoke().method("getCounters").withoutArgs(); - tagCloudModel.clear(); - for (final Map.Entry<String, AtomicLong> counter : counters.entrySet()) { - tagCloudModel.addTag(new DefaultTagCloudItem(counter.getKey(), (int) counter.getValue().get())); - } - - } catch (final DisplayNotFoundException ex) { - CockpitBean.LOG.warn("Display not found.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); - } catch (final MirrorException ex) { - CockpitBean.LOG.warn("Reflection exception.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); - } catch (final InvalidAnalysisStateException ex) { - CockpitBean.LOG.info("Project is in invalid state.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); - } catch (final LockProjectException ex) { - CockpitBean.LOG.info("An error occured.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); - } + return result; } + /** + * Delivers a meter gauge update for the given display connector. + * + * @param displayConnectorName + * The name of the display connector. + * + * @return The current meter gauge visualization of the given display connector. + */ @SuppressWarnings("unchecked") - private void updateMeterGaugeDisplay(final UIComponent component, final MIDisplayConnector displayConnector) { - final boolean isAlreadyCorrectlyInitialized = (component.getChildCount() == 1) && (component.getChildren().get(0) instanceof MeterGaugeChart); - - final MeterGaugeChart meterGaugeChart; - final MeterGaugeChartModel meterGaugeChartModel; - - // Avoid unnecessary component creation. Use the existing components if they are already existing and from the correct type. - if (isAlreadyCorrectlyInitialized) { - meterGaugeChart = (MeterGaugeChart) component.getChildren().get(0); - meterGaugeChartModel = meterGaugeChart.getValue(); - } else { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final Application application = facesContext.getApplication(); - - // Create the Primefaces chart component - meterGaugeChart = (MeterGaugeChart) application.createComponent(facesContext, "org.primefaces.component.chart.MeterGaugeChart", - "org.primefaces.component.chart.MeterGaugeChartRenderer"); - meterGaugeChart.setTitle(displayConnector.getName()); - - // Add the corresponding model - meterGaugeChartModel = new MeterGaugeChartModel(); - meterGaugeChart.setValue(meterGaugeChartModel); - - component.getChildren().clear(); - component.getChildren().add(meterGaugeChart); - this.addButtonBoxToComponent(component, displayConnector, DisplayType.METER_GAUGE); - } + public MeterGaugeChartModel getMeterGaugeUpdate(final String displayConnectorName) { + final MeterGaugeChartModel model = new MeterGaugeChartModel(); try { - final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnector.getName()); - + 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 MeterGaugeDisplaySettings settings = this.getMeterGaugeDisplaySettings(displayConnectorName); - if (keys.isEmpty()) { - meterGaugeChartModel.setIntervals(Arrays.asList((Number) 50)); - meterGaugeChartModel.setValue(0); - } else { - if (!this.displaySettings.containsKey(displayConnector)) { - final MeterGaugeDisplaySetting setting = new MeterGaugeDisplaySetting(); - setting.setSelectedDiagram(keys.iterator().next()); - this.displaySettings.put(displayConnector, setting); - } - // TODO Use correct key + // Fill the settings with the available plots + settings.setAvailablePlots(Maps.asMap(keys, Functions.<String>identity())); + if (settings.getVisiblePlot().isEmpty() && !keys.isEmpty()) { + settings.setVisiblePlot(keys.iterator().next()); + } + + if (!settings.getVisiblePlot().isEmpty()) { final List<Number> intervals = (List<Number>) new Mirror().on(displayObj).invoke().method("getIntervals").withArgs(keys.iterator().next()); - final List<String> colors = (List<String>) new Mirror().on(displayObj).invoke().method("getIntervalColors").withArgs(keys.iterator().next()); - final Number value = (Number) new Mirror().on(displayObj).invoke().method("getValue") - .withArgs(((MeterGaugeDisplaySetting) this.displaySettings.get(displayConnector)).getSelectedDiagram()); - meterGaugeChart - .setTitle(displayConnector.getName() + " (" + ((MeterGaugeDisplaySetting) this.displaySettings.get(displayConnector)).getSelectedDiagram() - + ")"); - if (intervals.isEmpty()) { - meterGaugeChartModel.setIntervals(Arrays.asList((Number) 50)); - meterGaugeChartModel.setValue(0); + final Number value = (Number) new Mirror().on(displayObj).invoke().method("getValue").withArgs(keys.iterator().next()); + + model.setIntervals(intervals); + final Number maxInterval = intervals.get(intervals.size() - 1); + if (value.doubleValue() <= maxInterval.doubleValue()) { + model.setValue(value); } else { - meterGaugeChartModel.setIntervals(intervals); - meterGaugeChart.setShadow(true); - meterGaugeChart.setSeriesColors(colors.toString().replace("[", "").replace("]", "")); - final Number maxInterval = intervals.get(intervals.size() - 1); - if (value.doubleValue() <= maxInterval.doubleValue()) { - meterGaugeChartModel.setValue(value); - } else { - meterGaugeChartModel.setValue(maxInterval); - } + model.setValue(maxInterval); } } } catch (final DisplayNotFoundException ex) { CockpitBean.LOG.warn("Display not found.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final MirrorException ex) { CockpitBean.LOG.warn("Reflection exception.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final InvalidAnalysisStateException ex) { CockpitBean.LOG.info("Project is in invalid state.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final LockProjectException ex) { CockpitBean.LOG.info("An error occured.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } - } - @SuppressWarnings("unchecked") - private void updatePieChartDisplay(final UIComponent component, final MIDisplayConnector displayConnector) { - final boolean isAlreadyCorrectlyInitialized = (component.getChildCount() == 1) && (component.getChildren().get(0) instanceof PieChart); + // Make sure that default values are set if necessary + if (model.getIntervals().isEmpty()) { + model.setIntervals(Arrays.asList((Number) 50)); + model.setValue(0); + } - final PieChart pieChart; - final PieChartModel pieChartModel; + return model; + } - // Avoid unnecessary component creation. Use the existing components if they are already existing and from the correct type. - if (isAlreadyCorrectlyInitialized) { - pieChart = (PieChart) component.getChildren().get(0); - pieChartModel = (PieChartModel) pieChart.getValue(); - } else { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final Application application = facesContext.getApplication(); - - // Create the Primefaces chart component - pieChart = (PieChart) application.createComponent(facesContext, "org.primefaces.component.chart.PieChart", - "org.primefaces.component.chart.PieChartRenderer"); - pieChart.setTitle(displayConnector.getName()); - pieChart.setLegendPosition("e"); - pieChart.setShowDataLabels(true); - - // Add the corresponding model - pieChartModel = new PieChartModel(); - pieChart.setValue(pieChartModel); - - component.getChildren().clear(); - component.getChildren().add(pieChart); - this.addButtonBoxToComponent(component, displayConnector, DisplayType.PIE_CHART); - } + /** + * Delivers a tag cloud update for the given display connector. + * + * @param displayConnectorName + * The name of the display connector. + * + * @return The current tag cloud visualization of the given display connector. + */ + @SuppressWarnings("unchecked") + public TagCloudModel getTagCloudUpdate(final String displayConnectorName) { + final TagCloudModel model = new DefaultTagCloudModel(); try { - final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnector.getName()); - final Set<String> keys = (Set<String>) new Mirror().on(displayObj).invoke().method("getKeys").withoutArgs(); - - pieChart.setLegendCols((int) (Math.ceil(keys.size() / 10.0))); - pieChartModel.clear(); + final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnectorName); + final Map<String, AtomicLong> counters = (Map<String, AtomicLong>) new Mirror().on(displayObj).invoke().method("getCounters").withoutArgs(); - if (keys.isEmpty()) { - pieChartModel.set(null, 0); - } else { - for (final String key : keys) { - final Number value = (Number) new Mirror().on(displayObj).invoke().method("getValue").withArgs(key); - pieChartModel.set(key, value); - } + for (final Map.Entry<String, AtomicLong> counter : counters.entrySet()) { + model.addTag(new DefaultTagCloudItem(counter.getKey(), (int) counter.getValue().get())); } } catch (final DisplayNotFoundException ex) { CockpitBean.LOG.warn("Display not found.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final MirrorException ex) { CockpitBean.LOG.warn("Reflection exception.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final InvalidAnalysisStateException ex) { CockpitBean.LOG.info("Project is in invalid state.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final LockProjectException ex) { CockpitBean.LOG.info("An error occured.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); - } - } - - private void addButtonBoxToSettingsDialog() { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final Application application = facesContext.getApplication(); - - // Create the components rendering the div elements - final HtmlPanelGroup div = new HtmlPanelGroup(); - div.setLayout("block"); - div.setStyle("text-align: right"); - - // Create the components for the horizontal line - final Separator separator = (Separator) application.createComponent(facesContext, "org.primefaces.component.Separator", - "org.primefaces.component.SeparatorRenderer"); - - // Create the button to close the settings dialog - final CommandButton button = (CommandButton) application.createComponent(facesContext, "org.primefaces.component.CommandButton", - "org.primefaces.component.CommandButtonRenderer"); - button.setValue("Ok"); - button.setOnclick("displaySettingsDlg.hide()"); - - // Add all components - div.getChildren().add(separator); - div.getChildren().add(button); - this.displaySettingsDialog.getChildren().add(div); - } - - private void addButtonBoxToComponent(final UIComponent component, final MIDisplayConnector displayConnector, final DisplayType type) { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final Application application = facesContext.getApplication(); - - // Create the components rendering the div elements - final HtmlPanelGroup div = new HtmlPanelGroup(); - div.setLayout("block"); - div.setStyle("text-align: right"); - - // Create the button to show the settings dialog - final CommandButton button = (CommandButton) application.createComponent(facesContext, "org.primefaces.component.CommandButton", - "org.primefaces.component.CommandButtonRenderer"); - button.setValue("Settings"); - button.setOnclick("displaySettingsDlg.show()"); - button.setAjax(true); - - if (type != null) { - switch (type) { - case HTML_TEXT: - button.setDisabled(true); - break; - case IMAGE: - button.setDisabled(true); - break; - case METER_GAUGE: - button.addActionListener(new ActionListener() { - @Override - public void processAction(final ActionEvent event) throws AbortProcessingException { - CockpitBean.this.updateMeterGaugeDisplaySettings(displayConnector); - } - }); - break; - case PIE_CHART: - button.setDisabled(true); - break; - case PLAIN_TEXT: - button.setDisabled(true); - break; - case TAG_CLOUD: - button.setDisabled(true); - break; - case XY_PLOT: - button.addActionListener(new ActionListener() { - @Override - public void processAction(final ActionEvent event) throws AbortProcessingException { - CockpitBean.this.updateXYPlotDisplaySettings(displayConnector); - } - }); - break; - default: - button.setDisabled(true); - break; - - } - } else { - button.setDisabled(true); } - button.setUpdate(":displaySettingsDialogForm"); - - final Separator separator = (Separator) application.createComponent(facesContext, "org.primefaces.component.Separator", - "org.primefaces.component.SeparatorRenderer"); - div.getChildren().add(separator); - div.getChildren().add(button); - component.getChildren().add(div); + return model; } + /** + * Delivers a line chart update for the given display connector. + * + * @param displayConnectorName + * The name of the display connector. + * + * @return The current line chart visualization of the given display connector. + */ @SuppressWarnings("unchecked") - private void updateXYPlotDisplay(final UIComponent component, final MIDisplayConnector displayConnector) { - final boolean isAlreadyCorrectlyInitialized = (component.getChildCount() == 2) && (component.getChildren().get(0) instanceof LineChart) - && (component.getChildren().get(1) instanceof CommandButton); - - final LineChart lineChart; - final CartesianChartModel linearModel; - - // Avoid unnecessary component creation. Use the existing components if they are already existing and from the correct type. - if (isAlreadyCorrectlyInitialized) { - lineChart = (LineChart) component.getChildren().get(0); - linearModel = (CartesianChartModel) lineChart.getValue(); - } else { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final Application application = facesContext.getApplication(); - - // Create the Primefaces chart component - lineChart = (LineChart) application.createComponent(facesContext, "org.primefaces.component.chart.LineChart", - "org.primefaces.component.chart.LineChartRenderer"); - lineChart.setTitle(displayConnector.getName()); - lineChart.setLegendPosition("e"); - - // Add the corresponding model - linearModel = new CartesianChartModel(); - lineChart.setValue(linearModel); - - component.getChildren().clear(); - component.getChildren().add(lineChart); - this.addButtonBoxToComponent(component, displayConnector, DisplayType.XY_PLOT); - } + public CartesianChartModel getXYPlotUpdate(final String displayConnectorName) { + final CartesianChartModel model = new CartesianChartModel(); try { - final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnector.getName()); + 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 XYPlotDisplaySettings settings = this.getXYPlotDisplaySettings(displayConnectorName); - if (!this.displaySettings.containsKey(displayConnector)) { - final List<String> selection = new LinkedList<String>(); - selection.addAll(keys); - final XYPlotDisplaySetting setting = new XYPlotDisplaySetting(); - setting.setSelectedLines(selection); - this.displaySettings.put(displayConnector, setting); + // Fill the settings with the available plots + settings.setAvailablePlots(Maps.asMap(keys, Functions.<String>identity())); + if (settings.getVisiblePlots().isEmpty() && !keys.isEmpty()) { + settings.setVisiblePlots(keys); } - lineChart.setFill(((XYPlotDisplaySetting) this.displaySettings.get(displayConnector)).isFilled()); - - lineChart.setLegendCols((int) (Math.ceil(keys.size() / 10.0))); - linearModel.clear(); - - if (keys.isEmpty()) { - final LineChartSeries series = new LineChartSeries(); - series.set(0, 0); - linearModel.addSeries(series); - } else { - for (final String key : keys) { - if (!((XYPlotDisplaySetting) this.displaySettings.get(displayConnector)).getSelectedLines().contains(key)) { - continue; - } + for (final String key : keys) { + if (settings.getVisiblePlots().contains(key)) { 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); @@ -894,143 +376,220 @@ public final class CockpitBean { } else { lineChartSeries.setData(entries); } - linearModel.addSeries(lineChartSeries); + model.addSeries(lineChartSeries); } } + } catch (final DisplayNotFoundException ex) { CockpitBean.LOG.warn("Display not found.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final MirrorException ex) { CockpitBean.LOG.warn("Reflection exception.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final InvalidAnalysisStateException ex) { CockpitBean.LOG.info("Project is in invalid state.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } catch (final LockProjectException ex) { CockpitBean.LOG.info("An error occured.", ex); - this.updateDisplayWithDefaultContent(component, displayConnector); } + // Make sure that default values are set if necessary + if (model.getSeries().isEmpty()) { + final LineChartSeries series = new LineChartSeries(); + series.set(0, 0); + model.addSeries(series); + } + + return model; } + /** + * Delivers a pie chart update for the given display connector. + * + * @param displayConnectorName + * The name of the display connector. + * + * @return The current pie chart visualization of the given display connector. + */ @SuppressWarnings("unchecked") - private void updateMeterGaugeDisplaySettings(final MIDisplayConnector displayConnector) { + public PieChartModel getPieChartUpdate(final String displayConnectorName) { + final PieChartModel model = new PieChartModel(); + try { - this.selectedDisplayConnector = displayConnector; - final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnector.getName()); + 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 SelectOneListbox selectOneListbox = (SelectOneListbox) application.createComponent(facesContext, - "org.primefaces.component.SelectOneListbox", "org.primefaces.component.SelectOneListboxRenderer"); - selectOneListbox.setLabel("Visible Plot"); - selectOneListbox.setValueExpression("value", CockpitBean.createValueExpression("#{cockpitBean.meterGaugeSelection}", String.class)); - - final Iterator<String> keyIter = keys.iterator(); - while (keyIter.hasNext()) { - final UISelectItem item = new UISelectItem(); - item.setValue(new SelectItem(keyIter.next())); - selectOneListbox.getChildren().add(item); + for (final String key : keys) { + final Number value = (Number) new Mirror().on(displayObj).invoke().method("getValue").withArgs(key); + model.set(key, value); } - - this.displaySettingsDialog.getChildren().clear(); - this.displaySettingsDialog.getChildren().add(selectOneListbox); - - this.addButtonBoxToSettingsDialog(); - } catch (final Exception ex) { // NOCS NOPMD (Temporary catch) - ex.printStackTrace(); + } catch (final DisplayNotFoundException ex) { + CockpitBean.LOG.warn("Display not found.", ex); + } catch (final MirrorException ex) { + CockpitBean.LOG.warn("Reflection exception.", ex); + } catch (final InvalidAnalysisStateException ex) { + CockpitBean.LOG.info("Project is in invalid state.", ex); + } catch (final LockProjectException ex) { + CockpitBean.LOG.info("An error occured.", ex); } - } - @SuppressWarnings("unchecked") - private void updateXYPlotDisplaySettings(final MIDisplayConnector displayConnector) { - try { - this.selectedDisplayConnector = displayConnector; - final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayConnector.getName()); - final Set<String> keys = (Set<String>) new Mirror().on(displayObj).invoke().method("getKeys").withoutArgs(); - - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final Application application = facesContext.getApplication(); + // Make sure that default values are set if necessary + if (model.getData().isEmpty()) { + model.set(null, 1); + } - 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)); + return model; + } - final Iterator<String> keyIter = keys.iterator(); - while (keyIter.hasNext()) { - final UISelectItem item = new UISelectItem(); - item.setValue(new SelectItem(keyIter.next())); - selectManyCheckbox.getChildren().add(item); + /** + * Delivers the display type of the given connector name. This method returns never null. + * + * @param displayConnectorName + * The name of the display connector. + * + * @return The type of the display connector or {@code DisplayType.UNKNOWN} if the type could not be detected. + */ + public DisplayType getDisplayType(final String displayConnectorName) { + DisplayType type = DisplayType.UNKNOWN; + + if ((displayConnectorName != null) && (this.activeView != null)) { + try { + type = this.projectService.getDisplayType(this.projectName, this.activeView.getName(), displayConnectorName); + } catch (final LockProjectException ex) { + CockpitBean.LOG.info("An error occured.", ex); } - - final SelectBooleanCheckbox checkBoxFilled = (SelectBooleanCheckbox) application.createComponent(facesContext, - "org.primefaces.component.SelectBooleanCheckbox", "org.primefaces.component.SelectBooleanCheckboxRenderer"); - final HtmlOutputText outputText = new HtmlOutputText(); - outputText.setValue("Filled"); - checkBoxFilled.setValueExpression("value", CockpitBean.createValueExpression("#{cockpitBean.xyplotFilled}", Boolean.class)); - - this.displaySettingsDialog.getChildren().clear(); - this.displaySettingsDialog.getChildren().add(selectManyCheckbox); - this.displaySettingsDialog.getChildren().add(outputText); - this.displaySettingsDialog.getChildren().add(checkBoxFilled); - - this.addButtonBoxToSettingsDialog(); - } catch (final Exception ex) { // NOCS NOPMD (Temporary catch) - ex.printStackTrace(); } + + return type; } - public String getMeterGaugeSelection() { - return ((MeterGaugeDisplaySetting) this.displaySettings.get(this.selectedDisplayConnector)).getSelectedDiagram(); + /** + * Checks whether the analysis is currently running. + * + * @return true if and only if the analysis is running. + */ + public boolean isAnalysisRunning() { + try { + return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.RUNNING; + } catch (final NullPointerException ex) { + // This exception can occur, when the projectsBean has not been initialized + LOG.warn("A null pointer exception occured.", ex); + } catch (final LockProjectException ex) { + LOG.warn("An error occured.", ex); + } + return false; } /** - * Sets the configuration for the currently selected meter gauge. + * Checks whether the analysis is currently in the ready state. * - * @param meterGaugeSelection - * The new configuration of the meter gauge. + * @return true if and only if the analysis is ready to be started. */ - public void setMeterGaugeSelection(final String meterGaugeSelection) { - ((MeterGaugeDisplaySetting) this.displaySettings.get(this.selectedDisplayConnector)).setSelectedDiagram(meterGaugeSelection); + public boolean isAnalysisReady() { + try { + return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.READY; + } catch (final NullPointerException ex) { + // This exception can occur, when the projectsBean has not been initialized + LOG.warn("A null pointer exception occured.", ex); + } catch (final LockProjectException ex) { + LOG.warn("An error occured.", ex); + } + return false; } - public boolean getXyplotFilled() { - return ((XYPlotDisplaySetting) this.displaySettings.get(this.selectedDisplayConnector)).isFilled(); + /** + * Checks whether the analysis is not available. + * + * @return true if and only if the analysis is <b>not</b> available. + */ + public boolean isAnalysisNotAvailable() { + try { + return this.projectService.getCurrentState(this.projectName) == null; + } catch (final NullPointerException ex) { + // This exception can occur, when the projectsBean has not been initialized + LOG.warn("A null pointer exception occured.", ex); + } catch (final LockProjectException ex) { + LOG.warn("An error occured.", ex); + } + return true; } - public void setXyplotFilled(final boolean xyplotFilled) { - ((XYPlotDisplaySetting) this.displaySettings.get(this.selectedDisplayConnector)).setFilled(xyplotFilled); + /** + * Checks whether the analysis is currently terminated. + * + * @return true if and only if the analysis has been terminated. + */ + public boolean isAnalysisTerminated() { + try { + return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.TERMINATED; + } catch (final NullPointerException ex) { + // This exception can occur, when the projectsBean has not been initialized + LOG.warn("A null pointer exception occured.", ex); + } catch (final LockProjectException ex) { + LOG.warn("An error occured.", ex); + } + return false; } - public List<String> getXyplotSelection() { - return ((XYPlotDisplaySetting) this.displaySettings.get(this.selectedDisplayConnector)).getSelectedLines(); + /** + * Checks whether the analysis is currently terminating. + * + * @return true if and only if the analysis is currently terminating. + */ + public boolean isAnalysisTerminating() { + try { + return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.TERMINATING; + } catch (final NullPointerException ex) { + // This exception can occur, when the projectsBean has not been initialized + LOG.warn("A null pointer exception occured.", ex); + } catch (final LockProjectException ex) { + LOG.warn("An error occured.", ex); + } + return false; } /** - * Sets the configuration for the currently selected XY plot. + * Checks whether the analysis is currently in the failed state. * - * @param xyplotSelection - * The new configuration of the XY plot. + * @return true if and only if the analysis has failed. */ - public void setXyplotSelection(final List<String> xyplotSelection) { - ((XYPlotDisplaySetting) this.displaySettings.get(this.selectedDisplayConnector)).setSelectedLines(xyplotSelection); + public boolean isAnalysisFailed() { + try { + return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.FAILED; + } catch (final NullPointerException ex) { + // This exception can occur, when the projectsBean has not been initialized + LOG.warn("A null pointer exception occured.", ex); + } catch (final LockProjectException ex) { + LOG.warn("An error occured.", ex); + } + return false; } - private static ValueExpression createValueExpression(final String valueExpression, final Class<?> valueType) { - final FacesContext context = FacesContext.getCurrentInstance(); - return context.getApplication().getExpressionFactory() - .createValueExpression(context.getELContext(), valueExpression, valueType); + private void createSettingsMapsForViews() { + for (final MIView view : this.project.getViews()) { + this.displaySettings.put(view, new ConcurrentHashMap<String, IDisplayConnectorSettings>()); + } } - public HtmlForm getDisplaySettingsDialog() { - return this.displaySettingsDialog; + private void loadCockpitLayout() { + try { + this.cockpitLayout = new CockpitLayout(this.project, this.projectService.getCockpitLayout(this.projectName), NUMBER_OF_COCKPIT_COLUMNS); + } catch (final LockProjectException ex) { + LOG.error("An error occured while loading the layout.", ex); + this.cockpitLayout = new CockpitLayout(this.project, null, NUMBER_OF_COCKPIT_COLUMNS); + } } - public void setDisplaySettingsDialog(final HtmlForm displaySettingsDialog) { - this.displaySettingsDialog = displaySettingsDialog; + private void loadProject() throws ProjectLoadException { + try { + this.project = this.projectService.loadProject(this.projectName); + } catch (final IOException ex) { + LOG.error("An error occured while loading the project.", ex); + throw new ProjectLoadException("An error occured while loading the project.", ex); + } catch (final ProjectNotExistingException ex) { + LOG.info("A project with the given name does not exist.", ex); + throw new ProjectLoadException("A project with the given name does not exist.", ex); + } catch (final LockProjectException ex) { + LOG.error("An error occured while loading the project.", ex); + throw new ProjectLoadException("An error occured while loading the project.", ex); + } } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CockpitEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CockpitEditorBean.java index b91a9bc28c1d0469ffca77bc0405583728af09a0..08eef839b0c3db7bde224d64464a49383720a1a0 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CockpitEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CockpitEditorBean.java @@ -239,7 +239,7 @@ public final class CockpitEditorBean { } public void copyView(final CopyViewBean copyViewBean) { - + // Not implemented yet } public void editView(final EditViewBean editViewBean) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/CockpitLayout.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/CockpitLayout.java index abb29b53ddd67f96611a69ea145cb5f15c0f1ce4..05f7c81515a2bc4093bb6cdbeaeeb059553b9f3f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/CockpitLayout.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/CockpitLayout.java @@ -78,11 +78,13 @@ public final class CockpitLayout { final List<List<MIDisplayConnector>> original = this.layout.get(view); final List<List<MIDisplayConnector>> copy = new ArrayList<List<MIDisplayConnector>>(); - for (final List<MIDisplayConnector> columnOriginal : original) { - final List<MIDisplayConnector> columnCopy = new ArrayList<MIDisplayConnector>(); - columnCopy.addAll(columnOriginal); + if (view != null) { + for (final List<MIDisplayConnector> columnOriginal : original) { + final List<MIDisplayConnector> columnCopy = new ArrayList<MIDisplayConnector>(); + columnCopy.addAll(columnOriginal); - copy.add(columnCopy); + copy.add(columnCopy); + } } return copy; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IDisplaySetting.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/IDisplayConnectorSettings.java similarity index 82% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/IDisplaySetting.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/IDisplayConnectorSettings.java index 3e743bffed134413b54de5e21b7895a329964d34..6e2f2b6246fc4a02202359875cb61fb633e85bee 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IDisplaySetting.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/IDisplayConnectorSettings.java @@ -14,11 +14,13 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.web.utility; /** + * This interface marks classes containing settings for display connectors within the cockpit. + * * @author Nils Christian Ehmke */ -public interface IDisplaySetting { +public interface IDisplayConnectorSettings { } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/MeterGaugeDisplaySetting.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/MeterGaugeDisplaySettings.java similarity index 52% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/MeterGaugeDisplaySetting.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/MeterGaugeDisplaySettings.java index adc33a100f02d01541a9f83d239fef7b02c69a35..5bf61f42518c0eae661b89eeb1b71fb2d8f55232 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/MeterGaugeDisplaySetting.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/MeterGaugeDisplaySettings.java @@ -14,25 +14,42 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.web.utility; + +import java.util.Collections; +import java.util.Map; /** + * This is a settings container for a meter gauge within the cockpit. + * * @author Nils Christian Ehmke */ -public class MeterGaugeDisplaySetting implements IDisplaySetting { +public class MeterGaugeDisplaySettings implements IDisplayConnectorSettings { - private volatile String selectedDiagram; + private Map<String, String> availablePlots = Collections.emptyMap(); + private String visiblePlot = ""; - public MeterGaugeDisplaySetting() { + /** + * Creates a new instance of this class. + */ + public MeterGaugeDisplaySettings() { // No code necessary } - public String getSelectedDiagram() { - return this.selectedDiagram; + public Map<String, String> getAvailablePlots() { + return this.availablePlots; + } + + public void setAvailablePlots(final Map<String, String> availablePlots) { + this.availablePlots = availablePlots; + } + + public String getVisiblePlot() { + return this.visiblePlot; } - public void setSelectedDiagram(final String selectedDiagram) { - this.selectedDiagram = selectedDiagram; + public void setVisiblePlot(final String visiblePlot) { + this.visiblePlot = visiblePlot; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/XYPlotDisplaySetting.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/PieChartDisplaySettings.java similarity index 50% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/XYPlotDisplaySetting.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/PieChartDisplaySettings.java index 4123920d7bec2d9e941947717b2b85988ee6ed3f..345fc729d5e8660ca255e98e980a0f27c8541d33 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/XYPlotDisplaySetting.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/PieChartDisplaySettings.java @@ -14,33 +14,27 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; - -import java.util.Collections; -import java.util.List; +package kieker.webgui.web.utility; /** + * This is a settings container for a pie chart within the cockpit. + * * @author Nils Christian Ehmke */ -public class XYPlotDisplaySetting implements IDisplaySetting { +public class PieChartDisplaySettings implements IDisplayConnectorSettings { - private volatile List<String> selectedLines = Collections.emptyList(); - private volatile boolean usingShadows; - private volatile boolean filled; - private volatile boolean stacked; + private boolean usingShadows = true; + private boolean usingFilledChart = false; + private boolean usingVisibleDataLabels = true; + private boolean usingVisibleLegend = true; - public XYPlotDisplaySetting() { + /** + * Creates a new instance of this class. + */ + public PieChartDisplaySettings() { // No code necessary } - public List<String> getSelectedLines() { - return this.selectedLines; - } - - public void setSelectedLines(final List<String> selectedLines) { - this.selectedLines = selectedLines; - } - public boolean isUsingShadows() { return this.usingShadows; } @@ -49,20 +43,28 @@ public class XYPlotDisplaySetting implements IDisplaySetting { this.usingShadows = usingShadows; } - public boolean isFilled() { - return this.filled; + public boolean isUsingFilledChart() { + return this.usingFilledChart; + } + + public void setUsingFilledChart(final boolean usingFilledChart) { + this.usingFilledChart = usingFilledChart; + } + + public boolean isUsingVisibleDataLabels() { + return this.usingVisibleDataLabels; } - public void setFilled(final boolean filled) { - this.filled = filled; + public void setUsingVisibleDataLabels(final boolean usingVisibleDataLabels) { + this.usingVisibleDataLabels = usingVisibleDataLabels; } - public boolean isStacked() { - return this.stacked; + public boolean isUsingVisibleLegend() { + return this.usingVisibleLegend; } - public void setStacked(final boolean stacked) { - this.stacked = stacked; + public void setUsingVisibleLegend(final boolean usingVisibleLegend) { + this.usingVisibleLegend = usingVisibleLegend; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/XYPlotDisplaySettings.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/XYPlotDisplaySettings.java new file mode 100644 index 0000000000000000000000000000000000000000..f25229179d52873766b326440ac11db9c829eae1 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/XYPlotDisplaySettings.java @@ -0,0 +1,92 @@ +/*************************************************************************** + * Copyright 2013 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +package kieker.webgui.web.utility; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +/** + * This is a settings container for a line chart within the cockpit. + * + * @author Nils Christian Ehmke + */ +public class XYPlotDisplaySettings implements IDisplayConnectorSettings { + + private Map<String, String> availablePlots = Collections.emptyMap(); + private Collection<String> visiblePlots = Collections.emptyList(); + private boolean usingShadows = true; + private boolean usingFilledChart = false; + private boolean usingStackedCharts = false; + private boolean usingVisibleLegend = true; + + /** + * Creates a new instance of this class. + */ + public XYPlotDisplaySettings() { + // No code necessary + } + + public boolean isUsingShadows() { + return this.usingShadows; + } + + public void setUsingShadows(final boolean usingShadows) { + this.usingShadows = usingShadows; + } + + public boolean isUsingFilledChart() { + return this.usingFilledChart; + } + + public void setUsingFilledChart(final boolean usingFilledChart) { + this.usingFilledChart = usingFilledChart; + } + + public boolean isUsingStackedCharts() { + return this.usingStackedCharts; + } + + public void setUsingStackedCharts(final boolean usingStackedCharts) { + this.usingStackedCharts = usingStackedCharts; + } + + public boolean isUsingVisibleLegend() { + return this.usingVisibleLegend; + } + + public void setUsingVisibleLegend(final boolean usingVisibleLegend) { + this.usingVisibleLegend = usingVisibleLegend; + } + + public Collection<String> getVisiblePlots() { + return this.visiblePlots; + } + + public void setVisiblePlots(final Collection<String> visiblePlots) { + this.visiblePlots = visiblePlots; + } + + public Map<String, String> getAvailablePlots() { + return this.availablePlots; + } + + public void setAvailablePlots(final Map<String, String> availablePlots) { + this.availablePlots = availablePlots; + } + +} diff --git a/Kieker.WebGUI/src/main/webapp/LoginPage.xhtml b/Kieker.WebGUI/src/main/webapp/LoginPage.xhtml index c9dad0941e5f6fd625012f9babe532a152c7ad89..0452dd2f682cfd86949158a216a38a3e41948271 100644 --- a/Kieker.WebGUI/src/main/webapp/LoginPage.xhtml +++ b/Kieker.WebGUI/src/main/webapp/LoginPage.xhtml @@ -72,7 +72,7 @@ <c:if test="#{state == 'fail'}"> <div class="login-form-hint-panel"> <p:spacer width="0" height="25" /> - <h:outputText style="color: red" value="#{localizedLoginMessages.lblLoginFailed}"/><br/> + <h:outputText styleClass="login-failed-hint" value="#{localizedLoginMessages.lblLoginFailed}"/><br/> </div> </c:if> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml index 65090d5bc81a17e76355b7f625aea5646854195a..58b62cf819ff1f2235aa2799369d3d5f85f0c771 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml @@ -70,4 +70,14 @@ <util:constant id="ROLE_GUEST" static-field="kieker.webgui.domain.Role.GUEST"/> <util:constant id="ROLE_USER" static-field="kieker.webgui.domain.Role.USER"/> <util:constant id="ROLE_ADMIN" static-field="kieker.webgui.domain.Role.ADMINISTRATOR"/> + + <util:constant id="XY_PLOT" static-field="kieker.webgui.domain.DisplayType.XY_PLOT"/> + <util:constant id="PIE_CHART" static-field="kieker.webgui.domain.DisplayType.PIE_CHART"/> + <util:constant id="PLAIN_TEXT" static-field="kieker.webgui.domain.DisplayType.PLAIN_TEXT"/> + <util:constant id="HTML_TEXT" static-field="kieker.webgui.domain.DisplayType.HTML_TEXT"/> + <util:constant id="IMAGE" static-field="kieker.webgui.domain.DisplayType.IMAGE"/> + <util:constant id="METER_GAUGE" static-field="kieker.webgui.domain.DisplayType.METER_GAUGE"/> + <util:constant id="TAG_CLOUD" static-field="kieker.webgui.domain.DisplayType.TAG_CLOUD"/> + <util:constant id="UNKNOWN" static-field="kieker.webgui.domain.DisplayType.UNKNOWN"/> + </beans> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml index e7c8af0b2fac1d250a4aa50392635aaf0abe01a9..b7b131da3514ebd41b8a2c96aad9ca88b46bd2a7 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml @@ -13,7 +13,12 @@ <!-- This parameter determines the current stage of the project. --> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> - <param-value>Production</param-value> + <param-value>Development</param-value> + </context-param> + + <context-param> + <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> + <param-value>0</param-value> </context-param> <!-- This parameter makes sure that the primefaces theme chooser will work. --> diff --git a/Kieker.WebGUI/src/main/webapp/css/CockpitPage.css b/Kieker.WebGUI/src/main/webapp/css/CockpitPage.css index 0a260bbb311d74c31f75cebc43e7ec01020a27f7..67b613ce2f4cbaacbbbdafc7470b424922448647 100644 --- a/Kieker.WebGUI/src/main/webapp/css/CockpitPage.css +++ b/Kieker.WebGUI/src/main/webapp/css/CockpitPage.css @@ -14,6 +14,22 @@ ui-dashboard-column { border : 0px !important; } +.ui-datagrid * { + padding-left: 0px; + padding-top: 0px; + padding-right: 0px; +} + +.ui-datagrid-content { + border : 0px !important; +} + +.ui-datagrid-column { + width: 50%; + vertical-align: top; +} + + .settings-dialog-column { vertical-align: top !important; } \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/css/LoginPage.css b/Kieker.WebGUI/src/main/webapp/css/LoginPage.css index d6febd73c41c12edb1818376cf9424e5ebb5c2c5..abaa1e8ff3cc36c88b104e87674509d970307e6c 100644 --- a/Kieker.WebGUI/src/main/webapp/css/LoginPage.css +++ b/Kieker.WebGUI/src/main/webapp/css/LoginPage.css @@ -28,6 +28,10 @@ font-size: 11px; } +.login-failed-hint { + color: red; +} + .ui-panel { font-size: 12px; } diff --git a/Kieker.WebGUI/src/main/webapp/pages/CockpitPage.xhtml b/Kieker.WebGUI/src/main/webapp/pages/CockpitPage.xhtml index 55f45b8ec819fb4f92e95836e74d6b7768c1de58..fd01f88cea92c0e97b15439b74e43bb538d82eb4 100644 --- a/Kieker.WebGUI/src/main/webapp/pages/CockpitPage.xhtml +++ b/Kieker.WebGUI/src/main/webapp/pages/CockpitPage.xhtml @@ -36,7 +36,7 @@ <p:submenu label="#{localizedMessages.lblFile}"> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-reloadSmall" value=" #{localizedMessages.lblReloadProject}" ajax="false" url="cockpit?projectName=#{cockpitBean.projectName}" disabled="#{empty cockpitBean.project}" /> <p:separator/> - <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-settings" value=" #{localizedMessages.lblSettings}" onclick="settingsDlg.show()" ajax="true"/> + <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-settings" value=" #{localizedMessages.lblSettings}" onclick="settingsDlg.show();" ajax="true"/> <p:separator /> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-close" value=" #{localizedMessages.lblCloseProject}" action="ProjectOverviewPage.xhtml?faces-redirect=true" ajax="false"/> </p:submenu> @@ -45,7 +45,33 @@ <ui:define name="centerLayout"> <p:layoutUnit position="center"> <h:form id="centerForm"> - <p:dashboard disabled="true" id="dynamicDashboard" binding="#{cockpitBean.dashboard}"/> + <p:dataGrid value="#{cockpitBean.cockpitLayout.getCurrentLayout(cockpitBean.activeView)}" emptyMessage="" var="column"> + <ui:repeat var="display" value="#{column}"> + <p:panel header="#{display.name}"> + <p:lineChart fill="#{cockpitBean.getXYPlotDisplaySettings(display.name).usingFilledChart}" + shadow="#{cockpitBean.getXYPlotDisplaySettings(display.name).usingShadows}" + stacked="#{cockpitBean.getXYPlotDisplaySettings(display.name).usingStackedCharts}" + legendPosition="#{cockpitBean.getXYPlotDisplaySettings(display.name).usingVisibleLegend ? 'e' : ''}" + legendRows="10" + title="#{display.name}" value="#{cockpitBean.getXYPlotUpdate(display.name)}" rendered="#{cockpitBean.getDisplayType(display.name) == XY_PLOT}"/> + <p:meterGaugeChart title="#{display.name}" value="#{cockpitBean.getMeterGaugeUpdate(display.name)}" rendered="#{cockpitBean.getDisplayType(display.name) == METER_GAUGE}"/> + <h:outputText value="#{cockpitBean.getPlainTextUpdate(display.name)}" rendered="#{cockpitBean.getDisplayType(display.name) == PLAIN_TEXT}"/> + <h:outputText value="N/A" rendered="#{empty cockpitBean.getDisplayType(display.name)}"/> + <p:pieChart fill="#{cockpitBean.getPieChartDisplaySettings(display.name).usingFilledChart}" + shadow="#{cockpitBean.getPieChartDisplaySettings(display.name).usingShadows}" + showDataLabels="#{cockpitBean.getPieChartDisplaySettings(display.name).usingVisibleDataLabels}" + legendPosition="#{cockpitBean.getPieChartDisplaySettings(display.name).usingVisibleLegend ? 'e' : ''}" + value="#{cockpitBean.getPieChartUpdate(display.name)}" rendered="#{cockpitBean.getDisplayType(display.name) == PIE_CHART}"/> + <p:tagCloud model="#{cockpitBean.getTagCloudUpdate(display.name)}" rendered="#{cockpitBean.getDisplayType(display.name) == TAG_CLOUD}"/> + <h:outputText value="Not implemented yet" rendered="#{(cockpitBean.getDisplayType(display.name) == HTML_TEXT) or (cockpitBean.getDisplayType(display.name) == IMAGE)}"/> + <hr/> + <div align="right"> + <p:commandButton value="Settings" update=":displaySettingsForm" oncomplete="displaySettingsDlg.show()" action="#{cockpitBean.setSelectedDisplay(display.name)}" disabled="#{cockpitBean.getDisplayType(display.name) != PIE_CHART and cockpitBean.getDisplayType(display.name) != XY_PLOT and cockpitBean.getDisplayType(display.name) != METER_GAUGE}"/> + </div> + </p:panel> + <p:spacer height="5"/> + </ui:repeat> + </p:dataGrid> </h:form> </p:layoutUnit> </ui:define> @@ -97,7 +123,7 @@ </h:form> <h:form> - <p:poll widgetVar="poll" interval="1" listener="#{cockpitBean.updateDisplaysOfActiveView()}" update=":centerForm :ledsForm"/> + <p:poll widgetVar="poll" interval="1" update=":centerForm :ledsForm"/> </h:form> </div> </p:layoutUnit> @@ -106,7 +132,44 @@ <ui:define name="furtherDialogIncludes"> <p:dialog id="displaySettingsDialog" header="Settings" onHide="poll.start()" onShow="poll.stop()" resizable="false" modal="true" widgetVar="displaySettingsDlg"> - <h:form binding="#{cockpitBean.displaySettingsDialog}" id="displaySettingsDialogForm"> + <h:form id="displaySettingsForm"> + <h:panelGroup rendered="#{cockpitBean.getDisplayType(cockpitBean.selectedDisplay) == PIE_CHART}"> + <h:panelGrid columns="2"> + <h:outputText value="Fill Chart"/> + <p:selectBooleanCheckbox value="#{cockpitBean.getPieChartDisplaySettings(cockpitBean.selectedDisplay).usingFilledChart}"/> + <h:outputText value="Visible Legend"/> + <p:selectBooleanCheckbox value="#{cockpitBean.getPieChartDisplaySettings(cockpitBean.selectedDisplay).usingVisibleLegend}" /> + <h:outputText value="Show Data Labels"/> + <p:selectBooleanCheckbox value="#{cockpitBean.getPieChartDisplaySettings(cockpitBean.selectedDisplay).usingVisibleDataLabels}" /> + <h:outputText value="Use Shadows"/> + <p:selectBooleanCheckbox value="#{cockpitBean.getPieChartDisplaySettings(cockpitBean.selectedDisplay).usingShadows}"/> + </h:panelGrid> + </h:panelGroup> + <h:panelGroup rendered="#{cockpitBean.getDisplayType(cockpitBean.selectedDisplay) == XY_PLOT}"> + <h:panelGrid columns="2"> + <h:outputText value="Fill Chart"/> + <p:selectBooleanCheckbox value="#{cockpitBean.getXYPlotDisplaySettings(cockpitBean.selectedDisplay).usingFilledChart}"/> + <h:outputText value="Stack"/> + <p:selectBooleanCheckbox value="#{cockpitBean.getXYPlotDisplaySettings(cockpitBean.selectedDisplay).usingStackedCharts}"/> + <h:outputText value="Visible Legend"/> + <p:selectBooleanCheckbox value="#{cockpitBean.getXYPlotDisplaySettings(cockpitBean.selectedDisplay).usingVisibleLegend}"/> + <h:outputText value="Use Shadows"/> + <p:selectBooleanCheckbox value="#{cockpitBean.getXYPlotDisplaySettings(cockpitBean.selectedDisplay).usingShadows}"/> + </h:panelGrid> + <br/> + <p:selectCheckboxMenu style="width: 100%" label="Visible Plots" filter="true" filterMatchMode="startsWith" value="#{cockpitBean.getXYPlotDisplaySettings(cockpitBean.selectedDisplay).visiblePlots}" > + <f:selectItems value="#{cockpitBean.getXYPlotDisplaySettings(cockpitBean.selectedDisplay).availablePlots}" /> + </p:selectCheckboxMenu> + </h:panelGroup> + <h:panelGroup rendered="#{cockpitBean.getDisplayType(cockpitBean.selectedDisplay) == METER_GAUGE}"> + <p:selectOneListbox style="width: 100%" label="Visible Plots" value="#{cockpitBean.getMeterGaugeDisplaySettings(cockpitBean.selectedDisplay).visiblePlot}" > + <f:selectItems value="#{cockpitBean.getMeterGaugeDisplaySettings(cockpitBean.selectedDisplay).availablePlots}" /> + </p:selectOneListbox> + </h:panelGroup> + <hr/> + <div align="right"> + <p:commandButton value="Ok" onclick="displaySettingsDlg.hide();"/> + </div> </h:form> </p:dialog> </ui:define>