- moved campanula package to parent package
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / campanula / ToggleableTextField.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;
11
12 import org.eclipse.swt.SWT;
13 import org.eclipse.swt.widgets.Button;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Display;
16 import org.eclipse.swt.widgets.Text;
17 import org.eclipse.ui.forms.widgets.FormToolkit;
18 import org.eclipse.ui.forms.widgets.TableWrapData;
19 import org.eclipse.ui.forms.widgets.TableWrapLayout;
20
21 /**
22 * @author pplitzner
23 * @date 14.08.2013
24 *
25 */
26 public class ToggleableTextField extends Composite {
27 private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
28 private Text text;
29 private Button editButton;
30
31 /**
32 * Create the composite.
33 * @param parent
34 * @param style
35 */
36 public ToggleableTextField(Composite parent, int style) {
37 super(parent, style);
38 {
39 TableWrapLayout tableWrapLayout = new TableWrapLayout();
40 tableWrapLayout.numColumns = 2;
41 tableWrapLayout.verticalSpacing = 0;
42 tableWrapLayout.topMargin = 0;
43 tableWrapLayout.rightMargin = 0;
44 tableWrapLayout.leftMargin = 0;
45 tableWrapLayout.horizontalSpacing = 0;
46 tableWrapLayout.bottomMargin = 0;
47 setLayout(tableWrapLayout);
48 }
49
50 text = formToolkit.createText(this, "New Text", SWT.WRAP);
51 text.setText("");
52 TableWrapData twd_text = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1);
53 twd_text.grabVertical = true;
54 text.setLayoutData(twd_text);
55
56 editButton = formToolkit.createButton(this, "Edit", SWT.TOGGLE);
57
58 }
59
60 @Override
61 protected void checkSubclass() {
62 // Disable the check that prevents subclassing of SWT components
63 }
64
65 public Text getText() {
66 return text;
67 }
68 public Button getEditButton() {
69 return editButton;
70 }
71 }