Project

General

Profile

Download (1.35 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.section.media;
11

    
12
import org.eclipse.jface.action.Action;
13
import org.eclipse.jface.action.IAction;
14

    
15
import eu.etaxonomy.taxeditor.model.ImageResources;
16

    
17
/**
18
 * Adds a switch to a section with an {@link ITogglableMediaElement}
19
 * to allow switching between simple and advanced media view
20
 * @author pplitzner
21
 * @date Jun 29, 2015
22
 *
23
 */
24
public class MediaViewSwitch {
25

    
26
    /**
27
     * Creates an {@link IAction} for the given {@link ITogglableMediaElement}
28
     * that switches between the two states of the element.
29
     */
30
    public static IAction createSwitch(final ITogglableMediaElement togglableMediaElement) {
31
        final String label = "Change View Type";
32

    
33
        Action switchAction = new Action(label, ImageResources.getImageDescriptor(ImageResources.SWITCH_VIEW_TYPE)) {
34
            @Override
35
            public void run() {
36
                if(togglableMediaElement!=null){
37
                    togglableMediaElement.toggleAdvancedMediaView();
38
                }
39
            }
40
        };
41
        switchAction.setToolTipText(label);
42

    
43
        return switchAction;
44
    }
45
}
(10-10/10)