merged campanula branch to trunk. Main features are: BioCase Query via Imports, Deriv...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / campanula / basicFields / EntityCollectionElement.java
1 // $Id$
2 /**
3 * Copyright (C) 2013 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.campanula.basicFields;
11
12 import org.eclipse.jface.action.Action;
13 import org.eclipse.jface.action.IAction;
14 import org.eclipse.jface.action.ToolBarManager;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Display;
18 import org.eclipse.swt.widgets.Label;
19 import org.eclipse.swt.widgets.ToolBar;
20 import org.eclipse.ui.forms.widgets.ExpandableComposite;
21 import org.eclipse.ui.forms.widgets.FormToolkit;
22 import org.eclipse.wb.swt.ResourceManager;
23 import org.eclipse.wb.swt.SWTResourceManager;
24
25 /**
26 * @author pplitzner
27 * @date 16.08.2013
28 *
29 */
30 public class EntityCollectionElement extends ExpandableComposite {
31 private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
32
33 /**
34 * Create the composite.
35 * @param parent
36 * @param style
37 */
38 public EntityCollectionElement(Composite parent, int style) {
39 super(parent, style);
40 setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
41 setExpanded(true);
42
43 ToolBar toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT);
44 setTextClient(toolBar);
45
46 Label label = formToolkit.createLabel(this, "", SWT.NONE);
47 setClient(label);
48
49 ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
50
51 Action addAction = new Action("add", IAction.AS_PUSH_BUTTON){
52 /* (non-Javadoc)
53 * @see org.eclipse.jface.action.Action#run()
54 */
55 @Override
56 public void run() {
57 // ELEMENT element = createNewElement();
58 // if(element != null){
59 // addElement(element);
60 // if(! getSection().isExpanded()) {
61 // getSection().setExpanded(true);
62 // }
63 // internalUpdateSection(true);
64 // }
65 }
66 };
67 addAction.setImageDescriptor(ResourceManager.getPluginImageDescriptor("eu.etaxonomy.taxeditor.store", "icons/add_no_bg2.gif"));
68 // addAction.setToolTipText(getTooltipString());
69
70 toolBarManager.add(addAction);
71
72 }
73
74 @Override
75 protected void checkSubclass() {
76 // Disable the check that prevents subclassing of SWT components
77 }
78
79 }