Friday 15 June 2012

java - SWT/JFace TextCellEditor Field Assist Not Working -



java - SWT/JFace TextCellEditor Field Assist Not Working -

i trying execute code block extending textcelleditor , using org.eclipse.jface.fieldassist fire content proposal. code executing fine content proposal pop not beingness fired. cell not editable. please allow me know wrong here?

public class snippet060textcelleditorwithcontentproposal { private static class color { public string name; public color(string name) { this.name = name; } public string tostring() { homecoming name; } } public static class textcelleditorwithcontentproposal extends textcelleditor { private contentproposaladapter contentproposaladapter; private boolean popupopen = false; // true, iff popup open public textcelleditorwithcontentproposal(composite parent, icontentproposalprovider contentproposalprovider, keystroke keystroke, char[] autoactivationcharacters) { super(parent); enablecontentproposal(contentproposalprovider, keystroke, autoactivationcharacters); } private void enablecontentproposal( icontentproposalprovider contentproposalprovider, keystroke keystroke, char[] autoactivationcharacters) { contentproposaladapter = new contentproposaladapter(text, new textcontentadapter(), contentproposalprovider, keystroke, autoactivationcharacters); // hear popup open/close events able handle focus // events correctly contentproposaladapter .addcontentproposallistener(new icontentproposallistener2() { public void proposalpopupclosed( contentproposaladapter adapter) { popupopen = false; } public void proposalpopupopened( contentproposaladapter adapter) { popupopen = true; } }); } /** * homecoming {@link contentproposaladapter} of cell editor. * * @return {@link contentproposaladapter} */ public contentproposaladapter getcontentproposaladapter() { homecoming contentproposaladapter; } protected void focuslost() { if (!popupopen) { // focus lost deactivates cell editor. // must not happen if focus lost caused activating // completion proposal popup. super.focuslost(); } } protected boolean dependsonexternalfocuslistener() { // homecoming false; // otherwise, columnviewereditor install additional // focus listener // cancels cell editing on focus lost, if focus gets lost // due // activation of completion proposal popup. see bug 58777. homecoming false; } } private static class colornameeditingsupport extends editingsupport { private textcelleditorwithcontentproposal celleditor; public colornameeditingsupport(tableviewer viewer) { super(viewer); icontentproposalprovider contentproposalprovider = new simplecontentproposalprovider( new string[] { "red", "green", "blue" }); celleditor = new textcelleditorwithcontentproposal( viewer.gettable(), contentproposalprovider, null, null); } protected boolean canedit(object element) { homecoming (element instanceof color); } protected celleditor getcelleditor(object element) { homecoming celleditor; } protected object getvalue(object element) { homecoming ((color) element).name; } protected void setvalue(object element, object value) { ((color) element).name = value.tostring(); getviewer().update(element, null); } } public snippet060textcelleditorwithcontentproposal(shell shell) { final tableviewer viewer = new tableviewer(shell, swt.border | swt.full_selection); final table table = viewer.gettable(); table.setlinesvisible(true); table.setheadervisible(true); final tableviewercolumn colorcolumn = new tableviewercolumn(viewer, swt.left); colorcolumn.getcolumn().settext("color name"); colorcolumn.getcolumn().setwidth(200); colorcolumn.setlabelprovider(new columnlabelprovider()); colorcolumn.seteditingsupport(new colornameeditingsupport(viewer)); viewer.setcontentprovider(new arraycontentprovider()); columnviewereditoractivationstrategy activationsupport = new columnviewereditoractivationstrategy( viewer) { protected boolean iseditoractivationevent( columnviewereditoractivationevent event) { homecoming event.eventtype == columnviewereditoractivationevent.traversal || event.eventtype == columnviewereditoractivationevent.mouse_double_click_selection || event.eventtype == columnviewereditoractivationevent.programmatic || (event.eventtype == columnviewereditoractivationevent.key_pressed && event.keycode == keylookupfactory .getdefault().formalkeylookup( ikeylookup.enter_name)); } }; activationsupport.setenableeditoractivationwithkeyboard(true); /* * without focus highlighter, keyboard events not delivered * columnviewereditoractivationstragety#iseditoractivationevent(...) * (see above) */ focuscellhighlighter focuscellhighlighter = new focuscellownerdrawhighlighter( viewer); tableviewerfocuscellmanager focuscellmanager = new tableviewerfocuscellmanager( viewer, focuscellhighlighter); tableviewereditor.create(viewer, focuscellmanager, activationsupport, columnviewereditor.tabbing_vertical | columnviewereditor.keyboard_activation); viewer.setinput(createmodel()); } private color[] createmodel() { homecoming new color[] { new color("red"), new color("green") }; } /** * @param args */ public static void main(string[] args) { display display = new display(); shell shell = new shell(display); shell.setlayout(new filllayout()); new snippet060textcelleditorwithcontentproposal(shell); shell.open(); while (!shell.isdisposed()) { if (!display.readanddispatch()) display.sleep(); } display.dispose(); } }

this working expected, did'nt realize cells registered mouse double click action. double click brings pop up

java swt jface

No comments:

Post a Comment