2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
.container
;
14 import org
.eclipse
.core
.runtime
.Assert
;
15 import org
.eclipse
.jface
.dialogs
.Dialog
;
16 import org
.eclipse
.jface
.text
.IDocument
;
17 import org
.eclipse
.jface
.window
.DefaultToolTip
;
18 import org
.eclipse
.swt
.custom
.StyledText
;
19 import org
.eclipse
.swt
.dnd
.DND
;
20 import org
.eclipse
.swt
.dnd
.DragSource
;
21 import org
.eclipse
.swt
.dnd
.Transfer
;
22 import org
.eclipse
.swt
.events
.ControlAdapter
;
23 import org
.eclipse
.swt
.events
.ControlEvent
;
24 import org
.eclipse
.swt
.events
.ControlListener
;
25 import org
.eclipse
.swt
.events
.FocusAdapter
;
26 import org
.eclipse
.swt
.events
.FocusEvent
;
27 import org
.eclipse
.swt
.events
.FocusListener
;
28 import org
.eclipse
.swt
.events
.ModifyEvent
;
29 import org
.eclipse
.swt
.events
.ModifyListener
;
30 import org
.eclipse
.swt
.events
.MouseAdapter
;
31 import org
.eclipse
.swt
.events
.MouseEvent
;
32 import org
.eclipse
.swt
.graphics
.Color
;
33 import org
.eclipse
.swt
.graphics
.Font
;
34 import org
.eclipse
.swt
.graphics
.Image
;
35 import org
.eclipse
.swt
.widgets
.Composite
;
36 import org
.eclipse
.swt
.widgets
.Control
;
37 import org
.eclipse
.swt
.widgets
.Display
;
38 import org
.eclipse
.swt
.widgets
.Label
;
39 import org
.eclipse
.swt
.widgets
.Menu
;
40 import org
.eclipse
.ui
.forms
.IFormPart
;
41 import org
.eclipse
.ui
.forms
.IManagedForm
;
42 import org
.eclipse
.ui
.forms
.widgets
.TableWrapData
;
43 import org
.eclipse
.ui
.forms
.widgets
.TableWrapLayout
;
45 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
46 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
47 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
48 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
49 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
50 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
51 import eu
.etaxonomy
.taxeditor
.editor
.CdmDataTransfer
;
52 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
53 import eu
.etaxonomy
.taxeditor
.editor
.name
.TaxonNameEditor
;
54 import eu
.etaxonomy
.taxeditor
.editor
.name
.dnd
.NameEditorDragListener
;
55 import eu
.etaxonomy
.taxeditor
.editor
.name
.dnd
.NameEditorDragSourceEffect
;
56 import eu
.etaxonomy
.taxeditor
.editor
.name
.operation
.CreateSynonymInNewGroupOperation
;
57 import eu
.etaxonomy
.taxeditor
.labels
.ILabelImageStrategy
;
58 import eu
.etaxonomy
.taxeditor
.labels
.LabelImageProvider
;
59 import eu
.etaxonomy
.taxeditor
.model
.NameHelper
;
60 import eu
.etaxonomy
.taxeditor
.model
.TextHelper
;
61 import eu
.etaxonomy
.taxeditor
.parser
.ParseHandler
;
62 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
65 * Formats <code>GroupedComposite</code> with cosmetic and layout properties specific to the
66 * Editor. This should be used to maintain a consistent look and feel for all Editor
67 * freetext area components, such as DescriptionElementComposite.
69 * Requires an <code>IManagedForm</code>, whose <code>input</code> is set to the contents
70 * of {@link #getData()} when the <code>GroupedComposite</code> gets focus, i.e. to
71 * populate the property sheet with the data.
74 * The <code>IManagedForm</code> is also required to have a <code>Taxon</code> in its
75 * own <code>getData()</code>.
78 * The <code>IManagedForm</code> can also used for drawing borders by calling the method
79 * <code>createBorderSupport()</code>.
87 abstract public class AbstractGroupedContainer
<T
extends TaxonBase
> implements IFormPart
, IContainerConstants
{
89 protected ParseHandler parseHandler
;
91 private FocusListener nameCompositeFocusListener
;
92 private ModifyListener nameCompositeModifyListener
;
94 protected NameViewer nameViewer
;
96 private AbstractGroup group
;
98 private Label nonEditableInfoLabel
;
99 private DefaultToolTip nonEditableInfoHover
;
101 private static AbstractGroupedContainer selection
;
103 private FocusListener focusListener
;
104 private LineBreakListener lineBreakListener
;
106 private int cursorPosition
;
108 protected Composite control
;
110 private Color backgroundColor
;
111 private boolean isDirty
;
115 * <p>Constructor for AbstractGroupedContainer.</p>
117 * @param editor a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
118 * @param group a {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup} object.
119 * @param taxonBase a T object.
120 * @param <T> a T object.
122 public AbstractGroupedContainer(T taxonBase
){
124 parseHandler
= ParseHandler
.NewInstance(taxonBase
.getName());
127 public void createContent(){
131 createLineWrapSupport();
132 createLineBreakListener();
134 setMenu(getEditor().getMenu());
136 setDraggableControl(new Control
[]{getControl(), getNameViewer().getRulerControl()});
138 createEmptyViewerPrompt(EMPTY_NAME_PROMPT
);
141 initializeComposite();
151 * <p>createListener</p>
153 protected void createListener(){
154 nameCompositeModifyListener
= new ModifyListener(){
156 public void modifyText(ModifyEvent e
) {
157 // mark the composite dirty
160 String text
= nameViewer
.getTextWidget().getText();
162 NonViralName name
= parseHandler
.parse(text
);
163 getTaxonBase().setName(name
);
164 getTaxonBase().setTitleCache((getTaxonBase().generateTitle()));
166 // show errors resulting from parsing
168 // store the position of the cursor
170 // notify selection listener
171 setDelayedSelection();
174 nameCompositeFocusListener
= new FocusAdapter(){
177 * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
180 public void focusLost(FocusEvent e
) {
190 private void addListener(){
191 getNameViewer().getTextWidget().addModifyListener(nameCompositeModifyListener
);
192 getNameViewer().getTextWidget().addFocusListener(nameCompositeFocusListener
);
195 private void removeListener(){
196 getNameViewer().getTextWidget().removeModifyListener(nameCompositeModifyListener
);
197 getNameViewer().getTextWidget().removeFocusListener(nameCompositeFocusListener
);
201 * Initialize the composite specific code
203 protected abstract void initializeComposite();
206 * <p>getEmptyTextPrompt</p>
208 * @return a {@link java.lang.String} object.
210 protected String
getEmptyTextPrompt() {
211 return EMPTY_NAME_PROMPT
;
217 private void showNameRelations() {
218 TaxonNameBase
<?
, ?
> name
= getName();
223 ILabelImageStrategy strategy
= LabelImageProvider
.getLabelStrategy(name
);
224 LabelImageProvider labelProvider
= new LabelImageProvider(strategy
);
226 Set
<NameRelationship
> nameRelations
= name
.getNameRelations();
227 if (nameRelations
.size() == 0) {
230 // for (NameRelationship nameRelation : nameRelations) {
231 // String typeLabel = null;
232 // TaxonNameBase<?, ?> relatedName = null;
234 // if (name.equals(nameRelation.getFromName())) {
235 // typeLabel = labelProvider.getNameRelationTypeLabel(
236 // nameRelation.getType());
237 // relatedName = nameRelation.getToName();
239 // typeLabel = labelProvider.getNameRelationTypeInverseLabel(
240 // nameRelation.getType());
241 // relatedName = nameRelation.getFromName();
244 // setNonEditableInfo(typeLabel + " " + NameHelper.getDisplayName(relatedName));
249 * <p>initTextViewer</p>
251 protected void initTextViewer() {
253 // showNameRelations();
259 String text
= NameHelper
.getDisplayNameWithRef(getData());
261 if (text
.length() == 0) {
264 getNameViewer().setText(text
);
271 * <p>calculateErrors</p>
273 synchronized protected void calculateErrors() {
274 getNameViewer().clearErrors();
275 getNameViewer().setShowParsingErrors(getName());
279 * <p>handleSplitText</p>
281 * @param text a {@link java.lang.String} object.
283 protected void handleSplitText(String text
) {
284 // Create a synonym in a new homotypic group using text as name
285 TaxonNameBase synonymName
= ParseHandler
.quickParse(text
);
287 EditorUtil
.executeOperation(new CreateSynonymInNewGroupOperation
288 ("New Heterotypic Synonym", getEditor().getUndoContext(), getEditor().getTaxon(), synonymName
, getEditor()));
292 * Refreshes the display with latest data from the model.
294 * Note: Will not parse the text and not calculate errors!
296 public void refresh() {
297 // showNameRelations();
299 String text
= NameHelper
.getDisplayNameWithRef(getTaxonBase());
301 if(getNameViewer().getTextWidget() == null){
302 // we might get here via dnd. Look slike it can be ignored
306 if (text
.length() == 0) {
308 } else if(! getNameViewer().getTextWidget().getText().equals(text
)) {
310 getNameViewer().getTextWidget().setText(text
);
314 updateNonEditableInfo();
326 protected abstract void updateIcon();
329 protected abstract void updateIndent();
333 * <p>updateNonEditableInfo</p>
335 protected abstract void updateNonEditableInfo();
340 private void isFreeTextEnabled() {
341 // Decide whether editing of freetext is allowed or not.
342 if (freetextEditingAllowed()) {
345 getNameViewer().getTextWidget().setEditable(true);
347 // restore foreground font color again
348 getNameViewer().getTextWidget().setForeground(control
.getForeground());
351 getNameViewer().getTextWidget().setEditable(false);
353 // grey out text as a non-editable indicator
354 getNameViewer().getTextWidget().setForeground(EditorUtil
.getColor(Resources
.COLOR_DISABLED_EDITOR
));
360 * Checks whether the freetext should be editable based on specific empty fields.
363 private boolean freetextEditingAllowed() {
364 NonViralName name
= (NonViralName
) HibernateProxyHelper
.deproxy(getName());
365 boolean enableFreetext
= true;
367 enableFreetext
&= isNameUsedMultipleTimes(name
);
368 enableFreetext
&= isNameParsable(name
);
371 getNameViewer().setShowNameNotParsableWarning(name
);
374 return enableFreetext
;
377 private boolean isNameUsedMultipleTimes(NonViralName name
){
378 if(name
.getTaxonBases().size() != 1){
379 getNameViewer().setShowMultipleNameUsageWarning(name
);
385 private boolean isNameParsable(NonViralName name
){
386 boolean isParsable
= true;
387 isParsable
&= CdmUtils
.isEmpty(name
.getAppendedPhrase()); //taxonFieldsEmpty();
389 isParsable
&= ! name
.isProtectedAuthorshipCache();
390 isParsable
&= ! name
.isProtectedNameCache();
397 * Parse the text and calculate errors
399 public void parseAndCalculateErrors(){
401 String unparsedNameString
= getNameViewer().getTextWidget().getText();
402 parseHandler
.parse(unparsedNameString
);
408 * <p>getTaxonBase</p>
410 * @return the taxonBase
412 public T
getTaxonBase() {
419 * @return a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
421 public TaxonNameBase
getName(){
422 return (TaxonNameBase
) HibernateProxyHelper
.deproxy(getTaxonBase().getName());
428 public void persistName(){
430 getNameViewer().getTextWidget().setEnabled(false);
431 final String unparsedNameString
= getNameViewer().getTextWidget().getText();
432 // Job job = new Job("Persisting Name"){
435 // protected IStatus run(IProgressMonitor monitor) {
437 final NonViralName name
= parseHandler
.parseAndResolveDuplicates(unparsedNameString
);
439 // Display.getDefault().asyncExec(new Runnable(){
440 // public void run() {
441 getTaxonBase().setName(name
);
442 getTaxonBase().setTitleCache((getTaxonBase().generateTitle()));
444 getNameViewer().getTextWidget().setEnabled(true);
449 // return Status.OK_STATUS;
454 // job.setPriority(Job.DECORATE);
460 * <p>Getter for the field <code>group</code>.</p>
462 * @return a {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup} object.
464 public AbstractGroup
getGroup(){
466 throw new IllegalStateException("Group shall not be null.");
474 public void remove(){
475 getGroup().remove(this);
479 * <p>createControl</p>
481 protected void createControl() {
482 control
= getEditor().getToolkit().createComposite(getGroup().getControl());
484 control
.setLayoutData(new TableWrapData(TableWrapData
.FILL_GRAB
));
485 TableWrapLayout layout
= new TableWrapLayout();
486 layout
.leftMargin
= 0;
487 layout
.rightMargin
= 0;
488 layout
.topMargin
= 5;
489 layout
.bottomMargin
= 5;
491 layout
.verticalSpacing
= 0;
492 layout
.horizontalSpacing
= 0;
494 control
.setLayout(layout
);
501 protected TaxonNameEditor
getEditor() {
502 return getGroup().getEditor();
506 * <p>Getter for the field <code>control</code>.</p>
508 * @return a {@link org.eclipse.swt.widgets.Composite} object.
510 public Composite
getControl(){
515 * <p>createLineWrapSupport</p>
517 protected void createLineWrapSupport() {
518 new LineWrapSupport(getNameViewer(), getEditor().getManagedForm());
523 * <p>createTextViewer</p>
525 protected void createTextViewer() {
526 nameViewer
= new NameViewer(control
);
528 focusListener
= new FocusAdapter() {
529 public void focusGained(FocusEvent e
) {
530 for(AbstractGroupedContainer container
: getEditor().getGroupedContainers()){
531 container
.colorSelected(NOT_SELECTED
);
533 getEditor().getManagedForm().setInput(AbstractGroupedContainer
.this);
535 colorSelected(SELECTED_FOCUS
);
538 nameViewer
.getTextWidget().addFocusListener(focusListener
);
541 MouseAdapter mouseListener
= new MouseAdapter() {
542 public void mouseDown(MouseEvent e
) {
546 control
.addMouseListener(mouseListener
);
547 nameViewer
.getRulerControl().addMouseListener(mouseListener
);
548 nameViewer
.getTextWidget().addMouseListener(mouseListener
);
554 * @param icon a {@link org.eclipse.swt.graphics.Image} object.
556 public void setIcon(Image icon
) {
557 getNameViewer().setIcon(icon
);
563 * @param indent a int.
565 public void setIndent(int indent
) {
566 if (control
.getLayout() instanceof TableWrapLayout
) {
567 TableWrapLayout layout
= ((TableWrapLayout
) control
.getLayout());
568 layout
.leftMargin
= indent
;
569 layout
.rightMargin
= ACCEPTED_INDENT
;
570 control
.setLayout(layout
);
573 new RuntimeException("Couldn't indent - composite's layout must be TableWrapLayout.");
580 public void setSelected() {
581 getNameViewer().getTextWidget().setFocus();
589 public boolean isSelected(){
590 return getEditor().getSelectedContainer() == this;
594 * <p>colorSelected</p>
598 public void colorSelected(int mode
){
599 if(!control
.isDisposed()){
600 String colorString
= null;
604 colorString
= Resources
.COLOR_CONTROL_SELECTED_FOCUS
;
606 case SELECTED_NO_FOCUS
:
607 colorString
= Resources
.COLOR_CONTROL_SELECTED
;
610 colorString
= Resources
.COLOR_COMPOSITE_BACKGROUND
;
613 backgroundColor
= EditorUtil
.getColor(colorString
);
615 setBackground(backgroundColor
);
621 * <p>setDelayedSelection</p>
623 protected void setDelayedSelection(){
624 //TODO this might be done better
625 // this is the quickest solution i could come up with and it improves performance
626 // please reimplement if you know better.
630 Display display
= Display
.getCurrent();
631 Runnable runnable
= new Runnable() {
634 getEditor().getManagedForm().setInput(selection
);
637 display
.timerExec(1000, runnable
);
642 * <p>setBackground</p>
644 * @param color a {@link org.eclipse.swt.graphics.Color} object.
646 public void setBackground(Color color
) {
647 control
.setBackground(color
);
649 for(Control child
: control
.getChildren()){
650 child
.setBackground(color
);
653 getNameViewer().setBackground(color
);
657 * @see org.eclipse.swt.widgets.Control#setFont(org.eclipse.swt.graphics.Font)
662 * @param font a {@link org.eclipse.swt.graphics.Font} object.
664 public void setFont(Font font
) {
665 getNameViewer().getTextWidget().setFont(font
);
669 * <p>Getter for the field <code>nameViewer</code>.</p>
671 * @return a {@link eu.etaxonomy.taxeditor.editor.name.container.NameViewer} object.
673 public NameViewer
getNameViewer() {
674 if (nameViewer
== null){
675 throw new RuntimeException("The Name Viewer is corrupt for Name Container: " + getTaxonBase().getName().getTitleCache());
681 * If <code>textViewer</code> has already been set, it will show a
682 * <code>prompt</code> along the lines of "Click here to start entering data"
685 * @param prompt a {@link java.lang.String} object.
687 public void createEmptyViewerPrompt(final String prompt
) {
689 Assert
.isNotNull(getNameViewer());
691 final StyledText textControl
= getNameViewer().getTextWidget();
692 final IDocument document
= getNameViewer().getDocument();
694 setFocusListener(new FocusListener() {
697 public void focusGained(FocusEvent e
) {
698 if (document
.get().equals(prompt
)) {
699 textControl
.setFont(getViewerFont());
705 public void focusLost(FocusEvent e
) {
706 if (document
.getLength() == 0) {
712 textControl
.addFocusListener(getFocusListener());
714 if (document
.getLength() == 0) {
715 textControl
.setFont(EditorUtil
.getFont(Resources
.FONT_DEFAULT_PROMPT
));
716 document
.set(prompt
);
721 * <p>getViewerFont</p>
723 * @return a {@link org.eclipse.swt.graphics.Font} object.
725 abstract protected Font
getViewerFont();
728 * <p>initEmptyText</p>
730 protected void initEmptyText() {
731 Font defaultFont
= EditorUtil
.getFont(Resources
.FONT_DEFAULT_PROMPT
);
732 getNameViewer().getTextWidget().setFont(defaultFont
);
734 getNameViewer().getDocument().set(getEmptyTextPrompt());
739 * <p>Setter for the field <code>focusListener</code>.</p>
741 * @param focusListener a {@link org.eclipse.swt.events.FocusListener} object.
743 protected void setFocusListener(FocusListener focusListener
) {
744 this.focusListener
= focusListener
;
747 private FocusListener
getFocusListener() {
748 return focusListener
;
754 * @param isDirty a boolean.
756 public void setDirty(boolean isDirty
) {
758 getEditor().getManagedForm().dirtyStateChanged();
760 this.isDirty
= isDirty
;
768 public boolean isDirty(){
775 * @param menu a {@link org.eclipse.swt.widgets.Menu} object.
777 public void setMenu (Menu menu
) {
778 control
.setMenu(menu
);
780 getNameViewer().setMenu(menu
);
783 private Control
[] draggableControls
;
786 * <p>setDraggableControl</p>
788 * @param controls an array of {@link org.eclipse.swt.widgets.Control} objects.
790 protected void setDraggableControl(Control
[] controls
) {
791 draggableControls
= controls
;
795 * <p>setIsDraggable</p>
797 * @param draggable a boolean.
799 public void setIsDraggable(boolean draggable
) {
803 if (draggableControls
== null) {
804 throw new NullPointerException(
805 "Draggable controls must be set to add draggability");
808 Transfer
[] types
= new Transfer
[] { CdmDataTransfer
.getInstance() };
809 int operations
= DND
.DROP_MOVE
;
811 for(Control draggableControl
: draggableControls
){
812 DragSource dragSource
= new DragSource(draggableControl
, operations
);
813 dragSource
.setTransfer(types
);
815 dragSource
.addDragListener(new NameEditorDragListener(this));
816 dragSource
.setDragSourceEffect(new NameEditorDragSourceEffect(control
));
821 private String nonEditableText
;
823 ControlListener nonEditableResizeListener
= new ControlAdapter() {
827 public void controlResized(ControlEvent e
) {
828 if (nonEditableInfoLabel
.getBounds().width
== width
) {
831 width
= nonEditableInfoLabel
.getBounds().width
;
832 if (nonEditableInfoLabel
.getBounds().width
> 0) {
833 nonEditableInfoLabel
.setText(
834 Dialog
.shortenText(nonEditableText
.toUpperCase(),
835 nonEditableInfoLabel
));
840 private String nonEditableHoverText
;
842 private LabelEllipsisListener nonEditableLabelEllipsisListener
;
847 * nonEditableInfo is a label displayed underneath a GroupedComposite's
848 * input field. For instance, NameComposites display things like name relations,
849 * sec. references, etc. here.
851 * @param info the text to display in the label
852 * @param append whether the string should be appended to text that is already shown in the label
854 public void setNonEditableInfo(String info
, boolean append
) {
855 // TODO non editable info should only be drawn once, when everything else is drawn
856 info
= info
.toUpperCase();
859 nonEditableText
+= ", " + info
;
860 nonEditableHoverText
+= "\n" + info
;
862 nonEditableText
= info
;
863 nonEditableHoverText
= info
;
866 if (nonEditableInfoLabel
== null) {
867 nonEditableInfoLabel
= getEditor().getToolkit().createLabel(control
, "");
868 TableWrapData layoutData
= new TableWrapData(TableWrapData
.FILL_GRAB
, TableWrapData
.TOP
);
869 // Set indent to viewer ruler's width
870 if (getNameViewer().getRulerControl() != null) {
871 // TODO right justify
872 layoutData
.indent
= NameViewer
.RULER_WIDTH
;
874 nonEditableInfoLabel
.setLayoutData(layoutData
);
878 nonEditableLabelEllipsisListener
= new LabelEllipsisListener(nonEditableInfoLabel
) {
880 public String
getLabelText() {
881 return nonEditableText
.toUpperCase();
884 nonEditableInfoLabel
.addControlListener(nonEditableLabelEllipsisListener
);
886 nonEditableInfoHover
= new DefaultToolTip(nonEditableInfoLabel
);
887 nonEditableInfoHover
.setRespectDisplayBounds(true);
890 nonEditableInfoHover
.setText(nonEditableHoverText
);
891 nonEditableInfoLabel
.setText(nonEditableText
);
895 * <p>Getter for the field <code>data</code>.</p>
897 * @return a T object.
904 * <p>Setter for the field <code>data</code>.</p>
906 * @param data a T object.
908 public void setData(T data
){
909 this.data
= (T
) HibernateProxyHelper
.deproxy(data
);
913 * If the user hitting carriage return should cause something to happen -
914 * i.e. the creation of a new composite - call this method and override
915 * the method handleSplitText().
917 protected void createLineBreakListener() {
918 lineBreakListener
= new LineBreakListener() {
920 public void handleSplitText(String text
) {
921 AbstractGroupedContainer
.this.handleSplitText(text
);
925 getNameViewer().getTextWidget().addVerifyListener(lineBreakListener
);
926 getNameViewer().getTextWidget().addKeyListener(lineBreakListener
);
929 abstract class LabelEllipsisListener
extends ControlAdapter
{
934 LabelEllipsisListener(Label label
) {
938 abstract public String
getLabelText();
940 public void controlResized(ControlEvent e
) {
941 if (label
.getBounds().width
== width
) {
944 width
= label
.getBounds().width
;
945 if (label
.getBounds().width
> 0) {
946 label
.setText(TextHelper
.shortenText(getLabelText(), label
));
954 public void storeCursor() {
955 this.cursorPosition
= getNameViewer().getCursorPosition();
959 * Puts the cursor to the position it was last seen on or to the end of line
960 * if no former position is known.
962 public void placeCursor(){
963 if(cursorPosition
== 0){
964 getNameViewer().setCursorToEOL();
966 getNameViewer().setCursorPosition(cursorPosition
);
973 * <p>Setter for the field <code>group</code>.</p>
975 * @param group a {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup} object.
977 public void setGroup(AbstractGroup group
) {
984 * <p>restoreColor</p>
986 public void restoreColor() {
987 setBackground(backgroundColor
);
993 * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
996 public void initialize(IManagedForm form
) {
997 // TODO Auto-generated method stub
1003 * @see org.eclipse.ui.forms.IFormPart#dispose()
1006 public void dispose() {
1007 if(getControl() != null){
1009 getControl().dispose();
1015 * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
1018 public void commit(boolean onSave
) {
1026 * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
1029 public boolean setFormInput(Object input
) {
1030 // TODO Auto-generated method stub
1036 * @see org.eclipse.ui.forms.IFormPart#setFocus()
1039 public void setFocus() {
1040 getNameViewer().getControl().setFocus();
1045 * @see org.eclipse.ui.forms.IFormPart#isStale()
1048 public boolean isStale() {
1049 // TODO Auto-generated method stub