1 11 package org.eclipse.jdt.internal.ui.refactoring; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.swt.widgets.Table; 16 import org.eclipse.swt.widgets.TableItem; 17 import org.eclipse.swt.widgets.Widget; 18 19 import org.eclipse.jface.viewers.CheckboxTableViewer; 20 21 import org.eclipse.jdt.internal.corext.refactoring.structure.IMemberActionInfo; 22 23 class PullPushCheckboxTableViewer extends CheckboxTableViewer{ 24 public PullPushCheckboxTableViewer(Table table) { 25 super(table); 26 } 27 28 31 protected void doUpdateItem(Widget widget, Object element, boolean fullMap) { 32 super.doUpdateItem(widget, element, fullMap); 33 if (! (widget instanceof TableItem)) 34 return; 35 TableItem item= (TableItem)widget; 36 IMemberActionInfo info= (IMemberActionInfo)element; 37 item.setChecked(PullPushCheckboxTableViewer.getCheckState(info)); 38 Assert.isTrue(item.getChecked() == PullPushCheckboxTableViewer.getCheckState(info)); 39 } 40 41 44 protected void inputChanged(Object input, Object oldInput) { 45 super.inputChanged(input, oldInput); 46 setCheckState((IMemberActionInfo[])input); 48 } 49 50 private void setCheckState(IMemberActionInfo[] infos) { 51 if (infos == null) 52 return; 53 for (int i= 0; i < infos.length; i++) { 54 IMemberActionInfo info= infos[i]; 55 setChecked(info, PullPushCheckboxTableViewer.getCheckState(info)); 56 } 57 } 58 59 private static boolean getCheckState(IMemberActionInfo info) { 60 return info.isActive(); 61 } 62 63 66 public void refresh() { 67 int topIndex = getTable().getTopIndex(); 68 super.refresh(); 69 setCheckState((IMemberActionInfo[])getInput()); 71 if (topIndex < getTable().getItemCount()) 72 getTable().setTopIndex(topIndex); } 74 } 75 | Popular Tags |