Search in sources :

Example 11 with TableView

use of javafx.scene.control.TableView in project org.csstudio.display.builder by kasemir.

the class WidgetInfoDialog method createPVs.

private Tab createPVs(final Collection<NameStateValue> pvs) {
    // Use text field to allow users to copy the name, value to clipboard
    final TableColumn<NameStateValue, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
    name.setCellFactory(TextFieldTableCell.forTableColumn());
    name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().name));
    final TableColumn<NameStateValue, String> state = new TableColumn<>(Messages.WidgetInfoDialog_State);
    state.setCellFactory(TextFieldTableCell.forTableColumn());
    state.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().state));
    final TableColumn<NameStateValue, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
    value.setCellFactory(TextFieldTableCell.forTableColumn());
    value.setCellValueFactory(param -> {
        String text;
        final VType vtype = param.getValue().value;
        if (vtype == null)
            text = Messages.WidgetInfoDialog_Disconnected;
        else {
            // so only show the basic type info
            if (vtype instanceof VNumberArray)
                text = vtype.toString();
            else
                text = VTypeUtil.getValueString(vtype, true);
            if (vtype instanceof Alarm) {
                final Alarm alarm = (Alarm) vtype;
                if (alarm.getAlarmSeverity() != AlarmSeverity.NONE)
                    text = text + " [" + alarm.getAlarmSeverity().toString() + ", " + alarm.getAlarmName() + "]";
            }
        }
        return new ReadOnlyStringWrapper(text);
    });
    final ObservableList<NameStateValue> pv_data = FXCollections.observableArrayList(pvs);
    pv_data.sort((a, b) -> a.name.compareTo(b.name));
    final TableView<NameStateValue> table = new TableView<>(pv_data);
    table.getColumns().add(name);
    table.getColumns().add(state);
    table.getColumns().add(value);
    table.setEditable(true);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    return new Tab(Messages.WidgetInfoDialog_TabPVs, table);
}
Also used : VNumberArray(org.diirt.vtype.VNumberArray) VType(org.diirt.vtype.VType) Tab(javafx.scene.control.Tab) ReadOnlyStringWrapper(javafx.beans.property.ReadOnlyStringWrapper) Alarm(org.diirt.vtype.Alarm) TableColumn(javafx.scene.control.TableColumn) TableView(javafx.scene.control.TableView)

Example 12 with TableView

use of javafx.scene.control.TableView in project org.csstudio.display.builder by kasemir.

the class PointsTable method create.

/**
 * @return Top-level {@link Node}
 */
public Node create() {
    // Layout:
    // 
    // | table |  [Add]
    // | table |  [Remove]
    // | table |
    // | table |
    // Create table with editable columns for type Double (supported as Number)
    final TableColumn<Point, Number> x_col = new TableColumn<>(Messages.PointsTable_X);
    x_col.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Point, Number>, ObservableValue<Number>>() {

        @Override
        public ObservableValue<Number> call(CellDataFeatures<Point, Number> param) {
            return new SimpleDoubleProperty(param.getValue().getX());
        }
    });
    x_col.setCellFactory(TextFieldTableCell.<Point, Number>forTableColumn(new NumberStringConverter()));
    x_col.setOnEditCommit(event -> {
        final int row = event.getTablePosition().getRow();
        points.setX(row, event.getNewValue().doubleValue());
    });
    final TableColumn<Point, Number> y_col = new TableColumn<>(Messages.PointsTable_Y);
    y_col.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Point, Number>, ObservableValue<Number>>() {

        @Override
        public ObservableValue<Number> call(CellDataFeatures<Point, Number> param) {
            return new SimpleDoubleProperty(param.getValue().getY());
        }
    });
    y_col.setCellFactory(TextFieldTableCell.<Point, Number>forTableColumn(new NumberStringConverter()));
    y_col.setOnEditCommit(event -> {
        final int row = event.getTablePosition().getRow();
        points.setY(row, event.getNewValue().doubleValue());
    });
    final ObservableList<Point> data = new PointsAdapter(points);
    final TableView<Point> table = new TableView<>(data);
    table.getColumns().add(x_col);
    table.getColumns().add(y_col);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setPlaceholder(new Label(Messages.PointsTable_Empty));
    table.setEditable(true);
    // Buttons
    final Button add = new Button(Messages.Add, JFXUtil.getIcon("add.png"));
    add.setMaxWidth(Double.MAX_VALUE);
    add.setOnAction(event -> data.add(new Point(0, 0)));
    final Button remove = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
    remove.setMaxWidth(Double.MAX_VALUE);
    remove.setOnAction(event -> {
        final int sel = table.getSelectionModel().getSelectedIndex();
        if (sel >= 0)
            data.remove(sel);
    });
    final Button up = new Button(Messages.MoveUp, JFXUtil.getIcon("up.png"));
    up.setMaxWidth(Double.MAX_VALUE);
    up.setOnAction(event -> TableHelper.move_item_up(table, data));
    final Button down = new Button(Messages.MoveDown, JFXUtil.getIcon("down.png"));
    down.setMaxWidth(Double.MAX_VALUE);
    down.setOnAction(event -> TableHelper.move_item_down(table, data));
    final VBox buttons = new VBox(10, add, remove, up, down);
    final HBox content = new HBox(10, table, buttons);
    HBox.setHgrow(table, Priority.ALWAYS);
    return content;
}
Also used : HBox(javafx.scene.layout.HBox) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableValue(javafx.beans.value.ObservableValue) Label(javafx.scene.control.Label) Point(org.csstudio.display.builder.model.properties.Point) TableColumn(javafx.scene.control.TableColumn) Point(org.csstudio.display.builder.model.properties.Point) NumberStringConverter(javafx.util.converter.NumberStringConverter) Button(javafx.scene.control.Button) VBox(javafx.scene.layout.VBox) TableView(javafx.scene.control.TableView)

Example 13 with TableView

use of javafx.scene.control.TableView in project financial by greatkendy123.

the class MoneyService method getAllTeamFWF.

/**
 * 在加载上一场或从昨天加载利润表时(点击平帐按钮)先缓存总团队服务费的值
 * @time 2018年1月5日
 * @param table
 * @return
 */
private static String getAllTeamFWF(TableView<ProfitInfo> table) {
    String allTeamFWF = "0";
    try {
        ProfitInfo profitInfo = TableUtil.getItem(table).filtered(info -> "总团队服务费".equals(info.getProfitType())).get(0);
        allTeamFWF = profitInfo.getProfitAccount();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return allTeamFWF;
}
Also used : Arrays(java.util.Arrays) ZijinInfo(com.kendy.entity.ZijinInfo) Constants(application.Constants) ListIterator(java.util.ListIterator) NumUtil(com.kendy.util.NumUtil) Date(java.util.Date) Huishui(com.kendy.entity.Huishui) DangjuInfo(com.kendy.entity.DangjuInfo) Logger(org.apache.log4j.Logger) StringUtil(com.kendy.util.StringUtil) Map(java.util.Map) KaixiaoInfo(com.kendy.entity.KaixiaoInfo) MyController(application.MyController) ExportTeamhsExcel(com.kendy.excel.ExportTeamhsExcel) TableView(javafx.scene.control.TableView) PingzhangInfo(com.kendy.entity.PingzhangInfo) TeamHuishuiInfo(com.kendy.entity.TeamHuishuiInfo) TotalInfo(com.kendy.entity.TotalInfo) JiaoshouInfo(com.kendy.entity.JiaoshouInfo) Set(java.util.Set) UserInfos(com.kendy.entity.UserInfos) List(java.util.List) TypeReference(com.alibaba.fastjson.TypeReference) ShowUtil(com.kendy.util.ShowUtil) TextInputDialog(javafx.scene.control.TextInputDialog) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) ErrorUtil(com.kendy.util.ErrorUtil) CurrentMoneyInfo(com.kendy.entity.CurrentMoneyInfo) ExportMembersExcel(com.kendy.excel.ExportMembersExcel) SimpleDateFormat(java.text.SimpleDateFormat) GDController(com.kendy.controller.GDController) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) TableUtil(com.kendy.util.TableUtil) LinkedList(java.util.LinkedList) TeamInfo(com.kendy.entity.TeamInfo) DataConstans(application.DataConstans) DBUtil(com.kendy.db.DBUtil) Player(com.kendy.entity.Player) Label(javafx.scene.control.Label) Iterator(java.util.Iterator) DecimalFormat(java.text.DecimalFormat) ProfitInfo(com.kendy.entity.ProfitInfo) Main(application.Main) JSON(com.alibaba.fastjson.JSON) WanjiaInfo(com.kendy.entity.WanjiaInfo) Collections(java.util.Collections) Entity(com.kendy.interfaces.Entity) ProfitInfo(com.kendy.entity.ProfitInfo)

Example 14 with TableView

use of javafx.scene.control.TableView in project financial by greatkendy123.

the class MoneyService method add2AllTeamFWF_from_tableProfit.

/**
 * 利润表修改总团队服务费(累积该团队的服务费)
 * @time 2018年1月5日
 * @param teamFWF
 */
public static void add2AllTeamFWF_from_tableProfit(TableView<ProfitInfo> table, Double teamFWF) {
    try {
        ProfitInfo profitInfo = TableUtil.getItem(table).filtered(info -> "总团队服务费".equals(info.getProfitType())).get(0);
        String allTeamFWF = NumUtil.digit0(NumUtil.getNum(profitInfo.getProfitAccount()) + teamFWF);
        profitInfo.setProfitAccount(allTeamFWF);
        table.refresh();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Arrays(java.util.Arrays) ZijinInfo(com.kendy.entity.ZijinInfo) Constants(application.Constants) ListIterator(java.util.ListIterator) NumUtil(com.kendy.util.NumUtil) Date(java.util.Date) Huishui(com.kendy.entity.Huishui) DangjuInfo(com.kendy.entity.DangjuInfo) Logger(org.apache.log4j.Logger) StringUtil(com.kendy.util.StringUtil) Map(java.util.Map) KaixiaoInfo(com.kendy.entity.KaixiaoInfo) MyController(application.MyController) ExportTeamhsExcel(com.kendy.excel.ExportTeamhsExcel) TableView(javafx.scene.control.TableView) PingzhangInfo(com.kendy.entity.PingzhangInfo) TeamHuishuiInfo(com.kendy.entity.TeamHuishuiInfo) TotalInfo(com.kendy.entity.TotalInfo) JiaoshouInfo(com.kendy.entity.JiaoshouInfo) Set(java.util.Set) UserInfos(com.kendy.entity.UserInfos) List(java.util.List) TypeReference(com.alibaba.fastjson.TypeReference) ShowUtil(com.kendy.util.ShowUtil) TextInputDialog(javafx.scene.control.TextInputDialog) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) ErrorUtil(com.kendy.util.ErrorUtil) CurrentMoneyInfo(com.kendy.entity.CurrentMoneyInfo) ExportMembersExcel(com.kendy.excel.ExportMembersExcel) SimpleDateFormat(java.text.SimpleDateFormat) GDController(com.kendy.controller.GDController) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) TableUtil(com.kendy.util.TableUtil) LinkedList(java.util.LinkedList) TeamInfo(com.kendy.entity.TeamInfo) DataConstans(application.DataConstans) DBUtil(com.kendy.db.DBUtil) Player(com.kendy.entity.Player) Label(javafx.scene.control.Label) Iterator(java.util.Iterator) DecimalFormat(java.text.DecimalFormat) ProfitInfo(com.kendy.entity.ProfitInfo) Main(application.Main) JSON(com.alibaba.fastjson.JSON) WanjiaInfo(com.kendy.entity.WanjiaInfo) Collections(java.util.Collections) Entity(com.kendy.interfaces.Entity) ProfitInfo(com.kendy.entity.ProfitInfo)

Example 15 with TableView

use of javafx.scene.control.TableView in project financial by greatkendy123.

the class TGFwfService method setFwfDetail.

public void setFwfDetail(String tgCompany, TableView<TGFwfinfo> tableTGFwf, TableView<TypeValueInfo> tableTGFwfSum) {
    if (StringUtil.isBlank(tgCompany)) {
        ShowUtil.show("请选择托管公司");
    // return;
    }
    TGController tgController = MyController.tgController;
    List<TGCompanyModel> tgCompanys = DBUtil.get_all_tg_company();
    Set<String> teamSet = new HashSet<>();
    if (CollectUtil.isHaveValue(tgCompanys)) {
        teamSet = tgCompanys.stream().filter(info -> tgCompany.equals(info.getTgCompanyName())).flatMap((TGCompanyModel info) -> Stream.of(info.getTgTeamsStr().split("#"))).collect(Collectors.toSet());
    }
    if (CollectUtil.isNullOrEmpty(teamSet)) {
        ShowUtil.show("没有托管团队!", 2);
        return;
    }
    List<TGTeamInfo> companyProxyTeamInfo = new ArrayList<>();
    for (String teamId : teamSet) {
        // 获取代理查询的团队数据
        final List<ProxyTeamInfo> proxyTeamInfoList = tgController.getProxyTeamInfoList(teamId);
        companyProxyTeamInfo.addAll(convert2TGTeamInfo(proxyTeamInfoList));
    }
    int renci = companyProxyTeamInfo.size();
    if (CollectUtil.isNullOrEmpty(companyProxyTeamInfo)) {
        ShowUtil.show("没有代理数据!", 2);
        return;
    }
    // 转化为托管公司的团队数据
    Map<String, List<TGTeamInfo>> teamProxys = companyProxyTeamInfo.stream().collect(Collectors.groupingBy(TGTeamInfo::getTgTeamId));
    List<TGFwfinfo> tgFwfInfoList = new ArrayList<>();
    teamProxys.forEach((teamID, tgTeamInfoList) -> {
        // 1 战绩2.5%:
        double zjRate25Sum = tgTeamInfoList.stream().mapToDouble(info -> NumUtil.getNum(info.getTgZJ25())).sum();
        // 2 战绩未知
        double zjRateUnknowSum = tgTeamInfoList.stream().mapToDouble(info -> NumUtil.getNum(info.getTgZJUnknow())).sum();
        // 3 保险
        double zjBaoxianSum = tgTeamInfoList.stream().mapToDouble(info -> NumUtil.getNum(info.getTgBaoxian())).sum() * (-0.975);
        // 4 回保
        double zjHuibaoSum = tgTeamInfoList.stream().mapToDouble(info -> NumUtil.getNum(info.getTgHuiBao())).sum();
        // 5 总和
        double zjProfitSum = zjRate25Sum - zjRateUnknowSum + zjBaoxianSum - zjHuibaoSum;
        double huibaoDouble = zjBaoxianSum * tgController.getTgTeamHuibaoRate(teamID);
        double teamFwfRate = tgController.getTgTeamFwfRate(teamID);
        TGFwfinfo fwfInfo = new TGFwfinfo(tgCompany, teamID, // 服务回水 = 战绩2.5% - 战绩未知
        NumUtil.digit2(zjRate25Sum - zjRateUnknowSum + ""), // 服务回保 = 保险 - 回保
        NumUtil.digit2(huibaoDouble + ""), // 单个总利润
        NumUtil.digit2(zjProfitSum + ""), // 服务返水
        NumUtil.digit2(zjRateUnknowSum + ""), // 服务返保
        NumUtil.digit2(zjHuibaoSum + ""), // 服务全水
        NumUtil.digit2(zjRate25Sum + ""), // 服务全保
        NumUtil.digit2(zjBaoxianSum + ""), // 服务合计
        NumUtil.digit2((zjRate25Sum + zjBaoxianSum) * teamFwfRate + ""));
        tgFwfInfoList.add(fwfInfo);
    });
    // 排序
    sort(tgFwfInfoList);
    // 设值
    tableTGFwf.setItems(FXCollections.observableArrayList(tgFwfInfoList));
    // 设总和表
    setTableTGFwfSumData(tableTGFwf, tableTGFwfSum, renci);
}
Also used : Arrays(java.util.Arrays) NumUtil(com.kendy.util.NumUtil) FXCollections(javafx.collections.FXCollections) TypeValueInfo(com.kendy.entity.TypeValueInfo) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) StringUtil(com.kendy.util.StringUtil) Map(java.util.Map) TGTeamModel(com.kendy.entity.TGTeamModel) MyController(application.MyController) TableView(javafx.scene.control.TableView) DBUtil(com.kendy.db.DBUtil) TGFwfinfo(com.kendy.entity.TGFwfinfo) TGTeamInfo(com.kendy.entity.TGTeamInfo) Set(java.util.Set) TGController(com.kendy.controller.TGController) Collectors(java.util.stream.Collectors) TGCompanyModel(com.kendy.entity.TGCompanyModel) List(java.util.List) Stream(java.util.stream.Stream) CollectUtil(com.kendy.util.CollectUtil) ShowUtil(com.kendy.util.ShowUtil) ProxyTeamInfo(com.kendy.entity.ProxyTeamInfo) ObservableList(javafx.collections.ObservableList) Comparator(java.util.Comparator) Collections(java.util.Collections) ProxyTeamInfo(com.kendy.entity.ProxyTeamInfo) TGController(com.kendy.controller.TGController) ArrayList(java.util.ArrayList) TGTeamInfo(com.kendy.entity.TGTeamInfo) TGFwfinfo(com.kendy.entity.TGFwfinfo) TGCompanyModel(com.kendy.entity.TGCompanyModel) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) HashSet(java.util.HashSet)

Aggregations

TableView (javafx.scene.control.TableView)70 TableColumn (javafx.scene.control.TableColumn)60 Map (java.util.Map)40 List (java.util.List)39 ArrayList (java.util.ArrayList)38 Button (javafx.scene.control.Button)38 Label (javafx.scene.control.Label)38 FXCollections (javafx.collections.FXCollections)37 Insets (javafx.geometry.Insets)36 Collectors (java.util.stream.Collectors)33 Scene (javafx.scene.Scene)33 Tab (javafx.scene.control.Tab)33 BorderPane (javafx.scene.layout.BorderPane)32 Optional (java.util.Optional)31 ObservableValue (javafx.beans.value.ObservableValue)30 VBox (javafx.scene.layout.VBox)29 Collections (java.util.Collections)28 MenuItem (javafx.scene.control.MenuItem)28 HashMap (java.util.HashMap)27 Set (java.util.Set)27