spritey.ui.actions.CollapseAllAction.java Source code

Java tutorial

Introduction

Here is the source code for spritey.ui.actions.CollapseAllAction.java

Source

/**
 * This source file is part of Spritey - the sprite sheet creator.
 * 
 * Copyright 2011 Maksym Bykovskyy.
 * 
 * Spritey is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * Spritey is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * Spritey. If not, see <http://www.gnu.org/licenses/>.
 */
package spritey.ui.actions;

import static spritey.ui.Application.COLLAPSE_ALL_IMG_ID;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.graphics.Image;

import spritey.ui.Application;
import spritey.ui.Messages;

/**
 * Action for collapsing tree items.
 */
public class CollapseAllAction extends ViewerAction {

    public CollapseAllAction(TreeViewer viewer) {
        super(viewer);
        Image image = Application.getImageRegistry().get(COLLAPSE_ALL_IMG_ID);
        setImageDescriptor(ImageDescriptor.createFromImage(image));
        setToolTipText(Messages.ADD_SPRITES_COLLAPSE_ALL);
        setText(Messages.ADD_SPRITES_COLLAPSE_ALL);
    }

    @Override
    public void run() {
        ((TreeViewer) getViewer()).collapseAll();
    }

}