Search in sources :

Example 51 with TreeItem

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

the class WidgetTree method addTabs.

private void addTabs(final List<TabItemProperty> added) {
    for (TabItemProperty tab : added) {
        final TreeItem<WidgetOrTab> widget_item = widget2tree.get(tab.getWidget());
        final TreeItem<WidgetOrTab> tab_item = new TreeItem<>(WidgetOrTab.of(tab));
        widget_item.getChildren().add(tab_item);
        tab_name2tree.put(tab.name(), tab_item);
        tab.name().addPropertyListener(tab_name_listener);
        for (Widget child : tab.children().getValue()) addWidget(child, -1);
        tab.children().addPropertyListener(children_listener);
    }
}
Also used : TabItemProperty(org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty) TreeItem(javafx.scene.control.TreeItem) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) Widget(org.csstudio.display.builder.model.Widget)

Example 52 with TreeItem

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

the class WidgetTree method addWidget.

/**
 * Add widget to existing model & tree
 *  @param added_widget Widget to add
 *  @param index Index of widget within parent. -1 to add at end
 */
private void addWidget(final Widget added_widget, final int index) {
    // Have widget and its parent in model
    final Widget widget_parent = added_widget.getParent().get();
    // Determine parent tree item
    TreeItem<WidgetOrTab> item_parent = null;
    if (widget_parent instanceof TabsWidget) {
        for (TabItemProperty tab : ((TabsWidget) widget_parent).propTabs().getValue()) if (tab.children().getValue().contains(added_widget)) {
            item_parent = tab_name2tree.get(tab.name());
            break;
        }
    } else
        item_parent = widget2tree.get(widget_parent);
    Objects.requireNonNull(item_parent, "Cannot obtain parent item for " + added_widget);
    // Create Tree item
    final TreeItem<WidgetOrTab> item = new TreeItem<>(WidgetOrTab.of(added_widget));
    widget2tree.put(added_widget, item);
    item.setExpanded(true);
    if (index >= 0)
        // Add at same index into Tree
        item_parent.getChildren().add(index, item);
    else
        // Append to end
        item_parent.getChildren().add(item);
    added_widget.propName().addPropertyListener(name_listener);
    if (added_widget instanceof TabsWidget) {
        final ArrayWidgetProperty<TabItemProperty> tabs = ((TabsWidget) added_widget).propTabs();
        addTabs(tabs.getValue());
        tabs.addPropertyListener(tabs_property_listener);
    } else {
        final ChildrenProperty children = ChildrenProperty.getChildren(added_widget);
        if (children != null) {
            children.addPropertyListener(children_listener);
            for (Widget child : children.getValue()) addWidget(child, -1);
        }
    }
}
Also used : ChildrenProperty(org.csstudio.display.builder.model.ChildrenProperty) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) TabItemProperty(org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty) TreeItem(javafx.scene.control.TreeItem) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) Widget(org.csstudio.display.builder.model.Widget)

Example 53 with TreeItem

use of javafx.scene.control.TreeItem in project blue by kunstmusik.

the class SoundObjectExportPane method submitSoundObject.

private void submitSoundObject() {
    try {
        TreePath path = soundObjectLibraryTree.getSelectionPath();
        if (path == null) {
            return;
        }
        Object userObj = path.getLastPathComponent();
        TreeItem<LibraryItem<SoundObject>> node = (TreeItem<LibraryItem<SoundObject>>) userObj;
        if (!node.isLeaf()) {
            return;
        }
        SoundObject soundObject = node.getValue().getValue();
        DefaultMutableTreeNode tempNode = (DefaultMutableTreeNode) categoryTree.getSelectionPath().getLastPathComponent();
        BlueShareSoundObjectCategory category = (BlueShareSoundObjectCategory) tempNode.getUserObject();
        String username = namePasswordPanel.getUsername();
        String password = namePasswordPanel.getPassword();
        int categoryId = category.getCategoryId();
        String name = soundObject.getName();
        String soundObjectType = soundObject.getClass().getName();
        String description = descriptionText.getText();
        String soundObjectText = soundObject.saveAsXML(new HashMap<>()).toString();
        System.out.println(soundObject.saveAsXML(new HashMap<>()).getTextString());
        BlueShareRemoteCaller.submitSoundObject(username, password, categoryId, name, soundObjectType, description, soundObjectText);
    } catch (IOException | XmlRpcException e) {
        JOptionPane.showMessageDialog(null, "Error submitting SoundObject" + "\n\n" + e.getLocalizedMessage(), BlueSystem.getString("common.error"), JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
        return;
    }
    JOptionPane.showMessageDialog(null, "SoundObject was successfully received.", BlueSystem.getString("common.success"), JOptionPane.PLAIN_MESSAGE);
}
Also used : LibraryItem(blue.library.LibraryItem) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeItem(javafx.scene.control.TreeItem) HashMap(java.util.HashMap) IOException(java.io.IOException) TreePath(javax.swing.tree.TreePath) SoundObject(blue.soundObject.SoundObject) SoundObject(blue.soundObject.SoundObject) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 54 with TreeItem

use of javafx.scene.control.TreeItem in project uPMT by coco35700.

the class AddPropertyToClassCommand method execute.

@Override
public void execute() {
    // adding the new property to the scheme
    TreeItem<TypeController> newType = new TreeItem<TypeController>();
    TypeController tc = new TypeController(newp, controller.getType());
    newType.setValue(tc);
    tree.getChildren().add(newType);
    tree.setExpanded(true);
    controller.getAddPropertySchemeController().update(newp);
    MainViewTransformations.updateGrid(main);
    main.needToSave();
}
Also used : TypeController(controller.controller.TypeController) TreeItem(javafx.scene.control.TreeItem)

Example 55 with TreeItem

use of javafx.scene.control.TreeItem in project certmgr by hdecarne.

the class StoreController method updateDetailsViewHelper.

private void updateDetailsViewHelper(TreeItem<AttributeModel> parentItem, Attributes attribute, boolean expand) {
    TreeItem<AttributeModel> attributeItem = new TreeItem<>(new AttributeModel(attribute));
    List<Attributes> attributeChildren = attribute.children();
    int childCount = attributeChildren.size();
    int childIndex = 0;
    for (Attributes child : attributeChildren) {
        if (childIndex >= DETAILS_VIEW_ATTRIBUTE_LIMIT) {
            attributeItem.getChildren().add(new TreeItem<>(new AttributeModel(StoreI18N.formatSTR_TEXT_DETAILS_OMITTED(childCount - childIndex))));
            break;
        }
        updateDetailsViewHelper(attributeItem, child, false);
        childIndex++;
    }
    parentItem.getChildren().add(attributeItem);
    attributeItem.setExpanded(expand);
}
Also used : TreeItem(javafx.scene.control.TreeItem) Attributes(de.carne.certmgr.certs.x509.Attributes)

Aggregations

TreeItem (javafx.scene.control.TreeItem)76 File (java.io.File)15 TreeView (javafx.scene.control.TreeView)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 ObjectProperty (javafx.beans.property.ObjectProperty)9 MenuItem (javafx.scene.control.MenuItem)9 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 IOException (java.io.IOException)7 Optional (java.util.Optional)7 FXCollections (javafx.collections.FXCollections)7 ListChangeListener (javafx.collections.ListChangeListener)7 ObservableList (javafx.collections.ObservableList)7 ActionEvent (javafx.event.ActionEvent)7 ContextMenu (javafx.scene.control.ContextMenu)7 Stage (javafx.stage.Stage)7 FXML (javafx.fxml.FXML)6 Button (javafx.scene.control.Button)6