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

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


     * @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


    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

     *            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

     *            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)) {
            IEntity copyEntity = getDuplicata((IEntity) node.getData(), null, recursive);
            duplicata = buildNode(copyEntity, recursive);
            if ((duplicata != null) && (copyEntity != null)) {
                duplicata.setName(copyEntity.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

    @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

    private List<ITreeNode> extractTreeNodes(List<?> selection) {
        List<ITreeNode> nodes = new ArrayList<ITreeNode>();
        if (getModel() != null) {
            for (Object child : selection) {
                if (child instanceof DefaultMutableTreeNode) {
                    ITreeNode node = getModel().getTreeNode((DefaultMutableTreeNode) child);
                    if (node.getData() instanceof IEntity) {
                        IEntity entity = (IEntity) node.getData();
                        if (entity.getDirectory() != null) {
                            nodes.add(node);
                        }
                    }
                }
View Full Code Here

                }
            }
            else {
                toDrop = nodes;
            }
            ITreeNode realTarget = TreeNodeUtils.findDirectoryNode(target);
            if (realTarget != null) {
                realTarget.addNodes(toDrop.toArray(new ITreeNode[toDrop.size()]));
                IDirectory directory = (IDirectory) realTarget.getData();
                for (ITreeNode node : toDrop) {
                    if (node.getData() instanceof IEntity) {
                        ((IEntity) node.getData()).setDirectory(directory);
                    }
                }
View Full Code Here

    /**
     * Notifies mediators for the need to save all nodes
     */
    public void notifySaveAll() {
        ITreeNode rootNode = getRootNode();
        if (rootNode != null) {
            targetDelegate.warnMediators(new NodeInformation(this, rootNode));
        }
        repaint();
    }
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.