KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > actions > NewEntryAction


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.browser.ui.actions;
22
23
24 import org.apache.directory.ldapstudio.browser.common.actions.BrowserAction;
25 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
26 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
27 import org.apache.directory.ldapstudio.browser.ui.wizards.NewEntryWizard;
28 import org.eclipse.jface.resource.ImageDescriptor;
29 import org.eclipse.jface.viewers.IStructuredSelection;
30 import org.eclipse.jface.wizard.WizardDialog;
31 import org.eclipse.ui.IWorkbenchWindow;
32
33
34 /**
35  * This Action lauches the New Entry Wizard.
36  *
37  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
38  * @version $Rev$, $Date$
39  */

40 public class NewEntryAction extends BrowserAction
41 {
42     private IWorkbenchWindow window;
43
44
45     /**
46      * Creates a new instance of NewEntryAction.
47      */

48     public NewEntryAction()
49     {
50     }
51
52
53     /**
54      * Creates a new instance of NewEntryAction.
55      *
56      * @param window
57      * the associated Window
58      */

59     public NewEntryAction( IWorkbenchWindow window )
60     {
61         super();
62         this.window = window;
63     }
64
65
66     /**
67      * {@inheritDoc}
68      */

69     public void dispose()
70     {
71         super.dispose();
72         this.window = null;
73     }
74
75
76     /**
77      * {@inheritDoc}
78      */

79     public void init( IWorkbenchWindow window )
80     {
81         super.init( window );
82         this.window = window;
83     }
84
85
86     /**
87      * {@inheritDoc}
88      */

89     public void run()
90     {
91         NewEntryWizard wizard = new NewEntryWizard();
92
93         wizard.init( this.window.getWorkbench(), ( IStructuredSelection ) this.window.getSelectionService()
94             .getSelection() );
95         WizardDialog dialog = new WizardDialog( getShell(), wizard );
96         dialog.setBlockOnOpen( true );
97         dialog.create();
98         dialog.open();
99     }
100
101
102     /**
103      * {@inheritDoc}
104      */

105     public String JavaDoc getText()
106     {
107         return "New Entry...";
108     }
109
110
111     /**
112      * {@inheritDoc}
113      */

114     public ImageDescriptor getImageDescriptor()
115     {
116         return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_ADD );
117     }
118
119
120     /**
121      * {@inheritDoc}
122      */

123     public String JavaDoc getCommandId()
124     {
125         return null;
126     }
127
128
129     /**
130      * {@inheritDoc}
131      */

132     public boolean isEnabled()
133     {
134         return true;
135     }
136 }
137
Popular Tags