EventType()源码实例Demo

javax.swing.event.DocumentEvent#EventType()源码实例Demo

下面列出了javax.swing.event.DocumentEvent#EventType() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: DocumentUtilities.java
/**
 * Get string representation of an offset for debugging purposes
 * in form "offset[line:column]". Both lines and columns start counting from 1
 * like in the editor's status bar. Tabs are expanded when counting the column.
 *
 * @param sb valid string builder to which text will be appended or null in which case
 *  the method itself will create a string builder and it will return it.
 * @param evt non-null document event.
 * @return non-null string builder to which the description was added.
 * @since 1.27
 */
public static StringBuilder appendEvent(StringBuilder sb, DocumentEvent evt) {
    if (sb == null) {
        sb = new StringBuilder(100);
    }
    DocumentEvent.EventType type = evt.getType();
    sb.append(type).append(", ");
    appendOffset(sb, evt.getDocument(), evt.getOffset());
    sb.append(", l=").append(evt.getLength());
    // Possibly append the modification text
    String modText;
    if ((modText = getModificationText(evt)) != null) {
        sb.append(", modText=\"");
        CharSequenceUtilities.debugText(sb, modText);
        sb.append('"');
    }
    return sb;
}
 
源代码2 项目: netbeans   文件: BaseDocumentEvent.java
/** Construct document event instance.
   * @param offset position in the document where the insert/remove/change
   *   occured
   * @param length number of the characters affected by the event
   * @param type type of the event - INSERT/REMOVE/CHANGE
   */
   public BaseDocumentEvent(BaseDocument doc, int offset, int length,
                            DocumentEvent.EventType type) {
       ((AbstractDocument)doc).super(offset, length, type);

hasBeenDone2 = true;
alive2 = true;
       inProgress2 = true;
   }
 
源代码3 项目: netbeans   文件: BaseDocument.java
protected BaseDocumentEvent createDocumentEvent(int pos, int length,
        DocumentEvent.EventType type) {
    return new BaseDocumentEvent(this, pos, length, type);
}
 
源代码4 项目: netbeans   文件: BaseDocument.java
final BaseDocumentEvent getDocumentEvent(int pos, int length, DocumentEvent.EventType type, AttributeSet attribs) {
    BaseDocumentEvent bde = createDocumentEvent(pos, length, type);
    bde.attachChangeAttribs(attribs);
    return bde;
}
 
源代码5 项目: netbeans   文件: GuardedDocument.java
protected @Override BaseDocumentEvent createDocumentEvent(int offset, int length,
        DocumentEvent.EventType type) {
    return new GuardedDocumentEvent(this, offset, length, type);
}
 
源代码6 项目: netbeans   文件: GuardedDocumentEvent.java
public GuardedDocumentEvent(GuardedDocument doc, int offset, int length,
                            DocumentEvent.EventType type) {
    super(doc, offset, length, type);
}
 
源代码7 项目: consulo   文件: SearchableOptionsRegistrar.java
@Nonnull
public abstract ConfigurableHit getConfigurables(final Configurable[] allConfigurables,
                                                   final DocumentEvent.EventType type,
                                                   final Set<Configurable> configurables,
                                                   final String option,
                                                   final Project project);
 
源代码8 项目: consulo   文件: OptionsEditor.java
public Promise<?> update(DocumentEvent.EventType type, boolean adjustSelection, boolean now) {
  if (!myUpdateEnabled) return Promises.rejectedPromise();

  final String text = mySearch.getText();
  if (getFilterText().length() == 0) {
    myContext.setHoldingFilter(false);
    myFiltered = null;
  }
  else {
    myContext.setHoldingFilter(true);
    myHits = myIndex.getConfigurables(myConfigurables, type, myFiltered, text, myProject);
    myFiltered = myHits.getAll();
  }

  if (myFiltered != null && myFiltered.isEmpty()) {
    mySearch.getTextEditor().setBackground(LightColors.RED);
  }
  else {
    mySearch.getTextEditor().setBackground(UIUtil.getTextFieldBackground());
  }


  final Configurable current = getContext().getCurrentConfigurable();

  boolean shouldMoveSelection = true;

  if (myHits != null && (myHits.getNameFullHits().contains(current) || myHits.getContentHits().contains(current))) {
    shouldMoveSelection = false;
  }

  if (shouldMoveSelection && type != DocumentEvent.EventType.INSERT && (myFiltered == null || myFiltered.contains(current))) {
    shouldMoveSelection = false;
  }

  Configurable toSelect = adjustSelection ? current : null;
  if (shouldMoveSelection && myHits != null) {
    if (!myHits.getNameHits().isEmpty()) {
      toSelect = suggestToSelect(myHits.getNameHits(), myHits.getNameFullHits());
    }
    else if (!myHits.getContentHits().isEmpty()) {
      toSelect = suggestToSelect(myHits.getContentHits(), null);
    }
  }

  updateSpotlight(false);

  if ((myFiltered == null || !myFiltered.isEmpty()) && toSelect == null && myLastSelected != null) {
    toSelect = myLastSelected;
    myLastSelected = null;
  }

  if (toSelect == null && current != null) {
    myLastSelected = current;
  }

  final Promise<?> callback = fireUpdate(adjustSelection ? myTree.findNodeFor(toSelect) : null, adjustSelection, now);

  myFilterDocumentWasChanged = true;

  return callback;
}
 
源代码9 项目: consulo   文件: SearchableOptionsRegistrarImpl.java
@Override
@Nonnull
public ConfigurableHit getConfigurables(Configurable[] allConfigurables, final DocumentEvent.EventType type, Set<Configurable> configurables, String option, Project project) {

  final ConfigurableHit hits = new ConfigurableHit();
  final Set<Configurable> contentHits = hits.getContentHits();

  Set<String> options = getProcessedWordsWithoutStemming(option);
  if (configurables == null) {
    contentHits.addAll(SearchUtil.expandGroup(allConfigurables));
  }
  else {
    contentHits.addAll(configurables);
  }

  String optionToCheck = option.trim().toLowerCase();
  for (Configurable each : contentHits) {
    if (each.getDisplayName() == null) continue;
    final String displayName = each.getDisplayName().toLowerCase();
    final List<String> allWords = StringUtil.getWordsIn(displayName);
    if (displayName.contains(optionToCheck)) {
      hits.getNameFullHits().add(each);
      hits.getNameHits().add(each);
    }
    for (String eachWord : allWords) {
      if (eachWord.startsWith(optionToCheck)) {
        hits.getNameHits().add(each);
        break;
      }
    }

    if (options.isEmpty()) {
      hits.getNameHits().add(each);
      hits.getNameFullHits().add(each);
    }
  }

  final Set<Configurable> currentConfigurables = new HashSet<>(contentHits);
  if (options.isEmpty()) { //operate with substring
    String[] components = REG_EXP.split(optionToCheck);
    if (components.length > 0) {
      Collections.addAll(options, components);
    }
    else {
      options.add(option);
    }
  }
  Set<String> helpIds = null;
  for (String opt : options) {
    final Set<OptionDescription> optionIds = getAcceptableDescriptions(opt);
    if (optionIds == null) {
      contentHits.clear();
      return hits;
    }
    final Set<String> ids = new HashSet<>();
    for (OptionDescription id : optionIds) {
      ids.add(id.getConfigurableId());
    }
    if (helpIds == null) {
      helpIds = ids;
    }
    helpIds.retainAll(ids);
  }
  if (helpIds != null) {
    for (Iterator<Configurable> it = contentHits.iterator(); it.hasNext(); ) {
      Configurable configurable = it.next();
      if (CodeStyleFacade.getInstance(project).isUnsuitableCodeStyleConfigurable(configurable)) {
        it.remove();
        continue;
      }
      if (!(configurable instanceof SearchableConfigurable && helpIds.contains(((SearchableConfigurable)configurable).getId()))) {
        it.remove();
      }
    }
  }
  if (currentConfigurables.equals(contentHits) && !(configurables == null && type == DocumentEvent.EventType.CHANGE)) {
    return getConfigurables(allConfigurables, DocumentEvent.EventType.CHANGE, null, option, project);
  }
  return hits;
}