0506ebfa8f32813d8e77e53108bc4f783bb3bb1a
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / media / MediaViewSwitch.java
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 /**
16 * Adds a switch to a section with an {@link ITogglableMediaElement}
17 * to allow switching between simple and advanced media view
18 * @author pplitzner
19 * @date Jun 29, 2015
20 *
21 */
22 public class MediaViewSwitch {
23
24 /**
25 * Creates an {@link IAction} for the given {@link ITogglableMediaElement}
26 * that switches between the two states of the element.
27 */
28 public static IAction createSwitch(final ITogglableMediaElement togglableMediaElement) {
29 final String label = "Change View Type";
30
31 Action switchAction = new Action(label, IAction.AS_PUSH_BUTTON) {
32 @Override
33 public void run() {
34 if(togglableMediaElement!=null){
35 togglableMediaElement.toggleAdvancedMediaView();
36 }
37 }
38 };
39 switchAction.setToolTipText(label);
40
41 return switchAction;
42 }
43 }