Java 类com.intellij.ui.speedSearch.FilteringListModel 实例源码

项目:MissingInActions    文件:ContentChooser.java   
private void rebuildListContent() {
    ArrayList<Item> items = new ArrayList<>();
    int i = 0;
    List<Data> contents = new ArrayList<>(getContents());
    for (Data content : contents) {
        String fullString = getStringRepresentationFor(content);
        if (fullString != null) {
            fullString = StringUtil.convertLineSeparators(fullString);
            String shortString = getShortStringFor(content, fullString);
            items.add(new Item(i++, shortString, fullString));
        }
    }
    myAllContents = contents;
    FilteringListModel listModel = (FilteringListModel) myList.getModel();
    ((CollectionListModel) listModel.getOriginalModel()).removeAll();
    listModel.addAll(items);
    ListWithFilter listWithFilter = UIUtil.getParentOfType(ListWithFilter.class, myList);
    if (listWithFilter != null) {
        listWithFilter.getSpeedSearch().update();
        if (listModel.getSize() == 0) listWithFilter.resetFilter();
    }
}
项目:intellij-ce-playground    文件:ListUtil.java   
private static DefaultListModel getModel(JList list) {
  final ListModel model = list.getModel();
  if (model instanceof FilteringListModel) {
    return (DefaultListModel)((FilteringListModel)model).getOriginalModel();
  }
  if (model instanceof CollectionListModel) {
    return getWrapperModel(((CollectionListModel)model));
  }
  return (DefaultListModel)model;
}
项目:intellij-ce-playground    文件:ListUtil.java   
private static ListModelExtension getExtensions(ListModel model) {
  if (model instanceof DefaultListModel) return DEFAULT_MODEL;
  if (model instanceof SortedListModel) return SORTED_MODEL;
  if (model instanceof FilteringListModel) return FILTERED_MODEL;
  if (model instanceof CollectionListModel) return COLLECTION_MODEL;

  if (model == null) LOG.assertTrue(false);
  else LOG.error("Unknown model class: " + model.getClass().getName());
  return null;
}
项目:intellij-ce-playground    文件:MasterDetailPopupBuilder.java   
private void removeSelectedItems() {
  if (myChooserComponent instanceof JList) {
    JList list = (JList)myChooserComponent;
    ListModel listModel = list.getModel();

    int index = list.getSelectedIndex();
    if (index == -1 || index >= listModel.getSize()) {
      return;
    }

    @SuppressWarnings("deprecation") Object[] values = list.getSelectedValues();
    for (Object value : values) {
      ItemWrapper item = (ItemWrapper)value;
      if (item.allowedToRemove()) {
        DefaultListModel model = listModel instanceof DefaultListModel ?
                                 (DefaultListModel)listModel :
                                 (DefaultListModel)((FilteringListModel)listModel).getOriginalModel();

        model.removeElement(item);

        if (model.getSize() > 0) {
          if (model.getSize() == index) {
            list.setSelectedIndex(model.getSize() - 1);
          }
          else if (model.getSize() > index) {
            list.setSelectedIndex(index);
          }
        }
        else {
          list.clearSelection();
        }

        item.removed(myProject);
      }
    }
  }
  else {
    myDelegate.removeSelectedItemsInTree();
  }
}
项目:tools-idea    文件:ListUtil.java   
private static DefaultListModel getModel(JList list) {
  final ListModel model = list.getModel();
  if (model instanceof FilteringListModel) {
    return (DefaultListModel)((FilteringListModel)model).getOriginalModel();
  }
  if (model instanceof CollectionListModel) {
    return getWrapperModel(((CollectionListModel)model));
  }
  return (DefaultListModel)model;
}
项目:tools-idea    文件:ListUtil.java   
private static ListModelExtension getExtensions(ListModel model) {
  if (model instanceof DefaultListModel) return DEFAULT_MODEL;
  if (model instanceof SortedListModel) return SORTED_MODEL;
  if (model instanceof FilteringListModel) return FILTERED_MODEL;
  if (model instanceof CollectionListModel) return COLLECTION_MODEL;

  if (model == null) LOG.assertTrue(false);
  else LOG.error("Unknown model class: " + model.getClass().getName());
  return null;
}
项目:tools-idea    文件:MasterDetailPopupBuilder.java   
public void removeSelectedItems(Project project) {
  if (myChooserComponent instanceof JList) {
    final JList list = (JList)myChooserComponent;
    int index = list.getSelectedIndex();
    if (index == -1 || index >= list.getModel().getSize()) {
      return;
    }
    Object[] values = list.getSelectedValues();
    for (Object value : values) {
      ItemWrapper item = (ItemWrapper)value;

      DefaultListModel model = list.getModel() instanceof DefaultListModel
                               ? (DefaultListModel)list.getModel()
                               : (DefaultListModel)((FilteringListModel)list.getModel()).getOriginalModel();
      if (item.allowedToRemove()) {
        model.removeElement(item);

        if (model.getSize() > 0) {
          if (model.getSize() == index) {
            list.setSelectedIndex(model.getSize() - 1);
          }
          else if (model.getSize() > index) {
            list.setSelectedIndex(index);
          }
        }
        else {
          list.clearSelection();
        }
        item.removed(project);
      }
    }
  }
  else {
    myDelegate.removeSelectedItemsInTree();
  }
}
项目:consulo    文件:ListUtil.java   
private static DefaultListModel getModel(JList list) {
  final ListModel model = list.getModel();
  if (model instanceof FilteringListModel) {
    return (DefaultListModel)((FilteringListModel)model).getOriginalModel();
  }
  if (model instanceof CollectionListModel) {
    return getWrapperModel(((CollectionListModel)model));
  }
  return (DefaultListModel)model;
}
项目:consulo    文件:ListUtil.java   
private static ListModelExtension getExtensions(ListModel model) {
  if (model instanceof DefaultListModel) return DEFAULT_MODEL;
  if (model instanceof SortedListModel) return SORTED_MODEL;
  if (model instanceof FilteringListModel) return FILTERED_MODEL;
  if (model instanceof CollectionListModel) return COLLECTION_MODEL;

  if (model == null) LOG.assertTrue(false);
  else LOG.error("Unknown model class: " + model.getClass().getName());
  return null;
}
项目:consulo    文件:MasterDetailPopupBuilder.java   
public void removeSelectedItems(Project project) {
  if (myChooserComponent instanceof JList) {
    final JList list = (JList)myChooserComponent;
    int index = list.getSelectedIndex();
    if (index == -1 || index >= list.getModel().getSize()) {
      return;
    }
    Object[] values = list.getSelectedValues();
    for (Object value : values) {
      ItemWrapper item = (ItemWrapper)value;

      DefaultListModel model = list.getModel() instanceof DefaultListModel
                               ? (DefaultListModel)list.getModel()
                               : (DefaultListModel)((FilteringListModel)list.getModel()).getOriginalModel();
      if (item.allowedToRemove()) {
        model.removeElement(item);

        if (model.getSize() > 0) {
          if (model.getSize() == index) {
            list.setSelectedIndex(model.getSize() - 1);
          }
          else if (model.getSize() > index) {
            list.setSelectedIndex(index);
          }
        }
        else {
          list.clearSelection();
        }
        item.removed(project);
      }
    }
  }
  else {
    myDelegate.removeSelectedItemsInTree();
  }
}
项目:intellij-ce-playground    文件:ListUtil.java   
public Object get(FilteringListModel model, int index) {
  return model.getElementAt(index);
}
项目:intellij-ce-playground    文件:ListUtil.java   
public void remove(FilteringListModel model, int index) {
  model.remove(index);
}
项目:intellij-ce-playground    文件:ContentChooser.java   
private void rebuildListContent() {
  ArrayList<Item> items = new ArrayList<Item>();
  int i = 0;
  List<Data> contents = new ArrayList<Data>(getContents());
  for (Data content : contents) {
    String fullString = getStringRepresentationFor(content);
    if (fullString != null) {
      String shortString;
      fullString = StringUtil.convertLineSeparators(fullString);
      int newLineIdx = fullString.indexOf('\n');
      if (newLineIdx == -1) {
        shortString = fullString.trim(); 
      }
      else {
        int lastLooked = 0;
        do  {
          int nextLineIdx = fullString.indexOf("\n", lastLooked);
          if (nextLineIdx > lastLooked) {
            shortString = fullString.substring(lastLooked, nextLineIdx).trim() + " ...";
            break;
          }
          else if (nextLineIdx == -1) {
            shortString = " ...";
            break;
          }
          lastLooked = nextLineIdx + 1;
        } while (true);
      }
      items.add(new Item(i ++, shortString, fullString));
    }
  }
  myAllContents = contents;
  FilteringListModel listModel = (FilteringListModel)myList.getModel();
  ((CollectionListModel)listModel.getOriginalModel()).removeAll();
  listModel.addAll(items);
  ListWithFilter listWithFilter = UIUtil.getParentOfType(ListWithFilter.class, myList);
  if (listWithFilter != null) {
    listWithFilter.getSpeedSearch().update();
    if (listModel.getSize() == 0) listWithFilter.resetFilter();
  }
}
项目:intellij-ce-playground    文件:BookmarksAction.java   
static boolean notFiltered(JList list) {
  ListModel model1 = list.getModel();
  if (!(model1 instanceof FilteringListModel)) return true;
  final FilteringListModel model = (FilteringListModel)model1;
  return model.getOriginalModel().getSize() == model.getSize();
}
项目:tools-idea    文件:ListUtil.java   
public Object get(FilteringListModel model, int index) {
  return model.getElementAt(index);
}
项目:tools-idea    文件:ListUtil.java   
public void remove(FilteringListModel model, int index) {
  model.remove(index);
}
项目:tools-idea    文件:ContentChooser.java   
private void rebuildListContent() {
  ArrayList<Item> items = new ArrayList<Item>();
  int i = 0;
  List<Data> contents = new ArrayList<Data>(getContents());
  for (Data content : contents) {
    String fullString = getStringRepresentationFor(content);
    if (fullString != null) {
      String shortString;
      fullString = StringUtil.convertLineSeparators(fullString);
      int newLineIdx = fullString.indexOf('\n');
      if (newLineIdx == -1) {
        shortString = fullString.trim(); 
      }
      else {
        int lastLooked = 0;
        do  {
          int nextLineIdx = fullString.indexOf("\n", lastLooked);
          if (nextLineIdx > lastLooked) {
            shortString = fullString.substring(lastLooked, nextLineIdx).trim() + " ...";
            break;
          }
          else if (nextLineIdx == -1) {
            shortString = " ...";
            break;
          }
          lastLooked = nextLineIdx + 1;
        } while (true);
      }
      items.add(new Item(i ++, shortString, fullString));
    }
  }
  myAllContents = contents;
  FilteringListModel listModel = (FilteringListModel)myList.getModel();
  ((CollectionListModel)listModel.getOriginalModel()).removeAll();
  listModel.addAll(items);
  ListWithFilter listWithFilter = UIUtil.getParentOfType(ListWithFilter.class, myList);
  if (listWithFilter != null) {
    listWithFilter.getSpeedSearch().update();
    if (listModel.getSize() == 0) listWithFilter.resetFilter();
  }
}
项目:tools-idea    文件:BookmarksAction.java   
static boolean notFiltered(JList list) {
  if (!(list.getModel() instanceof FilteringListModel)) return true;
  final FilteringListModel model = (FilteringListModel)list.getModel();
  return model.getOriginalModel().getSize() == model.getSize();
}
项目:consulo    文件:ListUtil.java   
public Object get(FilteringListModel model, int index) {
  return model.getElementAt(index);
}
项目:consulo    文件:ListUtil.java   
public void remove(FilteringListModel model, int index) {
  model.remove(index);
}
项目:consulo    文件:ContentChooser.java   
private void rebuildListContent() {
  ArrayList<Item> items = new ArrayList<Item>();
  int i = 0;
  List<Data> contents = new ArrayList<Data>(getContents());
  for (Data content : contents) {
    String fullString = getStringRepresentationFor(content);
    if (fullString != null) {
      String shortString;
      fullString = StringUtil.convertLineSeparators(fullString);
      int newLineIdx = fullString.indexOf('\n');
      if (newLineIdx == -1) {
        shortString = fullString.trim(); 
      }
      else {
        int lastLooked = 0;
        do  {
          int nextLineIdx = fullString.indexOf("\n", lastLooked);
          if (nextLineIdx > lastLooked) {
            shortString = fullString.substring(lastLooked, nextLineIdx).trim() + " ...";
            break;
          }
          else if (nextLineIdx == -1) {
            shortString = " ...";
            break;
          }
          lastLooked = nextLineIdx + 1;
        } while (true);
      }
      items.add(new Item(i ++, shortString, fullString));
    }
  }
  myAllContents = contents;
  FilteringListModel listModel = (FilteringListModel)myList.getModel();
  ((CollectionListModel)listModel.getOriginalModel()).removeAll();
  listModel.addAll(items);
  ListWithFilter listWithFilter = UIUtil.getParentOfType(ListWithFilter.class, myList);
  if (listWithFilter != null) {
    listWithFilter.getSpeedSearch().update();
    if (listModel.getSize() == 0) listWithFilter.resetFilter();
  }
}
项目:consulo    文件:BookmarksAction.java   
static boolean notFiltered(JList list) {
  if (!(list.getModel() instanceof FilteringListModel)) return true;
  final FilteringListModel model = (FilteringListModel)list.getModel();
  return model.getOriginalModel().getSize() == model.getSize();
}