Java 类com.intellij.psi.search.TodoPattern 实例源码

项目:intellij-ce-playground    文件:IdCacheTest.java   
public void testUpdateOnTodoChange() throws Exception {
  TodoPattern pattern = new TodoPattern("newtodo", TodoAttributesUtil.createDefault(), true);
  TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns();
  TodoConfiguration.getInstance().setTodoPatterns(new TodoPattern[]{pattern});

  try{
    final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
    checkResult(new String[]{"2.java"}, convert(todocache.getFilesWithTodoItems()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("1.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(1, todocache.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
  }
  finally{
    TodoConfiguration.getInstance().setTodoPatterns(oldPatterns);
  }
}
项目:intellij-ce-playground    文件:TodoFilter.java   
/**
 * @param element with filter's data.
 * @param patterns all available patterns
 */
public void readExternal(Element element, @NotNull List<TodoPattern> patterns) {
  myName = element.getAttributeValue(ATTRIBUTE_NAME);
  if (myName == null) {
    throw new IllegalArgumentException();
  }
  myTodoPatterns.clear();
  for (Element child : element.getChildren()) {
    if (!ELEMENT_PATTERN.equals(child.getName())) {
      continue;
    }
    try {
      int index = Integer.parseInt(child.getAttributeValue(ATTRIBUTE_INDEX));
      if (index < 0 || index > patterns.size() - 1) {
        continue;
      }
      TodoPattern pattern = patterns.get(index);
      if (myTodoPatterns.contains(pattern)) {
        continue;
      }
      myTodoPatterns.add(pattern);
    }
    catch (NumberFormatException ignored) {
    }
  }
}
项目:intellij-ce-playground    文件:TodoFilter.java   
public boolean equals(Object obj){
  if(!(obj instanceof TodoFilter)){
    return false;
  }
  TodoFilter filter=(TodoFilter)obj;

  if(!myName.equals(filter.myName)){
    return false;
  }

  if(myTodoPatterns.size()!=filter.myTodoPatterns.size()){
    return false;
  }

  for (TodoPattern pattern : myTodoPatterns) {
    if (!filter.contains(pattern)) {
      return false;
    }
  }

  return true;
}
项目:intellij-ce-playground    文件:FilterDialog.java   
/**
 * @param parent      parent component.
 * @param filter      filter to be edited.
 * @param filterIndex index of <code>filter</code> in the <code>filters</code>. This parameter is
 *                    needed to not compare filter with itself when validating.
 * @param filters     all already configured filters. This parameter is used to
 * @param patterns    all patterns available in this filter.
 */
public FilterDialog(Component parent,
                    TodoFilter filter,
                    int filterIndex,
                    List<TodoFilter> filters,
                    List<TodoPattern> patterns) {
  super(parent, true);
  myFilter = filter;
  myFilterIndex = filterIndex;
  myPatterns = patterns;
  myFilters = filters;
  myNameField = new JTextField(filter.getName());
  MyModel model = new MyModel();
  myTable = new Table(model);
  init();
}
项目:intellij-ce-playground    文件:FilterDialog.java   
@Override
public void setValueAt(Object value, int row, int column) {
  switch (column) {
    case 0:
      TodoPattern pattern = myPatterns.get(row);
      if (((Boolean)value).booleanValue()) {
        if (!myFilter.contains(pattern)) {
          myFilter.addTodoPattern(pattern);
        }
      }
      else {
        myFilter.removeTodoPattern(pattern);
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
项目:intellij-ce-playground    文件:TodoConfigurable.java   
private void editSelectedPattern() {
  stopEditing();
  int selectedIndex = myPatternsTable.getSelectedRow();
  if (selectedIndex < 0 || selectedIndex >= myPatternsModel.getRowCount()) {
    return;
  }
  TodoPattern sourcePattern = myPatterns.get(selectedIndex);
  TodoPattern pattern = sourcePattern.clone();
  PatternDialog dialog = new PatternDialog(myPanel, pattern);
  dialog.setTitle(IdeBundle.message("title.edit.todo.pattern"));
  if (!dialog.showAndGet()) {
    return;
  }
  myPatterns.set(selectedIndex, pattern);
  myPatternsModel.fireTableRowsUpdated(selectedIndex, selectedIndex);
  myPatternsTable.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
  // Update model with patterns
  for (int i = 0; i < myFilters.size(); i++) {
    TodoFilter filter = myFilters.get(i);
    if (filter.contains(sourcePattern)) {
      filter.removeTodoPattern(sourcePattern);
      filter.addTodoPattern(pattern);
      myFiltersModel.fireTableRowsUpdated(i, i);
    }
  }
}
项目:intellij-ce-playground    文件:TodoConfigurable.java   
@Override
public void reset() {
  // Patterns
  myPatterns.clear();
  TodoConfiguration todoConfiguration = TodoConfiguration.getInstance();
  TodoPattern[] patterns = todoConfiguration.getTodoPatterns();
  for (TodoPattern pattern : patterns) {
    myPatterns.add(pattern.clone());
  }
  myPatternsModel.fireTableDataChanged();
  // Filters
  myFilters.clear();
  TodoFilter[] filters = todoConfiguration.getTodoFilters();
  for (TodoFilter filter : filters) {
    myFilters.add(filter.clone());
  }
  myFiltersModel.fireTableDataChanged();
}
项目:intellij-ce-playground    文件:FiltersTableModel.java   
@Override
public Object getValueAt(int row,int column){
  TodoFilter filter=myFilters.get(row);
  switch(column){
    case 0:{ // "Name" column
      return filter.getName();
    }case 1:{
      StringBuffer sb=new StringBuffer();
      for(Iterator i=filter.iterator();i.hasNext();){
        TodoPattern pattern=(TodoPattern)i.next();
        sb.append(pattern.getPatternString());
        if(i.hasNext()){
          sb.append(" | ");
        }
      }
      return sb.toString();
    }default:{
      throw new IllegalArgumentException();
    }
  }
}
项目:intellij-ce-playground    文件:PatternsTableModel.java   
@Override
public void setValueAt(Object value,int row,int column){
  TodoPattern pattern=myPatterns.get(row);
  switch(column){
    case 0:{
      pattern.getAttributes().setIcon((Icon)value);
      break;
    }case 1:{
      pattern.setCaseSensitive(((Boolean)value).booleanValue());
      break;
    }case 2:{
      pattern.setPatternString(((String)value).trim());
      break;
    }default:{
      throw new IllegalArgumentException();
    }
  }
}
项目:intellij-ce-playground    文件:TodoPatternTableCellRenderer.java   
@Override
public Component getTableCellRendererComponent(
  JTable table,
  Object value,
  boolean isSelected,
  boolean hasFocus,
  int row,
  int column
){
  super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
  TodoPattern pattern=myPatterns.get(row);
  if(isSelected){
    setForeground(UIUtil.getTableSelectionForeground());
  }else{
    if(pattern.getPattern()==null){
      setForeground(JBColor.RED);
    }else{
      setForeground(UIUtil.getTableForeground());
    }
  }
  return this;
}
项目:tools-idea    文件:IdCacheTest.java   
public void testUpdateOnTodoChange() throws Exception {
  TodoPattern pattern = new TodoPattern("newtodo", TodoAttributes.createDefault(), true);
  TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns();
  TodoConfiguration.getInstance().setTodoPatterns(new TodoPattern[]{pattern});

  try{
    final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
    checkResult(new String[]{"2.java"}, convert(todocache.getFilesWithTodoItems()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("1.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(1, todocache.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
  }
  finally{
    TodoConfiguration.getInstance().setTodoPatterns(oldPatterns);
  }
}
项目:tools-idea    文件:TodoConfiguration.java   
private void doSetTodoPatterns(@NotNull TodoPattern[] todoPatterns, final boolean shouldNotifyIndices) {
  TodoPattern[] oldTodoPatterns = myTodoPatterns;
  IndexPattern[] oldIndexPatterns = myIndexPatterns;

  myTodoPatterns = todoPatterns;
  buildIndexPatterns();

  // only trigger index refresh actual index patterns have changed
  if (shouldNotifyIndices && !Arrays.deepEquals(myIndexPatterns, oldIndexPatterns)) {
    final PropertyChangeEvent event =
      new PropertyChangeEvent(this, IndexPatternProvider.PROP_INDEX_PATTERNS, oldTodoPatterns, todoPatterns);
    myMessageBus.syncPublisher(IndexPatternProvider.INDEX_PATTERNS_CHANGED).propertyChange(event);
  }

  // only trigger gui and code daemon refresh when either the index patterns or presentation attributes have changed
  if (!Arrays.deepEquals(myTodoPatterns, oldTodoPatterns)) {
    final PropertyChangeListener multicaster = myPropertyChangeMulticaster.getMulticaster();
    multicaster.propertyChange(new PropertyChangeEvent(this, PROP_TODO_PATTERNS, oldTodoPatterns, todoPatterns));
  }
}
项目:tools-idea    文件:TodoConfiguration.java   
@Override
public void readExternal(Element element) throws InvalidDataException {
  ArrayList<TodoPattern> patternsList = new ArrayList<TodoPattern>();
  ArrayList<TodoFilter> filtersList = new ArrayList<TodoFilter>();
  for (Object o : element.getChildren()) {
    Element child = (Element)o;
    if (ELEMENT_PATTERN.equals(child.getName())) {
      TodoPattern pattern = new TodoPattern();
      pattern.readExternal(child);
      patternsList.add(pattern);
    }
    else if (ELEMENT_FILTER.equals(child.getName())) {
      TodoPattern[] patterns = patternsList.toArray(new TodoPattern[patternsList.size()]);
      TodoFilter filter = new TodoFilter();
      filter.readExternal(child, patterns);
      filtersList.add(filter);
    }
  }
  doSetTodoPatterns(patternsList.toArray(new TodoPattern[patternsList.size()]), false);
  setTodoFilters(filtersList.toArray(new TodoFilter[filtersList.size()]));
}
项目:tools-idea    文件:FilterDialog.java   
/**
 * @param parent      parent component.
 * @param filter      filter to be edited.
 * @param filterIndex index of <code>filter</code> in the <code>filters</code>. This parameter is
 *                    needed to not compare filter with itself when validating.
 * @param filters     all already configured filters. This parameter is used to
 * @param patterns    all patterns available in this filter.
 */
public FilterDialog(Component parent,
                    TodoFilter filter,
                    int filterIndex,
                    List<TodoFilter> filters,
                    List<TodoPattern> patterns) {
  super(parent, true);
  myFilter = filter;
  myFilterIndex = filterIndex;
  myPatterns = patterns;
  myFilters = filters;
  myNameField = new JTextField(filter.getName());
  MyModel model = new MyModel();
  myTable = new Table(model);
  init();
}
项目:tools-idea    文件:FilterDialog.java   
@Override
public void setValueAt(Object value, int row, int column) {
  switch (column) {
    case 0:
      TodoPattern pattern = myPatterns.get(row);
      if (((Boolean)value).booleanValue()) {
        myFilter.addTodoPattern(pattern);
      }
      else {
        myFilter.removeTodoPattern(pattern);
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
项目:tools-idea    文件:TodoConfigurable.java   
@Override
public void reset() {
  // Patterns
  myPatterns.clear();
  TodoConfiguration todoConfiguration = TodoConfiguration.getInstance();
  TodoPattern[] patterns = todoConfiguration.getTodoPatterns();
  for (TodoPattern pattern : patterns) {
    myPatterns.add(pattern.clone());
  }
  myPatternsModel.fireTableDataChanged();
  // Filters
  myFilters.clear();
  TodoFilter[] filters = todoConfiguration.getTodoFilters();
  for (TodoFilter filter : filters) {
    myFilters.add(filter.clone());
  }
  myFiltersModel.fireTableDataChanged();
}
项目:tools-idea    文件:FiltersTableModel.java   
@Override
public Object getValueAt(int row,int column){
  TodoFilter filter=myFilters.get(row);
  switch(column){
    case 0:{ // "Name" column
      return filter.getName();
    }case 1:{
      StringBuffer sb=new StringBuffer();
      for(Iterator i=filter.iterator();i.hasNext();){
        TodoPattern pattern=(TodoPattern)i.next();
        sb.append(pattern.getPatternString());
        if(i.hasNext()){
          sb.append(" | ");
        }
      }
      return sb.toString();
    }default:{
      throw new IllegalArgumentException();
    }
  }
}
项目:tools-idea    文件:PatternsTableModel.java   
@Override
public void setValueAt(Object value,int row,int column){
  TodoPattern pattern=myPatterns.get(row);
  switch(column){
    case 0:{
      pattern.getAttributes().setIcon((Icon)value);
      break;
    }case 1:{
      pattern.setCaseSensitive(((Boolean)value).booleanValue());
      break;
    }case 2:{
      pattern.setPatternString(((String)value).trim());
      break;
    }default:{
      throw new IllegalArgumentException();
    }
  }
}
项目:tools-idea    文件:TodoPatternTableCellRenderer.java   
@Override
public Component getTableCellRendererComponent(
  JTable table,
  Object value,
  boolean isSelected,
  boolean hasFocus,
  int row,
  int column
){
  super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
  TodoPattern pattern=myPatterns.get(row);
  if(isSelected){
    setForeground(UIUtil.getTableSelectionForeground());
  }else{
    if(pattern.getPattern()==null){
      setForeground(JBColor.RED);
    }else{
      setForeground(UIUtil.getTableForeground());
    }
  }
  return this;
}
项目:tools-idea    文件:TodoFilter.java   
public boolean equals(Object obj){
  if(!(obj instanceof TodoFilter)){
    return false;
  }
  TodoFilter filter=(TodoFilter)obj;

  if(!myName.equals(filter.myName)){
    return false;
  }

  if(myTodoPatterns.size()!=filter.myTodoPatterns.size()){
    return false;
  }

  for (TodoPattern pattern : myTodoPatterns) {
    if (!filter.contains(pattern)) {
      return false;
    }
  }

  return true;
}
项目:consulo    文件:TodoFilter.java   
public boolean equals(Object obj){
  if(!(obj instanceof TodoFilter)){
    return false;
  }
  TodoFilter filter=(TodoFilter)obj;

  if(!myName.equals(filter.myName)){
    return false;
  }

  if(myTodoPatterns.size()!=filter.myTodoPatterns.size()){
    return false;
  }

  for (TodoPattern pattern : myTodoPatterns) {
    if (!filter.contains(pattern)) {
      return false;
    }
  }

  return true;
}
项目:consulo    文件:TodoTreeStructure.java   
/**
 * @return number of <code>TodoItem</code>s located in the file.
 */
public final int getTodoItemCount(PsiFile psiFile) {
  int count = 0;
  if (psiFile != null) {
    if (myTodoFilter != null) {
      for (Iterator i = myTodoFilter.iterator(); i.hasNext(); ) {
        TodoPattern pattern = (TodoPattern)i.next();
        count += getSearchHelper().getTodoItemsCount(psiFile, pattern);
      }
    }
    else {
      count = getSearchHelper().getTodoItemsCount(psiFile);
    }
  }
  return count;
}
项目:consulo    文件:FilterDialog.java   
/**
 * @param parent      parent component.
 * @param filter      filter to be edited.
 * @param filterIndex index of <code>filter</code> in the <code>filters</code>. This parameter is
 *                    needed to not compare filter with itself when validating.
 * @param filters     all already configured filters. This parameter is used to
 * @param patterns    all patterns available in this filter.
 */
public FilterDialog(Component parent,
                    TodoFilter filter,
                    int filterIndex,
                    List<TodoFilter> filters,
                    List<TodoPattern> patterns) {
  super(parent, true);
  myFilter = filter;
  myFilterIndex = filterIndex;
  myPatterns = patterns;
  myFilters = filters;
  myNameField = new JTextField(filter.getName());
  MyModel model = new MyModel();
  myTable = new Table(model);
  init();
}
项目:consulo    文件:FilterDialog.java   
@Override
public void setValueAt(Object value, int row, int column) {
  switch (column) {
    case 0:
      TodoPattern pattern = myPatterns.get(row);
      if (((Boolean)value).booleanValue()) {
        myFilter.addTodoPattern(pattern);
      }
      else {
        myFilter.removeTodoPattern(pattern);
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
项目:consulo    文件:TodoConfigurable.java   
@Override
public void reset() {
  // Patterns
  myPatterns.clear();
  TodoConfiguration todoConfiguration = TodoConfiguration.getInstance();
  TodoPattern[] patterns = todoConfiguration.getTodoPatterns();
  for (TodoPattern pattern : patterns) {
    myPatterns.add(pattern.clone());
  }
  myPatternsModel.fireTableDataChanged();
  // Filters
  myFilters.clear();
  TodoFilter[] filters = todoConfiguration.getTodoFilters();
  for (TodoFilter filter : filters) {
    myFilters.add(filter.clone());
  }
  myFiltersModel.fireTableDataChanged();
}
项目:consulo    文件:FiltersTableModel.java   
@Override
public Object getValueAt(int row,int column){
  TodoFilter filter=myFilters.get(row);
  switch(column){
    case 0:{ // "Name" column
      return filter.getName();
    }case 1:{
      StringBuffer sb=new StringBuffer();
      for(Iterator i=filter.iterator();i.hasNext();){
        TodoPattern pattern=(TodoPattern)i.next();
        sb.append(pattern.getPatternString());
        if(i.hasNext()){
          sb.append(" | ");
        }
      }
      return sb.toString();
    }default:{
      throw new IllegalArgumentException();
    }
  }
}
项目:consulo    文件:PatternsTableModel.java   
@Override
public void setValueAt(Object value,int row,int column){
  TodoPattern pattern=myPatterns.get(row);
  switch(column){
    case 0:{
      pattern.getAttributes().setIcon((Icon)value);
      break;
    }case 1:{
      pattern.setCaseSensitive(((Boolean)value).booleanValue());
      break;
    }case 2:{
      pattern.setPatternString(((String)value).trim());
      break;
    }default:{
      throw new IllegalArgumentException();
    }
  }
}
项目:consulo    文件:TodoPatternTableCellRenderer.java   
@Override
public Component getTableCellRendererComponent(
  JTable table,
  Object value,
  boolean isSelected,
  boolean hasFocus,
  int row,
  int column
){
  super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
  TodoPattern pattern=myPatterns.get(row);
  if(isSelected){
    setForeground(UIUtil.getTableSelectionForeground());
  }else{
    if(pattern.getPattern()==null){
      setForeground(JBColor.RED);
    }else{
      setForeground(UIUtil.getTableForeground());
    }
  }
  return this;
}
项目:consulo-java    文件:IdCacheTest.java   
public void testUpdateOnTodoChange() throws Exception {
  TodoPattern pattern = new TodoPattern("newtodo", TodoAttributesUtil.createDefault(), true);
  TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns();
  TodoConfiguration.getInstance().setTodoPatterns(new TodoPattern[]{pattern});

  try{
    final TodoCacheManager todocache = TodoCacheManager.getInstance(myProject);
    checkResult(new String[]{"2.java"}, convert(todocache.getFilesWithTodoItems()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("1.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(1, todocache.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
  }
  finally{
    TodoConfiguration.getInstance().setTodoPatterns(oldPatterns);
  }
}
项目:intellij-ce-playground    文件:TodoItemsCreator.java   
@NotNull
private TodoPattern mapPattern(@NotNull IndexPattern pattern) {
  for(TodoPattern todoPattern: myTodoPatterns) {
    if (todoPattern.getIndexPattern() == pattern) {
      return todoPattern;
    }
  }
  LOG.error("Could not find matching TODO pattern for index pattern " + pattern.getPatternString());
  return null;
}
项目:intellij-ce-playground    文件:PsiTodoSearchHelperImpl.java   
@Override
public int getTodoItemsCount(@NotNull PsiFile file, @NotNull TodoPattern pattern) {
  int count = TodoCacheManager.SERVICE.getInstance(myManager.getProject()).getTodoCount(file.getVirtualFile(), pattern.getIndexPattern());
  if (count != -1) return count;
  TodoItem[] items = findTodoItems(file);
  count = 0;
  for (TodoItem item : items) {
    if (item.getPattern().equals(pattern)) count++;
  }
  return count;
}
项目:intellij-ce-playground    文件:TodoFilter.java   
/**
 * @return <code>true</code> if and only if specified <code>psiFile</code> has
 * <code>TodoItem</code>s accepted by the filter.
 */
public boolean accept(PsiTodoSearchHelper searchHelper,PsiFile psiFile){
  for(Iterator<TodoPattern> i=iterator();i.hasNext();){
    TodoPattern todoPattern= i.next();
    if(searchHelper.getTodoItemsCount(psiFile,todoPattern)>0){
      return true;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:TodoFilter.java   
/**
 * @param element in which all data will be stored
 * @param patterns all available patterns
 */
public void writeExternal(Element element, TodoPattern[] patterns){
  element.setAttribute(ATTRIBUTE_NAME,myName);
  for (TodoPattern pattern : myTodoPatterns) {
    int index = ArrayUtilRt.find(patterns, pattern);
    LOG.assertTrue(index != -1);
    Element child = new Element(ELEMENT_PATTERN);
    child.setAttribute(ATTRIBUTE_INDEX, Integer.toString(index));
    element.addContent(child);
  }
}
项目:intellij-ce-playground    文件:TodoFilter.java   
@Override
public TodoFilter clone(){
  try{
    TodoFilter filter = (TodoFilter)super.clone();
    filter.myTodoPatterns=new HashSet<TodoPattern>(myTodoPatterns);
    return filter;
  }catch(CloneNotSupportedException e){
    LOG.error(e);
    return null;
  }
}
项目:intellij-ce-playground    文件:TodoTreeStructure.java   
/**
 * @return number of <code>TodoItem</code>s located in the file.
 */
public final int getTodoItemCount(PsiFile psiFile){
  int count=0;
  if(psiFile != null){
    if(myTodoFilter!=null){
      for(Iterator i=myTodoFilter.iterator();i.hasNext();){
        TodoPattern pattern=(TodoPattern)i.next();
        count+=getSearchHelper().getTodoItemsCount(psiFile,pattern);
      }
    }else{
      count=getSearchHelper().getTodoItemsCount(psiFile);
    }
  }
  return count;
}
项目:intellij-ce-playground    文件:FilterDialog.java   
@Override
public Object getValueAt(int row, int column) {
  TodoPattern pattern = myPatterns.get(row);
  switch (column) {
    case 0:
      // "Available" column
      return myFilter.contains(pattern);
    case 1:
      // "Pattern" column
      return pattern.getPatternString();
    default:
      throw new IllegalArgumentException();
  }
}
项目:intellij-ce-playground    文件:TodoConfigurable.java   
/**
 * Invoked by reflection
 */
public TodoConfigurable() {
  myPatterns = new ArrayList<TodoPattern>();
  myFilters = new ArrayList<TodoFilter>();
  myFiltersModel = new FiltersTableModel(myFilters);
  myPatternsModel = new PatternsTableModel(myPatterns);
}
项目:intellij-ce-playground    文件:TodoConfigurable.java   
private boolean arePatternsModified() {
  TodoConfiguration todoConfiguration = TodoConfiguration.getInstance();
  TodoPattern[] initialPatterns = todoConfiguration.getTodoPatterns();
  if (initialPatterns.length != myPatterns.size()) {
    return true;
  }
  for (TodoPattern initialPattern : initialPatterns) {
    if (!myPatterns.contains(initialPattern)) {
      return true;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:TodoConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  stopEditing();
  if (arePatternsModified()) {
    TodoPattern[] patterns = myPatterns.toArray(new TodoPattern[myPatterns.size()]);
    TodoConfiguration.getInstance().setTodoPatterns(patterns);
  }
  if (areFiltersModified()) {
    TodoFilter[] filters = myFilters.toArray(new TodoFilter[myFilters.size()]);
    TodoConfiguration.getInstance().setTodoFilters(filters);
  }
}
项目:intellij-ce-playground    文件:PatternsTableModel.java   
@Override
public Object getValueAt(int row,int column){
  TodoPattern pattern=myPatterns.get(row);
  switch(column){
    case 0:{ // "Icon" column
      return pattern.getAttributes().getIcon();
    }case 1:{ // "Case Sensitive" column
      return pattern.isCaseSensitive()?Boolean.TRUE:Boolean.FALSE;
    }case 2:{ // "Pattern" column
      return pattern.getPatternString();
    }default:{
      throw new IllegalArgumentException();
    }
  }
}