KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > schemas > controller > actions > HideObjectClassesAction


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.schemas.controller.actions;
21
22
23 import org.apache.directory.ldapstudio.schemas.Activator;
24 import org.apache.directory.ldapstudio.schemas.Messages;
25 import org.apache.directory.ldapstudio.schemas.PluginConstants;
26 import org.eclipse.jface.action.Action;
27 import org.eclipse.jface.viewers.TreeViewer;
28 import org.eclipse.ui.plugin.AbstractUIPlugin;
29
30
31 /**
32  * This class implements the Hide Object Classes Action for the Schema Elements View.
33  *
34  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
35  * @version $Rev$, $Date$
36  */

37 public class HideObjectClassesAction extends Action
38 {
39     /** The String for storing the checked state of the action */
40     public static final String JavaDoc HIDE_OBJECT_CLASSES_DS_KEY = HideObjectClassesAction.class.getName()
41         + ".dialogsettingkey"; //$NON-NLS-1$
42

43     /** The associated viewer */
44     private TreeViewer viewer;
45
46
47     /**
48      * Creates a new instance of HideObjectClassesAction.
49      *
50      * @param viewer
51      * the associated viewer
52      */

53     public HideObjectClassesAction( TreeViewer viewer )
54     {
55         super( Messages.getString( "HideObjectClassesAction.Hide_Object_Classes" ), AS_CHECK_BOX ); //$NON-NLS-1$
56
setToolTipText( getText() );
57         setId( PluginConstants.CMD_HIDE_OBJECT_CLASSES );
58         setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
59             PluginConstants.IMG_HIDE_OBJECT_CLASSES ) );
60         setEnabled( true );
61         this.viewer = viewer;
62
63         // Setting up the default key value (if needed)
64
if ( Activator.getDefault().getDialogSettings().get( HIDE_OBJECT_CLASSES_DS_KEY ) == null )
65         {
66             Activator.getDefault().getDialogSettings().put( HIDE_OBJECT_CLASSES_DS_KEY, false );
67         }
68
69         // Setting state from the dialog settings
70
setChecked( Activator.getDefault().getDialogSettings().getBoolean( HIDE_OBJECT_CLASSES_DS_KEY ) );
71     }
72
73
74     /* (non-Javadoc)
75      * @see org.eclipse.jface.action.Action#run()
76      */

77     public void run()
78     {
79         setChecked( isChecked() );
80         Activator.getDefault().getDialogSettings().put( HIDE_OBJECT_CLASSES_DS_KEY, isChecked() );
81
82         viewer.refresh();
83     }
84 }
85
Popular Tags