KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > common > widgets > entryeditor > ShowQuickFilterAction


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.common.widgets.entryeditor;
22
23
24 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
25 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
26 import org.eclipse.jface.action.Action;
27 import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
28
29
30 /**
31  * This action shows/hides the instant search.
32  *
33  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
34  * @version $Rev$, $Date$
35  */

36 public class ShowQuickFilterAction extends Action
37 {
38
39     /** The Constant SHOW_QUICKFILTER_DIALOGSETTING_KEY. */
40     public static final String JavaDoc SHOW_QUICKFILTER_DIALOGSETTING_KEY = ShowQuickFilterAction.class.getName()
41         + ".showQuickFilter";
42
43     /** The quick filter widget. */
44     private EntryEditorWidgetQuickFilterWidget quickFilterWidget;
45
46
47     /**
48      * Creates a new instance of ShowQuickFilterAction.
49      *
50      * @param quickFilterWidget the quick filter widget
51      */

52     public ShowQuickFilterAction( EntryEditorWidgetQuickFilterWidget quickFilterWidget )
53     {
54         super( "Show Quick Filter", AS_CHECK_BOX );
55         setToolTipText( "Show Quick Filter" );
56         setImageDescriptor( BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_FILTER ) );
57         setActionDefinitionId( IWorkbenchActionDefinitionIds.FIND_REPLACE );
58         setEnabled( true );
59
60         this.quickFilterWidget = quickFilterWidget;
61
62         if ( BrowserCommonActivator.getDefault().getDialogSettings().get( SHOW_QUICKFILTER_DIALOGSETTING_KEY ) == null )
63         {
64             BrowserCommonActivator.getDefault().getDialogSettings().put( SHOW_QUICKFILTER_DIALOGSETTING_KEY, false );
65         }
66
67         // call the super implementation here because the local implementation
68
// does nothing.
69
super.setChecked( BrowserCommonActivator.getDefault().getDialogSettings().getBoolean(
70             SHOW_QUICKFILTER_DIALOGSETTING_KEY ) );
71         quickFilterWidget.setActive( isChecked() );
72     }
73
74
75     /**
76      * {@inheritDoc}
77      *
78      * This implementation toggles the checked state and
79      * activates or deactivates the quick filter accordingly.
80      */

81     public void run()
82     {
83         boolean checked = isChecked();
84         super.setChecked( !checked );
85
86         BrowserCommonActivator.getDefault().getDialogSettings().put( SHOW_QUICKFILTER_DIALOGSETTING_KEY, isChecked() );
87
88         if ( quickFilterWidget != null )
89         {
90             quickFilterWidget.setActive( isChecked() );
91         }
92     }
93
94
95     /**
96      * {@inheritDoc}
97      *
98      * This implementation does nothing. Toggling of the checked state is done within the run() method.
99      */

100     public void setChecked( boolean checked )
101     {
102     }
103
104
105     /**
106      * Disposes this action.
107      */

108     public void dispose()
109     {
110         quickFilterWidget = null;
111     }
112
113 }
114
Popular Tags