Skip to content

Commit

Permalink
More native testing cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Apr 23, 2024
1 parent 02ab7d5 commit d667361
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
*/
package org.primefaces.showcase.view.data.datatable;

import jakarta.annotation.PostConstruct;
import jakarta.faces.context.FacesContext;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.time.temporal.Temporal;
Expand All @@ -32,13 +37,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;


import jakarta.annotation.PostConstruct;
import jakarta.faces.context.FacesContext;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;

import io.quarkus.runtime.annotations.RegisterForReflection;
import org.primefaces.component.datatable.DataTable;
import org.primefaces.showcase.domain.Customer;
import org.primefaces.showcase.service.CustomerService;
Expand All @@ -47,15 +46,14 @@
@ViewScoped
public class ColumnsView implements Serializable {

@Inject
CustomerService service;
private String columnTemplate = "name country date status activity";
private List<ColumnModel> columns;
private List<Customer> customers;
private List<Customer> filteredCustomers;
private Map<String, Class> validColumns;

@Inject
CustomerService service;

@PostConstruct
public void init() {
customers = service.getCustomers(10);
Expand All @@ -64,10 +62,6 @@ public void init() {
createDynamicColumns();
}

public void setColumns(List<ColumnModel> columns) {
this.columns = columns;
}

public List<Customer> getCustomers() {
return customers;
}
Expand Down Expand Up @@ -104,6 +98,10 @@ public List<ColumnModel> getColumns() {
return columns;
}

public void setColumns(List<ColumnModel> columns) {
this.columns = columns;
}

private void createDynamicColumns() {
String[] columnKeys = columnTemplate.split(" ");
columns = new ArrayList<>();
Expand All @@ -126,12 +124,13 @@ public void updateColumns() {
createDynamicColumns();
}

@RegisterForReflection
public static class ColumnModel implements Serializable {

private String header;
private String property;
private final String header;
private final String property;
private String type;
private Class<?> klazz;
private final Class<?> klazz;

public ColumnModel(String header, String property, Class klazz) {
this.header = header;
Expand Down Expand Up @@ -159,10 +158,9 @@ public Class<?> getKlazz() {
private void initType() {
if (Temporal.class.isAssignableFrom(klazz)) {
type = "date";
}
else if (klazz.isEnum()) {
} else if (klazz.isEnum()) {
type = "enum";
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
*/
package org.primefaces.showcase.view.data.treetable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


import jakarta.annotation.PostConstruct;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import io.quarkus.runtime.annotations.RegisterForReflection;
import org.primefaces.model.TreeNode;
import org.primefaces.showcase.domain.Document;
import org.primefaces.showcase.service.DocumentService;
Expand Down Expand Up @@ -91,10 +90,11 @@ public List<ColumnModel> getColumns() {
return columns;
}

@RegisterForReflection
public static class ColumnModel implements Serializable {

private String header;
private String property;
private final String header;
private final String property;

public ColumnModel(String header, String property) {
this.header = header;
Expand All @@ -109,4 +109,4 @@ public String getProperty() {
return property;
}
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/resources/template/template.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
<h:outputScript name="jquery/jquery.js" library="primefaces" target="head"/>
<h:outputScript name="jquery/jquery-plugins.js" library="primefaces" target="head"/>
<h:outputScript name="locales/locale-#{app.locale.language}.js" library="primefaces" target="head"/>
<h:outputScript name="validation/validation.js" library="primefaces" target="head"/>
<h:outputScript name="validation/validation.bv.js" library="primefaces" target="head"/>
</f:view>
</h:body>

Expand Down
73 changes: 57 additions & 16 deletions src/main/resources/META-INF/resources/template/topbar.xhtml
Original file line number Diff line number Diff line change
@@ -1,39 +1,80 @@
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="jakarta.faces.html" xmlns:f="jakarta.faces.core"
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="jakarta.faces.html"
xmlns:ui="jakarta.faces.facelets" xmlns:p="http://primefaces.org/ui">

<div class="layout-topbar">
<a class="menu-button" tabindex="0">
<i class="pi pi-bars"></i>
</a>
<h:link styleClass="logo" outcome="/index.xhtml">
<p:graphicImage name="images/primefaces-logo.svg" library="showcase" />
<p:graphicImage name="images/primefaces-logo.svg" library="showcase" height="33" width="180"
alt="Quarkus Faces"/>
</h:link>
<p:outputPanel id="app-theme-logo" class="app-theme">
<p:graphicImage id="app-theme-image" name="images/themes/#{app.themeImage}" library="showcase" />
<p:tooltip for="app-theme-logo" value="#{app.theme}" position="bottom" showDelay="0" />
<p:graphicImage id="app-theme-image" name="images/themes/#{app.themeImage}" library="showcase"/>
<p:tooltip for="app-theme-logo" value="#{app.theme}" position="bottom" showDelay="0"/>
</p:outputPanel>

<h:form styleClass="topbar-form">
<ul class="topbar-menu">
<li class="topbar-submenu">
<a tabindex="0"><i class="pi pi-palette mr-2"></i>Themes</a>
<ul class="connected-overlay-in">

<li class="topbar-submenu-header">PRIMEONE</li>
<li><p:commandLink actionListener="#{app.changeTheme('saga', false)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/saga.png" alt="Saga"/><span>Saga</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('vela', true)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/vela.png" alt="Vela"/><span>Vela</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('arya', true)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/arya.png" alt="Arya"/><span>Arya</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('saga', false)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/saga.png" alt="Saga"/><span>Saga</span></p:commandLink>
</li>
<li><p:commandLink actionListener="#{app.changeTheme('vela', true)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/vela.png" alt="Vela"/><span>Vela</span></p:commandLink>
</li>
<li><p:commandLink actionListener="#{app.changeTheme('arya', true)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/arya.png" alt="Arya"/><span>Arya</span></p:commandLink>
</li>
<li class="topbar-submenu-header">LEGACY</li>
<li><p:commandLink actionListener="#{app.changeTheme('nova-light', false)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/nova.png" alt="Nova"/><span>Nova</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('nova-dark', true)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/nova-alt.png" alt="Nova Alt"/><span>Nova Alt</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('nova-colored', true)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/nova-accent.png" alt="Nova Accent"/><span>Nova Accent</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('luna-amber', true)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/luna-amber.png" alt="Luna Amber"/><span>Luna Amber</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('luna-blue', true)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/luna-blue.png" alt="Luna Blue"/><span>Luna Blue</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('luna-green', true)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/luna-green.png" alt="Luna Green"/><span>Luna Green</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('luna-pink', true)}" oncomplete="window.location.reload();" update=":app-theme-logo"><h:graphicImage name="showcase/images/themes/luna-pink.png" alt="Luna Pink"/><span>Luna Pink</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('nova-light', false)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/nova.png" alt="Nova"/><span>Nova</span></p:commandLink>
</li>
<li><p:commandLink actionListener="#{app.changeTheme('nova-dark', true)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/nova-alt.png"
alt="Nova Alt"/><span>Nova Alt</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('nova-colored', true)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/nova-accent.png"
alt="Nova Accent"/><span>Nova Accent</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('luna-amber', true)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/luna-amber.png"
alt="Luna Amber"/><span>Luna Amber</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('luna-blue', true)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/luna-blue.png"
alt="Luna Blue"/><span>Luna Blue</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('luna-green', true)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/luna-green.png"
alt="Luna Green"/><span>Luna Green</span></p:commandLink></li>
<li><p:commandLink actionListener="#{app.changeTheme('luna-pink', true)}"
oncomplete="window.location.reload();"
update=":app-theme-logo"><h:graphicImage
name="showcase/images/themes/luna-pink.png"
alt="Luna Pink"/><span>Luna Pink</span></p:commandLink></li>
</ul>
</li>
</ul>
</h:form>
</div>
</ui:composition>
</ui:composition>
56 changes: 30 additions & 26 deletions src/main/resources/META-INF/resources/ui/chart/pie.xhtml
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="jakarta.faces.facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="/template/template.xhtml">

<ui:define name="head">
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<!-- Must load plugin JS (here using OmniFaces CDN handler) -->
<h:outputScript library="cdn" name="chartjs-plugin-datalabels.js" target="body"/>
<script>
function chartExtender() {
var options = {
plugins: [ChartDataLabels],
options: {
plugins: {
// Change options for ALL labels of THIS CHART
datalabels: {
color: 'HotPink'
}
}
},
data: {
datasets: [{
// Change options only for labels of THIS DATASET
datalabels: {
color: 'Indigo'
}
}]
plugins: [ChartDataLabels],
options: {
plugins: {
// Change options for ALL labels of THIS CHART
datalabels: {
color: 'HotPink'
}
}
};
},
data: {
datasets: [{
// Change options only for labels of THIS DATASET
datalabels: {
color: 'Indigo'
}
}]
}
};

//merge all options into the main chart options
$.extend(true, this.cfg.config, options);
//merge all options into the main chart options
$.extend(true, this.cfg.config, options);
}
</script>
</ui:define>

<ui:define name="title">
Charts <span class="subitem">Pie</span>
</ui:define>

<ui:define name="description">
PieChart is created with raw JSON or using an <a href="https://github.com/xdev-software/chartjs-java-model" target="_blank" rel="noopener noreferrer">XDEV</a> model.
Using the <strong>extender</strong> functionality to add Data Labels to the pie chart with the Data Labels plugin.
PieChart is created with raw JSON or using an <a href="https://github.com/xdev-software/chartjs-java-model"
target="_blank" rel="noopener noreferrer">XDEV</a> model.
Using the
<strong>extender</strong> functionality to add Data Labels to the pie chart with the Data Labels plugin.
</ui:define>

<ui:param name="documentationLink" value="/components/chart" />
<ui:param name="widgetLink" value="Chart" />
<ui:param name="documentationLink" value="/components/chart"/>
<ui:param name="widgetLink" value="Chart"/>

<ui:define name="implementation">
<div class="grid">
Expand All @@ -55,4 +59,4 @@
</div>
</ui:define>

</ui:composition>
</ui:composition>
Loading

0 comments on commit d667361

Please sign in to comment.