public List<AnAction> getActions(boolean originalProvider) { final Ref<ActionToolbar> toolbar = new Ref<ActionToolbar>(); if (myToolbar != null) { new AwtVisitor(myToolbar) { @Override public boolean visit(Component component) { if (component instanceof ActionToolbar) { toolbar.set((ActionToolbar)component); return true; } return false; } }; } if (toolbar.get() != null) { return toolbar.get().getActions(originalProvider); } return null; }
@Override public List<SwitchTarget> getTargets(final boolean onlyVisible, boolean originalProvider) { final ArrayList<SwitchTarget> result = new ArrayList<SwitchTarget>(); TabInfo selected = myTabs.getSelectedInfo(); new AwtVisitor(selected.getComponent()) { @Override public boolean visit(Component component) { if (component instanceof JBTabs) { JBTabs tabs = (JBTabs)component; if (tabs != myTabs) { result.addAll(tabs.getTargets(onlyVisible, false)); return true; } } return false; } }; return result; }
@Override public SwitchTarget getCurrentTarget() { TabInfo selected = myTabs.getSelectedInfo(); final Ref<SwitchTarget> targetRef = new Ref<SwitchTarget>(); new AwtVisitor(selected.getComponent()) { @Override public boolean visit(Component component) { if (component instanceof JBTabs) { JBTabs tabs = (JBTabs)component; if (tabs != myTabs) { targetRef.set(tabs.getCurrentTarget()); return true; } } return false; } }; return targetRef.get(); }
private void resetProgressBars(final boolean enabled, @Nullable final Boolean completed) { new AwtVisitor(myPassStatuses) { @Override public boolean visit(Component component) { if (component instanceof JProgressBar) { JProgressBar progress = (JProgressBar)component; progress.setEnabled(enabled); if (completed != null) { if (completed) { progress.setValue(TrafficLightRenderer.MAX); myProgressToText.get(progress).setText(MAX_TEXT); } else { progress.setValue(0); myProgressToText.get(progress).setText(MIN_TEXT); } } } return false; } }; }
public List<SwitchTarget> getTargets(final boolean onlyVisible, boolean originalProvider) { final ArrayList<SwitchTarget> result = new ArrayList<SwitchTarget>(); TabInfo selected = myTabs.getSelectedInfo(); new AwtVisitor(selected.getComponent()) { @Override public boolean visit(Component component) { if (component instanceof JBTabs) { JBTabs tabs = (JBTabs)component; if (tabs != myTabs) { result.addAll(tabs.getTargets(onlyVisible, false)); return true; } } return false; } }; return result; }
public SwitchTarget getCurrentTarget() { TabInfo selected = myTabs.getSelectedInfo(); final Ref<SwitchTarget> targetRef = new Ref<SwitchTarget>(); new AwtVisitor(selected.getComponent()) { @Override public boolean visit(Component component) { if (component instanceof JBTabs) { JBTabs tabs = (JBTabs)component; if (tabs != myTabs) { targetRef.set(tabs.getCurrentTarget()); return true; } } return false; } }; return targetRef.get(); }
private void setPassesEnabled(final boolean enabled, @Nullable final Boolean completed) { new AwtVisitor(myPassStatuses) { @Override public boolean visit(Component component) { if (component instanceof JProgressBar) { JProgressBar progress = (JProgressBar)component; progress.setEnabled(enabled); if (completed != null) { if (completed) { progress.setValue(MAX); myProgressToText.get(progress).setText(MAX_TEXT); } else { progress.setValue(0); myProgressToText.get(progress).setText(MIN_TEXT); } } } return false; } }; }
public static void unregisterKeyboardActions(final JRootPane rootPane) { new AwtVisitor(rootPane) { @Override public boolean visit(final Component component) { if (component instanceof JComponent) { final JComponent eachComp = (JComponent)component; final ActionMap actionMap = eachComp.getActionMap(); final KeyStroke[] strokes = eachComp.getRegisteredKeyStrokes(); for (KeyStroke eachStroke : strokes) { boolean remove = true; if (actionMap != null) { for (int i : new int[]{JComponent.WHEN_FOCUSED, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, JComponent.WHEN_IN_FOCUSED_WINDOW}) { final InputMap inputMap = eachComp.getInputMap(i); final Object key = inputMap.get(eachStroke); if (key != null) { final Action action = actionMap.get(key); if (action instanceof UIResource) remove = false; } } } if (remove) eachComp.unregisterKeyboardAction(eachStroke); } } return false; } }; }
public void initStyle(Component c, boolean includeChildren) { if (includeChildren) { new AwtVisitor(c) { @Override public boolean visit(Component component) { doInit(component); return false; } }; } else { doInit(c); } }
private void processEnabled() { new AwtVisitor(this) { @Override public boolean visit(Component component) { if (component != myEnabled) { component.setEnabled(myQaEnabled); } return false; } }; }
public static void unregisterKeyboardActions(final JRootPane rootPane) { new AwtVisitor(rootPane) { @Override public boolean visit(final Component component) { if (component instanceof JComponent) { final JComponent eachComp = (JComponent)component; final ActionMap actionMap = eachComp.getActionMap(); final KeyStroke[] strokes = eachComp.getRegisteredKeyStrokes(); for (KeyStroke eachStroke : strokes) { boolean remove = true; if (actionMap != null) { for (int i = 0; i < 3; i++) { final InputMap inputMap = eachComp.getInputMap(i); final Object key = inputMap.get(eachStroke); if (key != null) { final Action action = actionMap.get(key); if (action instanceof UIResource) remove = false; } } } if (remove) eachComp.unregisterKeyboardAction(eachStroke); } } return false; } }; }