예제 #1
0
 @Override
 public void init(IPageSite pageSite) {
   super.init(pageSite);
   fShowEnclosingDefinitionsAction = new ShowEnclosingDefinitionsAction();
   IMenuManager menuManager = pageSite.getActionBars().getMenuManager();
   menuManager.add(fShowEnclosingDefinitionsAction);
   menuManager.updateAll(true);
   pageSite.getActionBars().updateActionBars();
 }
예제 #2
0
 @Override
 public void saveState(IMemento memento) {
   super.saveState(memento);
   saveColumnWidths();
   memento.putInteger(KEY_DEFINITION_COLUMN_WIDTH, fColumnWidths[DEFINITION_COLUMN_INDEX]);
   memento.putInteger(KEY_LOCATION_COLUMN_WIDTH, fColumnWidths[LOCATION_COLUMN_INDEX]);
   memento.putInteger(KEY_MATCH_COLUMN_WIDTH, fColumnWidths[MATCH_COLUMN_INDEX]);
   memento.putBoolean(KEY_SHOW_ENCLOSING_DEFINITIONS, fShowEnclosingDefinitions);
 }
예제 #3
0
  private String getColoredLabelWithCounts(Object element, String coloredName) {
    AbstractTextSearchResult result = fPage.getInput();
    if (result == null) return coloredName;

    int matchCount = result.getMatchCount(element);
    if (matchCount <= 1) return coloredName;

    String countInfo =
        Messages.format(SearchMessages.FileLabelProvider_count_format, new Integer(matchCount));
    coloredName += " ";
    coloredName += countInfo;
    return coloredName;
  }
  private StyledString getColoredLabelWithCounts(Object element, StyledString coloredName) {
    AbstractTextSearchResult result = fPage.getInput();
    if (result == null) {
      return coloredName;
    }

    int matchCount = result.getMatchCount(element);
    if (matchCount <= 1) {
      return coloredName;
    }

    String countInfo = MessageFormat.format("({0} matches)", matchCount);
    coloredName.append(' ').append(countInfo, StyledString.COUNTER_STYLER);
    return coloredName;
  }
예제 #5
0
  private String getLineElementLabel(LineElement lineElement) {
    int lineNumber = lineElement.getLine();
    String lineNumberString =
        Messages.format(SearchMessages.FileLabelProvider_line_number, new Integer(lineNumber));

    String str = new String(lineNumberString);

    Match[] matches = lineElement.getMatches(fPage.getInput());
    Arrays.sort(matches, fMatchComparator);

    String content = lineElement.getContents();

    int pos = evaluateLineStart(matches, content, lineElement.getOffset());

    int length = content.length();

    int charsToCut =
        getCharsToCut(
            length, matches); // number of characters to leave away if the line is too long
    for (int i = 0; i < matches.length; i++) {
      FileMatch match = (FileMatch) matches[i];
      int start = Math.max(match.getOriginalOffset() - lineElement.getOffset(), 0);
      // append gap between last match and the new one
      if (pos < start) {
        if (charsToCut > 0) {
          charsToCut = appendShortenedGap(content, pos, start, charsToCut, i == 0, str);
        } else {
          str += content.substring(pos, start);
        }
      }
      // append match
      int end =
          Math.min(
              match.getOriginalOffset() + match.getOriginalLength() - lineElement.getOffset(),
              lineElement.getLength());
      str += content.substring(start, end);
      pos = end;
    }
    // append rest of the line
    if (charsToCut > 0) {
      appendShortenedGap(content, pos, length, charsToCut, false, str);
    } else {
      str += content.substring(pos);
    }
    return str;
  }
  private StyledString getLineElementLabel(ICustomLineElement lineElement) {
    int lineNumber = lineElement.getLine();
    String lineNumberString = MessageFormat.format("{0}:", lineNumber);

    StyledString str = new StyledString(lineNumberString, StyledString.QUALIFIER_STYLER);

    Match[] matches = lineElement.getMatches(fPage.getInput());
    Arrays.sort(matches, fMatchComparator);

    String content = lineElement.getContents();

    int pos = evaluateLineStart(matches, content, lineElement.getOffset());

    int length = content.length();

    int charsToCut =
        getCharsToCut(
            length, matches); // number of characters to leave away if the line is too long
    for (int i = 0; i < matches.length; i++) {
      ICustomMatch match = (ICustomMatch) matches[i];
      int start = Math.max(match.getOriginalOffset() - lineElement.getOffset(), 0);
      // append gap between last match and the new one
      if (pos < start) {
        if (charsToCut > 0) {
          charsToCut = appendShortenedGap(content, pos, start, charsToCut, i == 0, str);
        } else {
          str.append(content.substring(pos, start));
        }
      }
      // append match
      int end =
          Math.min(
              match.getOriginalOffset() + match.getOriginalLength() - lineElement.getOffset(),
              lineElement.getLength());
      str.append(content.substring(start, end), DecoratingFileSearchLabelProvider.HIGHLIGHT_STYLE);
      pos = end;
    }
    // append rest of the line
    if (charsToCut > 0) {
      appendShortenedGap(content, pos, length, charsToCut, false, str);
    } else {
      str.append(content.substring(pos));
    }
    return str;
  }
예제 #7
0
 @Override
 public void restoreState(IMemento memento) {
   super.restoreState(memento);
   IDialogSettings settings = getSettings();
   boolean showEnclosingDefinitions = true;
   if (settings.get(KEY_SHOW_ENCLOSING_DEFINITIONS) != null)
     showEnclosingDefinitions = settings.getBoolean(KEY_SHOW_ENCLOSING_DEFINITIONS);
   if (memento != null) {
     Boolean value = memento.getBoolean(KEY_SHOW_ENCLOSING_DEFINITIONS);
     if (value != null) showEnclosingDefinitions = value.booleanValue();
     String[] keys = {
       KEY_LOCATION_COLUMN_WIDTH, KEY_DEFINITION_COLUMN_WIDTH, KEY_MATCH_COLUMN_WIDTH
     };
     for (int i = 0; i < keys.length; i++) {
       Integer width = memento.getInteger(keys[i]);
       if (width == null) continue;
       if (width > 0) fColumnWidths[i] = width;
     }
   }
   setShowEnclosingDefinitions(showEnclosingDefinitions);
 }