Project

General

Profile

« Previous | Next » 

Revision f5979052

Added by Katja Luther over 6 years ago

fix multiple representation by removing conversation of selection dialog

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java
31 31
import eu.etaxonomy.cdm.model.common.User;
32 32
import eu.etaxonomy.cdm.model.molecular.Amplification;
33 33
import eu.etaxonomy.cdm.model.molecular.Primer;
34
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
34
import eu.etaxonomy.cdm.model.reference.Reference;
35 35
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
36 36
import eu.etaxonomy.taxeditor.model.ImageResources;
37 37
import eu.etaxonomy.taxeditor.preference.Resources;
......
58 58
 * @param <T>
59 59
 */
60 60
public class EntitySelectionElement<T extends CdmBase> extends
61
		AbstractCdmFormElement implements  SelectionListener, IEnableableFormElement, ISelectableElement, IEntityElement<T>, ILabeledElement, IConversationEnabled, Observer {
61
		AbstractCdmFormElement implements  SelectionListener, IEnableableFormElement, ISelectableElement, IEntityElement<T>, ILabeledElement, //IConversationEnabled,
62
		Observer {
62 63

  
63 64
	private static final EnumSet<CRUD> UPDATE = EnumSet.of(CRUD.UPDATE);
64 65
	private static final EnumSet<CRUD> DELETE = EnumSet.of(CRUD.DELETE);
......
67 68
	/**
68 69
	 * Bitmask for configuring functionality of selection element
69 70
	 */
70
	public static final int NOTHING = 0; // 000
71
	public static final int EDITABLE = 1 << 0; // 001
72
	public static final int DELETABLE = 1 << 1; // 010
73
	public static final int SELECTABLE = 1 << 2; // 100
74
	public static final int ALL = EDITABLE | DELETABLE | SELECTABLE; // 111
75

  
71
	public static final int NOTHING = 0; // 0000
72
	public static final int EDITABLE = 1 << 0; // 0001
73
	public static final int DELETABLE = 1 << 1; // 0010
74
	public static final int SELECTABLE = 1 << 2; // 0100
75
	public static final int EXTERNAL = 1 << 3; // 1000
76
	public static final int ALL = EDITABLE | DELETABLE | SELECTABLE ; // 0111
77
	public static final int ALL_WITH_EXT = EDITABLE | DELETABLE | SELECTABLE | EXTERNAL ; // 1111
76 78
	protected T entity;
77 79
	protected T filteredEntity;
78 80

  
......
80 82
	protected Text text;
81 83
	protected Button button_selection;
82 84

  
85
	protected Button button_selectionExt;
86

  
83 87
	private SelectionArbitrator selectionArbitrator;
84 88

  
85 89
	protected Button button_edit;
......
93 97
	private final boolean isEditable;
94 98

  
95 99
	private final boolean isDeletable;
100
	private final boolean isExternal;
96 101

  
97
	private final ConversationHolder conversation;
102
//	private final ConversationHolder conversation;
98 103
	private Class<T> clazz;
99 104

  
100 105
	public EntitySelectionElement(CdmFormFactory formFactory,
101
			ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz,
106
//			ConversationHolder conversation,
107
	        ICdmFormElement parentElement, Class<T> clazz,
102 108
			String labelString, T entity, int mode, int style, boolean filterElement) {
103 109
		super(formFactory, parentElement);
104 110

  
105 111
		this.clazz = clazz;
106 112
		this.isEditable = (mode & EDITABLE) == EDITABLE;
107 113
		this.isDeletable = (mode & DELETABLE) == DELETABLE;
114
		this.isExternal= (mode & EXTERNAL) == EXTERNAL;
108 115
		boolean isSelectable = (mode & SELECTABLE) == SELECTABLE;
109 116

  
110 117
		this.labelString = (labelString == null || labelString.equals("")) ? "" : labelString;
111 118

  
112
		this.conversation = conversation;
119
//		this.conversation = conversation;
113 120

  
114 121
		if (isSelectable && formFactory.getSelectionProvider() != null) {
115 122
			selectionArbitrator = formFactory.createSelectionArbitrator(this);
......
128 135

  
129 136
    }
130 137

  
131
    public EntitySelectionElement(CdmFormFactory formFactory,
132
            ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz,
138
    public EntitySelectionElement(CdmFormFactory formFactory,//ConversationHolder conversation,
139
             ICdmFormElement parentElement, Class<T> clazz,
133 140
            String labelString, T entity, int mode, int style){
134
        this(formFactory, conversation, parentElement, clazz, labelString, entity, mode, style, false);
141
        this(formFactory, //conversation,
142
                parentElement, clazz, labelString, entity, mode, style, false);
135 143
    }
136 144

  
137 145
	private void createControls(Composite parent, int style) {
......
150 158
		if (isDeletable) {
151 159
			columns += 1;
152 160
		}
161
		if (isExternal) {
162
            columns += 1;
163
        }
153 164

  
154 165
		selectableComposite.setLayout(LayoutConstants.LAYOUT(columns, false));
155 166
		selectableComposite.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
......
172 183

  
173 184
		addControl(button_selection);
174 185
		button_selection.addSelectionListener(this);
175

  
186
		if (isExternal){
187
    		button_selectionExt = formFactory.createButton(selectableComposite, null,
188
                    SWT.PUSH);
189
    		button_selectionExt.setImage(ImageResources
190
                    .getImage(ImageResources.BROWSE_ICON));
191
    		button_selectionExt.setToolTipText("Browse existing from external cdm store");
192
    		button_selectionExt.setText("Ext");
193
            addControl(button_selectionExt);
194
            button_selectionExt.addSelectionListener(this);
195
		}
176 196
		if (isEditable) {
177 197
			button_edit = formFactory.createButton(selectableComposite, null,
178 198
					SWT.PUSH);
......
196 216

  
197 217
	@Override
198 218
    public void widgetSelected(SelectionEvent e) {
199
		T selection = SelectionDialogFactory.getSelectionFromDialog(clazz, getShell(), getConversationHolder(), getFilteredEntity(), getParentElement());
200
		setSelectionInternal(selection);
219
	    if (e.getSource().equals(button_selection) ){
220
	        T selection = SelectionDialogFactory.getSelectionFromDialog(clazz, getShell(), //getConversationHolder(),
221
	                getFilteredEntity(), getParentElement());
222
            setSelectionInternal(selection);
223
	    }else{
224
	        Reference selection = SelectionDialogFactory.getSelectionFromExtDialog(Reference.class, getShell(),//null,
225
	                getParentElement());
226
            setSelectionInternal((T)selection);
227
	    }
228

  
201 229
	}
202 230

  
203 231
	/**
......
437 465
	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
438 466
	 *         object.
439 467
	 */
440
	@Override
468
//	@Override
441 469
	public ConversationHolder getConversationHolder() {
442
		return conversation;
470
	    if(getParentElement() instanceof IConversationEnabled) {
471
            return ((IConversationEnabled)getParentElement()).getConversationHolder();
472
        }
473
	    return null;
443 474
	}
444 475

  
445 476
	/** {@inheritDoc} */
......
474 505
	}
475 506

  
476 507
	/** {@inheritDoc} */
477
	@Override
478
	public void update(CdmDataChangeMap changeEvents) {
479
	}
508
//	@Override
509
//	public void update(CdmDataChangeMap changeEvents) {
510
//	}
480 511

  
481 512
	/* (non-Javadoc)
482 513
	 * @see eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement#removeElements()

Also available in: Unified diff