private Object[] keys(boolean all) { java.util.HashSet<Object> keys = new java.util.HashSet<Object>(); Component c = component; for (;;) { if (c instanceof JComponent) { javax.swing.ActionMap m = ((JComponent) c).getActionMap(); if (m != null) { java.util.List<Object> l; Object[] keyList = null; if (all) { keyList = m.allKeys(); } else { keyList = m.keys(); } if (keyList != null) { keys.addAll(java.util.Arrays.asList(keyList)); } } } if (c instanceof Lookup.Provider) { break; } c = c.getParent(); if (c == null) { break; } } return keys.toArray(); }
ArrayList<Object> old = new ArrayList<Object>(); if (prev != null) { Object[] all = prev.allKeys(); if (all != null) { old.addAll(Arrays.asList(all)); if (newMap != null) { Object[] toRem = newMap.allKeys(); if (toRem != null) { old.removeAll(Arrays.asList(toRem)); Object[] allK = newMap.allKeys(); if (allK != null) { for (int i = 0; i < allK.length; i++) {
final void notifyListeners(ActionMap prev, ActionMap now) { if (prev == null) prev = new ActionMap(); if (now == null) now = new ActionMap(); HashSet<Object> keys = new HashSet<Object>(); Object[] allPrev = prev.allKeys(); Object[] allNow = now.allKeys(); if (allPrev != null) { keys.addAll(Arrays.asList(allPrev)); } if (allNow != null) { keys.addAll(Arrays.asList(allNow)); } for (Object k : keys) { Set<GeneralAction.BaseDelAction> actions = listeners.get(k); if (actions == null) { continue; } for (GeneralAction.BaseDelAction del : actions) { if (del != null) { del.updateState(prev, now, true); } } } }
private Object[] keys(boolean all) { java.util.HashSet<Object> keys = new java.util.HashSet<Object>(); Component c = component; for (;;) { if (c instanceof JComponent) { javax.swing.ActionMap m = ((JComponent) c).getActionMap(); if (m != null) { java.util.List<Object> l; Object[] keyList = null; if (all) { keyList = m.allKeys(); } else { keyList = m.keys(); } if (keyList != null) { keys.addAll(java.util.Arrays.asList(keyList)); } } } if (c instanceof Lookup.Provider) { break; } c = c.getParent(); if (c == null) { break; } } return keys.toArray(); }
public Object[] getCommands() { ActionMap map = component.getActionMap(); return map.allKeys(); }
public Object[] getCommands() { ActionMap map = component.getActionMap(); return map.allKeys(); }
public Object[] getCommands() { ActionMap map = component.getActionMap(); return map.allKeys(); }
public Object[] getCommands() { ActionMap map = component.getActionMap(); return map.allKeys(); }
private Object[] keys(boolean all) { java.util.Set keys = new java.util.HashSet (); javax.swing.ActionMap m = delegate == null ? component.getActionMap () : delegate; if (m != null) { java.util.List l; if (all) { l = java.util.Arrays.asList (m.allKeys ()); } else { l = java.util.Arrays.asList (m.keys ()); } keys.addAll (l); } return keys.toArray (); }
private Object[] keys(boolean all) { java.util.Set keys = new java.util.HashSet (); javax.swing.ActionMap m = delegate == null ? component.getActionMap () : delegate; if (m != null) { java.util.List l; if (all) { l = java.util.Arrays.asList (m.allKeys ()); } else { l = java.util.Arrays.asList (m.keys ()); } keys.addAll (l); } return keys.toArray (); }
/** * Searches all actions of a JTextComponent for ab action of the given class and returns * the first one that matches that class, or null if no Action is found * * @return Action object of that class or null */ public static <T extends Action> T getAction(JTextComponent target, Class<T> aClass) { for (Object k : target.getActionMap().allKeys()) { Action a = target.getActionMap().get(k); if (aClass.isInstance(a)) { @SuppressWarnings("unchecked") T t = (T) a; return t; } } return null; }
static @Nonnull Object findActionKey(@Nonnull String name, @Nonnull ActionMap actionMap) { Action action = actionMap.get(name); if (action != null) { return name; } Object[] allKeys = actionMap.allKeys(); if (allKeys != null) { for (Object key : allKeys) { action = actionMap.get(key); if (name.equals(action.getValue(NAME))) { return checkNotNull(key); } } } String message = String.format("The action '%s' is not available", name); if (allKeys != null && allKeys.length > 0) { message = concat(message, ", available actions:", formatAllActionKeys(allKeys)); } throw actionFailure(message); }
/** * Searches all actions of a JTextComponent for ab action of the given class and returns * the first one that matches that class, or null if no Action is found * @param <T> * @param target * @param aClass * @return Action object of that class or null */ public static <T extends Action> T getAction(JTextComponent target, Class<T> aClass) { for (Object k : target.getActionMap().allKeys()) { Action a = target.getActionMap().get(k); if (aClass.isInstance(a)) { @SuppressWarnings("unchecked") T t = (T) a; return t; } } return null; }
/** * Adds Net2Plan's global key combinations to a given input and action map. * The added actions correspond to the ones that are found on the top menu at the main window. * Useful for adding these actions to new windows that are not contained within GUINet2Plan. * @param iMap Input window input map. * @param aMap Input window action map. */ public static void addGlobalActions(InputMap iMap, ActionMap aMap) { assert inputMap != null; assert actionMap != null; if (inputMap.allKeys() == null) return; if (actionMap.allKeys() == null) return; for (KeyStroke keyStroke : inputMap.allKeys()) { final Object o = inputMap.get(keyStroke); iMap.put(keyStroke, inputMap.get(keyStroke)); aMap.put(o, actionMap.get(o)); } }
/** * Updates locale-dependent state. * * Here: updates registered column actions' locale-dependent state. * <p> * * PENDING: Try better to find all column actions including custom * additions? Or move to columnControl? * * @see #setLocale(Locale) */ protected void updateLocaleState(Locale locale) { for (Object key : getActionMap().allKeys()) { if (key instanceof String) { String keyString = getUIString((String) key, locale); if (!key.equals(keyString)) { getActionMap().get(key).putValue(Action.NAME, keyString); } } } bindSearchLabel(locale); }
/** * Updates locale-dependent state. * * Here: updates registered column actions' locale-dependent state. * <p> * * PENDING: Try better to find all column actions including custom * additions? Or move to columnControl? * * @see #setLocale(Locale) */ protected void updateLocaleState(Locale locale) { for (Object key : getActionMap().allKeys()) { if (key instanceof String) { String keyString = getUIString((String) key, locale); if (!key.equals(keyString)) { getActionMap().get(key).putValue(Action.NAME, keyString); } } } bindSearchLabel(locale); }
/** * Updates locale-dependent state. * * Here: updates registered column actions' locale-dependent state. * <p> * * PENDING: Try better to find all column actions including custom * additions? Or move to columnControl? * * @see #setLocale(Locale) */ protected void updateLocaleState(Locale locale) { for (Object key : getActionMap().allKeys()) { if (key instanceof String) { String keyString = getUIString((String) key, locale); if (!key.equals(keyString)) { getActionMap().get(key).putValue(Action.NAME, keyString); } } } bindSearchLabel(locale); }
/** * Updates locale-dependent state. * * Here: updates registered column actions' locale-dependent state. * <p> * * PENDING: Try better to find all column actions including custom * additions? Or move to columnControl? * * @see #setLocale(Locale) */ protected void updateLocaleState(Locale locale) { for (Object key : getActionMap().allKeys()) { if (key instanceof String) { String keyString = getUIString((String) key, locale); if (!key.equals(keyString)) { getActionMap().get(key).putValue(Action.NAME, keyString); } } } bindSearchLabel(locale); }
/** * Updates locale-dependent state. * * Here: updates registered column actions' locale-dependent state. * <p> * * PENDING: Try better to find all column actions including custom * additions? Or move to columnControl? * * @see #setLocale(Locale) */ protected void updateLocaleState(Locale locale) { for (Object key : getActionMap().allKeys()) { if (key instanceof String) { String keyString = getUIString((String) key, locale); if (!key.equals(keyString)) { getActionMap().get(key).putValue(Action.NAME, keyString); } } } bindSearchLabel(locale); }
/** * Updates this dialog's locale-dependent state. * * Here: updates title and actions. * <p> * * * @see #setLocale(Locale) */ protected void updateLocaleState(Locale locale) { setTitleFromContent(); for (Object key : getRootPane().getActionMap().allKeys()) { if (key instanceof String) { Action contentAction = content.getActionMap().get(key); Action rootPaneAction = getAction(key); if ((!rootPaneAction.equals(contentAction))) { String keyString = getUIString((String) key, locale); if (!key.equals(keyString)) { rootPaneAction.putValue(Action.NAME, keyString); } } } } }