public void filter(ActionFilter filter) { List<String> filteredActionIds = filter(allActionIds, filter); // Build the table data int nbRows = filteredActionIds.size(); actionIds = new String[nbRows]; descriptions = new String[nbRows]; data = new Object[nbRows][NUM_OF_COLUMNS]; for (int i = 0; i < nbRows; ++i) { String actionId = filteredActionIds.get(i); actionIds[i] = actionId; ActionDescriptor actionDescriptor = ActionProperties.getActionDescriptor(actionId); data[i][ACTION_DESCRIPTION_COLUMN_INDEX] = db.get(actionId).get(this.description); KeyStroke accelerator = (KeyStroke) db.get(actionId).get(this.accelerator); setAccelerator(accelerator, i); KeyStroke alternativeAccelerator = (KeyStroke) db.get(actionId).get(this.alt_accelerator); setAlternativeAccelerator(alternativeAccelerator, i); descriptions[i] = actionDescriptor.getDescription(); } ShortcutsTable.this.clearSelection(); ((DefaultTableModel) getModel()).setRowCount(data.length); ShortcutsTable.this.repaint(); ShortcutsTable.this.scrollToVisible(0, 0); }
public ShortcutsTableData() { allActionIds = new ArrayList<String>(); Iterator<String> iterator = ActionManager.getActionIds(); while (iterator.hasNext()) allActionIds.add(iterator.next()); Collections.sort(allActionIds, ACTIONS_COMPARATOR); final int nbActions = allActionIds.size(); db = new HashMap<String, HashMap<Integer, Object>>(nbActions); int nbRows = allActionIds.size(); data = new Object[nbRows][NUM_OF_COLUMNS]; for (String actionId : allActionIds) { ActionDescriptor actionDescriptor = ActionProperties.getActionDescriptor(actionId); HashMap<Integer, Object> actionProperties = new HashMap<Integer, Object>(); ImageIcon actionIcon = actionDescriptor.getIcon(); if (actionIcon == null) actionIcon = transparentIcon; String actionLabel = actionDescriptor.getLabel(); /* 0 -> action's icon & name pair */ actionProperties.put( description, new Pair<ImageIcon, String>( IconManager.getPaddedIcon(actionIcon, new Insets(0, 4, 0, 4)), actionLabel)); /* 1 -> action's accelerator */ actionProperties.put(accelerator, ActionKeymap.getAccelerator(actionId)); /* 2 -> action's alternate accelerator */ actionProperties.put(alt_accelerator, ActionKeymap.getAlternateAccelerator(actionId)); /* 3 -> action's description */ actionProperties.put(tooltips, actionDescriptor.getDescription()); db.put(actionId, actionProperties); } }