Package fr.soleil.salsa.entity.event

Examples of fr.soleil.salsa.entity.event.DirectoryModel


    }

    @Override
    public void notifyNewDirectory(String directoryName) {
        if ((directoryName != null) && (!directoryName.trim().isEmpty())) {
            DirectoryModel directory = new DirectoryModel();
            directory.setName(directoryName);
            view.addEntity(directory);
        }
    }
View Full Code Here


    }

    @Override
    public void notifyNewDirectory(String directoryName) {
        if ((directoryName != null) && (!directoryName.trim().isEmpty())) {
            DirectoryModel directory = new DirectoryModel();
            directory.setName(directoryName);
            view.addEntity(directory);
        }
    }
View Full Code Here

     * Method called when the user clicks on the new directory button.
     */
    @Override
    public void notifyNewDirectory(String directoryName) {
        if (directoryName != null && !"".equals(directoryName.trim())) {
            DirectoryModel directory = new DirectoryModel();
            directory.setName(directoryName);
            if (currentDirectory == null) {
                currentDirectory = rootDirectory;
            }
            if (currentDirectory != null) {
                moveDirectory(directory, currentDirectory);
            }
            DirectoryModel savedDirectory = saveDirectory(directory);
            if (rootDirectory == null) {
                rootDirectory = savedDirectory;
            }
            currentDirectory = savedDirectory;
            refresh();
            ATreeNode treeNode = new DirectoryTreeNode(currentDirectory);
            if (savedDirectory.getDirectory() != null) {
                view.expandNode(new DirectoryTreeNode(savedDirectory.getDirectory()));
            }
            view.setSelection(treeNode);
        }
    }
View Full Code Here

                    }
                }
                else {
                    if (!isChild(target, treeNode)) {
                        DirectoryTreeNode directoryTreeNode = (DirectoryTreeNode) treeNode;
                        DirectoryModel movedDirectory = (DirectoryModel) directoryTreeNode
                                .getDirectory();
                        if (!movedDirectory.equals(targetDirectory)
                                && !targetDirectory.equals(movedDirectory.getDirectory())) {
                            moveDirectory(movedDirectory, targetDirectory);
                            directoryTreeNode.setDirectory(saveDirectory(movedDirectory));
                        }
                    }
                }
View Full Code Here

     * Copy and paste the directory in directoryTreeNode to the current directory.
     *
     * @param directoryTreeNode
     */
    private void copyPasteDirectory(DirectoryTreeNode directoryTreeNode) {
        DirectoryModel copiedDirectoryModel = (DirectoryModel) directoryTreeNode.getDirectory();

        // The configuration are not fully loaded when the configuration is first created to save
        // time.
        // We need to load all of the configurations contained in the directory and its
        // subdirectories to copy them too.
        loadConfigRecursive(copiedDirectoryModel);

        // To copy the object, we serialize it to a byte array, then we recover a copy from it.
        // This way, we can reuse the existing serialization rather than implement the clone
        // method on every entity.
        IDirectory copiedDirectory = AutoCopier.toImpl(copiedDirectoryModel, IDirectory.class);
        DirectoryModel copyDirectoryModel;
        IDirectory copyDirectory;
        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            objectOutputStream.writeObject(copiedDirectory);
            byte[] buffer = byteArrayOutputStream.toByteArray();
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer);
            ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
            copyDirectory = (IDirectory) objectInputStream.readObject();
        }
        catch (IOException e) {
            // The streams work on the RAM, so an IOException should never happen.
            e.printStackTrace();
            copyDirectory = null;
        }
        catch (ClassNotFoundException e) {
            // This should never happen as well.
            e.printStackTrace();
            copyDirectory = null;
        }

        // copiedDirectoryModel needs to be rewrapped.
        /*DirectoryModel restoreCopiedDirectoryModel = DirectoryModelWrapperFactory.getInstance()
                .wrap(copiedDirectory);
        if (copiedDirectoryModel == currentDirectory) {
            currentDirectory = restoreCopiedDirectoryModel;
        }*/

        copyDirectory = AutoCopier.copyDirectoryToModel(copyDirectory);
        // We need to set the identifiers of the new directories and configurations to null.
        nullId(copyDirectory);
        moveDirectory(copyDirectory, currentDirectory);
        copyDirectoryModel = (DirectoryModel) copyDirectory;// DirectoryModelWrapperFactory.getInstance().wrap(copyDirectory);

        DirectoryModel savedDirectory = saveDirectoryRecursive(copyDirectoryModel);
        currentDirectory.getSubDirectoriesList().remove(copyDirectory);
        currentDirectory.getSubDirectoriesList().add(savedDirectory);
        directoryTreeNode.setDirectory(copiedDirectory);
    }
View Full Code Here

     * Cut and paste (move) the directory in directoryTreeNode to the current directory.
     *
     * @param directoryTreeNode
     */
    private void cutPasteDirectory(DirectoryTreeNode directoryTreeNode) {
        DirectoryModel movedDirectory = (DirectoryModel) directoryTreeNode.getDirectory();
        if (!movedDirectory.equals(currentDirectory)) {
            moveDirectory(movedDirectory, currentDirectory);
            directoryTreeNode.setDirectory(saveDirectory(movedDirectory));
        }
    }
View Full Code Here

     * @param directoryModel
     * @return
     */
    private DirectoryModel saveDirectory(DirectoryModel directoryModel) {
        // IDirectory directoryImpl = directoryModelWrapperFactory.unWrap(directoryModel);
        DirectoryModel savedDirectoryModel = null;
        try {
            savedDirectoryModel = (DirectoryModel) ConfigAPIService.saveDirectory(directoryModel);

            if (directoryModel.getDirectory() != null && savedDirectoryModel.getDirectory() != null) {
                directoryModel.getDirectory().setTimestamp(
                        savedDirectoryModel.getDirectory().getTimestamp());
            }
            savedDirectoryModel.setDirectory(directoryModel.getDirectory());
            savedDirectoryModel.setConfigList(directoryModel.getConfigList());
            savedDirectoryModel.setSubDirectoriesList(directoryModel.getSubDirectoriesList());
            // savedDirectoryModel = directoryModelWrapperFactory.wrap(savedDirectoryImpl);
        }
        catch (PersistenceException e) {
            e.printStackTrace();
            errorMessage("Error saving directory " + directoryModel.getName() + ". Details : "
View Full Code Here

     * @param directoryModel
     * @return
     */
    private DirectoryModel saveDirectoryRecursive(DirectoryModel directoryModel) {
        directoryModel.setName(directoryModel.getName() + " (copy)");
        DirectoryModel savedDirectoryModel = saveDirectory(directoryModel);
        for (IDirectory subDirectory : savedDirectoryModel.getSubDirectoriesList()) {
            saveDirectoryRecursive((DirectoryModel) subDirectory);
        }
        for (IConfig<?> config : savedDirectoryModel.getConfigList()) {
            config.setDirectory(savedDirectoryModel);
            config.setName(config.getName() + " (copy)");
            saveConfig(config);
        }
        return savedDirectoryModel;
View Full Code Here

            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());
View Full Code Here

     * Method called when the user clicks on the new directory button.
     */
    @Override
    public void notifyNewDirectory(String directoryName) {
        if (directoryName != null && !"".equals(directoryName.trim())) {
            DirectoryModel directory = new DirectoryModel();
            directory.setName(directoryName);
            if (currentDirectory == null) {
                currentDirectory = rootDirectory;
            }
            if (currentDirectory != null) {
                moveDirectory(directory, currentDirectory);
            }
            DirectoryModel savedDirectory = saveDirectory(directory);
            if (rootDirectory == null) {
                rootDirectory = savedDirectory;
            }
            currentDirectory = savedDirectory;
            refresh();
            ATreeNode treeNode = new DirectoryTreeNode(currentDirectory);
            if (savedDirectory.getDirectory() != null) {
                view.expandNode(new DirectoryTreeNode(savedDirectory.getDirectory()));
            }
            view.setSelection(treeNode);
        }
    }
View Full Code Here

TOP

Related Classes of fr.soleil.salsa.entity.event.DirectoryModel

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.