Java Code Examples for javafx.collections.ObservableList#isEmpty()

The following examples show how to use javafx.collections.ObservableList#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UiUtils.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Find a tree item by object id.
 *
 * @param <T>      the type parameter
 * @param root     the root item.
 * @param objectId the object id.
 * @return the tree item or null.
 */
@FxThread
public static @Nullable <T> TreeItem<T> findItem(@NotNull final TreeItem<T> root, final long objectId) {

    final T value = root.getValue();

    if (value instanceof UObject && ((UObject) value).getObjectId() == objectId) {
        return root;
    }

    final ObservableList<TreeItem<T>> children = root.getChildren();

    if (!children.isEmpty()) {
        for (final TreeItem<T> treeItem : children) {
            final TreeItem<T> result = findItem(treeItem, objectId);
            if (result != null) return result;
        }
    }

    return null;
}
 
Example 2
Source File: UiUtils.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Visit all items.
 *
 * @param <T>     the type parameter.
 * @param item    the tree item.
 * @param visitor the visitor.
 * @return true of we can visit child elements.
 */
@FxThread
public static <T> boolean visitUntil(@NotNull final TreeItem<T> item,
                                     @NotNull final Predicate<TreeItem<T>> visitor) {

    if (!visitor.test(item)) return false;

    final ObservableList<TreeItem<T>> children = item.getChildren();
    if (children.isEmpty()) return true;

    for (final TreeItem<T> child : children) {
        if (!visitUntil(child, visitor)) return false;
    }

    return true;
}
 
Example 3
Source File: MainController.java    From logbook-kai with MIT License 6 votes vote down vote up
/**
 * 泊地修理タイマー
 */
private void akashiTimer() {
    ObservableList<Node> nodes = this.akashiTimer.getChildren();

    if (AppCondition.get().getAkashiTimer() == 0) {
        if (!nodes.isEmpty()) {
            nodes.clear();
        }
    } else {
        if (nodes.isEmpty()) {
            nodes.add(new AkashiTimerPane());
        } else {
            ((AkashiTimerPane) nodes.get(0)).update();
        }
    }
}
 
Example 4
Source File: FocusTraversalPolicy.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns the inner most {@link IContentPart} child within the part
 * hierarchy of the given {@link IContentPart}. If the given
 * {@link IContentPart} does not have any {@link IContentPart} children,
 * then the given {@link IContentPart} is returned.
 *
 * @param part
 *            The {@link IContentPart} for which to determine the inner most
 *            {@link IContentPart} child.
 * @return The inner most {@link IContentPart} child within the part
 *         hierarchy of the given {@link IContentPart}.
 */
protected IContentPart<? extends Node> findInnerMostContentPart(
		IContentPart<? extends Node> part) {
	ObservableList<IVisualPart<? extends Node>> children = part
			.getChildrenUnmodifiable();
	while (!children.isEmpty()) {
		for (int i = children.size() - 1; i >= 0; i--) {
			IVisualPart<? extends Node> child = children.get(i);
			if (child instanceof IContentPart) {
				// continue searching for content part children within this
				// child's part hierarchy
				part = (IContentPart<? extends Node>) child;
				children = part.getChildrenUnmodifiable();
				break;
			}
		}
	}
	// did not find a content part child => return the given content part
	return part;
}
 
Example 5
Source File: ServiceImplConfig.java    From Vert.X-generator with MIT License 5 votes vote down vote up
/**
 * 通过 ObservableList<TableAttributeKeyValue>初始化
 * 
 * @param tableItem
 */
public ServiceImplConfig(ObservableList<TableAttributeKeyValue> item) {
	super();
	if (item != null && !item.isEmpty()) {
		tableItem.addAll(item);
	}
}
 
Example 6
Source File: AbstractFxmlView.java    From spring-labs with Apache License 2.0 5 votes vote down vote up
/**
 * Scene Builder creates for each FXML document a root container. This method omits the root container (e.g.
 * {@link AnchorPane}) and gives you the access to its first child.
 *
 * @return the first child of the {@link AnchorPane}
 */
public Node getViewWithoutRootContainer() {

	ObservableList<Node> children = getView().getChildrenUnmodifiable();
	if (children.isEmpty()) {
		return null;
	}

	return children.listIterator().next();
}
 
Example 7
Source File: RouterConfig.java    From Vert.X-generator with MIT License 5 votes vote down vote up
/**
 * 通过 ObservableList<TableAttributeKeyValue>初始化
 * 
 * @param tableItem
 */
public RouterConfig(ObservableList<TableAttributeKeyValue> item, String templateName, boolean overrideFile) {
	super();
	if (item != null && !item.isEmpty()) {
		tableItem.addAll(item);
	}
	this.templateName = templateName;
	this.overrideFile = overrideFile;
}
 
Example 8
Source File: JFXColorPalette.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void buildCustomColors() {
    final ObservableList<Color> customColors = colorPicker.getCustomColors();
    customColorGrid.getChildren().clear();
    if (customColors.isEmpty()) {
        customColorLabel.setVisible(false);
        customColorLabel.setManaged(false);
        customColorGrid.setVisible(false);
        customColorGrid.setManaged(false);
        return;
    } else {
        customColorLabel.setVisible(true);
        customColorLabel.setManaged(true);
        customColorGrid.setVisible(true);
        customColorGrid.setManaged(true);
    }

    int customColumnIndex = 0;
    int customRowIndex = 0;
    int remainingSquares = customColors.size() % NUM_OF_COLUMNS;
    int numEmpty = (remainingSquares == 0) ? 0 : NUM_OF_COLUMNS - remainingSquares;

    for (int i = 0; i < customColors.size(); i++) {
        Color c = customColors.get(i);
        ColorSquare square = new ColorSquare(c, i, true);
        customColorGrid.add(square, customColumnIndex, customRowIndex);
        customColumnIndex++;
        if (customColumnIndex == NUM_OF_COLUMNS) {
            customColumnIndex = 0;
            customRowIndex++;
        }
    }
    for (int i = 0; i < numEmpty; i++) {
        ColorSquare emptySquare = new ColorSquare();
        customColorGrid.add(emptySquare, customColumnIndex, customRowIndex);
        customColumnIndex++;
    }
    requestLayout();
}
 
Example 9
Source File: MainAction.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void deleteRedisKeyAction() {
    ObservableList list = mc.redisValueTable.getSelectionModel().getSelectedItems();
    if (list.isEmpty()) {
        Toast.makeText("请选择要删除的记录").show(mc.pane.getScene().getWindow());
        return;
    }
    StringBuilder key = new StringBuilder();
    int i = 0;
    for (Object object : list) {
        Map mp = (Map) object;
        key.append(mp.get("key"));
        if (i != list.size() - 1) {
            key.append(",");
        }
        i++;
    }
    Alert a = new Alert(Alert.AlertType.CONFIRMATION);
    a.setTitle("确认删除");
    a.setContentText("确认要删除[" + key + "]这些键值吗?");
    a.initOwner(mc.pane.getScene().getWindow());
    Optional<ButtonType> o = a.showAndWait();
    if (o.get().getButtonData().equals(ButtonBar.ButtonData.OK_DONE)) {
        String[] keys = key.toString().split(",");
        String name = (String) mc.redisDatabaseList.getSelectionModel().getSelectedItem();
        RedisUtil.deleteKeys(name, keys);
        Toast.makeText("删除成功", Duration.seconds(1)).show(mc.pane.getScene().getWindow());
        mc.paginationForValue.getPageFactory().call(0);
    }
}
 
Example 10
Source File: AttachmentsViewController.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public void setFiles(ObservableList<File> files){
    filesTab.setFiles(files);
    if(autoExpand && !files.isEmpty()) {
        Platform.runLater(() ->
        {
            titledPane.setExpanded(true);
        });
    }
}
 
Example 11
Source File: ServiceConfig.java    From Vert.X-generator with MIT License 5 votes vote down vote up
/**
 * 通过 ObservableList<TableAttributeKeyValue>初始化
 * 
 * @param tableItem
 */
public ServiceConfig(ObservableList<TableAttributeKeyValue> item, String templateName, boolean overrideFile) {
	super();
	if (item != null && !item.isEmpty()) {
		tableItem.addAll(item);
	}
	this.templateName = templateName;
	this.overrideFile = overrideFile;
}
 
Example 12
Source File: SmoothedChart.java    From OEE-Designer with MIT License 5 votes vote down vote up
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) {
    if (fillElements.isEmpty()) return;
    // as we do not have direct access to the data, first recreate the list of all the data points we have
    final Point[] dataPoints = new Point[strokeElements.size()];
    for (int i = 0; i < strokeElements.size(); i++) {
        final PathElement element = strokeElements.get(i);
        if (element instanceof MoveTo) {
            final MoveTo move = (MoveTo) element;
            dataPoints[i] = new Point(move.getX(), move.getY());
        } else if (element instanceof LineTo) {
            final LineTo line = (LineTo) element;
            final double x = line.getX(), y = line.getY();
            dataPoints[i] = new Point(x, y);
        }
    }
    double firstX = dataPoints[0].getX();
    double lastX  = dataPoints[dataPoints.length - 1].getX();

    Point[] points = Helper.subdividePoints(dataPoints, getSubDivisions());

    fillElements.clear();
    fillElements.add(new MoveTo(firstX, HEIGHT));

    strokeElements.clear();
    strokeElements.add(new MoveTo(points[0].getX(), points[0].getY()));

    for (Point p : points) {
        if (Double.compare(p.getX(), firstX) >= 0) {
            fillElements.add(new LineTo(p.getX(), p.getY()));
            strokeElements.add(new LineTo(p.getX(), p.getY()));
        }
    }

    fillElements.add(new LineTo(lastX, HEIGHT));
    fillElements.add(new LineTo(0, HEIGHT));
    fillElements.add(new ClosePath());
}
 
Example 13
Source File: SqlAssistConfig.java    From Vert.X-generator with MIT License 5 votes vote down vote up
/**
 * 通过 ObservableList<TableAttributeKeyValue>初始化
 * 
 * @param tableItem
 */
public SqlAssistConfig(ObservableList<TableAttributeKeyValue> item, String templateName, boolean overrideFile) {
	super();
	if (item != null && !item.isEmpty()) {
		tableItem.addAll(item);
	}
	this.templateName = templateName;
	this.overrideFile = overrideFile;
}
 
Example 14
Source File: MapperConfig.java    From Spring-generator with MIT License 5 votes vote down vote up
/**
 * 通过 ObservableList<TableAttributeKeyValue>初始化
 * 
 * @param tableItem
 */
public MapperConfig(ObservableList<TableAttributeKeyValue> item, String templateName, boolean overrideFile) {
	super();
	if (item != null && !item.isEmpty()) {
		tableItem.addAll(item);
	}
	this.templateName = templateName;
	this.overrideFile = overrideFile;
}
 
Example 15
Source File: SqlAssistConfig.java    From Spring-generator with MIT License 5 votes vote down vote up
/**
 * 通过 ObservableList<TableAttributeKeyValue>初始化
 * 
 * @param tableItem
 */
public SqlAssistConfig(ObservableList<TableAttributeKeyValue> item) {
	super();
	if (item != null && !item.isEmpty()) {
		tableItem.addAll(item);
	}
}
 
Example 16
Source File: SqlAssistConfig.java    From Spring-generator with MIT License 5 votes vote down vote up
/**
 * 通过 ObservableList<TableAttributeKeyValue>初始化
 * 
 * @param tableItem
 */
public SqlAssistConfig(ObservableList<TableAttributeKeyValue> item, String templateName, boolean overrideFile) {
	super();
	if (item != null && !item.isEmpty()) {
		tableItem.addAll(item);
	}
	this.templateName = templateName;
	this.overrideFile = overrideFile;
}
 
Example 17
Source File: ServiceImplConfig.java    From Spring-generator with MIT License 5 votes vote down vote up
/**
 * 通过 ObservableList<TableAttributeKeyValue>初始化
 * 
 * @param tableItem
 */
public ServiceImplConfig(ObservableList<TableAttributeKeyValue> item, String templateName, boolean overrideFile) {
	super();
	if (item != null && !item.isEmpty()) {
		tableItem.addAll(item);
	}
	this.templateName = templateName;
	this.overrideFile = overrideFile;
}
 
Example 18
Source File: UnitTestConfig.java    From Vert.X-generator with MIT License 5 votes vote down vote up
/**
 * 通过 ObservableList<TableAttributeKeyValue>初始化
 * 
 * @param tableItem
 */
public UnitTestConfig(ObservableList<TableAttributeKeyValue> item) {
	super();
	if (item != null && !item.isEmpty()) {
		tableItem.addAll(item);
	}
}
 
Example 19
Source File: DisputeManager.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
protected void onPeerOpenedDisputeMessage(PeerOpenedDisputeMessage peerOpenedDisputeMessage) {
    T disputeList = getDisputeList();
    if (disputeList == null) {
        log.warn("disputes is null");
        return;
    }

    String errorMessage = null;
    Dispute dispute = peerOpenedDisputeMessage.getDispute();
    if (!isAgent(dispute)) {
        if (!disputeList.contains(dispute)) {
            Optional<Dispute> storedDisputeOptional = findDispute(dispute);
            if (!storedDisputeOptional.isPresent()) {
                dispute.setStorage(disputeListService.getStorage());
                disputeList.add(dispute);
                Optional<Trade> tradeOptional = tradeManager.getTradeById(dispute.getTradeId());
                tradeOptional.ifPresent(trade -> trade.setDisputeState(getDisputeState_StartedByPeer()));
                errorMessage = null;
            } else {
                // valid case if both have opened a dispute and agent was not online.
                log.debug("We got a dispute already open for that trade and trading peer. TradeId = {}",
                        dispute.getTradeId());
            }
        } else {
            errorMessage = "We got a dispute msg what we have already stored. TradeId = " + dispute.getTradeId();
            log.warn(errorMessage);
        }
    } else {
        errorMessage = "Arbitrator received peerOpenedDisputeMessage. That must never happen.";
        log.error(errorMessage);
    }

    // We use the ChatMessage not the peerOpenedDisputeMessage for the ACK
    ObservableList<ChatMessage> messages = peerOpenedDisputeMessage.getDispute().getChatMessages();
    if (!messages.isEmpty()) {
        ChatMessage msg = messages.get(0);
        sendAckMessage(msg, dispute.getAgentPubKeyRing(), errorMessage == null, errorMessage);
    }

    sendAckMessage(peerOpenedDisputeMessage, dispute.getAgentPubKeyRing(), errorMessage == null, errorMessage);
}
 
Example 20
Source File: DisputeManager.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
protected void onOpenNewDisputeMessage(OpenNewDisputeMessage openNewDisputeMessage) {
    T disputeList = getDisputeList();
    if (disputeList == null) {
        log.warn("disputes is null");
        return;
    }

    String errorMessage = null;
    Dispute dispute = openNewDisputeMessage.getDispute();

    // Disputes from clients < 1.2.0 always have support type ARBITRATION in dispute as the field didn't exist before
    dispute.setSupportType(openNewDisputeMessage.getSupportType());

    dispute.setStorage(disputeListService.getStorage());
    Contract contractFromOpener = dispute.getContract();
    PubKeyRing peersPubKeyRing = dispute.isDisputeOpenerIsBuyer() ? contractFromOpener.getSellerPubKeyRing() : contractFromOpener.getBuyerPubKeyRing();
    if (isAgent(dispute)) {
        if (!disputeList.contains(dispute)) {
            Optional<Dispute> storedDisputeOptional = findDispute(dispute);
            if (!storedDisputeOptional.isPresent()) {
                disputeList.add(dispute);
                errorMessage = sendPeerOpenedDisputeMessage(dispute, contractFromOpener, peersPubKeyRing);
            } else {
                // valid case if both have opened a dispute and agent was not online.
                log.debug("We got a dispute already open for that trade and trading peer. TradeId = {}",
                        dispute.getTradeId());
            }
        } else {
            errorMessage = "We got a dispute msg what we have already stored. TradeId = " + dispute.getTradeId();
            log.warn(errorMessage);
        }
    } else {
        errorMessage = "Trader received openNewDisputeMessage. That must never happen.";
        log.error(errorMessage);
    }

    // We use the ChatMessage not the openNewDisputeMessage for the ACK
    ObservableList<ChatMessage> messages = dispute.getChatMessages();
    if (!messages.isEmpty()) {
        ChatMessage chatMessage = messages.get(0);
        PubKeyRing sendersPubKeyRing = dispute.isDisputeOpenerIsBuyer() ? contractFromOpener.getBuyerPubKeyRing() : contractFromOpener.getSellerPubKeyRing();
        sendAckMessage(chatMessage, sendersPubKeyRing, errorMessage == null, errorMessage);
    }

    // In case of refundAgent we add a message with the mediatorsDisputeSummary. Only visible for refundAgent.
    if (dispute.getMediatorsDisputeResult() != null) {
        String mediatorsDisputeResult = Res.get("support.mediatorsDisputeSummary", dispute.getMediatorsDisputeResult());
        ChatMessage mediatorsDisputeResultMessage = new ChatMessage(
                getSupportType(),
                dispute.getTradeId(),
                pubKeyRing.hashCode(),
                false,
                mediatorsDisputeResult,
                p2PService.getAddress());
        mediatorsDisputeResultMessage.setSystemMessage(true);
        dispute.addAndPersistChatMessage(mediatorsDisputeResultMessage);
    }
}