1 package eu
.etaxonomy
.taxeditor
.view
.nameviewersupport
;
3 import org
.apache
.log4j
.Logger
;
4 import org
.eclipse
.jface
.text
.TextViewer
;
5 import org
.eclipse
.swt
.SWT
;
6 import org
.eclipse
.swt
.graphics
.Font
;
7 import org
.eclipse
.swt
.graphics
.Image
;
8 import org
.eclipse
.swt
.widgets
.Composite
;
9 import org
.eclipse
.swt
.widgets
.Display
;
10 import org
.eclipse
.swt
.widgets
.Label
;
11 import org
.eclipse
.swt
.widgets
.Menu
;
12 import org
.eclipse
.ui
.forms
.IFormPart
;
13 import org
.eclipse
.ui
.forms
.IManagedForm
;
14 import org
.eclipse
.ui
.forms
.widgets
.TableWrapData
;
15 import org
.eclipse
.ui
.forms
.widgets
.TableWrapLayout
;
17 abstract public class EditableGroupedComposite
extends GroupedComposite
{
18 private static final Logger logger
= Logger
.getLogger(TaxonCompositeFactory
.class);
20 protected TextViewer textViewer
;
21 protected TableWrapLayout layout
;
23 ISelectionWrapper selectionWrapper
;
25 private Label draggableLabel
;
27 protected IManagedForm managedForm
;
28 protected IFormPart formPart
;
29 protected boolean dirty
;
31 public EditableGroupedComposite(Composite parent
, IManagedForm managedForm
) {
34 this.managedForm
= managedForm
;
35 this.formPart
= new FormPart(managedForm
);
39 protected void createContent() {
40 setLayoutData(new TableWrapData(TableWrapData
.FILL_GRAB
));
41 layout
= new TableWrapLayout();
42 layout
.numColumns
= 2;
43 layout
.leftMargin
= 0;
46 setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
48 draggableLabel
= new Label(this, SWT
.NONE
);
49 draggableLabel
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
50 draggableLabel
.setLayoutData(new TableWrapData(TableWrapData
.CENTER
, TableWrapData
.MIDDLE
));
52 setDraggableControl(draggableLabel
);
55 public TextViewer
getTextViewer() {
59 public void setTextViewer(TextViewer textViewer
) {
60 this.textViewer
= textViewer
;
63 public void setIcon(Image icon
) {
64 draggableLabel
.setImage(icon
);
67 public Label
getDraggableLabel() {
68 return draggableLabel
;
71 public void setIndent(int indent
) {
72 layout
.leftMargin
= indent
;
73 this.setLayout(layout
);
76 public boolean setFocus() {
77 if (selectionWrapper
!= null) {
78 selectionWrapper
.setSelection();
80 return super.setFocus();
83 public void setFont(Font font
) {
84 getTextViewer().getTextWidget().setFont(font
);
87 public void setSelectionWrapper (ISelectionWrapper selectionWrapper
) {
88 this.selectionWrapper
= selectionWrapper
;
91 public Menu
getMenu () {
93 Menu menu
= draggableLabel
.getMenu();
95 menu
= new Menu(draggableLabel
);
96 draggableLabel
.setMenu(menu
);
101 public void createBorderSupport(IManagedForm managedForm
) {
102 CompositeBorderDecorator borderDecorator
= new CompositeBorderDecorator(
104 TextViewer textViewer
= getTextViewer();
105 if (textViewer
!= null) {
106 borderDecorator
.setBorderedComposite(textViewer
111 protected void setDirty(boolean isDirty
) {
112 this.dirty
= isDirty
;
115 class FormPart
implements IFormPart
{
117 public FormPart(IManagedForm form
) {
122 public void commit(boolean onSave
) {}
125 public void dispose() {}
128 public void initialize(IManagedForm form
) {}
131 public boolean isDirty() {
136 public boolean isStale() {
141 public void refresh() {}
144 public void setFocus() {}
147 public boolean setFormInput(Object input
) {