Package org.apache.directory.studio.schemaeditor.controller

Examples of org.apache.directory.studio.schemaeditor.controller.ProjectsHandler


    /**
     * Loads the projects saved in the Projects File.
     */
    public static void loadProjects()
    {
        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
        File projectsFile = getProjectsFile();

        if ( projectsFile.exists() )
        {
            Project[] projects = null;
            try
            {
                projects = ProjectsImporter.getProjects( projectsFile.getAbsolutePath() );
            }
            catch ( ProjectsImportException e )
            {
                PluginUtils.logError( "An error occured when loading the projects.", e );
                ViewUtils.displayErrorMessageBox( "Projects Loading Error",
                    "An error occured when loading the projects." );
            }

            for ( Project project : projects )
            {
                projectsHandler.addProject( project );
            }
        }
    }
View Full Code Here


    /**
     * Saves the projects in the Projects File.
     */
    public static void saveProjects()
    {
        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
        File projectsFile = getProjectsFile();

        try
        {
            BufferedWriter buffWriter = new BufferedWriter( new FileWriter( projectsFile ) );
            buffWriter.write( ProjectsExporter.toXml( projectsHandler.getProjects().toArray( new Project[0] ) ) );
            buffWriter.close();
        }
        catch ( IOException e )
        {
            PluginUtils.logError( "An error occured when saving the projects.", e );
View Full Code Here

                    }
                }
            }
        }

        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
        projectsHandler.addProject( project );
        projectsHandler.openProject( project );

        return true;
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void run()
    {
        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();

        if ( !selection.isEmpty() )
        {
            StringBuilder title = new StringBuilder();
            StringBuilder message = new StringBuilder();

            int count = selection.size();

            if ( count <= 5 )
            {
                if ( count == 1 )
                {
                    // Only 1 project to delete
                    title.append( Messages.getString( "DeleteProjectAction.DeleteProjectTitle" ) ); //$NON-NLS-1$
                    message.append( Messages.getString( "DeleteProjectAction.SureDeleteFollowingProject" ) ); //$NON-NLS-1$
                }
                else
                {
                    // Between 2 to 5 projects to delete
                    title.append( Messages.getString( "DeleteProjectAction.DeleteProjectsTitle" ) ); //$NON-NLS-1$
                    message.append( Messages.getString( "DeleteProjectAction.SureDeleteFollowingProjects" ) ); //$NON-NLS-1$
                }

                // Appending the projects names
                for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); )
                {
                    message.append( ConnectionCoreConstants.LINE_SEPARATOR );
                    message.append( "  - " ); //$NON-NLS-1$
                    message.append( ( ( ProjectWrapper ) iterator.next() ).getProject().getName() );
                }
            }
            else
            {
                // More than 5 projects to delete
                title.append( Messages.getString( "DeleteProjectAction.DeleteProjectsTitle" ) ); //$NON-NLS-1$
                message.append( Messages.getString( "DeleteProjectAction.SureDeleteSelectedProjects" ) ); //$NON-NLS-1$
            }

            // Showing the confirmation window
            if ( MessageDialog.openConfirm( viewer.getControl().getShell(), title.toString(), message.toString() ) )
            {
                for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); )
                {
                    ProjectWrapper wrapper = ( ProjectWrapper ) iterator.next();
                    Project project = wrapper.getProject();

                    if ( project.getState() == ProjectState.OPEN )
                    {
                        // Closing the project before removing it.
                        projectsHandler.closeProject( project );
                    }

                    projectsHandler.removeProject( project );
                }
            }
        }
    }
View Full Code Here

    /**
     * Loads the projects saved in the Projects File.
     */
    public static void loadProjects()
    {
        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
        File projectsFile = getProjectsFile();
        boolean loadFailed = false;
        Project[] projects = null;

        // We try to load the projects file
        if ( projectsFile.exists() )
        {
            try
            {
                projects = ProjectsImporter.getProjects( new FileInputStream( projectsFile ), projectsFile
                    .getAbsolutePath() );
            }
            catch ( ProjectsImportException e )
            {
                loadFailed = true;
            }
            catch ( FileNotFoundException e )
            {
                loadFailed = true;
            }

            if ( !loadFailed )
            {
                // If everything went fine, we add the projects
                for ( Project project : projects )
                {
                    projectsHandler.addProject( project );
                }
            }
            else
            {
                // If something went wrong, we try to load the temp projects file
                File tempProjectsFile = getTempProjectsFile();

                if ( tempProjectsFile.exists() )
                {
                    try
                    {
                        projects = ProjectsImporter.getProjects( new FileInputStream( tempProjectsFile ), projectsFile
                            .getAbsolutePath() );

                        loadFailed = false;
                    }
                    catch ( ProjectsImportException e )
                    {
                        reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), e, Messages //$NON-NLS-1$
                            .getString( "PluginUtils.ProjectsLoadingError" ), Messages //$NON-NLS-1$
                            .getString( "PluginUtils.ErrorLoadingProject" ) ); //$NON-NLS-1$
                        return;
                    }
                    catch ( FileNotFoundException e )
                    {
                        reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), e, Messages //$NON-NLS-1$
                            .getString( "PluginUtils.ProjectsLoadingError" ), Messages //$NON-NLS-1$
                            .getString( "PluginUtils.ErrorLoadingProject" ) ); //$NON-NLS-1$
                        return;
                    }

                    // We add the projects
                    for ( Project project : projects )
                    {
                        projectsHandler.addProject( project );
                    }
                }
                else
                {
                    reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), null, Messages //$NON-NLS-1$
View Full Code Here

    /**
     * Loads the projects saved in the Projects File.
     */
    public static void loadProjects()
    {
        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
        File projectsFile = getProjectsFile();
        boolean loadFailed = false;
        Project[] projects = null;

        // We try to load the projects file
        if ( projectsFile.exists() )
        {
            try
            {
                projects = ProjectsImporter.getProjects( new FileInputStream( projectsFile ), projectsFile
                    .getAbsolutePath() );
            }
            catch ( ProjectsImportException e )
            {
                loadFailed = true;
            }
            catch ( FileNotFoundException e )
            {
                loadFailed = true;
            }

            if ( !loadFailed )
            {
                // If everything went fine, we add the projects
                for ( Project project : projects )
                {
                    projectsHandler.addProject( project );
                }
            }
            else
            {
                // If something went wrong, we try to load the temp projects file
                File tempProjectsFile = getTempProjectsFile();

                if ( tempProjectsFile.exists() )
                {
                    try
                    {
                        projects = ProjectsImporter.getProjects( new FileInputStream( tempProjectsFile ), projectsFile
                            .getAbsolutePath() );

                        loadFailed = false;
                    }
                    catch ( ProjectsImportException e )
                    {
                        reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), e, Messages //$NON-NLS-1$
                            .getString( "PluginUtils.ProjectsLoadingError" ), Messages //$NON-NLS-1$
                            .getString( "PluginUtils.ErrorLoadingProject" ) ); //$NON-NLS-1$
                        return;
                    }
                    catch ( FileNotFoundException e )
                    {
                        reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), e, Messages //$NON-NLS-1$
                            .getString( "PluginUtils.ProjectsLoadingError" ), Messages //$NON-NLS-1$
                            .getString( "PluginUtils.ErrorLoadingProject" ) ); //$NON-NLS-1$
                        return;
                    }

                    // We add the projects
                    for ( Project project : projects )
                    {
                        projectsHandler.addProject( project );
                    }
                }
                else
                {
                    reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), null, Messages //$NON-NLS-1$
View Full Code Here

    /**
     * Loads the projects saved in the Projects File.
     */
    public static void loadProjects()
    {
        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
        File projectsFile = getProjectsFile();
        boolean loadFailed = false;
        Project[] projects = null;

        // We try to load the projects file
        if ( projectsFile.exists() )
        {
            try
            {
                projects = ProjectsImporter.getProjects( new FileInputStream( projectsFile ), projectsFile
                    .getAbsolutePath() );
            }
            catch ( ProjectsImportException e )
            {
                loadFailed = true;
            }
            catch ( FileNotFoundException e )
            {
                loadFailed = true;
            }

            if ( !loadFailed )
            {
                // If everything went fine, we add the projects
                for ( Project project : projects )
                {
                    projectsHandler.addProject( project );
                }
            }
            else
            {
                // If something went wrong, we try to load the temp projects file
                File tempProjectsFile = getTempProjectsFile();

                if ( tempProjectsFile.exists() )
                {
                    try
                    {
                        projects = ProjectsImporter.getProjects( new FileInputStream( tempProjectsFile ), projectsFile
                            .getAbsolutePath() );

                        loadFailed = false;
                    }
                    catch ( ProjectsImportException e )
                    {
                        reportError( "An error occured when loading the projects.", e, "Projects Loading Error",
                            "An error occured when loading the projects." );
                        return;
                    }
                    catch ( FileNotFoundException e )
                    {
                        reportError( "An error occured when loading the projects.", e, "Projects Loading Error",
                            "An error occured when loading the projects." );
                        return;
                    }

                    // We add the projects
                    for ( Project project : projects )
                    {
                        projectsHandler.addProject( project );
                    }
                }
                else
                {
                    reportError( "An error occured when loading the projects.", null, "Projects Loading Error",
View Full Code Here

    /* (non-Javadoc)
     * @see org.eclipse.jface.action.Action#run()
     */
    public void run()
    {
        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();

        if ( !selection.isEmpty() )
        {
            MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                SWT.YES | SWT.NO | SWT.ICON_QUESTION );
            int count = selection.size();
            if ( count == 1 )
            {
                ProjectWrapper wrapper = ( ProjectWrapper ) selection.getFirstElement();
                messageBox.setMessage( "Are you sure you want to delete project '" + wrapper.getProject().getName()
                    + "'?" );
            }
            else
            {
                messageBox.setMessage( "Are you sure you want to delete these " + count + " projects?" );
            }
            if ( messageBox.open() == SWT.YES )
            {
                for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); )
                {
                    ProjectWrapper wrapper = ( ProjectWrapper ) iterator.next();
                    Project project = wrapper.getProject();

                    if ( project.getState() == ProjectState.OPEN )
                    {
                        // Closing the project before removing it.
                        projectsHandler.closeProject( project );
                    }

                    projectsHandler.removeProject( project );
                }
            }
        }

    }
View Full Code Here

                }
            }
        }
        //        }

        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
        projectsHandler.addProject( project );
        projectsHandler.openProject( project );

        return true;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.schemaeditor.controller.ProjectsHandler

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.