KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > cheatsheets > views > CheatSheetExpandRestoreAction


1 /*******************************************************************************
2  * Copyright (c) 2002, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.cheatsheets.views;
12
13
14 import org.eclipse.core.runtime.IPath;
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.ui.internal.cheatsheets.*;
18
19 /**
20  * Action used to enable / disable method filter properties
21  */

22 public class CheatSheetExpandRestoreAction extends Action {
23     private CheatSheetViewer viewer;
24     private boolean collapsed = false;
25
26     private ImageDescriptor collapseImage;
27     private ImageDescriptor disabledImage;
28
29     public CheatSheetExpandRestoreAction(String JavaDoc title, boolean initValue, CheatSheetViewer viewer) {
30         super(title);
31         this.viewer = viewer;
32
33         IPath path = CheatSheetPlugin.ICONS_PATH.append(CheatSheetPlugin.T_ELCL).append("collapse_expand_all.gif");//$NON-NLS-1$
34
collapseImage = CheatSheetPlugin.createImageDescriptor(CheatSheetPlugin.getPlugin().getBundle(), path);
35         path = CheatSheetPlugin.ICONS_PATH.append(CheatSheetPlugin.T_DLCL).append("collapse_expand_all.gif");//$NON-NLS-1$
36
disabledImage = CheatSheetPlugin.createImageDescriptor(CheatSheetPlugin.getPlugin().getBundle(), path);
37         setDisabledImageDescriptor(disabledImage);
38         setImageDescriptor(collapseImage);
39         setCollapsed(initValue);
40     }
41     
42     /*
43      * @see Action#actionPerformed
44      */

45     public void run() {
46         viewer.toggleExpandRestore();
47     }
48     
49     public boolean isCollapsed() {
50         return collapsed;
51     }
52
53     public void setCollapsed(boolean value) {
54         super.setChecked(value);
55         collapsed = value;
56         if(value) {
57             setToolTipText(Messages.RESTORE_ALL_TOOLTIP);
58         } else {
59             setToolTipText(Messages.COLLAPSE_ALL_BUT_CURRENT_TOOLTIP);
60         }
61     }
62 }
63
Popular Tags