* @param <ENTITY>
* a ENTITY object.
*/
- protected AbstractFormSection(CdmFormFactory formFactory, ICdmFormElement parentElement,
- int style) {
+ protected AbstractFormSection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
super(parentElement.getLayoutComposite(), style);
this.parentElement = parentElement;
this.setClient(client);
}
- /**
- * <p>
- * Constructor for AbstractFormSection.
- * </p>
- *
- * @param formFactory
- * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
- * object.
- * @param conversation
- * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param selectionProvider
- * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
- * @param style
- * a int.
- */
- protected AbstractFormSection(CdmFormFactory formFactory,
- ICdmFormElement parentElement,
- ISelectionProvider selectionProvider, int style) {
- this(formFactory, parentElement, style);
- this.selectionProvider = selectionProvider;
- }
+ /**
+ * <p>
+ * Constructor for AbstractFormSection.
+ * </p>
+ *
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+ * object.
+ * @param conversation
+ * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+ * object.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param selectionProvider
+ * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
+ * @param style
+ * a int.
+ */
+ protected AbstractFormSection(CdmFormFactory formFactory, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
+ this(formFactory, parentElement, style);
+ this.selectionProvider = selectionProvider;
+ }
/**
* <p>
/** {@inheritDoc} */
@Override
public void firePropertyChangeEvent(CdmPropertyChangeEvent event) {
- Assert.isNotNull(propertyChangeListeners,
- "No property change listeners.");
- try {
- for (Object listener : propertyChangeListeners) {
- ((IPropertyChangeListener) listener).propertyChange(event);
- }
- } catch (ConcurrentModificationException e) {
- AbstractUtility.warn(getClass(),
- "ConcurrentModificationException while handling PropertyChangeEvents."
- + " It seems like this is not critical");
- }
+ Assert.isNotNull(propertyChangeListeners, "No property change listeners.");
+ try {
+ for (Object listener : propertyChangeListeners) {
+ ((IPropertyChangeListener) listener).propertyChange(event);
+ }
+ } catch (ConcurrentModificationException e) {
+ AbstractUtility.warn(getClass(), "ConcurrentModificationException while handling PropertyChangeEvents."
+ + " It seems like this is not critical");
+ }
}
/**
* a {@link org.eclipse.swt.events.SelectionEvent} object.
*/
public void widgetSelected(SelectionEvent e) {
- Widget widget = e.widget;
-
- if (widget instanceof Control) {
- Control control = (Control) widget;
- if (checkControlAncestryForWidget(control)) {
- if (getEntity() != null) {
- IStructuredSelection selection = new StructuredSelection(
- getEntity());
- if (selectionProvider != null) {
- selectionProvider.setSelection(selection);
- }
- }
- }
- }
+ Widget widget = e.widget;
+
+ if (widget instanceof Control) {
+ Control control = (Control) widget;
+ if (checkControlAncestryForWidget(control)) {
+ if (getEntity() != null) {
+ IStructuredSelection selection = new StructuredSelection(getEntity());
+ if (selectionProvider != null) {
+ selectionProvider.setSelection(selection);
+ }
+ }
+ }
+ }
}
private boolean checkControlAncestryForWidget(Control control) {
return element;
}
+ public GeneralDetailSection createFOSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
+ GeneralDetailSection generalSection = new GeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
+ parentElement.addElement(generalSection);
+ adapt(generalSection);
+ return generalSection;
+ }
+
+ public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
+ GatheringEventDetailSection gatheringSection = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
+ parentElement.addElement(gatheringSection);
+ adapt(gatheringSection);
+ return gatheringSection;
+ }
+
+ public FieldObservationDetailSection createFODetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
+ FieldObservationDetailSection foDetailsSection = new FieldObservationDetailSection(this, conversation, parentElement, selectionProvider, style);
+ parentElement.addElement(foDetailsSection);
+ adapt(foDetailsSection);
+ return foDetailsSection;
+ }
+
/**
* <p>
* createCdmDetailSection
ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
AbstractFormSection section = null;
- System.out.println("DetailSection: " + detailType);
+// System.out.println("DetailSection: " + detailType);
switch (detailType) {
case SCIENTIFICNAME:
section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
ConversationHolder conversation, ICdmFormElement parentElement, int style) {
AbstractFormSection section = null;
- System.out.println("EntityDetailSection: " + entityDetailType);
+// System.out.println("EntityDetailSection: " + entityDetailType);
switch (entityDetailType) {
case TEAM:
// TODO this is not an AbstractEntityCollectionSection
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.ui.element;
* <p>
* TextWithLabelElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @version $Id: $
*/
-public class TextWithLabelElement extends AbstractCdmFormElement implements
- ModifyListener, IEnableableFormElement, ISelectable {
-
- protected Text text;
- private Label label;
-
- /** Constant <code>MAX_HEIGHT=0</code> */
- public static final int MAX_HEIGHT = 0;
- /** Constant <code>SINGLE=-1</code> */
- public static final int SINGLE = -1;
-
- /**
- * <p>
- * Constructor for TextWithLabelElement.
- * </p>
- *
- * @param formFactory
- * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param initialText
- * a {@link java.lang.String} object.
- * @param textHeight
- * a {@link java.lang.Integer} object.
- * @param style
- * a int.
- */
- protected TextWithLabelElement(CdmFormFactory formFactory,
- ICdmFormElement parentElement, String labelString,
- String initialText, Integer textHeight, int style) {
- super(formFactory, parentElement);
-
- if (labelString != null) {
- label = formFactory.createLabel(getLayoutComposite(),
- CdmUtils.Nz(labelString), SWT.NULL);
- addControl(label);
- label.setLayoutData(LayoutConstants.LEFT());
- }
-
- int scrollStyle = textHeight == null ? SWT.NULL
- : (SWT.V_SCROLL | SWT.MULTI);
-
- int combinedStyle = style | SWT.BORDER | scrollStyle;
-
- //SWT.PASSWORD does not work when SWT.WRAP is set.
- if(style != SWT.PASSWORD){
- combinedStyle = combinedStyle | SWT.WRAP;
- }
-
- text = formFactory.createText(getLayoutComposite(), "", combinedStyle);
-
- addControl(text);
-
- // text.setWO
-
- if (textHeight == null) {
- text.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.character == SWT.CR) {
- // Don't accept carriage returns as input when in single
- // line mode
- e.doit = false;
- } else if (e.character == SWT.TAB) {
- // traverse is not working for wrapped text widgets so
- // we reintroduce it here
- e.doit = false;
- TextWithLabelElement.this.text
- .traverse(SWT.TRAVERSE_TAB_NEXT);
- }
- }
- });
- }
-
- TableWrapData layoutData = LayoutConstants.FILL();
- if (textHeight != null && textHeight > 0) {
- (layoutData).heightHint = textHeight;
- }
-
- text.setLayoutData(layoutData);
-
- text.addModifyListener(this);
-
- setText(initialText);
- }
-
- /**
- * Get the text of this composites text composite
- *
- * @return a {@link java.lang.String} object.
- */
- public String getText() {
- return text.getText();
- }
-
- /**
- * Set the text of this composites text composite
- *
- * @param string
- * a {@link java.lang.String} object.
- */
- public void setText(String string) {
- Listener[] listeners = text.getListeners(SWT.Modify);
-
- for (Listener listener : listeners) {
- text.removeListener(SWT.Modify, listener);
- }
-
- text.setText(CdmUtils.Nz(string));
-
- for (Listener listener : listeners) {
- text.addListener(SWT.Modify, listener);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events
- * .ModifyEvent)
- */
- /** {@inheritDoc} */
- public void modifyText(ModifyEvent e) {
- firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
- }
-
- /** {@inheritDoc} */
- public void setEnabled(boolean enabled) {
- text.setEnabled(enabled);
- String symbolicName = enabled ? Resources.COLOR_FONT_DEFAULT
- : Resources.COLOR_TEXT_DISABLED;
- text.setForeground(getColor(symbolicName));
- }
-
- /** {@inheritDoc} */
- public void setIrrelevant(boolean irrelevant) {
- String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT
- : Resources.COLOR_COMPOSITE_BACKGROUND;
-
- Color color = getColor(colorId);
- text.setBackground(color);
- }
-
- /** {@inheritDoc} */
- @Override
- public void setBackground(Color color) {
- if (label != null)
- label.setBackground(color);
- }
-
- @Override
- public void setSelected(boolean selected) {
- setBackground(selected ? SELECTED : getPersistentBackground());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#setFocus()
- */
- /** {@inheritDoc} */
- @Override
- public void setFocus() {
- text.setFocus();
- }
-
- /**
- * <p>
- * getMainControl
- * </p>
- *
- * @return a {@link org.eclipse.swt.widgets.Control} object.
- */
- public Control getMainControl() {
- return text;
- }
-
- /**
- * <p>
- * setTextLimit
- * </p>
- *
- * @param limit
- * a int.
- */
- public void setTextLimit(int limit) {
- text.setTextLimit(limit);
- }
+public class TextWithLabelElement extends AbstractCdmFormElement implements ModifyListener, IEnableableFormElement,
+ ISelectable {
+
+ protected Text text;
+ private Label label;
+
+ /** Constant <code>MAX_HEIGHT=0</code> */
+ public static final int MAX_HEIGHT = 0;
+ /** Constant <code>SINGLE=-1</code> */
+ public static final int SINGLE = -1;
+
+ /**
+ * <p>
+ * Constructor for TextWithLabelElement.
+ * </p>
+ *
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+ * object.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param initialText
+ * a {@link java.lang.String} object.
+ * @param textHeight
+ * a {@link java.lang.Integer} object.
+ * @param style
+ * a int.
+ * @wbp.parser.entryPoint
+ */
+ protected TextWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
+ String initialText, Integer textHeight, int style) {
+ super(formFactory, parentElement);
+
+ if (labelString != null) {
+ label = formFactory.createLabel(getLayoutComposite(), CdmUtils.Nz(labelString), SWT.NULL);
+ addControl(label);
+ label.setLayoutData(LayoutConstants.LEFT());
+ }
+
+ int scrollStyle = textHeight == null ? SWT.NULL : (SWT.V_SCROLL | SWT.MULTI);
+
+ int combinedStyle = style | SWT.BORDER | scrollStyle;
+
+ // SWT.PASSWORD does not work when SWT.WRAP is set.
+ if (style != SWT.PASSWORD) {
+ combinedStyle = combinedStyle | SWT.WRAP;
+ }
+
+ text = formFactory.createText(getLayoutComposite(), "", combinedStyle);
+
+ addControl(text);
+
+ // text.setWO
+
+ if (textHeight == null) {
+ text.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.character == SWT.CR) {
+ // Don't accept carriage returns as input when in single
+ // line mode
+ e.doit = false;
+ } else if (e.character == SWT.TAB) {
+ // traverse is not working for wrapped text widgets so
+ // we reintroduce it here
+ e.doit = false;
+ TextWithLabelElement.this.text.traverse(SWT.TRAVERSE_TAB_NEXT);
+ }
+ }
+ });
+ }
+
+ TableWrapData layoutData = LayoutConstants.FILL();
+ if (textHeight != null && textHeight > 0) {
+ (layoutData).heightHint = textHeight;
+ }
+
+ text.setLayoutData(layoutData);
+
+ text.addModifyListener(this);
+
+ setText(initialText);
+ }
+
+ /**
+ * Get the text of this composites text composite
+ *
+ * @return a {@link java.lang.String} object.
+ */
+ public String getText() {
+ return text.getText();
+ }
+
+ /**
+ * Set the text of this composites text composite
+ *
+ * @param string
+ * a {@link java.lang.String} object.
+ */
+ public void setText(String string) {
+ Listener[] listeners = text.getListeners(SWT.Modify);
+
+ for (Listener listener : listeners) {
+ text.removeListener(SWT.Modify, listener);
+ }
+
+ text.setText(CdmUtils.Nz(string));
+
+ for (Listener listener : listeners) {
+ text.addListener(SWT.Modify, listener);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events
+ * .ModifyEvent)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void modifyText(ModifyEvent e) {
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setEnabled(boolean enabled) {
+ text.setEnabled(enabled);
+ String symbolicName = enabled ? Resources.COLOR_FONT_DEFAULT : Resources.COLOR_TEXT_DISABLED;
+ text.setForeground(getColor(symbolicName));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setIrrelevant(boolean irrelevant) {
+ String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT : Resources.COLOR_COMPOSITE_BACKGROUND;
+
+ Color color = getColor(colorId);
+ text.setBackground(color);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setBackground(Color color) {
+ if (label != null) {
+ label.setBackground(color);
+ }
+ }
+
+ @Override
+ public void setSelected(boolean selected) {
+ setBackground(selected ? SELECTED : getPersistentBackground());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#setFocus()
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void setFocus() {
+ text.setFocus();
+ }
+
+ /**
+ * <p>
+ * getMainControl
+ * </p>
+ *
+ * @return a {@link org.eclipse.swt.widgets.Control} object.
+ */
+ public Control getMainControl() {
+ return text;
+ }
+
+ /**
+ * <p>
+ * setTextLimit
+ * </p>
+ *
+ * @param limit
+ * a int.
+ */
+ public void setTextLimit(int limit) {
+ text.setTextLimit(limit);
+ }
}
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* @version 1.0
*/
public abstract class AbstractCdmViewPart extends ViewPart implements ISelectionListener, IPostOperationEnabled, IConversationEnabled, IDirtyMarkableSelectionProvider{
-
+
protected ISelectionService selectionService;
public static IStructuredSelection EMPTY_SELECTION = new StructuredSelection();
-
+
protected IWorkbenchPart part;
-
+
private PageBook pageBook;
private Label emptySelectionLabel;
private Composite viewerComposite;
-
+
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
selectionService = getSite().getWorkbenchWindow().getSelectionService();
selectionService.addSelectionListener(this);
-
+
pageBook = new PageBook(parent, SWT.NULL);
createViewerComposite(pageBook);
createViewer(viewerComposite);
-
+
// Page 2: Nothing selected
emptySelectionLabel = new Label(pageBook, SWT.TOP + SWT.LEFT + SWT.WRAP);
-
+
setInitialSelection();
}
-
+
/**
- *
+ *
*/
private void setInitialSelection() {
selectionChanged(StoreUtil.getActivePart(), getInitialSelection());
protected ISelection getInitialSelection() {
return selectionService.getSelection();
}
-
+
private void createViewerComposite(Composite parent) {
viewerComposite = new SashForm(parent, SWT.HORIZONTAL);
}
-
+
/**
* <p>showEmptyPage</p>
*/
public void showEmptyPage(){
pageBook.showPage(emptySelectionLabel);
}
-
+
/**
* <p>showViewer</p>
*
* @param selection a {@link org.eclipse.jface.viewers.ISelection} object.
*/
public void showViewer(IWorkbenchPart part, IStructuredSelection selection){
- this.part = part;
-
+ this.part = part;
+
Object element = selection.getFirstElement();
-
+
getViewer().setInput(element);
-
+
showViewer();
}
-
+
/**
* <p>getViewer</p>
*
public void showViewer(){
pageBook.showPage(viewerComposite);
}
-
+
public void setEnabled(boolean enabled){
pageBook.setEnabled(enabled);
}
-
+
/** {@inheritDoc} */
@Override
public void setFocus() {
if(getConversationHolder() != null){
getConversationHolder().bind();
- }
- getViewer().getControl().setFocus();
+ }
+ getViewer().getControl().setFocus();
}
-
+
/**
* <p>createViewer</p>
*
* @param parent a {@link org.eclipse.swt.widgets.Composite} object.
*/
public abstract void createViewer(Composite parent);
-
+
/** {@inheritDoc} */
- public boolean postOperation(CdmBase objectAffectedByOperation) {
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
changed(objectAffectedByOperation);
return true;
}
-
+
/** {@inheritDoc} */
- public abstract void changed(Object object);
-
+ @Override
+ public abstract void changed(Object object);
+
/**
* <p>getConversationHolder</p>
*
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
*/
- public ConversationHolder getConversationHolder() {
- if(part != null)
- return ((IConversationEnabled) part).getConversationHolder();
-
+ @Override
+ public ConversationHolder getConversationHolder() {
+ if(part != null) {
+ return ((IConversationEnabled) part).getConversationHolder();
+ }
+
return null;
}
-
+
/** {@inheritDoc} */
- public void update(CdmDataChangeMap changeEvents) {
-
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {
+
}
-
+
/** {@inheritDoc} */
@Override
public void dispose() {
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* @version 1.0
*/
public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartContentHasSupplementalData{
-
+
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.forms.det"{trunked}</code> */
public static String ID = "eu.etaxonomy.taxeditor.view.detail";
@Override
public void createViewer(Composite parent) {
//selectionService.addPostSelectionListener(this);
-
+
viewer = new DetailsViewer(parent, this);
getSite().setSelectionProvider(viewer);
}
/** {@inheritDoc} */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if(StoreUtil.getActiveEditor() == null){
showEmptyPage();
return;
}
-
+
if(part == this){
return;
}
-
+
if(!(selection instanceof IStructuredSelection)){
return;
}
-
+
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-
+
if((part instanceof IEditorPart) || (part instanceof AbstractCdmViewPart)) {
if(structuredSelection.size() != 1){
showEmptyPage();
return;
}
-
- // do not show details for feature nodes TODO really?
+
+ // do not show details for feature nodes TODO really?
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
// do show the map for distributions
Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature();
return;
}
}
-
+
showViewer(part, structuredSelection);
}else{
- showEmptyPage();
- }
+ showEmptyPage();
+ }
}
-
+
/** {@inheritDoc} */
@Override
public boolean postOperation(CdmBase objectAffectedByOperation) {
-
+
viewer.setInput(objectAffectedByOperation);
-
+
return super.postOperation(objectAffectedByOperation);
}
-
-
+
+
/** {@inheritDoc} */
@Override
public Viewer getViewer() {
return viewer;
}
-
+
/** {@inheritDoc} */
@Override
public void dispose() {
*
* @return a boolean.
*/
- public boolean onComplete() {
+ @Override
+ public boolean onComplete() {
return true;
}
}
| ExpandableComposite.EXPANDED);
addPart(definedTermDetailSection);
}
+
+ private void createFOSection(RootElement parent){
+ destroySections();
+
+ GeneralDetailSection generalDetailSection = formFactory.createFOSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ FieldObservationDetailSection fieldObservationDetailSection =formFactory.createFODetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+
+ addPart(generalDetailSection);
+ addPart(gatheringEventDetailSection);
+ addPart(fieldObservationDetailSection);
+ }
}