All pastes #364851 Raw Edit

mavines

public java v1 · immutable
#364851 ·published 2007-02-20 13:10 UTC
rendered paste body
		table.addListener(SWT.KeyDown,new Listener(){			public void handleEvent(Event e)			{				switch (e.character)				{				case SWT.DEL:					final int[] indices=table.getSelectionIndices();					int selectedIndex=(indices.length<=1)?table.getSelectionIndex():-1;										if (indices!=null && indices.length>0)					{						final Control[] children=table.getChildren();						for (int i=indices.length-1;i>=0&&selectedIndex==-1;i--)						{							int index=indices[i];							children[index].dispose();							final TableEditor ed=tableEditors.remove(index);							ed.getEditor().dispose();							ed.getItem().dispose();							ed.dispose();						}						if (selectedIndex>-1)						{							table.getChildren()[selectedIndex].dispose();							final TableEditor ed=tableEditors.remove(selectedIndex);							ed.dispose();						}						if (selectedIndex==-1)						{							table.remove(indices);							int index=indices[0];							for (int i=index;i<tableEditors.size();i++)							{								tableEditors.get(i).setItem(table.getItem(i));							}						}						else						{							table.remove(selectedIndex);							for (int i=selectedIndex;i<tableEditors.size();i++)							{								tableEditors.get(i).setItem(table.getItem(i));							}						}						table.changed(children);						table.redraw();					}					break;				default:					break;				}			}		});