Package fr.soleil.salsa.entity

Examples of fr.soleil.salsa.entity.IEntity


        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


                if (path != null) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
                            .getLastPathComponent();
                    ITreeNode treeNode = configTree.getModel().getTreeNode(node);
                    if (treeNode.getData() instanceof IEntity) {
                        IEntity entity = (IEntity) treeNode.getData();
                        String entityName = askNewEntityName(entity.getClass());
                        if (entityName != null) {
                            // updating node name will generate an event, that will make the source
                            // save the entity with an updated name
                            treeNode.setName(entityName);
                            configTree.repaint();
View Full Code Here

        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

     * @see #saveConfigNode(ITreeNode)
     * @see #saveDirectoryNode(ITreeNode, boolean)
     */
    protected void saveEntityNode(ITreeNode node, boolean recursive) {
        if (node != null) {
            IEntity entity = (IEntity) node.getData();
            // check name
            if (!ObjectUtils.sameObject(node.getName(), entity.getName())) {
                entity.setName(node.getName());
            }
            if (node.getParent() != null) {
                // check parent directory
                if (node.getParent().getData() instanceof IDirectory) {
                    IDirectory directory = (IDirectory) node.getParent().getData();
                    if (!ObjectUtils.sameObject(directory, entity.getDirectory())) {
                        entity.setDirectory(directory);
                    }
                }
                // check position in parent directory
                List<ITreeNode> children = node.getParent().getChildren();
                int currentIndex = (entity.getPositionInDirectory() == null ? -1 : entity
                        .getPositionInDirectory().intValue());
                if (children != null) {
                    int index = children.indexOf(node);
                    if ((index > -1) && (index != currentIndex)) {
                        entity.setPositionInDirectory(Integer.valueOf(index));
                    }
                }
            }
            if (entity instanceof IConfig<?>) {
                saveConfigNode(node);
View Full Code Here

     * @see #deleteDirectoryNode(ITreeNode)
     */
    protected void deleteEntityNode(ITreeNode node) {
        if (node != null) {
            node.removeTreeNodeListener(this);
            IEntity entity = (IEntity) node.getData();
            IDirectory directory = entity.getDirectory();
            if (entity instanceof IConfig<?>) {
                deleteConfigNode(node);
            }
            else if (entity instanceof IDirectory) {
                deleteDirectoryNode(node);
            }
            entity.setDirectory(null);
            if (directory != null) {
                List<IConfig<?>> children = directory.getConfigList();
                if (children != null) {
                    children.remove(entity);
                }
View Full Code Here

     * @param recursive Whether to recursively duplicate copy (i.e.: duplicate its children, grand
     *            children, etc...)
     * @return An {@link IEntity}
     */
    private static IEntity getDuplicata(IEntity entity, IDirectory parent, boolean recursive) {
        IEntity duplicata = null;
        if (entity instanceof IConfig<?>) {
            ConfigSerializer configSerializer = new ConfigSerializer();
            IConfig<?> copyConfig = configSerializer.cloneConfig((IConfig<?>) entity);
            copyConfig.setModified(true);
            duplicata = copyConfig;
        }
        else if (entity instanceof IDirectory) {
            IDirectory directory = (IDirectory) entity;
            IDirectory copyDirectory = new DirectoryModel();
            if (recursive) {
                List<IConfig<?>> configList = new ArrayList<IConfig<?>>();
                for (IConfig<?> config : directory.getConfigList()) {
                    configList.add((IConfig<?>) getDuplicata(config, copyDirectory, recursive));
                }
                copyDirectory.setConfigList(configList);
                List<IDirectory> subDirectoriesList = new ArrayList<IDirectory>();
                for (IDirectory dir : directory.getSubDirectoriesList()) {
                    subDirectoriesList
                            .add((IDirectory) getDuplicata(dir, copyDirectory, recursive));
                }
                copyDirectory.setSubDirectoriesList(subDirectoriesList);
            }
            duplicata = copyDirectory;
        }
        if (duplicata != null) {
            duplicata.setName(entity.getName());
            duplicata.setPositionInDirectory(entity.getPositionInDirectory());
            duplicata.setId(null);
            duplicata.setDirectory(parent);
        }
        return duplicata;
    }
View Full Code Here

                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
                            .getLastPathComponent();
                    String configPath = extractCompletePath(node);
                    ITreeNode treeNode = configTree.getModel().getTreeNode(node);
                    if (treeNode.getData() instanceof IEntity) {
                        IEntity entity = (IEntity) treeNode.getData();
                        String entityName = askRenameEntityName(entity.getClass(),
                                treeNode.getName());
                        if (entityName != null) {
                            // updating node name will generate an event, that will make the source
                            // save the entity with an updated name
                            treeNode.setName(entityName);
View Full Code Here

                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
                            .getLastPathComponent();
                    String configPath = extractCompletePath(node);
                    ITreeNode treeNode = configTree.getModel().getTreeNode(node);
                    if (treeNode.getData() instanceof IEntity) {
                        IEntity entity = (IEntity) treeNode.getData();
                        String entityName = askRenameEntityName(entity.getClass(),
                                treeNode.getName());
                        if (entityName != null) {
                            // updating node name will generate an event, that will make the source
                            // save the entity with an updated name
                            treeNode.setName(entityName);
View Full Code Here

     * @see #saveConfigNode(ITreeNode)
     * @see #saveDirectoryNode(ITreeNode, boolean)
     */
    protected void saveEntityNode(ITreeNode node, boolean recursive) {
        if (node != null) {
            IEntity entity = (IEntity) node.getData();
            // check name
            if (!ObjectUtils.sameObject(node.getName(), entity.getName())) {
                entity.setName(node.getName());
            }
            if (node.getParent() != null) {
                // check parent directory
                if (node.getParent().getData() instanceof IDirectory) {
                    IDirectory directory = (IDirectory) node.getParent().getData();
                    if (!ObjectUtils.sameObject(directory, entity.getDirectory())) {
                        entity.setDirectory(directory);
                    }
                }
            }
            if (entity instanceof IConfig<?>) {
                saveConfigNode(node);
View Full Code Here

     * @param recursive Whether to recursively duplicate copy (i.e.: duplicate its children, grand
     *            children, etc...)
     * @return An {@link IEntity}
     */
    private static IEntity getDuplicata(IEntity entity, IDirectory parent, boolean recursive) {
        IEntity duplicata = null;
        if (entity instanceof IConfig<?>) {
            ConfigSerializer configSerializer = new ConfigSerializer();
            IConfig<?> copyConfig = configSerializer.cloneConfig((IConfig<?>) entity);
            copyConfig.setModified(true);
            duplicata = copyConfig;
        }
        else if (entity instanceof IDirectory) {
            IDirectory directory = (IDirectory) entity;
            IDirectory copyDirectory = new DirectoryModel();
            if (recursive) {
                List<IConfig<?>> configList = new ArrayList<IConfig<?>>();
                for (IConfig<?> config : directory.getConfigList()) {
                    configList.add((IConfig<?>) getDuplicata(config, copyDirectory, recursive));
                }
                copyDirectory.setConfigList(configList);
                List<IDirectory> subDirectoriesList = new ArrayList<IDirectory>();
                for (IDirectory dir : directory.getSubDirectoriesList()) {
                    subDirectoriesList
                            .add((IDirectory) getDuplicata(dir, copyDirectory, recursive));
                }
                copyDirectory.setSubDirectoriesList(subDirectoriesList);
            }
            duplicata = copyDirectory;
        }
        if (duplicata != null) {
            duplicata.setName(entity.getName());
            duplicata.setPositionInDirectory(entity.getPositionInDirectory());
            duplicata.setId(null);
            duplicata.setDirectory(parent);
        }
        return duplicata;
    }
View Full Code Here

TOP

Related Classes of fr.soleil.salsa.entity.IEntity

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.