Java 类com.intellij.util.ui.AwtVisitor 实例源码

项目:intellij-ce-playground    文件:SimpleToolWindowPanel.java   
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;
}
项目:intellij-ce-playground    文件:EditorTabbedContainer.java   
@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;
}
项目:intellij-ce-playground    文件:EditorTabbedContainer.java   
@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();
}
项目:intellij-ce-playground    文件:TrafficProgressPanel.java   
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;
    }
  };
}
项目:tools-idea    文件:SimpleToolWindowPanel.java   
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;
}
项目:tools-idea    文件:EditorTabbedContainer.java   
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;
}
项目:tools-idea    文件:EditorTabbedContainer.java   
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();
}
项目:tools-idea    文件:TrafficProgressPanel.java   
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;
    }
  };
}
项目:consulo    文件:SimpleToolWindowPanel.java   
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;
}
项目:consulo    文件:TrafficProgressPanel.java   
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;
    }
  };
}
项目:intellij-ce-playground    文件:DialogWrapper.java   
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;
    }
  };
}
项目:intellij-ce-playground    文件:HintHint.java   
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);
  }
}
项目:intellij-ce-playground    文件:QuickAccessConfigurable.java   
private void processEnabled() {
  new AwtVisitor(this) {
    @Override
    public boolean visit(Component component) {
      if (component != myEnabled) {
        component.setEnabled(myQaEnabled);
      }
      return false;
    }
  };
}
项目:tools-idea    文件:DialogWrapper.java   
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;
    }
  };
}
项目:tools-idea    文件:HintHint.java   
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);
  }
}
项目:tools-idea    文件:QuickAccessConfigurable.java   
private void processEnabled() {
  new AwtVisitor(this) {
    @Override
    public boolean visit(Component component) {
      if (component != myEnabled) {
        component.setEnabled(myQaEnabled);
      }
      return false;
    }
  };
}