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.actions;
021
022
023 import org.apache.directory.studio.apacheds.ApacheDsPlugin;
024 import org.apache.directory.studio.apacheds.ApacheDsPluginConstants;
025 import org.apache.directory.studio.apacheds.wizards.NewServerWizard;
026 import org.eclipse.jface.action.Action;
027 import org.eclipse.jface.action.IAction;
028 import org.eclipse.jface.viewers.ISelection;
029 import org.eclipse.jface.viewers.StructuredSelection;
030 import org.eclipse.jface.wizard.WizardDialog;
031 import org.eclipse.ui.IWorkbenchWindow;
032 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
033 import org.eclipse.ui.PlatformUI;
034
035
036 /**
037 * This class implements the new server action.
038 *
039 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
040 * @version $Rev$, $Date$
041 */
042 public class NewServerAction extends Action implements IWorkbenchWindowActionDelegate
043 {
044 /**
045 * Creates a new instance of NewServerAction.
046 */
047 public NewServerAction()
048 {
049 super( Messages.getString( "NewServerAction.NewServer" ) ); //$NON-NLS-1$
050 setId( ApacheDsPluginConstants.CMD_NEW_SERVER );
051 setActionDefinitionId( ApacheDsPluginConstants.CMD_NEW_SERVER );
052 setToolTipText( Messages.getString( "NewServerAction.NewServerToolTip" ) ); //$NON-NLS-1$
053 setImageDescriptor( ApacheDsPlugin.getDefault().getImageDescriptor( ApacheDsPluginConstants.IMG_SERVER_NEW ) );
054 }
055
056
057 /* (non-Javadoc)
058 * @see org.eclipse.jface.action.Action#run()
059 */
060 public void run()
061 {
062 // Instantiates and initializes the wizard
063 NewServerWizard wizard = new NewServerWizard();
064 wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY );
065 // Instantiates the wizard container with the wizard and opens it
066 WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard );
067 dialog.create();
068 dialog.open();
069 }
070
071
072 /* (non-Javadoc)
073 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
074 */
075 public void run( IAction action )
076 {
077 run();
078 }
079
080
081 /* (non-Javadoc)
082 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
083 */
084 public void dispose()
085 {
086 // Nothing to do
087 }
088
089
090 /* (non-Javadoc)
091 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
092 */
093 public void init( IWorkbenchWindow window )
094 {
095 // Nothing to do
096 }
097
098
099 /* (non-Javadoc)
100 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
101 */
102 public void selectionChanged( IAction action, ISelection selection )
103 {
104 // Nothing to do
105 }
106 }