KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > ldifeditor > wizards > NewLdifFileWizard


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.ldifeditor.wizards;
22
23
24 import org.apache.directory.ldapstudio.ldifeditor.editor.LdifEditor;
25 import org.apache.directory.ldapstudio.ldifeditor.editor.NonExistingLdifEditorInput;
26 import org.eclipse.jface.viewers.IStructuredSelection;
27 import org.eclipse.jface.wizard.Wizard;
28 import org.eclipse.ui.IEditorInput;
29 import org.eclipse.ui.INewWizard;
30 import org.eclipse.ui.IWorkbench;
31 import org.eclipse.ui.IWorkbenchPage;
32 import org.eclipse.ui.IWorkbenchWindow;
33 import org.eclipse.ui.PartInitException;
34
35
36 /**
37  * The NewLdifFileWizard is used to add a "New LDIF" action to the platforms
38  * "New..." menu. It just opens an editor with a dummy LDIF editor input.
39  *
40  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
41  * @version $Rev$, $Date$
42  */

43
44 public class NewLdifFileWizard extends Wizard implements INewWizard
45 {
46
47     /** The window. */
48     private IWorkbenchWindow window;
49
50
51     /**
52      * Creates a new instance of NewLdifFileWizard.
53      */

54     public NewLdifFileWizard()
55     {
56     }
57
58
59     /**
60      * {@inheritDoc}
61      */

62     public void init( IWorkbench workbench, IStructuredSelection selection )
63     {
64         window = workbench.getActiveWorkbenchWindow();
65     }
66
67
68     /**
69      * {@inheritDoc}
70      */

71     public void dispose()
72     {
73         window = null;
74     }
75
76
77     /**
78      * Gets the id.
79      *
80      * @return the id
81      */

82     public static String JavaDoc getId()
83     {
84         return NewLdifFileWizard.class.getName();
85     }
86
87
88     /**
89      * {@inheritDoc}
90      */

91     public boolean performFinish()
92     {
93         IEditorInput input = new NonExistingLdifEditorInput();
94         String JavaDoc editorId = LdifEditor.getId();
95
96         try
97         {
98             IWorkbenchPage page = window.getActivePage();
99             page.openEditor( input, editorId );
100         }
101         catch ( PartInitException e )
102         {
103             return false;
104         }
105         return true;
106     }
107
108 }
109
Popular Tags