.
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / propertysheet / tabbed / NameOverviewSection.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 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
11 package eu.etaxonomy.taxeditor.propertysheet.tabbed;
12
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.layout.GridLayout;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.ui.IWorkbenchPart;
22 import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
23 import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
24
25 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
26 import eu.etaxonomy.cdm.model.name.NonViralName;
27 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
28
29 /**
30 * @author n.hoffmann
31 * @created 09.06.2009
32 * @version 1.0
33 */
34 public class NameOverviewSection extends AbstractPropertySection {
35 private static final Logger logger = Logger
36 .getLogger(NameOverviewSection.class);
37 private TaxonBase<?> taxonBase;
38 private NonViralName<?> name;
39 private CLabel title;
40
41 private CLabel parsingStatus;
42 private Composite composite;
43
44 /**
45 *
46 */
47 public NameOverviewSection() {}
48
49 /* (non-Javadoc)
50 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
51 */
52 @Override
53 public void createControls(Composite parent,
54 TabbedPropertySheetPage tabbedPropertySheetPage) {
55
56 super.createControls(parent, tabbedPropertySheetPage);
57
58 composite = getWidgetFactory().createComposite(parent);
59 composite.setLayout(new GridLayout(1, false));
60
61 title = getWidgetFactory().createCLabel(composite, "", SWT.WRAP);
62 parsingStatus = getWidgetFactory().createCLabel(composite, "");
63 }
64
65 /* (non-Javadoc)
66 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
67 */
68 @Override
69 public void refresh() {
70 super.refresh();
71
72 title.setText(name.getFullTitleCache());
73
74 parsingStatus.setText(name.hasProblem() ? "Name has problems" : "Name was succesfully parsed");
75 }
76
77 /* (non-Javadoc)
78 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
79 */
80 @Override
81 public void setInput(IWorkbenchPart part, ISelection selection) {
82 super.setInput(part, selection);
83 Assert.isTrue(selection instanceof IStructuredSelection);
84 Object input = ((IStructuredSelection) selection).getFirstElement();
85 Assert.isTrue(input instanceof TaxonBase);
86 taxonBase = (TaxonBase) input;
87 name = HibernateProxyHelper.deproxy( taxonBase.getName(), NonViralName.class);
88 }
89
90
91
92 }