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);
}
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;
}
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;
}
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();
}
}
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);
}
Aggregations