Skip to content

Commit

Permalink
Added sorting by actual in taxonomy view
Browse files Browse the repository at this point in the history
Issue: #3791
Issue: #3835
Co-authored-by: Fischer, Markus <[email protected]>
Co-authored-by: Andreas Buchen <[email protected]>
  • Loading branch information
Fischer, Markus and buchen committed Mar 21, 2024
1 parent 4bd4674 commit a651771
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ public class Messages extends NLS
public static String MenuTaxonomyMakeAssignment;
public static String MenuTaxonomyRename;
public static String MenuTaxonomySortByName;
public static String MenuTaxonomySortByTypName;
public static String MenuTaxonomySortByType;
public static String MenuTaxonomySortTreeBy;
public static String MenuTaxonomyWeightFix;
public static String MenuTransactionDelete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ bkolb
jimjaeger
mfrkn702001
kimmerin
mierin12
mierin12
gus484
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,7 @@ MenuTaxonomyRename = Rename taxonomy

MenuTaxonomySortByName = Name

MenuTaxonomySortByTypName = Type, Name
MenuTaxonomySortByType = Type

MenuTaxonomySortTreeBy = Sort by...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ MenuTaxonomyRename = P\u0159ejmenovat taxonomii

MenuTaxonomySortByName = N\u00E1zvu

MenuTaxonomySortByTypName = Typu, n\u00E1zvu
MenuTaxonomySortByType = Typu

MenuTaxonomySortTreeBy = Se\u0159adit podle...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ MenuTaxonomyRename = Omd\u00F8b taksonomi
MenuTaxonomySortByName = Navn
MenuTaxonomySortByTypName = Type, Navn
MenuTaxonomySortByType = Type
MenuTaxonomySortTreeBy = Sorter efter...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ MenuTaxonomyRename = Klassifizierung umbenennen

MenuTaxonomySortByName = Name

MenuTaxonomySortByTypName = Typ, Name
MenuTaxonomySortByType = Typ

MenuTaxonomySortTreeBy = Sortieren...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ MenuTaxonomyRename = Renombrar taxonom\u00EDa

MenuTaxonomySortByName = Nombre

MenuTaxonomySortByTypName = Tipo, Nombre
MenuTaxonomySortByType = Tipo

MenuTaxonomySortTreeBy = Ordenar por...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@ MenuTaxonomyRename = Renommer taxonomie

MenuTaxonomySortByName = Nom

MenuTaxonomySortByTypName = Type, Nom
MenuTaxonomySortByType = Type

MenuTaxonomySortTreeBy = Trier par...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ MenuTaxonomyRename = Rinomina tassonomia

MenuTaxonomySortByName = Nome

MenuTaxonomySortByTypName = Tipo, nome
MenuTaxonomySortByType = Tipo

MenuTaxonomySortTreeBy = Ordina per...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ MenuTaxonomyRename = Naam van taxonomie wijzigen
MenuTaxonomySortByName = Naam
MenuTaxonomySortByTypName = Type, naam
MenuTaxonomySortByType = Type
MenuTaxonomySortTreeBy = Sorteren op...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ MenuTaxonomyRename = Zmie\u0144 nazw\u0119 taksonomii
MenuTaxonomySortByName = Nazwa
MenuTaxonomySortByTypName = Typ, nazwa
MenuTaxonomySortByType = Typ
MenuTaxonomySortTreeBy = Sortuj wed\u0142ug...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ MenuTaxonomyRename = Renomear taxonomia

MenuTaxonomySortByName = Nome

MenuTaxonomySortByTypName = Tipo, Nome
MenuTaxonomySortByType = Tipo

MenuTaxonomySortTreeBy = Ordernar por...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ MenuTaxonomyRename = Renomear taxonomia

MenuTaxonomySortByName = Nome

MenuTaxonomySortByTypName = Tipo, Nome
MenuTaxonomySortByType = Tipo

MenuTaxonomySortTreeBy = Ordernar por...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ MenuTaxonomyRename = \u041F\u0435\u0440\u0435\u0438\u043C\u0435\u043D\u043E\u043

MenuTaxonomySortByName = \u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435

MenuTaxonomySortByTypName = \u0422\u0438\u043F, \u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435
MenuTaxonomySortByType = \u0422\u0438\u043F

MenuTaxonomySortTreeBy = \u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043F\u043E...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ MenuTaxonomyRename = Premenovanie taxon\u00F3mie
MenuTaxonomySortByName = N\u00E1zov
MenuTaxonomySortByTypName = Typ, n\u00E1zov
MenuTaxonomySortByType = Typ
MenuTaxonomySortTreeBy = Zoradi\u0165 pod\u013Ea...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ MenuTaxonomyRename = \u91CD\u547D\u540D\u7C7B\u522B

MenuTaxonomySortByName = \u540D\u79F0

MenuTaxonomySortByTypName = \u7C7B\u578B\uFF0C\u540D\u79F0
MenuTaxonomySortByType = \u7C7B\u578B

MenuTaxonomySortTreeBy = \u6392\u5E8F...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ MenuTaxonomyRename = \u91CD\u65B0\u547D\u540D\u5206\u985E
MenuTaxonomySortByName = \u540D\u7A31
MenuTaxonomySortByTypName = \u985E\u578B\u3001\u540D\u7A31
MenuTaxonomySortByType = \u985E\u578B
MenuTaxonomySortTreeBy = \u6309...\u6392\u5E8F
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ else if (targetNode.isAssignment())
}
}

private enum SortCriterion
{
TYPE, NAME, ACTUAL
}

protected static final String MENU_GROUP_DEFAULT_ACTIONS = "defaultActions"; //$NON-NLS-1$
protected static final String MENU_GROUP_CUSTOM_ACTIONS = "customActions"; //$NON-NLS-1$
protected static final String MENU_GROUP_DELETE_ACTIONS = "deleteActions"; //$NON-NLS-1$
Expand Down Expand Up @@ -849,8 +854,13 @@ protected void fillContextMenu(IMenuManager manager) // NOSONAR
manager.add(new Separator());

MenuManager sorting = new MenuManager(Messages.MenuTaxonomySortTreeBy);
sorting.add(new SimpleAction(Messages.MenuTaxonomySortByTypName, a -> doSort(node, true)));
sorting.add(new SimpleAction(Messages.MenuTaxonomySortByName, a -> doSort(node, false)));
sorting.add(new SimpleAction(
String.join(", ", Messages.MenuTaxonomySortByType, Messages.MenuTaxonomySortByName), //$NON-NLS-1$
a -> doSort(node, SortCriterion.TYPE, SortCriterion.NAME)));
sorting.add(new SimpleAction(String.join(", ", Messages.MenuTaxonomySortByType, Messages.ColumnActualValue), //$NON-NLS-1$
a -> doSort(node, SortCriterion.TYPE, SortCriterion.ACTUAL)));
sorting.add(new SimpleAction(Messages.MenuTaxonomySortByName, a -> doSort(node, SortCriterion.NAME)));
sorting.add(new SimpleAction(Messages.ColumnActualValue, a -> doSort(node, SortCriterion.ACTUAL)));

manager.add(sorting);

Expand Down Expand Up @@ -995,7 +1005,7 @@ else if (change > 0)
// do not fire model change -> called within modification listener
}

private void doSort(TaxonomyNode node, final boolean byType) // NOSONAR
private void doSort(TaxonomyNode node, SortCriterion... criteria) // NOSONAR
{
Collections.sort(node.getChildren(), (node1, node2) -> { // NOSONAR
// unassigned category always stays at the end of the list
Expand All @@ -1004,12 +1014,32 @@ private void doSort(TaxonomyNode node, final boolean byType) // NOSONAR
if (node2.isUnassignedCategory())
return -1;

if (byType && node1.isClassification() && !node2.isClassification())
return -1;
if (byType && !node1.isClassification() && node2.isClassification())
return 1;
for (int ii = 0; ii < criteria.length; ii++)
{
switch (criteria[ii])
{
case TYPE:
if (node1.isClassification() && !node2.isClassification())
return -1;
if (!node1.isClassification() && node2.isClassification())
return 1;
break;
case NAME:
int cn = TextUtil.compare(node1.getName(), node2.getName());
if (cn != 0)
return cn;
break;
case ACTUAL:
int ca = node2.getActual().compareTo(node1.getActual());
if (ca != 0)
return ca;
break;
default:

}
}

return TextUtil.compare(node1.getName(), node2.getName());
return 0;
});

int rank = 0;
Expand Down

0 comments on commit a651771

Please sign in to comment.