Merge branch 'release/4.6.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / configurator / ConfiguratorComposite.java
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.dialog.configurator;
10
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.events.DisposeEvent;
13 import org.eclipse.swt.events.DisposeListener;
14 import org.eclipse.swt.layout.FillLayout;
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Display;
17 import org.eclipse.ui.forms.events.ExpansionEvent;
18 import org.eclipse.ui.forms.events.IExpansionListener;
19 import org.eclipse.ui.forms.widgets.FormToolkit;
20 import org.eclipse.ui.forms.widgets.Section;
21
22 /**
23 * @author pplitzner
24 * @date Feb 16, 2015
25 *
26 */
27 public class ConfiguratorComposite extends Composite implements IExpansionListener{
28
29 private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
30 private final Section sctnConfigure;
31 /**
32 * Create the composite.
33 * @param parent
34 * @param style
35 */
36 public ConfiguratorComposite(final Composite parent, int style) {
37 super(parent, SWT.NONE);
38
39 addDisposeListener(new DisposeListener() {
40 @Override
41 public void widgetDisposed(DisposeEvent e) {
42 toolkit.dispose();
43 }
44 });
45 toolkit.paintBordersFor(this);
46 setLayout(new FillLayout(SWT.HORIZONTAL));
47
48 sctnConfigure = toolkit.createSection(this, Section.CLIENT_INDENT | Section.TWISTIE);
49 sctnConfigure.addExpansionListener(this);
50 sctnConfigure.setBackground(getBackground());
51 toolkit.paintBordersFor(sctnConfigure);
52 sctnConfigure.setText("Configure");
53
54
55 }
56
57
58 public void addConfiguratorComposite(Composite configuratorComposite){
59 toolkit.paintBordersFor(configuratorComposite);
60 sctnConfigure.setClient(configuratorComposite);
61 }
62
63 @Override
64 public void expansionStateChanged(ExpansionEvent e) {
65 getShell().setSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
66 }
67 @Override
68 public void expansionStateChanging(ExpansionEvent e) {
69 }
70 public Section getSectionConfigure() {
71 return sctnConfigure;
72 }
73 }