KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > proxy > controller > ProxyViewController


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 package org.apache.directory.ldapstudio.proxy.controller;
21
22
23 import org.apache.directory.ldapstudio.proxy.controller.actions.ConnectAction;
24 import org.apache.directory.ldapstudio.proxy.controller.actions.DisconnectAction;
25 import org.apache.directory.ldapstudio.proxy.view.ProxyView;
26 import org.eclipse.jface.action.IToolBarManager;
27
28
29 /**
30  * This class implements the controller for the Proxy View.
31  *
32  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
33  * @version $Rev$, $Date$
34  */

35 public class ProxyViewController
36 {
37     /** The associated view */
38     private ProxyView view;
39
40     // Actions
41
private ConnectAction connect;
42     private DisconnectAction disconnect;
43
44
45     /**
46      * Creates a new instance of ProxyViewController.
47      *
48      * @param view
49      * the associated view
50      */

51     public ProxyViewController( ProxyView view )
52     {
53         this.view = view;
54
55         initActions();
56         initToolbar();
57     }
58
59
60     /**
61      * Initializes the actions.
62      */

63     private void initActions()
64     {
65         connect = new ConnectAction( view );
66         disconnect = new DisconnectAction( view );
67     }
68
69
70     /**
71      * Initializes the toolbar.
72      */

73     private void initToolbar()
74     {
75         IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
76         toolbar.add( connect );
77         toolbar.add( disconnect );
78     }
79
80
81     /**
82      * Enables/Disables Actions.
83      */

84     private void updateActions()
85     {
86         if ( view.getLdapProxy() == null )
87         {
88             connect.setEnabled( true );
89             disconnect.setEnabled( false );
90         }
91         else
92         {
93             connect.setEnabled( false );
94             disconnect.setEnabled( true );
95         }
96     }
97 }
98
Popular Tags