Remove duplicate code for advanced media view (#4862)
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / media / AbstractTogglableMediaDetailsSection.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 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
11 package eu.etaxonomy.taxeditor.ui.section.media;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.jface.action.ToolBarManager;
16 import org.eclipse.jface.viewers.ISelectionProvider;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.widgets.Control;
19
20 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
21 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
24
25 /**
26 *
27 * @author pplitzner
28 * @date Jun 25, 2015
29 *
30 */
31 public abstract class AbstractTogglableMediaDetailsSection<ENTITY> extends AbstractCdmDetailSection<ENTITY> {
32
33 private ITogglableMediaElement togglableMediaElement;
34
35 public AbstractTogglableMediaDetailsSection(CdmFormFactory formFactory, ConversationHolder conversation,
36 ICdmFormElement parentElement,
37 ISelectionProvider selectionProvider, int style) {
38 super(formFactory, conversation, parentElement, selectionProvider, style);
39 }
40
41 @Override
42 protected Control createToolbar() {
43 ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
44
45 final String label = "Change View Type";
46
47 Action addAction = new Action(label, IAction.AS_PUSH_BUTTON) {
48 @Override
49 public void run() {
50 if(togglableMediaElement!=null){
51 togglableMediaElement.toggleAdvancedMediaView();
52 }
53 }
54 };
55 addAction.setToolTipText(label);
56
57 toolBarManager.add(addAction);
58
59 return toolBarManager.createControl(this);
60 }
61
62 public void setTogglableMediaElement(ITogglableMediaElement togglableMediaElement) {
63 this.togglableMediaElement = togglableMediaElement;
64 }
65
66 public ITogglableMediaElement getTogglableMediaElement() {
67 return togglableMediaElement;
68 }
69
70 }