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

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


    /* (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( NLS
                        .bind(
                            Messages.getString( "DeleteProjectAction.SureToDeleteProject" ), new String[] { wrapper.getProject().getName() } ) ); //$NON-NLS-1$
            }
            else
            {
                messageBox.setMessage( NLS.bind(
                    Messages.getString( "DeleteProjectAction.SureToDeleteProjects" ), new Object[] { count } ) ); //$NON-NLS-1$
            }
            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


    /**
     * 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
                            .getString( "PluginUtils.ProjectsLoadingError" ), Messages
                            .getString( "PluginUtils.ErrorLoadingProject" ) );
                        return;
                    }
                    catch ( FileNotFoundException e )
                    {
                        reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), e, Messages
                            .getString( "PluginUtils.ProjectsLoadingError" ), Messages
                            .getString( "PluginUtils.ErrorLoadingProject" ) );
                        return;
                    }

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

                    }
                }
            }
        }

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

        return true;
    }
View Full Code Here

                    }
                }
            }
//        }

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

        return true;
    }
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

    /**
     * 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.