Java 类javafx.scene.control.TableColumn.SortType 实例源码

项目:logbook-kai    文件:Tools.java   
/**
 * テーブルソート列の設定を行う
 * @param table テーブル
 * @param key テーブルのキー名
 */
public static <S> void setSortOrder(TableView<S> table, String key) {
    Map<String, String> setting = AppConfig.get()
            .getColumnSortOrderMap()
            .get(key);
    ObservableList<TableColumn<S, ?>> sortOrder = table.getSortOrder();
    if (setting != null) {
        // 初期設定
        Map<String, TableColumn<S, ?>> columnsMap = table.getColumns().stream()
                .collect(Collectors.toMap(c -> c.getText(), c -> c, (c1, c2) -> c1));
        setting.forEach((k, v) -> {
            Optional.ofNullable(columnsMap.get(k)).ifPresent(col -> {
                sortOrder.add(col);
                col.setSortType(SortType.valueOf(v));
            });
        });
    }
    // ソート列またはソートタイプが変更された時に設定を保存する
    sortOrder.addListener((ListChangeListener<TableColumn<S, ?>>) e -> storeSortOrder(table, key));
    table.getColumns().forEach(col -> {
        col.sortTypeProperty().addListener((ob, o, n) -> storeSortOrder(table, key));
    });
}
项目:myWMS    文件:BODTOTable.java   
public QueryDetail createQueryDetail() {
    QueryDetail q = new QueryDetail(0, 100);
    for (TableColumn<?,?> col : getTable().getSortOrder()) {
        SortType type = col.getSortType();
        q.addOrderByToken(col.getId(), type == SortType.ASCENDING);
    }
    if (q.getOrderBy().size() == 0) {
        q.addOrderByToken("id", false);         
    }
    return q;
}
项目:BudgetMaster    文件:ReportController.java   
private ReportPreferences getReportPreferences()
{
    ColumnOrder columnOrder = new ColumnOrder();
    for(TableColumn<ReportItem, ?> currentColumn : tableView.getColumns())
    {
        ColumnType currentType = (ColumnType)currentColumn.getUserData();           
        if(columnFilter.containsColumn(currentType))
        {
            columnOrder.addColumn(currentType);
        }
    }

    ReportSorting reportSorting = new ReportSorting();
    ObservableList<TableColumn<ReportItem, ?>> sortOrder = tableView.getSortOrder();
    if(sortOrder.size() >  0)
    {
        reportSorting.setColumnType((ColumnType)sortOrder.get(0).getUserData());
        reportSorting.setSortType(sortOrder.get(0).getSortType());
    }
    else
    {
        reportSorting.setColumnType(ColumnType.DATE);
        reportSorting.setSortType(SortType.DESCENDING);
    }

    String reportFolderPath = null;
    if(reportPreferences != null)
    {
        reportFolderPath = reportPreferences.getReportFolderPath();
    }

    return new ReportPreferences(columnOrder, 
                                checkBoxIncludeBudget.isSelected(),
                                checkBoxSplitTable.isSelected(),
                                checkBoxIncludeCategoryBudgets.isSelected(),
                                reportSorting, 
                                reportFolderPath);
}
项目:JVx.javafx    文件:DataBookViewList.java   
/**
 * {@inheritDoc}
 */
@Override
public void sort(Comparator<? super IDataRow> pComparator)
{
    ObservableList<TableColumn<IDataRow, ?>> sortOrder = dataBookView.getSortOrder();

    try
    {
        if (sortOrder == null || sortOrder.isEmpty())
        {
            dataBook.setSort(null);
        }
        else
        {
            String[] sortColumns = new String[sortOrder.size()];
            boolean[] sortColumnsAscending = new boolean[sortColumns.length];

            for (int index = 0; index < sortOrder.size(); index++)
            {
                TableColumn<IDataRow, ?> column = sortOrder.get(index);
                String columnName = (String) column.getUserData();

                sortColumns[index] = columnName;
                sortColumnsAscending[index] = column.getSortType() == SortType.ASCENDING;
            }

            dataBook.setSort(new SortDefinition(sortColumns, sortColumnsAscending));
        }

        String currentColumn = dataBook.getSelectedColumn();

        fireChangedEvent(0, dataBook.getRowCount());

        dataBook.setSelectedColumn(currentColumn);
    }
    catch (ModelException e)
    {
        throw new RuntimeException(e);
    }
}
项目:erlyberly    文件:ProcController.java   
private void updateProcessList(final ArrayList<ProcInfo> processList) {
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            ProcSort procSort = procSortProperty.get();
            if(procSort != null) {
                Comparator<ProcInfo> comparator = null;

                if("proc".equals(procSort.getSortField())) {
                    comparator = new Comparator<ProcInfo>() {
                        @Override
                        public int compare(ProcInfo o1, ProcInfo o2) {
                            return o1.getProcessName().compareTo(o2.getProcessName());
                        }};
                }
                else if("reduc".equals(procSort.getSortField())) {
                    comparator = new Comparator<ProcInfo>() {
                        @Override
                        public int compare(ProcInfo o1, ProcInfo o2) {
                            return Long.compare(o1.getReductions(), o2.getReductions());
                        }};
                }

                if(comparator != null) {
                    if(procSort.getSortType() == SortType.DESCENDING) {
                        comparator = Collections.reverseOrder(comparator);
                    }
                    Collections.sort(processList, comparator);
                }
            }
            processes.clear();
            processes.addAll(processList);
        }});
}
项目:javafx-demos    文件:SimpleTableViewDemo.java   
@SuppressWarnings("unchecked")
private void configureTable(StackPane root) {

    final ObservableList<MyDomain> data = FXCollections.observableArrayList(new MyDomain("Apple", "This is a fruit.", "Red"),
            new MyDomain("Orange", "This is also a fruit.", "Orange"), new MyDomain("Potato", "This is a vegetable.", "Brown"));

    final TableView<MyDomain> table = new TableView<MyDomain>();
    table.setManaged(true);
    TableColumn<MyDomain, String> titleColumn = new TableColumn<MyDomain, String>("Title");
    titleColumn.setPrefWidth(125);
    titleColumn.setCellValueFactory(new PropertyValueFactory<MyDomain, String>("name"));
    titleColumn.sortTypeProperty().addListener(new ChangeListener<SortType>() {
        @Override
        public void changed(ObservableValue<? extends SortType> arg0, SortType arg1, SortType arg2) {
            System.out.println(arg2);
        }
    });
    TableColumn<MyDomain, String> descCol = new TableColumn<MyDomain, String>("Description");
    descCol.setPrefWidth(200);
    descCol.setCellValueFactory(new PropertyValueFactory<MyDomain, String>("description"));

    TableColumn<MyDomain, String> colorCol = new TableColumn<MyDomain, String>("Color");
    colorCol.setPrefWidth(200);
    colorCol.setCellValueFactory(new PropertyValueFactory<MyDomain, String>("color"));

    table.getColumns().addAll(titleColumn, descCol, colorCol);
    table.itemsProperty().addListener(new ChangeListener<ObservableList<MyDomain>>() {
        @Override
        public void changed(ObservableValue<? extends ObservableList<MyDomain>> paramObservableValue, ObservableList<MyDomain> paramT1,
                ObservableList<MyDomain> paramT2) {
            table.setPrefHeight((table.getItems().size()*25) + 25);
        }});
    table.setItems(data);
    VBox vb = new VBox();
    vb.getChildren().addAll(StackPaneBuilder.create().prefHeight(100).style("-fx-background-color:red;").build(), table,
            StackPaneBuilder.create().prefHeight(100).style("-fx-background-color:blue;").build());
    root.getChildren().add(vb);

}
项目:BudgetMaster    文件:ReportSorting.java   
public ReportSorting(ColumnType columnType, SortType sortType)
{
    this.columnType = columnType;
    this.sortType = sortType;
}
项目:BudgetMaster    文件:ReportSorting.java   
public SortType getSortType()
{
    return sortType;
}
项目:BudgetMaster    文件:ReportSorting.java   
public void setSortType(SortType sortType)
{
    this.sortType = sortType;
}
项目:metastone    文件:BattleOfDecksResultView.java   
@SuppressWarnings("unchecked")
public BattleOfDecksResultView() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/BattleOfDecksResultView.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {
        fxmlLoader.load();
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }

    TableColumn<BattleDeckResult, String> nameColumn = new TableColumn<>("Deck name");
    nameColumn.setPrefWidth(200);
    TableColumn<BattleDeckResult, Double> winRateColumn = new TableColumn<>("Win rate");
    winRateColumn.setPrefWidth(150);

    nameColumn.setCellValueFactory(new PropertyValueFactory<BattleDeckResult, String>("deckName"));
    winRateColumn.setCellValueFactory(new PropertyValueFactory<BattleDeckResult, Double>("winRate"));

    winRateColumn.setCellFactory(new Callback<TableColumn<BattleDeckResult, Double>, TableCell<BattleDeckResult, Double>>() {
        public TableCell<BattleDeckResult, Double> call(TableColumn<BattleDeckResult, Double> p) {
            TableCell<BattleDeckResult, Double> cell = new TableCell<BattleDeckResult, Double>() {
                private final Label label = new Label();
                private final ProgressBar progressBar = new ProgressBar();
                private final StackPane stackPane = new StackPane();

                {
                    label.getStyleClass().setAll("progress-text");
                    stackPane.setAlignment(Pos.CENTER);
                    stackPane.getChildren().setAll(progressBar, label);
                    setGraphic(stackPane);
                }

                @Override
                protected void updateItem(Double winrate, boolean empty) {
                    super.updateItem(winrate, empty);
                    if (winrate == null || empty) {
                        setGraphic(null);
                        return;
                    }
                    progressBar.setProgress(winrate);
                    label.setText(String.format("%.2f", winrate * 100) + "%");
                    setGraphic(stackPane);
                }

            };
            return cell;
        }
    });

    rankingTable.getColumns().setAll(nameColumn, winRateColumn);
    rankingTable.getColumns().get(1).setSortType(SortType.DESCENDING);

    backButton.setOnAction(event -> NotificationProxy.sendNotification(GameNotification.MAIN_MENU));
}
项目:erlyberly    文件:ProcSort.java   
public ProcSort(String sortField, SortType sortType) {
    this.sortField = sortField;
    this.sortType = sortType;
}
项目:erlyberly    文件:ProcSort.java   
public SortType getSortType() {
    return sortType;
}
项目:javafx-demos    文件:TableViewAutoSizeDemo.java   
@SuppressWarnings("unchecked")
private void configureTable(StackPane root) {

    final ObservableList<MyDomain> data = FXCollections.observableArrayList(
            new MyDomain("Apple","This is a fruit.","Red"),
            new MyDomain("Orange","This is also a fruit.","Orange"),
            new MyDomain("Potato","This is a vegetable.","Brown")
            );

    CustomTableView<MyDomain> table = new CustomTableView<MyDomain>();

    CustomTableColumn<MyDomain,String> titleColumn = new CustomTableColumn<MyDomain,String>("Title");
    titleColumn.setPercentWidth(25);
    titleColumn.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("name"));
    titleColumn.sortTypeProperty().addListener(new ChangeListener<SortType>() {
        @Override
        public void changed(ObservableValue<? extends SortType> arg0,
                SortType arg1, SortType arg2) {
            System.out.println(arg2);
        }
    });
    CustomTableColumn<MyDomain,String> descCol = new CustomTableColumn<MyDomain,String>("Description");
    descCol.setPercentWidth(55);
    descCol.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("description"));

    CustomTableColumn<MyDomain,String> colorCol = new CustomTableColumn<MyDomain,String>("Color");
    colorCol.setPercentWidth(20);
    colorCol.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("color"));

    table.getTableView().getColumns().addAll(titleColumn,descCol,colorCol);
    table.getTableView().setItems(data);
    root.getChildren().add(table);

    table.getTableView().setOnMouseClicked(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent event) {
            System.out.println(event.getTarget());
        }
    });


    TableView<MyDomain> table2 = new TableView<MyDomain>();
    TableColumn<MyDomain,String> col1 = new TableColumn<MyDomain,String>();
    col1.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("name"));
}
项目:skadi    文件:MainWindow.java   
private void setupTable() {
    table = new TableView<>();
    table.setBorder(Border.EMPTY);
    table.setPadding(Insets.EMPTY);

    liveCol = new TableColumn<>("Live");
    liveCol.setCellValueFactory(p -> p.getValue().onlineProperty());
    liveCol.setSortType(SortType.DESCENDING);
    liveCol.setCellFactory(p -> new LiveCell());

    nameCol = new TableColumn<>("Channel");
    nameCol.setCellValueFactory(p -> p.getValue().nameProperty());


    titleCol = new TableColumn<>("Status");
    titleCol.setCellValueFactory(p -> p.getValue().titleProperty());

    gameCol = new TableColumn<>("Game");
    gameCol.setCellValueFactory(p -> p.getValue().gameProperty());

    viewerCol = new TableColumn<>("Viewer");
    viewerCol.setCellValueFactory(p -> p.getValue().viewerProperty().asObject());
    viewerCol.setSortType(SortType.DESCENDING);
    viewerCol.setCellFactory(p -> new RightAlignedCell<>());

    uptimeCol = new TableColumn<>("Uptime");
    uptimeCol.setCellValueFactory(p -> p.getValue().uptimeProperty().asObject());
    uptimeCol.setCellFactory(p -> new UptimeCell());

    table.setPlaceholder(new Label("no channels added/matching the filters"));

    //table.getColumns().add(liveCol);
    table.getColumns().add(nameCol);
    table.getColumns().add(titleCol);
    table.getColumns().add(gameCol);
    table.getColumns().add(viewerCol);
    table.getColumns().add(uptimeCol);

    //table.getSortOrder().add(liveCol);
    table.getSortOrder().add(viewerCol);
    table.getSortOrder().add(nameCol);


    filteredChannelListTable = new FilteredList<>(channelStore.getChannels());
    final SortedList<Channel> sortedChannelListTable = new SortedList<>(filteredChannelListTable);
    sortedChannelListTable.comparatorProperty().bind(table.comparatorProperty());

    table.setItems(sortedChannelListTable);

    table.getSelectionModel().selectedItemProperty().addListener((obs, oldV, newV) -> {
        onSelection(newV);
        if ((newV == null) && splitPane.getItems().contains(detailPane)) {
            doDetailSlide(false);
        }
    });

    table.setOnMousePressed(event -> {
        if (table.getSelectionModel().getSelectedItem() == null) {
            return;
        }

        if (event.getButton() == MouseButton.MIDDLE) {
            openStream(table.getSelectionModel().getSelectedItem());

        } else if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2) {
            openDetailPage(table.getSelectionModel().getSelectedItem());
        }
    });
}
项目:erlyberly    文件:ProcController.java   
public ProcController() {
    polling = new SimpleBooleanProperty();

    procSortProperty = new SimpleObjectProperty<>(new ProcSort("reduc", SortType.DESCENDING));

    procPollerThread = new ProcPollerThread();

    waiter = new Object();

    Platform.runLater(() -> {
        ErlyBerly.nodeAPI().connectedProperty().addListener((o) -> { startPollingThread(); } );
    });

    filter.addListener((o, ov, nv) -> { updateProcFilter(nv); });
}