Project

General

Profile

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

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

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

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

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

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

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