Package fr.soleil.salsa.entity

Examples of fr.soleil.salsa.entity.IDirectory


        super(view, applicationController == null ? null : applicationController
                .getErrorController());
        this.applicationController = applicationController;
        setConfigManager(applicationController == null ? null : applicationController
                .getConfigManager());
        IDirectory loadedRootDirectory = ConfigAPIService.getRootDirectory();
        if (loadedRootDirectory != null) {
            this.setRootDirectory(loadedRootDirectory);
        }
        else {
            this.setRootDirectory(null);
View Full Code Here


    @Override
    public void notifySave() {
        List<ATreeNode> listSave = view.getMultipleSelection();
        filterMultipleSelection(listSave);
        IConfig<?> saveConfig;
        IDirectory saveDirectory;
        for (ATreeNode saveNode : listSave) {
            if (saveNode instanceof ConfigTreeNode) {
                saveConfig = ((ConfigTreeNode) saveNode).getConfig();
                this.saveConfig(saveConfig);
            }
View Full Code Here

     */
    @Override
    public void notifyDrop(List<ATreeNode> droppedSelection, ATreeNode target) {
        if (droppedSelection != null && droppedSelection.size() > 0) {
            filterMultipleSelection(droppedSelection);
            IDirectory targetDirectory;
            if (target instanceof DirectoryTreeNode) {
                targetDirectory = ((DirectoryTreeNode) target).getDirectory();
            }
            else {
                targetDirectory = ((ConfigTreeNode) target).getConfig().getDirectory();
            }
            for (ATreeNode treeNode : droppedSelection) {
                if (treeNode instanceof ConfigTreeNode) {
                    ConfigTreeNode configTreeNode = (ConfigTreeNode) treeNode;
                    IConfig<?> movedConfig = configTreeNode.getConfig();
                    if (!targetDirectory.equals(movedConfig.getDirectory())) {
                        if (!movedConfig.isLoaded()) {
                            movedConfig = loadConfig(movedConfig);
                            configTreeNode.setConfig(movedConfig);
                        }
                        boolean modified = movedConfig.isModified();
                        moveConfig(movedConfig, targetDirectory);
                        if (!modified) {
                            configTreeNode.setConfig(saveConfig(movedConfig));
                        }
                    }
                }
                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

                    // Partial mode for recording.
                    setAttribute("dataRecorderPartialMode", false);

                    // Run name.
                    String runName = config.getName();
                    IDirectory directory = config.getDirectory();
                    while (directory != null) {
                        runName = directory.getName() + "." + runName;
                        directory = directory.getDirectory();
                    }
                    setAttribute("runName", runName);

                    // Scan number.
                    setAttribute("scanNumber", config.getScanNumber());
View Full Code Here

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

     */
    private boolean isChild(ATreeNode childNode, ATreeNode parentNode) {
        if (parentNode instanceof ConfigTreeNode) {
            return false;
        }
        IDirectory parent = ((DirectoryTreeNode) parentNode).getDirectory();
        IDirectory search;
        if (childNode instanceof ConfigTreeNode) {
            IConfig<?> config = ((ConfigTreeNode) childNode).getConfig();
            search = config.getDirectory();
        }
        else {
            IDirectory directory = ((DirectoryTreeNode) childNode).getDirectory();
            search = directory.getDirectory();
        }
        while (search != null) {
            if (search.equals(parent)) {
                return true;
            }
View Full Code Here

                }

            }
            else {
                IDirectory directoryModel = ((DirectoryTreeNode) treeNode).getDirectory();
                choice = view.confirmDeleteDirectory(directoryModel);
                if (choice == view.DELETE_DIRECTORY) {
                    // If the current configuration is in the deleted directory, then it is deleted
                    // as
                    // well.
                    if (currentConfig != null) {
                        IDirectory directorySearch = currentConfig.getDirectory();
                        boolean isConfigurationInside = false;
                        while (!isConfigurationInside && directorySearch != null) {
                            isConfigurationInside = directorySearch.equals(directoryModel);
                            directorySearch = directorySearch.getDirectory();
                        }
                        if (isConfigurationInside) {
                            currentConfig = null;
                            applicationController.setConfig(null);
                        }
                    }
                    // Case if the root directory is the deleted directory.
                    if (directoryModel.equals(rootDirectory)) {
                        rootDirectory = null;
                        currentDirectory = null;
                    }
                    // Cas if the current directory is the deleted directory or is inside the
                    // deleted
                    // directory.
                    if (currentDirectory != null) {
                        IDirectory directorySearch = currentDirectory.getDirectory();
                        boolean isDirectoryInside = currentDirectory.equals(directoryModel);
                        while (!isDirectoryInside && directorySearch != null) {
                            isDirectoryInside = directorySearch.equals(directoryModel);
                            directorySearch = directorySearch.getDirectory();
                        }
                        if (isDirectoryInside) {
                            currentDirectory = null;
                        }
                    }
                    // IDirectory directory = DirectoryModelWrapperFactory.getInstance().unWrap(
                    // directoryModel);
                    IDirectory directory = AutoCopier.copyDirectoryToImpl(directoryModel);
                    // directoryModel);
                    try {
                        ConfigApi.deleteDirectory(directory);
                        IDirectory parentDirectory = directoryModel.getDirectory();
                        if (parentDirectory != null) {
                            parentDirectory.getSubDirectoriesList().remove(directoryModel);
                        }
                    }
                    catch (PersistenceException e) {
                        e.printStackTrace();
                        errorMessage("Error deleting directory " + directory.getName()
View Full Code Here

     *
     * @param oldConfig
     * @param newConfig
     */
    private void updateDirectoryDirectory(IDirectory oldDirectory, IDirectory newDirectory) {
        IDirectory directory = oldDirectory.getDirectory();
        ListIterator<IDirectory> oldDirectoryIterator = directory.getSubDirectoriesList()
                .listIterator();
        IDirectory searchDirectory;
        while (oldDirectoryIterator.hasNext()) {
            searchDirectory = oldDirectoryIterator.next();
            if (searchDirectory == oldDirectory) {
                oldDirectoryIterator.set(newDirectory);
                break;
View Full Code Here

     *
     * @param oldConfig
     * @param newConfig
     */
    private void updateConfigDirectory(IConfig<?> oldConfig, IConfig<?> newConfig) {
        IDirectory directory = oldConfig.getDirectory();
        newConfig.setDirectory(directory);
        ListIterator<IConfig<?>> oldConfigIterator = directory.getConfigList().listIterator();
        IConfig<?> searchConfig;
        while (oldConfigIterator.hasNext()) {
            searchConfig = oldConfigIterator.next();
            if (searchConfig.equals(oldConfig)) {
                oldConfigIterator.set(newConfig);
View Full Code Here

            List<ATreeNode> multipleSelection = view.getMultipleSelection();
            filterMultipleSelection(multipleSelection);
            // Rather than loading each config and directory separately, we load the whole tree
            // structure in one go.
            // We can then load only the config we need.
            IDirectory loadRootDirectory = ConfigApi.getRootDirectory();
            boolean refreshCurrent = false;
            boolean currentAlreadyRefreshed = false;
            for (ATreeNode treeNode : multipleSelection) {
                if (treeNode instanceof ConfigTreeNode) {
                    IConfig<?> configToRefresh = ((ConfigTreeNode) treeNode).getConfig();
                    if (configToRefresh.equals(currentConfig)) {
                        currentAlreadyRefreshed = true;
                    }
                    refreshConfig(configToRefresh, loadRootDirectory);
                }
                else {
                    if (isChild(new ConfigTreeNode(currentConfig, null), treeNode)) {
                        refreshCurrent = true;
                    }
                    refreshDirectory(((DirectoryTreeNode) treeNode).getDirectory(),
                            loadRootDirectory);
                }
            }
            if (refreshCurrent && !currentAlreadyRefreshed) {
                IConfig<?> newCurrentConfig = loadConfig(currentConfig);
                this.currentConfig = newCurrentConfig;
                applicationController.setConfig(newCurrentConfig);
            }
        }
        else {
            IDirectory loadedRootDirectory = ConfigAPIService.getRootDirectory();
            if (loadedRootDirectory != null) {
                /*DirectoryModel rootDirectoryModel = directoryModelWrapperFactory
                        .wrap(loadedRootDirectory);*/
                this.setRootDirectory(loadedRootDirectory);
            }
View Full Code Here

TOP

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

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.