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

项目:consulo    文件:ListWithFilter.java   
private ListWithFilter(JList list, JScrollPane scroller, Function<T, String> namer, boolean highlightAllOccurrences) {
  super(new BorderLayout());

  if (list instanceof ComponentWithEmptyText) {
    ((ComponentWithEmptyText)list).getEmptyText().setText(UIBundle.message("message.noMatchesFound"));
  }

  myList = list;
  myScroller = scroller;

  mySearchField.getTextEditor().setFocusable(false);
  mySearchField.setVisible(false);

  add(mySearchField, BorderLayout.NORTH);
  add(myScroller, BorderLayout.CENTER);

  mySpeedSearch = new MySpeedSearch();
  mySpeedSearch.setEnabled(namer != null);
  mySpeedSearch.setEnabled(namer != null);
  myList.addKeyListener(mySpeedSearch);

  final int selectedIndex = myList.getSelectedIndex();
  final int modelSize = myList.getModel().getSize();
  myModel = new NameFilteringListModel<T>(myList, namer, new Condition<String>() {
    public boolean value(String s) {
      return mySpeedSearch.shouldBeShowing(s);
    }
  }, mySpeedSearch);
  if (myModel.getSize() == modelSize) {
    myList.setSelectedIndex(selectedIndex);
  }

  setBackground(list.getBackground());
  //setFocusable(true);
}
项目:intellij-ce-playground    文件:ListWithFilter.java   
private ListWithFilter(JList list, JScrollPane scroller, Function<T, String> namer) {
  super(new BorderLayout());

  if (list instanceof ComponentWithEmptyText) {
    ((ComponentWithEmptyText)list).getEmptyText().setText(UIBundle.message("message.noMatchesFound"));
  }

  myList = list;
  myScroller = scroller;

  mySearchField.getTextEditor().setFocusable(false);
  mySearchField.setVisible(false);

  add(mySearchField, BorderLayout.NORTH);
  add(myScroller, BorderLayout.CENTER);

  mySpeedSearch = new MySpeedSearch();
  mySpeedSearch.setEnabled(namer != null);

  myList.addKeyListener(new KeyAdapter() {
    public void keyPressed(final KeyEvent e) {
      if (e.getKeyCode() == KeyEvent.VK_A && (e.isControlDown() || e.isMetaDown())) {
        return;
      }
      mySpeedSearch.process(e);
    }
  });
  //new AnAction(){
  //  @Override
  //  public void actionPerformed(AnActionEvent e) {
  //    final InputEvent event = e.getInputEvent();
  //    if (event instanceof KeyEvent) {
  //      mySpeedSearch.process((KeyEvent)event);
  //    }
  //  }
  //
  //  @Override
  //  public void update(AnActionEvent e) {
  //    e.getPresentation().setEnabled(mySpeedSearch.searchFieldShown);
  //  }
  //}.registerCustomShortcutSet(CustomShortcutSet.fromString("BACK_SPACE", "DELETE"), list);
  final int selectedIndex = myList.getSelectedIndex();
  final int modelSize = myList.getModel().getSize();
  myModel = new NameFilteringListModel<T>(myList, namer, new Condition<String>() {
    public boolean value(String s) {
      return mySpeedSearch.shouldBeShowing(s);
    }
  }, mySpeedSearch);
  if (myModel.getSize() == modelSize) {
    myList.setSelectedIndex(selectedIndex);
  }

  setBackground(list.getBackground());
  //setFocusable(true);
}
项目:tools-idea    文件:ListWithFilter.java   
private ListWithFilter(JList list, JScrollPane scroller, Function<T, String> namer) {
  super(new BorderLayout());

  if (list instanceof ComponentWithEmptyText) {
    ((ComponentWithEmptyText)list).getEmptyText().setText(UIBundle.message("message.noMatchesFound"));
  }

  myList = list;
  myScroller = scroller;

  mySearchField.getTextEditor().setFocusable(false);
  mySearchField.setVisible(false);

  add(mySearchField, BorderLayout.NORTH);
  add(myScroller, BorderLayout.CENTER);

  mySpeedSearch = new MySpeedSearch();
  mySpeedSearch.setEnabled(namer != null);

  myList.addKeyListener(new KeyAdapter() {
    public void keyPressed(final KeyEvent e) {
      mySpeedSearch.process(e);
    }
  });
  //new AnAction(){
  //  @Override
  //  public void actionPerformed(AnActionEvent e) {
  //    final InputEvent event = e.getInputEvent();
  //    if (event instanceof KeyEvent) {
  //      mySpeedSearch.process((KeyEvent)event);
  //    }
  //  }
  //
  //  @Override
  //  public void update(AnActionEvent e) {
  //    e.getPresentation().setEnabled(mySpeedSearch.searchFieldShown);
  //  }
  //}.registerCustomShortcutSet(CustomShortcutSet.fromString("BACK_SPACE", "DELETE"), list);
  final int selectedIndex = myList.getSelectedIndex();
  final int modelSize = myList.getModel().getSize();
  myModel = new NameFilteringListModel<T>(myList, namer, new Condition<String>() {
    public boolean value(String s) {
      return mySpeedSearch.shouldBeShowing(s);
    }
  }, mySpeedSearch);
  if (myModel.getSize() == modelSize) {
    myList.setSelectedIndex(selectedIndex);
  }

  setBackground(list.getBackground());
  //setFocusable(true);
}