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

The following examples show how to use javafx.collections.ObservableList#contains() . 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: TimelinePanel.java    From constellation with Apache License 2.0 7 votes vote down vote up
public void setNodeLabelAttributes(final ArrayList<String> attrList) {
    if (attrList != null) {
        ObservableList<String> attrLabels = FXCollections.observableArrayList(attrList);

        if (!cmbAttributeNames.getItems().equals(attrLabels)) {
            final String current = cmbAttributeNames.getSelectionModel().getSelectedItem();

            cmbAttributeNames.setItems(attrLabels);

            if (attrLabels.contains(current)) {
                cmbAttributeNames.getSelectionModel().select(current);
            } else {
                cmbAttributeNames.getSelectionModel().clearSelection();
                cmbAttributeNames.setPromptText(Bundle.SelectLabelAttribute());
            }
        }
    } else {
        toolbar.getItems().remove(cmbAttributeNames);
        cmbAttributeNames = createComboNodeLabels();
        toolbar.getItems().add(cmbAttributeNames);

        //cmbAttributeNames.getItems().clear();
        cmbAttributeNames.setPromptText(Bundle.SelectLabelAttribute());
    }
}
 
Example 2
Source File: ConversationController.java    From BetonQuest-Editor with GNU General Public License v3.0 7 votes vote down vote up
/**
 * Sets the list of conversation which can be displayed in this tab.
 * 
 * @param conversations list of conversations
 */
public static void setConversations(ObservableList<Conversation> conversations) {
	instance.conversation.setItems(conversations);
	if (instance.currentConversation != null && conversations.contains(instance.currentConversation)) {
		instance.displayConversation(instance.currentConversation);
	} else {
		instance.displayConversation();
	}
	instance.npc.textProperty().addListener((observable, oldValue, newValue) -> {
	    if (newValue == null || newValue.isEmpty()) {
	    	instance.npc.setStyle("-fx-background-color: red");
	    } else {
	    	instance.npc.setStyle(null);
	    }
	});
}
 
Example 3
Source File: CreateTerrainDialog.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Update a list of available path sizes.
 */
@FxThread
private void updatePathSizeValues() {

    final ComboBox<Integer> pathSizeComboBox = getPatchSizeComboBox();
    final SingleSelectionModel<Integer> selectionModel = pathSizeComboBox.getSelectionModel();
    final Integer current = selectionModel.getSelectedItem();

    final ObservableList<Integer> items = pathSizeComboBox.getItems();
    items.clear();

    final ComboBox<Integer> totalSizeComboBox = getTotalSizeComboBox();
    final Integer naxValue = totalSizeComboBox.getSelectionModel().getSelectedItem();

    for (final Integer value : PATCH_SIZE_VARIANTS) {
        if (value >= naxValue) break;
        items.add(value);
    }

    if (items.contains(current)) {
        selectionModel.select(current);
    } else {
        selectionModel.select(items.get(items.size() - 1));
    }
}
 
Example 4
Source File: AddNewDrugController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
public void loadGenericNames()
{
    ArrayList<ArrayList<String>> generic = pharmacist.getGenericNames();
    ObservableList<String> generic2 = FXCollections.observableArrayList();
    int size = generic.size();
    for(int i = 1; i < size; i++)
    {
        String tmp  = generic.get(i).get(0);
        if (!generic2.contains(tmp))
        {
            generic2.add(tmp);
        }    
    }    
    generic2.add("");
    genericName.getItems().clear();
    genericName.getItems().addAll(generic2);
}
 
Example 5
Source File: AddNewDrugController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML private void showBrandNames()
{
    brandName.setDisable(false);
    
    String brands = (String)genericName.getSelectionModel().getSelectedItem();
    ArrayList<ArrayList<String>> drugBrands = pharmacist.getBrandNames(brands);
    ObservableList<String> drugBrands2 = FXCollections.observableArrayList();
    int size = drugBrands.size();
    for(int i = 1; i < size; i++)
    {
        String tmp  = drugBrands.get(i).get(0);
        if (!drugBrands2.contains(tmp))
        {
            drugBrands2.add(tmp);
        }    
    }    
    drugBrands2.add("");
    brandName.getItems().clear();
    brandName.getItems().addAll(drugBrands2);
}
 
Example 6
Source File: BendOnSegmentDragHandler.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns <code>true</code> if the given {@link MouseEvent} should trigger
 * bending. Otherwise returns <code>false</code>. Per default returns
 * <code>true</code> if a single mouse click is performed.
 *
 * @param event
 *            The {@link MouseEvent} in question.
 * @return <code>true</code> if the given {@link MouseEvent} should trigger
 *         focus and select, otherwise <code>false</code>.
 */
protected boolean isBend(MouseEvent event) {
	boolean isInvalid = false;
	if (!(getHost().getVisual().getRouter() instanceof OrthogonalRouter)) {
		// abort if non-orthogonal
		isInvalid = true;
	} else {
		IVisualPart<? extends Node> host = getHost();
		ObservableList<IContentPart<? extends Node>> selection = host
				.getRoot().getViewer().getAdapter(SelectionModel.class)
				.getSelectionUnmodifiable();
		if (selection.size() > 1 && selection.contains(host)) {
			// abort if part of multiple selection
			isInvalid = true;
		} else if (!getHost().getVisual().isStartConnected()
				&& !getHost().getVisual().isEndConnected()) {
			// abort if unconnected
			isInvalid = true;
		}
	}
	return !isInvalid;
}
 
Example 7
Source File: FX.java    From FxDock with Apache License 2.0 6 votes vote down vote up
/** adds or removes the specified style */
public static void setStyle(Node n, CssStyle st, boolean on)
{
	if(n == null)
	{
		return;
	}
	else if(st == null)
	{
		return;
	}
	
	String name = st.getName();
	ObservableList<String> ss = n.getStyleClass();
	if(on)
	{
		if(!ss.contains(name))
		{
			ss.add(st.getName());
		}
	}
	else
	{
		ss.remove(name);
	}
}
 
Example 8
Source File: ApplicationController.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
@FXML
public void addToFavoriteDir(ActionEvent actionEvent) {
    Path selectedTabPath = tabService.getSelectedTabPath();
    if (Files.isDirectory(selectedTabPath)) {
        ObservableList<String> favoriteDirectories = storedConfigBean.getFavoriteDirectories();
        boolean has = favoriteDirectories.contains(selectedTabPath.toString());
        if (!has) {
            favoriteDirectories.add(selectedTabPath.toString());
        }
    }
}
 
Example 9
Source File: FxUtils.java    From LogFX with GNU General Public License v3.0 5 votes vote down vote up
public static void addIfNotPresent( ObservableList<String> styleClasses,
                                    String... cssClasses ) {
    for ( String cssClass : cssClasses ) {
        if ( !styleClasses.contains( cssClass ) ) {
            styleClasses.add( cssClass );
        }
    }
}
 
Example 10
Source File: FileEditorTabPane.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setPreviewEditor(FileEditor fileEditor, boolean preview) {
	ObservableList<String> styleClasses = fileEditor.getTab().getStyleClass();
	if (preview) {
		if (!styleClasses.contains("preview"))
			styleClasses.add("preview");
	} else
		styleClasses.remove("preview");
}
 
Example 11
Source File: Machine.java    From CPUSim with GNU General Public License v3.0 5 votes vote down vote up
public boolean contains(Microinstruction micro) {
    for (String microClass : MICRO_CLASSES) {
        ObservableList v = microMap.get(microClass);
        if (v.contains(micro)) {
            return true;
        }
    }
    return false;
}
 
Example 12
Source File: Machine.java    From CPUSim with GNU General Public License v3.0 5 votes vote down vote up
public void setMicros(String microClass, ObservableList<Microinstruction> newMicros) {
    //first delete all references in machine instructions
    // to any old micros not in the new list
    ObservableList<Microinstruction> oldMicros = microMap.get(microClass);
    for (Microinstruction oldMicro : oldMicros) {
        if (!newMicros.contains(oldMicro)) {
            removeAllOccurencesOf(oldMicro);
        }
    }
    microMap.put(microClass, newMicros);
}
 
Example 13
Source File: AddNewDrugController.java    From HealthPlus with Apache License 2.0 5 votes vote down vote up
@FXML private void stockDetails()
{
    String tmp = drugPrice.getText();
    try{
        if (Integer.parseInt(tmp) > 0)
        {
            stock.setDisable(false);
            manuDate.setDisable(false);
            expDate.setDisable(false);
            supplier.setDisable(false);
            drugUnit2.setDisable(false);
            
            ArrayList<ArrayList<String>> suppliers = pharmacist.getSupplierNames2();
            System.out.println(suppliers);
            ObservableList<String> suppliers2 = FXCollections.observableArrayList();
            int size = suppliers.size();
            for(int i = 1; i < size; i++)
            {
                String tmp2  = suppliers.get(i).get(0);
                if (!suppliers2.contains(tmp2))
                {
                    suppliers2.add(tmp2);
                }    
            } 
            suppliers2.add("");
            supplier.getItems().clear();
            supplier.getItems().addAll(suppliers2);
        }
    }catch(Exception e){
    
        stock.setDisable(true);
        manuDate.setDisable(true);
        expDate.setDisable(true);
        supplier.setDisable(true);
        drugUnit.setDisable(true);
    }    
}
 
Example 14
Source File: TextureLayerSettings.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Refresh the layers list.
 */
@FxThread
public void refresh() {

    final ListView<TextureLayer> listView = getListView();
    final MultipleSelectionModel<TextureLayer> selectionModel = listView.getSelectionModel();
    final TextureLayer selectedItem = selectionModel.getSelectedItem();

    final ObservableList<TextureLayer> items = listView.getItems();
    items.clear();

    final int maxLevels = getMaxLevels() - 1;

    for (int i = 0; i < maxLevels; i++) {

        final float scale = getTextureScale(i);
        if (scale == -1F) {
            continue;
        }

        items.add(new TextureLayer(this, i));
    }

    if (items.contains(selectedItem)) {
        selectionModel.select(selectedItem);
    } else if (!items.isEmpty()) {
        selectionModel.select(items.get(0));
    }

    final ExecutorManager executorManager = ExecutorManager.getInstance();
    executorManager.addFxTask(this::refreshHeight);
    executorManager.addFxTask(this::refreshAddButton);
}
 
Example 15
Source File: SearchView.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private void displayChannelInfos(final List<ChannelInfo> channels)
{
    final ObservableList<ChannelInfo> items = channel_table.getItems();
    if (result_replace.isSelected())
        // Replace displayed channels
        items.setAll(channels);
    else
        // Add new channels but avoid duplicates
        for (ChannelInfo channel : channels)
            if (! items.contains(channel))
                items.add(channel);
}
 
Example 16
Source File: DesktopPane.java    From desktoppanefx with Apache License 2.0 5 votes vote down vote up
public DesktopPane removeInternalWindow(InternalWindow internalWindow) {
    ObservableList<Node> windows = internalWindowContainer.getChildren();
    if (internalWindow != null && windows.contains(internalWindow)) {
        internalWindows.remove(internalWindow);
        windows.remove(internalWindow);
        internalWindow.setDesktopPane(null);
    }

    return this;
}
 
Example 17
Source File: DateTimeRangeInputPane.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Set the highlighting of the TitlePane's title.
 * <p>
 * Highlighting is done by adding/removing our own style class. We attempt
 * to make sure that we don't add it more than once.
 *
 * @param highlight True to be highlighted, false to be unhighlighted.
 */
private void setUsingAbsolute(final boolean highlight) {
    final ObservableList<String> classes = absPane.getStyleClass();
    if (highlight) {
        if (!classes.contains(HIGHLIGHTED_CLASS)) {
            classes.add(0, HIGHLIGHTED_CLASS);
            clearRangeButtons();
        }
    } else {
        classes.remove(HIGHLIGHTED_CLASS);
    }
}
 
Example 18
Source File: ImportedPacketTableView.java    From trex-stateless-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Add index to duplicate list
 * @param duplicateIndexesList
 * @param tableData
 */
private void addDuplicateIndex(ObservableList<Integer> duplicateIndexesList,ImportPcapTableData tableData ){
    if(!duplicateIndexesList.contains(tableData.getIndex())){
        duplicateIndexesList.add(tableData.getIndex());
    }
}
 
Example 19
Source File: StyleHelper.java    From AsciidocFX with Apache License 2.0 4 votes vote down vote up
public static void addClass(Styleable styleable, String clazz) {
    ObservableList<String> styleClass = styleable.getStyleClass();
    if(!styleClass.contains(clazz)){
        styleClass.add(clazz);
    }
}
 
Example 20
Source File: TableViewLogAppender.java    From AsciidocFX with Apache License 2.0 4 votes vote down vote up
@Override
protected void append(ILoggingEvent event) {

    if (Objects.isNull(logViewer))
        return;

    String message = event.getFormattedMessage();
    String level = event.getLevel().toString();

    if (Objects.isNull(message)) {
        return;
    }

    if (event.getLevel() == Level.ERROR) {
        ObservableList<String> styleClass = logShowHider.getStyleClass();
        if (!styleClass.contains("red-label")) {
            styleClass.add("red-label");
        }
    }

    final String finalMessage = message;
    threadService.buff("logMessager").schedule(() -> {
        threadService.runActionLater(() -> {
            logShortMessage.setText(finalMessage);
        });
    }, 1, TimeUnit.SECONDS);


    IThrowableProxy tp = event.getThrowableProxy();
    if (Objects.nonNull(tp) && event.getLevel() == Level.ERROR) {
        String tpMessage = ThrowableProxyUtil.asString(tp);
        message += "\n" + tpMessage;
    }

    if (!message.isEmpty()) {
        MyLog myLog = new MyLog(level, message);
        buffer.add(myLog);
    }

    threadService.buff("logAppender").schedule(() -> {
        final List<MyLog> clone = new LinkedList<>(buffer);
        buffer.clear();
        threadService.runActionLater(() -> {
            logList.addAll(clone);
        });
    }, 2, TimeUnit.SECONDS);
}