Project

General

Profile

Revision aae0ca06

IDaae0ca069a639007aa180a7193fa0b510c0499d7
Parent 4b9974cd
Child 72836bf3

Added by Katja Luther 7 months ago

fix #8749: move proposal adapter creation to method in abstractComboDetailElement

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/AbstractComboElement.java
11 11
import java.util.ArrayList;
12 12

  
13 13
import org.eclipse.equinox.internal.p2.ui.misc.StringMatcher;
14
import org.eclipse.jface.fieldassist.ComboContentAdapter;
15
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
14 16
import org.eclipse.jface.fieldassist.IContentProposal;
17
import org.eclipse.jface.fieldassist.IContentProposalListener;
15 18
import org.eclipse.jface.fieldassist.IContentProposalProvider;
16 19
import org.eclipse.swt.SWT;
17 20
import org.eclipse.swt.events.DisposeEvent;
......
28 31
import eu.etaxonomy.taxeditor.preference.Resources;
29 32
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
30 33
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
34
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
31 35
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
32 36
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
33 37
import eu.etaxonomy.taxeditor.ui.element.ISelectable;
......
68 72
        combo.setLayoutData(fill_HORIZONTALLY);
69 73
        fill_HORIZONTALLY.maxWidth = 50;
70 74
        combo.setVisibleItemCount(DEFAULT_VISIBLE_ITEMS);
71

  
72

  
73

  
74 75
        //disable mouse-wheel selection
75 76
        combo.addListener(SWT.MouseWheel, e->e.doit=false);
76
//        combo.addListener(SWT.MouseUp, e->firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)));
77

  
78

  
77 79
    }
78 80

  
81

  
82

  
79 83
    /** {@inheritDoc} */
80 84
    @Override
81 85
    public void setBackground(Color color) {
......
143 147

  
144 148
    public abstract void setSelection(T selection);
145 149

  
150

  
151

  
152
    private AbstractComboElement<T> getComboElement(){
153
        return this;
154
    }
155

  
156

  
157
    protected void addContentProposalAdapter() {
158
        ContentProposalAdapter adapter;
159

  
160
        adapter = new ContentProposalAdapter(combo, new ComboContentAdapter(), getProposalProvider(), null, null);
161
        adapter.setPropagateKeys(true);
162
        adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
163
        adapter.addContentProposalListener(new IContentProposalListener() {
164
            @Override
165
            public void proposalAccepted(IContentProposal proposal) {
166
                setSelection((T)combo.getData(proposal.getContent()));
167
                firePropertyChangeEvent(new CdmPropertyChangeEvent(getComboElement(), null));
168
            }
169
        });
170
    }
171

  
146 172
    IContentProposalProvider getProposalProvider() {
147 173
        return new IContentProposalProvider() {
148 174
            @Override
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/EnumComboElement.java
177 177
		label.setText(getDefaultLabelString());
178 178
		populateTypes(comparator);
179 179
		combo.addSelectionListener(this);
180
		addContentProposalAdapter();
180 181
	}
181 182

  
182 183
	public void setIndent(int indent) {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/NameRelationshipTypeCombo.java
18 18
import org.eclipse.swt.events.SelectionEvent;
19 19

  
20 20
import eu.etaxonomy.cdm.model.common.Language;
21
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
21 22
import eu.etaxonomy.cdm.model.term.Representation;
22 23
import eu.etaxonomy.cdm.model.term.TermType;
23
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
24 24
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
25 25
import eu.etaxonomy.taxeditor.store.CdmStore;
26 26
import eu.etaxonomy.taxeditor.store.TermManager;
......
62 62
     this.useAbbrevLabel = useAbbrevLabel;
63 63
     populateTerms();
64 64
     label.setText(labelString);
65
     addContentProposalAdapter();
65 66
     FontDescriptor descriptor = FontDescriptor.createFrom(label.getFont());
66 67
  // setStyle method returns a new font descriptor for the given style
67 68
     descriptor = descriptor.setStyle(SWT.ITALIC);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/VocabularyComboElement.java
8 8
import java.util.Comparator;
9 9
import java.util.List;
10 10

  
11
import org.eclipse.jface.fieldassist.ComboContentAdapter;
12
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
13
import org.eclipse.jface.fieldassist.IContentProposal;
14
import org.eclipse.jface.fieldassist.IContentProposalListener;
15 11
import org.eclipse.jface.util.PropertyChangeEvent;
16 12
import org.eclipse.swt.SWT;
17 13
import org.eclipse.swt.events.SelectionEvent;
......
58 54

  
59 55
        combo.addSelectionListener(this);
60 56
        combo.addDisposeListener(this);
61
        ContentProposalAdapter adapter;
62

  
63
        adapter = new ContentProposalAdapter(combo, new ComboContentAdapter(), getProposalProvider(), null, null);
64
        adapter.setPropagateKeys(true);
65
        adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
66
        adapter.addContentProposalListener(new IContentProposalListener() {
67

  
68
            @Override
69
            public void proposalAccepted(IContentProposal proposal) {
70
                setSelection((VOC)combo.getData(proposal.getContent()));
71
                firePropertyChangeEvent(new CdmPropertyChangeEvent(getComboElement(), null));
72
            }
73
        });
57
        addContentProposalAdapter();
74 58

  
75 59
        PreferencesUtil.getPreferenceStore().addPropertyChangeListener(this);
76 60

  
......
79 63
        }
80 64
	}
81 65

  
82
	/**
66

  
67

  
68
    /**
83 69
	 * <p>Sets the selection of the combo to the given T object.</p>
84 70
	 * <p>Passing <code>null</code> to this method will set the selection to
85 71
	 * the empty element and effectively clear the selection</p>
......
252 238
        combo.remove(EMPTY_ELEMENT_LABEL);
253 239
    }
254 240

  
255
    private VocabularyComboElement<TERM, VOC> getComboElement(){
256
        return this;
257
    }
258

  
259 241
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/term/TermComboElement.java
127 127

  
128 128
        combo.addSelectionListener(this);
129 129
        combo.addDisposeListener(this);
130

  
131
        addContentProposalAdapter();
130 132
        PreferencesUtil.getPreferenceStore().addPropertyChangeListener(this);
131 133

  
132 134
        if (selection != null) {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)