Improved categories sorting and center content.
This commit is contained in:
parent
53732f23af
commit
01df6b63c0
5 changed files with 194 additions and 28 deletions
|
@ -19,6 +19,7 @@
|
|||
package fr.devinsy.statoolinfos.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
|
@ -72,4 +73,55 @@ public class Categories extends ArrayList<Category>
|
|||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse.
|
||||
*
|
||||
* @return the categories
|
||||
*/
|
||||
public Categories reverse()
|
||||
{
|
||||
Categories result;
|
||||
|
||||
Collections.reverse(this);
|
||||
|
||||
result = this;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort.
|
||||
*
|
||||
* @param sorting
|
||||
* the sorting
|
||||
* @return the issues
|
||||
*/
|
||||
public Categories sort(final CategoryComparator.Sorting sorting)
|
||||
{
|
||||
Categories result;
|
||||
|
||||
sort(new CategoryComparator(sorting));
|
||||
|
||||
result = this;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by name.
|
||||
*
|
||||
* @return the services
|
||||
*/
|
||||
public Categories sortByName()
|
||||
{
|
||||
Categories result;
|
||||
|
||||
result = sort(CategoryComparator.Sorting.NAME);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
110
src/fr/devinsy/statoolinfos/core/CategoryComparator.java
Normal file
110
src/fr/devinsy/statoolinfos/core/CategoryComparator.java
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
*
|
||||
*/
|
||||
package fr.devinsy.statoolinfos.core;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import fr.devinsy.statoolinfos.util.CompareUtils;
|
||||
|
||||
/**
|
||||
* The Class OrganizationComparator.
|
||||
*/
|
||||
public class CategoryComparator implements Comparator<Category>
|
||||
{
|
||||
public enum Sorting
|
||||
{
|
||||
NAME
|
||||
}
|
||||
|
||||
private Sorting sorting;
|
||||
|
||||
/**
|
||||
* Instantiates a new organization comparator.
|
||||
*
|
||||
* @param sorting
|
||||
* the sorting
|
||||
*/
|
||||
public CategoryComparator(final Sorting sorting)
|
||||
{
|
||||
this.sorting = sorting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare.
|
||||
*
|
||||
* @param alpha
|
||||
* the alpha
|
||||
* @param bravo
|
||||
* the bravo
|
||||
* @return the int
|
||||
*/
|
||||
@Override
|
||||
public int compare(final Category alpha, final Category bravo)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = compare(alpha, bravo, this.sorting);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare.
|
||||
*
|
||||
* @param alpha
|
||||
* the alpha
|
||||
* @param bravo
|
||||
* the bravo
|
||||
* @param sorting
|
||||
* the sorting
|
||||
* @return the int
|
||||
*/
|
||||
public static int compare(final Category alpha, final Category bravo, final Sorting sorting)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (sorting == null)
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (sorting)
|
||||
{
|
||||
default:
|
||||
case NAME:
|
||||
result = CompareUtils.compare(getName(alpha), getName(bravo));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @return the name
|
||||
*/
|
||||
public static String getName(final Category source)
|
||||
{
|
||||
String result;
|
||||
|
||||
if (source == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = source.getName();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -84,6 +84,8 @@ public class Factory
|
|||
result.add(category);
|
||||
}
|
||||
|
||||
result.sortByName();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
@ -105,7 +107,7 @@ public class Factory
|
|||
|
||||
result = loadCategories(source);
|
||||
|
||||
Category other = new Category("{Autres}", "Qui ne rentre pas dans une catégorie existante.");
|
||||
Category other = new Category("Autres", "Qui ne rentre pas dans une catégorie existante.");
|
||||
result.add(other);
|
||||
|
||||
for (Service service : federation.getAllServices())
|
||||
|
|
|
@ -57,7 +57,7 @@ public class CategoriesPage
|
|||
data.setContent("categoryCount", stats.size());
|
||||
|
||||
int index = 0;
|
||||
for (CategoryStat stat : stats.sortByName())
|
||||
for (CategoryStat stat : stats)
|
||||
{
|
||||
data.setEscapedContent("categoryListLine", index, "categoryListLineNameLink", stat.getCategory().getName());
|
||||
data.setAttribute("categoryListLine", index, "categoryListLineNameLink", "href", "category-" + stat.getCategory().getTechnicalName() + ".xhtml");
|
||||
|
|
|
@ -11,32 +11,34 @@
|
|||
<script src="Chart.bundle.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Catégories</h2>
|
||||
<div class="center">
|
||||
<h2>Catégories</h2>
|
||||
|
||||
<div>Nombre de catégories : <span id="categoryCount">n/a</span></div>
|
||||
<div>
|
||||
<table class="table_classic sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="">Nom de la catégorie</th>
|
||||
<th class="">Logiciels</th>
|
||||
<th class="" style="width: 100px;">Services</th>
|
||||
<th class="" style="width: 100px;">Organizations</th>
|
||||
<th class="" style="width: 100px;">Utilisateurs mensuels</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr id="categoryListLine">
|
||||
<td id="categoryListLineName" style="padding-top: 0; padding-bottom: 0;">
|
||||
<a href="#" id="categoryListLineNameLink" title="categoryListLineNameDescription">n/a</a>
|
||||
</td>
|
||||
<td id="categoryListLineSoftwares">n/a</td>
|
||||
<td id="categoryListLineServiceCount" class="td_number">n/a</td>
|
||||
<td id="categoryListLineOrganizationCount" class="td_number">n/a</td>
|
||||
<td id="categoryListLineUserCount" class="td_number">n/a</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div>Nombre de catégories : <span id="categoryCount">n/a</span></div>
|
||||
<div class="left">
|
||||
<table class="table_classic center_table sortable" style="width: 900px; margin-left: auto; margin-right: auto;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="">Nom de la catégorie</th>
|
||||
<th class="">Logiciels</th>
|
||||
<th class="" style="width: 100px;">Services</th>
|
||||
<th class="" style="width: 100px;">Organizations</th>
|
||||
<th class="" style="width: 100px;">Utilisateurs mensuels</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr id="categoryListLine">
|
||||
<td id="categoryListLineName" style="padding-top: 0; padding-bottom: 0;">
|
||||
<a href="#" id="categoryListLineNameLink" title="categoryListLineNameDescription">n/a</a>
|
||||
</td>
|
||||
<td id="categoryListLineSoftwares">n/a</td>
|
||||
<td id="categoryListLineServiceCount" class="td_number">n/a</td>
|
||||
<td id="categoryListLineOrganizationCount" class="td_number">n/a</td>
|
||||
<td id="categoryListLineUserCount" class="td_number">n/a</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue