001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    package org.apache.directory.studio.apacheds.wizards;
021    
022    
023    import org.apache.directory.studio.apacheds.ApacheDsPluginUtils;
024    import org.apache.directory.studio.apacheds.model.Server;
025    import org.apache.directory.studio.apacheds.model.ServersHandler;
026    import org.eclipse.jface.viewers.IStructuredSelection;
027    import org.eclipse.jface.wizard.Wizard;
028    import org.eclipse.ui.INewWizard;
029    import org.eclipse.ui.IWorkbench;
030    
031    
032    /**
033     * This class implements the new server wizard.
034     *
035     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036     * @version $Rev$, $Date$
037     */
038    public class NewServerWizard extends Wizard implements INewWizard
039    {
040        /** The wizard page */
041        private NewServerWizardPage page;
042    
043    
044        /* (non-Javadoc)
045         * @see org.eclipse.jface.wizard.Wizard#addPages()
046         */
047        public void addPages()
048        {
049            page = new NewServerWizardPage();
050            addPage( page );
051        }
052    
053    
054        /* (non-Javadoc)
055         * @see org.eclipse.jface.wizard.Wizard#performFinish()
056         */
057        public boolean performFinish()
058        {
059            // Creating the new server
060            Server server = new Server( page.getServerName() );
061    
062            // Adding the new server to the servers handler
063            ServersHandler.getDefault().addServer( server );
064    
065            // Creating the complete folder structure for the new server
066            ApacheDsPluginUtils.createNewServerFolder( server.getId() );
067    
068            return true;
069        }
070    
071    
072        /* (non-Javadoc)
073         * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
074         */
075        public void init( IWorkbench workbench, IStructuredSelection selection )
076        {
077            setNeedsProgressMonitor( false );
078        }
079    }