public void ensureSelectionVisible(boolean forceTopSelection) { if (isSelectionVisible() && !forceTopSelection) { return; } if (!forceTopSelection) { ListScrollingUtil.ensureIndexIsVisible(myList, myList.getSelectedIndex(), 1); return; } // selected item should be at the top of the visible list int top = myList.getSelectedIndex(); if (top > 0) { top--; // show one element above the selected one to give the hint that there are more // available via scrolling } int firstVisibleIndex = myList.getFirstVisibleIndex(); if (firstVisibleIndex == top) { return; } ListScrollingUtil.ensureRangeIsVisible( myList, top, top + myList.getLastVisibleIndex() - firstVisibleIndex); }
public void reset() { final ActionMacro[] allMacros = ActionMacroManager.getInstance().getAllMacros(); for (ActionMacro macro : allMacros) { myMacrosModel.addElement(macro.clone()); } myMacrosList.setModel(myMacrosModel); ListScrollingUtil.ensureSelectionExists(myMacrosList); }
private void initActionList(ActionMacro macro) { DefaultListModel actionModel = new DefaultListModel(); final ActionMacro.ActionDescriptor[] actions = macro.getActions(); for (ActionMacro.ActionDescriptor action : actions) { actionModel.addElement(action); } myMacroActionsList.setModel(actionModel); ListScrollingUtil.ensureSelectionExists(myMacroActionsList); }
private boolean isSelectionVisible() { return ListScrollingUtil.isIndexFullyVisible(myList, myList.getSelectedIndex()); }