KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > views > modificationlogs > ModificationLogsViewActionGroup


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.views.modificationlogs;
22
23
24 import java.util.HashMap JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.Map JavaDoc;
27
28 import org.apache.directory.ldapstudio.browser.ui.actions.proxy.ModificationLogsViewActionProxy;
29 import org.eclipse.jface.action.IAction;
30 import org.eclipse.jface.action.IMenuListener;
31 import org.eclipse.jface.action.IMenuManager;
32 import org.eclipse.jface.action.Separator;
33 import org.eclipse.jface.text.source.SourceViewer;
34 import org.eclipse.ui.IActionBars;
35
36
37 /**
38  * The ModificationLogsViewActionGroup manages all the actions of the modification logs view.
39  *
40  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
41  * @version $Rev$, $Date$
42  */

43 public class ModificationLogsViewActionGroup implements IMenuListener
44 {
45
46     /** The view. */
47     private ModificationLogsView view;
48
49     /** The Constant olderAction. */
50     private static final String JavaDoc olderAction = "olderAction";
51
52     /** The Constant newerAction. */
53     private static final String JavaDoc newerAction = "newerAction";
54
55     /** The Constant refreshAction. */
56     private static final String JavaDoc refreshAction = "refreshAction";
57
58     /** The modification logs view action map. */
59     private Map JavaDoc<String JavaDoc, ModificationLogsViewActionProxy> modificationLogsViewActionMap;
60
61
62     /**
63      * Creates a new instance of ModificationLogsViewActionGroup.
64      *
65      * @param view the modification logs view
66      */

67     public ModificationLogsViewActionGroup( ModificationLogsView view )
68     {
69         this.view = view;
70         SourceViewer viewer = this.view.getMainWidget().getSourceViewer();
71
72         modificationLogsViewActionMap = new HashMap JavaDoc<String JavaDoc, ModificationLogsViewActionProxy>();
73         modificationLogsViewActionMap.put( olderAction, new ModificationLogsViewActionProxy( viewer, new OlderAction(
74             view ) ) );
75         modificationLogsViewActionMap.put( newerAction, new ModificationLogsViewActionProxy( viewer, new NewerAction(
76             view ) ) );
77         modificationLogsViewActionMap.put( refreshAction, new ModificationLogsViewActionProxy( viewer,
78             new RefreshAction( view ) ) );
79     }
80
81
82     /**
83      * Disposes thes action group.
84      */

85     public void dispose()
86     {
87         if ( view != null )
88         {
89             for ( Iterator JavaDoc it = modificationLogsViewActionMap.keySet().iterator(); it.hasNext(); )
90             {
91                 String JavaDoc key = ( String JavaDoc ) it.next();
92                 ModificationLogsViewActionProxy action = ( ModificationLogsViewActionProxy ) modificationLogsViewActionMap
93                     .get( key );
94                 action.dispose();
95                 action = null;
96                 it.remove();
97             }
98             modificationLogsViewActionMap.clear();
99             modificationLogsViewActionMap = null;
100
101             view = null;
102         }
103     }
104
105
106     /**
107      * Fill the action bars.
108      *
109      * @param actionBars the action bars
110      */

111     public void fillActionBars( IActionBars actionBars )
112     {
113         // Tool Bar
114
actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get( refreshAction ) );
115         actionBars.getToolBarManager().add( new Separator() );
116         actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get( olderAction ) );
117         actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get( newerAction ) );
118     }
119
120
121     /**
122      * {@inheritDoc}
123      */

124     public void menuAboutToShow( IMenuManager menuManager )
125     {
126     }
127
128
129     /**
130      * Propagates the input to all actions.
131      *
132      * @param input the input
133      */

134     public void setInput( ModificationLogsViewInput input )
135     {
136         for ( Iterator JavaDoc it = modificationLogsViewActionMap.values().iterator(); it.hasNext(); )
137         {
138             ModificationLogsViewActionProxy action = ( ModificationLogsViewActionProxy ) it.next();
139             action.inputChanged( input );
140         }
141     }
142
143 }
144
Popular Tags