Skip to content
Snippets Groups Projects
Commit ab1c9c7d authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Continued with the cockpit

parent bbf18c92
No related branches found
No related tags found
No related merge requests found
......@@ -496,10 +496,14 @@ public final class CockpitBean {
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, displayConnectorName, DisplayType.PLAIN_TEXT);
}
try {
......@@ -548,6 +552,7 @@ public final class CockpitBean {
component.getChildren().clear();
component.getChildren().add(tagCloud);
this.addButtonBoxToComponent(component, displayConnectorName, DisplayType.TAG_CLOUD);
}
try {
......@@ -598,20 +603,9 @@ 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);
this.addButtonBoxToComponent(component, displayConnectorName, DisplayType.METER_GAUGE);
}
try {
......@@ -682,20 +676,9 @@ 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);
this.addButtonBoxToComponent(component, displayConnectorName, DisplayType.PIE_CHART);
}
try {
......@@ -728,6 +711,87 @@ public final class CockpitBean {
}
}
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 String displayConnectorName, 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);
button.addActionListener(new ActionListener() {
@Override
public void processAction(final ActionEvent event) throws AbortProcessingException {
switch (type) {
case HTML_TEXT:
break;
case IMAGE:
break;
case METER_GAUGE:
break;
case PIE_CHART:
break;
case PLAIN_TEXT:
break;
case TAG_CLOUD:
break;
case XY_PLOT:
CockpitBean.this.updateXYPlotDisplaySettings(displayConnectorName);
break;
default:
break;
}
}
});
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);
}
@SuppressWarnings("unchecked")
private void updateXYPlotDisplay(final UIComponent component, final String displayConnectorName) {
final boolean isAlreadyCorrectlyInitialized = (component.getChildCount() == 2) && (component.getChildren().get(0) instanceof LineChart)
......@@ -754,29 +818,9 @@ public final class CockpitBean {
linearModel = new CartesianChartModel();
lineChart.setValue(linearModel);
// Create the Primefaces Commandbutton component
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);
button.addActionListener(new ActionListener() {
@Override
public void processAction(final ActionEvent event) throws AbortProcessingException {
CockpitBean.this.updateXYPlotDisplaySettings(displayConnectorName);
}
});
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);
this.addButtonBoxToComponent(component, displayConnectorName, DisplayType.XY_PLOT);
}
try {
......@@ -855,23 +899,7 @@ public final class CockpitBean {
this.displaySettingsDialog.getChildren().clear();
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);
this.addButtonBoxToSettingsDialog();
} catch (final Exception ex) { // NOCS NOPMD (Temporary catch)
ex.printStackTrace();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment