3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.propertysheet
.tabbed
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.core
.runtime
.Assert
;
15 import org
.eclipse
.jface
.viewers
.ISelection
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.custom
.CLabel
;
19 import org
.eclipse
.swt
.events
.ModifyEvent
;
20 import org
.eclipse
.swt
.events
.ModifyListener
;
21 import org
.eclipse
.swt
.layout
.FormAttachment
;
22 import org
.eclipse
.swt
.layout
.FormData
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.swt
.widgets
.Text
;
25 import org
.eclipse
.ui
.IWorkbenchPart
;
26 import org
.eclipse
.ui
.views
.properties
.tabbed
.AbstractPropertySection
;
27 import org
.eclipse
.ui
.views
.properties
.tabbed
.ITabbedPropertyConstants
;
28 import org
.eclipse
.ui
.views
.properties
.tabbed
.TabbedPropertySheetPage
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
37 public class NameRelationsSection
extends AbstractPropertySection
{
38 private static final Logger logger
= Logger
39 .getLogger(NameRelationsSection
.class);
41 private TaxonBase taxonBase
;
43 private Text labelText
;
48 public NameRelationsSection() {
49 // TODO Auto-generated constructor stub
52 private ModifyListener listener
= new ModifyListener() {
54 public void modifyText(ModifyEvent arg0
) {
55 // TaxonBasePropertySource properties = (TaxonBasePropertySource) taxonBase
56 // .getAdapter(IPropertySource.class);
57 // properties.setPropertyValue(TaxonBasePropertySource.P_ID_TAXONNAME,
58 // labelText.getText());
64 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
67 public void createControls(Composite parent
, TabbedPropertySheetPage tabbedPropertySheetPage
) {
69 super.createControls(parent
, tabbedPropertySheetPage
);
70 Composite composite
= getWidgetFactory().createFlatFormComposite(parent
);
73 labelText
= getWidgetFactory().createText(composite
, ""); //$NON-NLS-1$
75 data
= new FormData();
76 data
.left
= new FormAttachment(0, STANDARD_LABEL_WIDTH
);
77 data
.right
= new FormAttachment(100, 0);
78 data
.top
= new FormAttachment(0, ITabbedPropertyConstants
.VSPACE
);
79 labelText
.setLayoutData(data
);
80 labelText
.addModifyListener(listener
);
82 CLabel labelLabel
= getWidgetFactory()
83 .createCLabel(composite
, "Label:"); //$NON-NLS-1$
85 data
= new FormData();
86 data
.left
= new FormAttachment(0, 0);
87 data
.right
= new FormAttachment(labelText
,
88 -ITabbedPropertyConstants
.HSPACE
);
89 data
.top
= new FormAttachment(labelText
, 0, SWT
.CENTER
);
90 labelLabel
.setLayoutData(data
);
95 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
98 public void refresh() {
100 labelText
.setText(taxonBase
.getName().getTitleCache());
104 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
107 public void setInput(IWorkbenchPart part
, ISelection selection
) {
109 super.setInput(part
, selection
);
110 Assert
.isTrue(selection
instanceof IStructuredSelection
);
111 Object input
= ((IStructuredSelection
) selection
).getFirstElement();
112 Assert
.isTrue(input
instanceof TaxonBase
);
113 this.taxonBase
= (TaxonBase
) input
;
116 // super.setInput(part, selection);