use of javafx.collections.ListChangeListener in project Gargoyle by callakrsos.
the class SqlMultiplePane method addNewTabResult.
/********************************
* 작성일 : 2016. 4. 20. 작성자 : KYJ
*
*
* @return
********************************/
private Tab addNewTabResult() {
TableView<Map<String, Object>> tbResult = new TableView<>();
// Cell 단위로 선택
tbResult.getSelectionModel().setCellSelectionEnabled(true);
tbResult.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
tbResult.getItems().addListener((ListChangeListener<Map<String, Object>>) arg0 -> {
int size = arg0.getList().size();
lblStatus.textProperty().set(size + " row");
});
tbResult.setOnKeyPressed(this::tbResultOnKeyClick);
{
tcSelectRow = new TableColumn<>("↓");
tcSelectRow.setMaxWidth(20);
tcSelectRow.setSortable(false);
tcSelectRow.setCellFactory(cell -> {
return new DragSelectionCell(tbResult);
});
// Table Select Drag 처리
endRowIndexProperty.addListener(event -> tableSelectCell());
endColIndexProperty.addListener(event -> tableSelectCell());
}
BorderPane tbResultLayout = new BorderPane(tbResult);
lblStatus = new Label("Ready...");
lblStatus.setMaxHeight(50d);
tbResultLayout.setBottom(lblStatus);
createResultTableContextMenu(tbResult);
Tab tab = new Tab("Example", tbResultLayout);
return tab;
}
use of javafx.collections.ListChangeListener in project Gargoyle by callakrsos.
the class ProjectInfoBaseInfoTab method supplyNode.
@Override
public BorderPane supplyNode() throws Exception {
BorderPane root = new BorderPane();
try {
/* BaseInfo */
baseInfoController = new BaseInfoComposite(this);
// FXMLLoader loader = new FXMLLoader();
// loader.setLocation(BaseInfoComposite.class.getResource("BaseInfoApp.fxml"));
// BorderPane supplyNode = loader.load();
// supplyNode.setPrefWidth(BorderPane.USE_COMPUTED_SIZE);
// BaseInfoComposite baseInfoController = loader.getController();
/* 버튼박스 */
HBox hboxButton = new HBox(5);
hboxButton.setPrefHeight(HBox.USE_COMPUTED_SIZE);
HBox.setHgrow(hboxButton, Priority.NEVER);
btnGenerate = new Button("사양서 생성");
btnGenerate.setOnMouseClicked(this::btnGenerateOnMouseClick);
btnGenerate.setPrefWidth(120);
hboxButton.getChildren().add(btnGenerate);
/* TableInfo */
gv = new CrudBaseGridView<MethodDVO>(MethodDVO.class, new AnnotateBizOptions<MethodDVO>(MethodDVO.class) {
@Override
public boolean isCreateColumn(String columnName) {
if ("methodMetaDVO".equals(columnName))
return false;
// return false;
return super.isCreateColumn(columnName);
}
@Override
public boolean visible(String columnName) {
if ("methodMetaDVO".equals(columnName))
return false;
return super.visible(columnName);
}
});
//이벤트 리스너로 그리드에 추가되는 항목이 존재하면 추가.
ObservableList<MethodDVO> methodData = baseInfoController.getMethodData();
methodData.addListener(new ListChangeListener<MethodDVO>() {
@Override
public void onChanged(javafx.collections.ListChangeListener.Change<? extends MethodDVO> c) {
if (c.next()) {
if (c.wasAdded()) {
gv.getItems().addAll(c.getAddedSubList());
} else if (c.wasRemoved()) {
gv.getItems().removeAll(c.getRemoved());
}
}
}
});
// ObservableList<MethodDVO> items = gv.getItems();
// gv.getItems().addAll(methodData);
baseInfoController.setBottom(hboxButton);
root.setTop(baseInfoController);
root.setCenter(gv);
baseInfoController.start();
} catch (IOException | NullPointerException e) {
LOGGER.error(ValueUtil.toString(e));
}
root.setPrefSize(BorderPane.USE_COMPUTED_SIZE, BorderPane.USE_COMPUTED_SIZE);
root.setPadding(new Insets(5, 5, 5, 5));
return root;
}
use of javafx.collections.ListChangeListener in project bitsquare by bitsquare.
the class NotificationCenter method onAllServicesAndViewsInitialized.
public void onAllServicesAndViewsInitialized() {
tradeManager.getTrades().addListener((ListChangeListener<Trade>) change -> {
change.next();
if (change.wasRemoved()) {
change.getRemoved().stream().forEach(trade -> {
String tradeId = trade.getId();
if (disputeStateSubscriptionsMap.containsKey(tradeId)) {
disputeStateSubscriptionsMap.get(tradeId).unsubscribe();
disputeStateSubscriptionsMap.remove(tradeId);
}
if (tradeStateSubscriptionsMap.containsKey(tradeId)) {
tradeStateSubscriptionsMap.get(tradeId).unsubscribe();
tradeStateSubscriptionsMap.remove(tradeId);
}
});
}
if (change.wasAdded()) {
change.getAddedSubList().stream().forEach(trade -> {
String tradeId = trade.getId();
if (disputeStateSubscriptionsMap.containsKey(tradeId)) {
log.debug("We have already an entry in disputeStateSubscriptionsMap.");
} else {
Subscription disputeStateSubscription = EasyBind.subscribe(trade.disputeStateProperty(), disputeState -> onDisputeStateChanged(trade, disputeState));
disputeStateSubscriptionsMap.put(tradeId, disputeStateSubscription);
}
if (tradeStateSubscriptionsMap.containsKey(tradeId)) {
log.debug("We have already an entry in tradeStateSubscriptionsMap.");
} else {
Subscription tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), tradeState -> onTradeStateChanged(trade, tradeState));
tradeStateSubscriptionsMap.put(tradeId, tradeStateSubscription);
}
});
}
});
tradeManager.getTrades().stream().forEach(trade -> {
String tradeId = trade.getId();
Subscription disputeStateSubscription = EasyBind.subscribe(trade.disputeStateProperty(), disputeState -> onDisputeStateChanged(trade, disputeState));
disputeStateSubscriptionsMap.put(tradeId, disputeStateSubscription);
Subscription tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), tradeState -> onTradeStateChanged(trade, tradeState));
tradeStateSubscriptionsMap.put(tradeId, tradeStateSubscription);
});
}
use of javafx.collections.ListChangeListener in project bisq-api by mrosseel.
the class MainViewModelHeadless method onBasicServicesInitialized.
private void onBasicServicesInitialized() {
log.info("onBasicServicesInitialized");
clock.start();
PaymentMethod.onAllServicesInitialized();
// disputeManager
disputeManager.onAllServicesInitialized();
disputeManager.getDisputesAsObservableList().addListener((ListChangeListener<Dispute>) change -> {
change.next();
onDisputesChangeListener(change.getAddedSubList(), change.getRemoved());
});
onDisputesChangeListener(disputeManager.getDisputesAsObservableList(), null);
// tradeManager
tradeManager.onAllServicesInitialized();
tradeManager.getTradableList().addListener((ListChangeListener<Trade>) c -> updateBalance());
tradeManager.getTradableList().addListener((ListChangeListener<Trade>) change -> onTradesChanged());
onTradesChanged();
// We handle the trade period here as we display a global popup if we reached dispute time
tradesAndUIReady = EasyBind.combine(isSplashScreenRemoved, tradeManager.pendingTradesInitializedProperty(), (a, b) -> a && b);
tradesAndUIReady.subscribe((observable, oldValue, newValue) -> {
if (newValue)
applyTradePeriodState();
});
// tradeManager.setTakeOfferRequestErrorMessageHandler(errorMessage -> new Popup<>()
// .warning(Res.get("popup.error.takeOfferRequestFailed", errorMessage))
// .show());
// walletService
btcWalletService.addBalanceListener(new BalanceListener() {
@Override
public void onBalanceChanged(Coin balance, Transaction tx) {
updateBalance();
}
});
openOfferManager.getObservableList().addListener((ListChangeListener<OpenOffer>) c -> updateBalance());
tradeManager.getTradableList().addListener((ListChangeListener<Trade>) c -> updateBalance());
openOfferManager.onAllServicesInitialized();
removeOffersWithoutAccountAgeWitness();
arbitratorManager.onAllServicesInitialized();
alertManager.alertMessageProperty().addListener((observable, oldValue, newValue) -> displayAlertIfPresent(newValue, false));
privateNotificationManager.privateNotificationProperty().addListener((observable, oldValue, newValue) -> displayPrivateNotification(newValue));
displayAlertIfPresent(alertManager.alertMessageProperty().get(), false);
p2PService.onAllServicesInitialized();
feeService.onAllServicesInitialized();
GUIUtil.setFeeService(feeService);
// daoManager.onAllServicesInitialized(errorMessage -> new Popup<>().error(errorMessage).show());
tradeStatisticsManager.onAllServicesInitialized();
accountAgeWitnessService.onAllServicesInitialized();
priceFeedService.setCurrencyCodeOnInit();
filterManager.onAllServicesInitialized();
// filterManager.addListener(filter -> {
// if (filter != null) {
// if (filter.getSeedNodes() != null && !filter.getSeedNodes().isEmpty())
// new Popup<>().warning(Res.get("popup.warning.nodeBanned", Res.get("popup.warning.seed"))).show();
//
// if (filter.getPriceRelayNodes() != null && !filter.getPriceRelayNodes().isEmpty())
// new Popup<>().warning(Res.get("popup.warning.nodeBanned", Res.get("popup.warning.priceRelay"))).show();
// }
// });
setupBtcNumPeersWatcher();
setupP2PNumPeersWatcher();
updateBalance();
if (DevEnv.DEV_MODE) {
preferences.setShowOwnOffersInOfferBook(true);
setupDevDummyPaymentAccounts();
}
fillPriceFeedComboBoxItems();
setupMarketPriceFeed();
swapPendingOfferFundingEntries();
showAppScreen.set(true);
// String key = "remindPasswordAndBackup";
// user.getPaymentAccountsAsObservable().addListener((SetChangeListener<PaymentAccount>) change -> {
// if (!walletsManager.areWalletsEncrypted() && preferences.showAgain(key) && change.wasAdded()) {
// new Popup<>().headLine(Res.get("popup.securityRecommendation.headline"))
// .information(Res.get("popup.securityRecommendation.msg"))
// .dontShowAgainId(key)
// .show();
// }
// });
checkIfOpenOffersMatchTradeProtocolVersion();
if (walletsSetup.downloadPercentageProperty().get() == 1)
checkForLockedUpFunds();
allBasicServicesInitialized = true;
}
use of javafx.collections.ListChangeListener in project Challenger4SysAdmins by fvarrui.
the class TreeItemFactory method createChallengeTreeItem.
/**
* @param challenge un chellenge
* @return un item
*/
public static TreeItem<Object> createChallengeTreeItem(Challenge challenge) {
TreeItem<Object> challengeItem = new TreeItem<Object>();
challengeItem.setExpanded(true);
challengeItem.setValue(challenge);
for (Goal goal : challenge.getGoals()) {
challengeItem.getChildren().add(createGoalTreeItem(goal));
}
challenge.goalsProperty().addListener(new ListChangeListener<Goal>() {
public void onChanged(Change<? extends Goal> c) {
while (c.next()) {
c.getAddedSubList().stream().forEach(g -> challengeItem.getChildren().add(createGoalTreeItem(g)));
c.getRemoved().stream().forEach(g -> {
TreeItem<Object> item = challengeItem.getChildren().stream().filter(i -> i.getValue().equals(g)).findFirst().get();
challengeItem.getChildren().remove(item);
});
}
}
});
return challengeItem;
}
Aggregations