Project

General

Profile

Revision edca2436

IDedca24366d5c18835b12ff06a5d209d6054ce4ba
Parent 66de5a6c
Child 6803fca4

Added by Katja Luther 12 months ago

ref #8748: fix filter, change combo from ccombo to combo

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;
16 14
import org.eclipse.jface.fieldassist.IContentProposal;
17 15
import org.eclipse.jface.fieldassist.IContentProposalProvider;
18 16
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.custom.CCombo;
20 17
import org.eclipse.swt.events.DisposeEvent;
21 18
import org.eclipse.swt.events.DisposeListener;
22 19
import org.eclipse.swt.events.SelectionEvent;
23 20
import org.eclipse.swt.events.SelectionListener;
24 21
import org.eclipse.swt.graphics.Color;
22
import org.eclipse.swt.widgets.Combo;
25 23
import org.eclipse.swt.widgets.Label;
26 24
import org.eclipse.ui.forms.widgets.TableWrapData;
27 25

  
......
51 49

  
52 50
    protected Label label;
53 51

  
54
    protected final CCombo combo;
52
    protected final Combo combo;
55 53

  
56 54

  
57 55

  
......
63 61
        addControl(label);
64 62

  
65 63
        // create combo
66
        combo = new CCombo(getLayoutComposite(), SWT.READ_ONLY|SWT.BORDER);
64
        combo = new Combo(getLayoutComposite(), SWT.BORDER);
67 65

  
68 66
        addControl(combo);
69 67
        TableWrapData fill_HORIZONTALLY = LayoutConstants.FILL_HORIZONTALLY();
70 68
        combo.setLayoutData(fill_HORIZONTALLY);
71 69
        fill_HORIZONTALLY.maxWidth = 50;
72 70
        combo.setVisibleItemCount(DEFAULT_VISIBLE_ITEMS);
73
        ContentProposalAdapter adapter = new ContentProposalAdapter(combo, new ComboContentAdapter(), getProposalProvider(), null, null);
74
        adapter.setPropagateKeys(true);
75
        adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
71

  
72

  
73

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

  
80 79
    /** {@inheritDoc} */
......
199 198
                        }
200 199
                    };
201 200
                }
201

  
202 202
                return proposals;
203 203
            }
204 204
        };
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;
11 15
import org.eclipse.jface.util.PropertyChangeEvent;
12 16
import org.eclipse.swt.SWT;
13 17
import org.eclipse.swt.events.SelectionEvent;
......
54 58

  
55 59
        combo.addSelectionListener(this);
56 60
        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
        });
74

  
57 75
        PreferencesUtil.getPreferenceStore().addPropertyChangeListener(this);
58 76

  
59 77
        if (selection != null) {
......
77 95

  
78 96
		Listener[] listeners = combo.getListeners(SWT.Selection);
79 97

  
80
		for (Listener listener : listeners) {
81
			combo.removeListener(SWT.Selection, listener);
82
		}
98
//		for (Listener listener : listeners) {
99
//			combo.removeListener(SWT.Selection, listener);
100
//		}
83 101
		int selectedIndex;
84 102
		if(selection == null){
85 103
			// set selection to the emptyElement
......
93 111
		}
94 112
		combo.select(selectedIndex);
95 113

  
96
		for (Listener listener : listeners) {
97
			combo.addListener(SWT.Selection, listener);
98
		}
114
//		for (Listener listener : listeners) {
115
//			combo.addListener(SWT.Selection, listener);
116
//		}
99 117
	}
100 118

  
101 119
	/**
......
151 169
			}
152 170

  
153 171
			combo.add(label);
172
			combo.setData(label, term);
154 173
			terms.add(term);
155 174

  
156 175
			i++;
......
200 219
	/** {@inheritDoc} */
201 220
	@Override
202 221
    public void widgetSelected(SelectionEvent e) {
203
		selection = terms.get(combo.getSelectionIndex());
222
	    int i = combo.getSelectionIndex();
223
	    if (i > -1){
224
	        selection = terms.get(i);
225
	    }else{
226
	        selection = null;
227
	    }
204 228
		firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
205 229
	}
206 230

  
......
228 252
        combo.remove(EMPTY_ELEMENT_LABEL);
229 253
    }
230 254

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

  
231 259
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)