Package fr.soleil.comete.definition.widget.util

Examples of fr.soleil.comete.definition.widget.util.ITreeNode


     * @return A {@link String}
     */
    private String extractName(DefaultMutableTreeNode node) {
        String name = null;
        if ((node != null) && (configTree != null) && (configTree.getModel() != null)) {
            ITreeNode treeNode = configTree.getModel().getTreeNode(node);
            if (treeNode != null) {
                name = treeNode.getName();
            }
        }
        return name;
    }
View Full Code Here


    }

    private String extractCompletePath(DefaultMutableTreeNode node) {
        String name = null;
        if ((node != null) && (configTree != null) && (configTree.getModel() != null)) {
            ITreeNode treeNode = configTree.getModel().getTreeNode(node);
            if (treeNode != null) {
                name = treeNode.getName();
                ITreeNode parent = treeNode.getParent();
                while (parent != null) {
                    name = parent.getName() + "/" + name;
                    parent = parent.getParent();
                }
            }
        }
        return name;
    }
View Full Code Here

    @Override
    public void nodeChanged(TreeNodeEvent event) {
        if (event != null) {
            if (event.getReason() != null) {
                ITreeNode sourceNode = event.getSource();
                ITreeNode[] children = event.getChildren();
                switch (event.getReason()) {
                    case NAME:
                        saveEntityNode(sourceNode, false);
                        break;
View Full Code Here

    public static void filterMultipleSelection(List<ITreeNode> multipleSelection) {
        if (multipleSelection != null) {
            int size = multipleSelection.size();
            int cursorSearch = 0;
            int cursorCompare;
            ITreeNode searchNode;
            ITreeNode compareNode;
            while (cursorSearch < size - 1) {
                searchNode = multipleSelection.get(cursorSearch);
                for (cursorCompare = cursorSearch + 1; cursorCompare < size; ++cursorCompare) {
                    compareNode = multipleSelection.get(cursorCompare);
                    if (isChild(compareNode, searchNode)) {
View Full Code Here

     *
     * @param node The {@link ITreeNode} from which to start the search
     * @return An {@link ITreeNode}
     */
    public static ITreeNode findDirectoryNode(ITreeNode node) {
        ITreeNode directoryNode = node;
        while ((directoryNode != null) && (!(directoryNode.getData() instanceof IDirectory))) {
            directoryNode = directoryNode.getParent();
        }
        return directoryNode;
    }
View Full Code Here

     * @param entity The {@link IEntity}
     * @param recursive Whether to build children {@link ITreeNode}s, when concerned
     * @return An {@link ITreeNode}. <code>null</code> if the entity is <code>null</code>
     */
    protected ITreeNode buildNode(IEntity entity, boolean recursive) {
        ITreeNode node = TreeNodeUtils.buildNode(entity, recursive);
        listenToNode(node, recursive);
        return node;
    }
View Full Code Here

     * @param entity The {@link IEntity}
     * @param recursive Whether to build children {@link ITreeNode}s, when concerned
     * @return An {@link ITreeNode}. <code>null</code> if the entity is <code>null</code>
     */
    public static ITreeNode buildNode(IEntity entity, boolean recursive) {
        ITreeNode node = null;
        if (entity != null) {
            node = new EqualityBasicTreeNode();
            node.setData(entity);
            node.setName(entity.getName());
            if (entity instanceof IDirectory) {
                // node.setImage(ImageTool.getCometeImage((ImageIcon) Icons
                // .getIcon("salsa.scanconfig.folder")));
                if (recursive) {
                    IDirectory directory = (IDirectory) entity;
                    List<IEntity> entityList = new ArrayList<IEntity>();
                    entityList.addAll(directory.getSubDirectoriesList());
                    entityList.addAll(directory.getConfigList());
                    Collections.sort(entityList, new EntityPositionComparator());
                    ITreeNode[] nodes = new ITreeNode[entityList.size()];
                    int index = 0;
                    for (IEntity child : entityList) {
                        nodes[index++] = buildNode(child, recursive);
                    }
                    node.addNodes(nodes);
                }
            }
            else if (entity instanceof IConfig1D) {
                node.setImage(ImageTool.getCometeImage((ImageIcon) Icons
                        .getIcon("salsa.scanconfig.1d.big")));
            }
            else if (entity instanceof IConfig2D) {
                node.setImage(ImageTool.getCometeImage((ImageIcon) Icons
                        .getIcon("salsa.scanconfig.2d.big")));
            }
            else if (entity instanceof IConfigK) {
                node.setImage(ImageTool.getCometeImage((ImageIcon) Icons
                        .getIcon("salsa.scanconfig.k.big")));
            }
            else if (entity instanceof IConfigHCS) {
                node.setImage(ImageTool.getCometeImage((ImageIcon) Icons
                        .getIcon("salsa.scanconfig.hcs.big")));
            }
            else if (entity instanceof IConfigEnergy) {
                node.setImage(ImageTool.getCometeImage((ImageIcon) Icons
                        .getIcon("salsa.scanconfig.energy.big")));
            }
        }
        return node;
    }
View Full Code Here

     * @param recursive Whether to recursively duplicate children nodes/entities (i.e. duplicate
     *            children, grand children, etc...)
     * @return An {@link ITreeNode}
     */
    public static ITreeNode getDuplicata(ITreeNode node, boolean recursive) {
        ITreeNode duplicata = null;
        if ((node != null) && (node.getData() instanceof IEntity)) {
            duplicata = buildNode(getDuplicata((IEntity) node.getData(), null, recursive),
                    recursive);
            if (duplicata != null) {
                duplicata.setName(node.getName());
                duplicata.setImage(node.getImage());
            }
        }
        return duplicata;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    private void updateSelectedConfig() {
        IConfig<?> config = null;
        ITreeNode[] selectedNodes = view.getConfigTree().getSelectedNodes();
        if ((selectedNodes != null) && (selectedNodes.length > 0)) {
            ITreeNode toCheck = selectedNodes[0];
            if (toCheck != lastListenedNode) {
                if (lastListenedNode != null) {
                    lastListenedNode.removeTreeNodeListener(this);
                }
                lastListenedNode = toCheck;
                if (lastListenedNode != null) {
                    lastListenedNode.addTreeNodeListener(this);
                }
            }
            if (toCheck.getData() instanceof IConfig<?>) {
                config = (IConfig<?>) toCheck.getData();
            }
        }
        // if (config != null) {
        if (config != lastSelectedConfig) {
            if (lastSelectedConfig instanceof IEventSource<?>) {
View Full Code Here

    @Override
    public void nodeChanged(TreeNodeEvent event) {
        if (event != null) {
            if (event.getReason() != null) {
                ITreeNode sourceNode = event.getSource();
                ITreeNode[] children = event.getChildren();
                switch (event.getReason()) {
                    case NAME:
                        saveEntityNode(sourceNode, false);
                        break;
View Full Code Here

TOP

Related Classes of fr.soleil.comete.definition.widget.util.ITreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.