Skip to content

Commit

Permalink
Added sort order
Browse files Browse the repository at this point in the history
fixes #499
  • Loading branch information
amitjoy committed Dec 14, 2022
1 parent 6cc7def commit f254400
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.osgifx.console.ui.bundles;

import static com.osgifx.console.event.topics.TableFilterUpdateTopics.UPDATE_BUNDLE_FILTER_EVENT_TOPIC;
import static javafx.scene.control.TableColumn.SortType.ASCENDING;

import java.util.function.Predicate;

Expand Down Expand Up @@ -130,6 +131,7 @@ private void createControls() {
table.setItems(filteredList);

TableFilter.forTableView(table).lazy(true).apply();
Fx.initSortOrder(table, idColumn, ASCENDING);
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.osgifx.console.ui.components;

import static com.osgifx.console.event.topics.TableFilterUpdateTopics.UPDATE_COMPONENT_FILTER_EVENT_TOPIC;
import static javafx.scene.control.TableColumn.SortType.ASCENDING;

import java.util.function.Predicate;

Expand Down Expand Up @@ -122,6 +123,7 @@ private void createControls() {
table.setItems(filteredList);

TableFilter.forTableView(table).lazy(true).apply();
Fx.initSortOrder(table, componentNameColumn, ASCENDING);
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.osgifx.console.ui.configurations;

import static com.osgifx.console.event.topics.TableFilterUpdateTopics.UPDATE_CONFIGURATION_FILTER_EVENT_TOPIC;
import static javafx.scene.control.TableColumn.SortType.ASCENDING;

import java.util.function.Predicate;

Expand Down Expand Up @@ -130,6 +131,7 @@ private void createControls() {
table.setItems(filteredList);

TableFilter.forTableView(table).lazy(true).apply();
Fx.initSortOrder(table, pidColumn, ASCENDING);
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
******************************************************************************/
package com.osgifx.console.ui.events;

import static javafx.scene.control.TableColumn.SortType.DESCENDING;

import java.util.Date;

import javax.inject.Inject;
Expand Down Expand Up @@ -109,13 +111,7 @@ private void createControls() {
table.setItems(events);

TableFilter.forTableView(table).lazy(true).apply();
sortByReceivedAt(receivedAtColumn);
}

private void sortByReceivedAt(final TableColumn<XEventDTO, Date> column) {
column.setSortType(TableColumn.SortType.DESCENDING);
table.getSortOrder().add(column);
table.sort();
Fx.initSortOrder(table, receivedAtColumn, DESCENDING);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
******************************************************************************/
package com.osgifx.console.ui.http;

import static javafx.scene.control.TableColumn.SortType.ASCENDING;

import javax.inject.Inject;
import javax.inject.Named;

Expand Down Expand Up @@ -126,6 +128,7 @@ private void createControls() {

table.setItems(dataProvider.httpComponents());
TableFilter.forTableView(table).lazy(true).apply();
Fx.initSortOrder(table, componentColumn, ASCENDING);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
******************************************************************************/
package com.osgifx.console.ui.leaks;

import static javafx.scene.control.TableColumn.SortType.ASCENDING;

import javax.inject.Inject;
import javax.inject.Named;

Expand Down Expand Up @@ -75,6 +77,7 @@ private void initCells() {

table.setItems(dataProvider.leaks());
TableFilter.forTableView(table).lazy(true).apply();
Fx.initSortOrder(table, idColumn, ASCENDING);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
******************************************************************************/
package com.osgifx.console.ui.logs;

import static javafx.scene.control.TableColumn.SortType.DESCENDING;

import java.util.Date;

import javax.inject.Inject;
Expand Down Expand Up @@ -118,13 +120,7 @@ private void createControls() {
table.setItems(logs);

TableFilter.forTableView(table).lazy(true).apply();
sortByLoggedAt(loggedAtColumn);
}

private void sortByLoggedAt(final TableColumn<XLogEntryDTO, Date> column) {
column.setSortType(TableColumn.SortType.DESCENDING);
table.getSortOrder().add(column);
table.sort();
Fx.initSortOrder(table, loggedAtColumn, DESCENDING);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.osgifx.console.ui.packages;

import static com.osgifx.console.event.topics.TableFilterUpdateTopics.UPDATE_PACKAGE_FILTER_EVENT_TOPIC;
import static javafx.scene.control.TableColumn.SortType.ASCENDING;

import java.util.function.Predicate;

Expand Down Expand Up @@ -122,6 +123,7 @@ private void createControls() {
table.setItems(filteredList);

TableFilter.forTableView(table).lazy(true).apply();
Fx.initSortOrder(table, nameColumn, ASCENDING);
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
******************************************************************************/
package com.osgifx.console.ui.properties;

import static javafx.scene.control.TableColumn.SortType.ASCENDING;

import javax.inject.Inject;
import javax.inject.Named;

Expand Down Expand Up @@ -72,6 +74,7 @@ private void initCells() {

propertyTable.setItems(dataProvider.properties());
TableFilter.forTableView(propertyTable).lazy(true).apply();
Fx.initSortOrder(propertyTable, propertyName, ASCENDING);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
******************************************************************************/
package com.osgifx.console.ui.roles;

import static javafx.scene.control.TableColumn.SortType.ASCENDING;

import javax.inject.Inject;
import javax.inject.Named;

Expand Down Expand Up @@ -103,6 +105,7 @@ private void createControls() {

table.setItems(dataProvider.roles());
TableFilter.forTableView(table).lazy(true).apply();
Fx.initSortOrder(table, roleNameColumn, ASCENDING);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.osgifx.console.ui.services;

import static com.osgifx.console.event.topics.TableFilterUpdateTopics.UPDATE_SERVICE_FILTER_EVENT_TOPIC;
import static javafx.scene.control.TableColumn.SortType.ASCENDING;
import static org.osgi.service.component.ComponentConstants.COMPONENT_ID;

import java.util.function.Predicate;
Expand Down Expand Up @@ -125,6 +126,7 @@ private void createControls() {
table.setItems(filteredList);

TableFilter.forTableView(table).lazy(true).apply();
Fx.initSortOrder(table, idColumn, ASCENDING);
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
******************************************************************************/
package com.osgifx.console.ui.threads;

import static javafx.scene.control.TableColumn.SortType.ASCENDING;

import javax.inject.Inject;
import javax.inject.Named;

Expand Down Expand Up @@ -92,6 +94,7 @@ private void initCells() {

table.setItems(dataProvider.threads());
TableFilter.forTableView(table).lazy(true).apply();
Fx.initSortOrder(table, nameColumn, ASCENDING);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.SortType;
import javafx.scene.control.TablePosition;
import javafx.scene.control.TableView;
import javafx.scene.control.Tooltip;
Expand Down Expand Up @@ -233,4 +234,12 @@ public static Node initStatusBarButton(final Runnable job,
}
return button;
}

public static <C> void initSortOrder(final TableView<C> table,
final TableColumn<C, ?> column,
final SortType sortType) {
column.setSortType(sortType);
table.getSortOrder().add(column);
table.sort();
}
}

0 comments on commit f254400

Please sign in to comment.